mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
rebase fixes
This commit is contained in:
parent
645510a4e1
commit
f8319151a4
3 changed files with 11 additions and 13 deletions
|
|
@ -7,9 +7,9 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/common/math"
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Wrapper type which allows PrecompiledContract to be used as PrecompiledContractWithCtx
|
// Wrapper type which allows PrecompiledContract to be used as PrecompiledContractWithCtx
|
||||||
|
|
@ -45,10 +45,10 @@ func NewContext(caller common.Address, evm *EVM) *precompileContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
var vmBlockCtx = BlockContext{
|
var vmBlockCtx = BlockContext{
|
||||||
CanTransfer: func(db StateDB, addr common.Address, amount *big.Int) bool {
|
CanTransfer: func(db StateDB, addr common.Address, amount *uint256.Int) bool {
|
||||||
return db.GetBalance(addr).Cmp(amount) >= 0
|
return db.GetBalance(addr).Cmp(amount) >= 0
|
||||||
},
|
},
|
||||||
Transfer: func(StateDB, common.Address, common.Address, *big.Int) {
|
Transfer: func(StateDB, common.Address, common.Address, *uint256.Int) {
|
||||||
panic("transfer: not implemented")
|
panic("transfer: not implemented")
|
||||||
},
|
},
|
||||||
GetHash: func(u uint64) common.Hash {
|
GetHash: func(u uint64) common.Hash {
|
||||||
|
|
@ -90,10 +90,8 @@ func (c *mint) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mintTo := common.BytesToAddress(input[0:32])
|
mintTo := common.BytesToAddress(input[0:32])
|
||||||
|
value, err := uint256.FromHex(hexutil.Encode(input[32:64]))
|
||||||
var parsed bool
|
if err != nil {
|
||||||
value, parsed := math.ParseBig256(hexutil.Encode(input[32:64]))
|
|
||||||
if !parsed {
|
|
||||||
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||||
}
|
}
|
||||||
|
|
@ -124,9 +122,8 @@ func (c *burn) Run(input []byte, ctx *precompileContext) ([]byte, error) {
|
||||||
|
|
||||||
burnFrom := common.BytesToAddress(input[0:32])
|
burnFrom := common.BytesToAddress(input[0:32])
|
||||||
|
|
||||||
var parsed bool
|
value, err := uint256.FromHex(hexutil.Encode(input[32:64]))
|
||||||
value, parsed := math.ParseBig256(hexutil.Encode(input[32:64]))
|
if err != nil {
|
||||||
if !parsed {
|
|
||||||
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
log.Error("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||||
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
return nil, fmt.Errorf("Error parsing transfer: unable to parse value from " + hexutil.Encode(input[32:64]))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ func minerTestGenesisBlock(period uint64, gasLimit uint64, faucet common.Address
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||||
Difficulty: big.NewInt(1),
|
Difficulty: big.NewInt(1),
|
||||||
Alloc: map[common.Address]types.Account{
|
Alloc: types.GenesisAlloc{
|
||||||
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
|
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
|
||||||
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
|
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
|
||||||
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
|
common.BytesToAddress([]byte{3}): {Balance: big.NewInt(1)}, // RIPEMD
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -63,10 +64,10 @@ func checkInput(id byte, inputLen int) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
var vmBlockCtx = vm.BlockContext{
|
var vmBlockCtx = vm.BlockContext{
|
||||||
CanTransfer: func(db vm.StateDB, addr common.Address, amount *big.Int) bool {
|
CanTransfer: func(db vm.StateDB, addr common.Address, amount *uint256.Int) bool {
|
||||||
return db.GetBalance(addr).Cmp(amount) >= 0
|
return db.GetBalance(addr).Cmp(amount) >= 0
|
||||||
},
|
},
|
||||||
Transfer: func(vm.StateDB, common.Address, common.Address, *big.Int) {
|
Transfer: func(vm.StateDB, common.Address, common.Address, *uint256.Int) {
|
||||||
panic("transfer: not implemented")
|
panic("transfer: not implemented")
|
||||||
},
|
},
|
||||||
GetHash: func(u uint64) common.Hash {
|
GetHash: func(u uint64) common.Hash {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue