From b898609e25a061dc8141283bfb233336ad06db26 Mon Sep 17 00:00:00 2001 From: Talha Cross <47772477+soc1c@users.noreply.github.com> Date: Wed, 7 Aug 2019 19:21:31 +0200 Subject: [PATCH] Backports for 6.0.7-beta (#21) * Fixed state transition logic for edge case (#17) * Update morden bootnodes (#16) * Updates bootnodes * what a fantastic test :) * Core execution refactor, EIP 684, edge case fixes, starting nonce for morden (#19) * Refactored Call * Refactored CallCode * Refactored DelegateCall * Refactored StaticCall * Added create before contract collision check * Refactored Call * Refactored CallCode * Refactored DelegateCall * Refactored StaticCall * Added create before contract collision check * Fixed state transition logic for edge case * Added create collision logic * Fix for edge case tests * Removed outdated contract collision tests and changed format of test output to be consistent * Rename exec function * utilize StartingNonce from state instead of explicit 0 nonce checks for contract collision and empty objects * Fixes morden seg fault edge case * adding starting nonce to created contracts --- core/execution.go | 282 ++++++++++++------ core/state/state_object.go | 3 +- core/state_transition.go | 152 +++++----- go.mod | 1 + go.sum | 2 + params/protocol_params.go | 1 + .../Homestead/stCallCreateCallCodeTest.json | 72 ----- .../Homestead/stSystemOperationsTest.json | 77 ----- .../Homestead/stCallCreateCallCodeTest.json | 72 ----- .../Homestead/stSystemOperationsTest.json | 77 ----- .../StateTests/stCallCreateCallCodeTest.json | 72 ----- .../StateTests/stSystemOperationsTest.json | 77 ----- tests/state_test.go | 13 - tests/state_test_util.go | 2 +- 14 files changed, 280 insertions(+), 623 deletions(-) diff --git a/core/execution.go b/core/execution.go index 31bc2c03d..ef496509a 100644 --- a/core/execution.go +++ b/core/execution.go @@ -17,53 +17,217 @@ package core import ( + "errors" "fmt" "math/big" "github.com/eth-classic/go-ethereum/common" + "github.com/eth-classic/go-ethereum/core/state" "github.com/eth-classic/go-ethereum/core/vm" "github.com/eth-classic/go-ethereum/crypto" + "github.com/eth-classic/go-ethereum/params" ) var ( + emptyCodeHash = crypto.Keccak256Hash(nil) + callCreateDepthMax = 1024 // limit call/create stack errCallCreateDepth = fmt.Errorf("Max call depth exceeded (%d)", callCreateDepthMax) maxCodeSize = 24576 errMaxCodeSizeExceeded = fmt.Errorf("Max Code Size exceeded (%d)", maxCodeSize) + + errContractAddressCollision = errors.New("contract address collision") ) -// Call executes within the given contract +// Call executes the contract associated with the addr with the given input as +// parameters. It also handles any necessary value transfer required and takes +// the necessary steps to create accounts and reverses the state in case of an +// execution error or failed value transfer. func Call(env vm.Environment, caller vm.ContractRef, addr common.Address, input []byte, gas, gasPrice, value *big.Int) (ret []byte, err error) { - ret, _, err = exec(env, caller, &addr, &addr, env.Db().GetCodeHash(addr), input, env.Db().GetCode(addr), gas, gasPrice, value, false) + evm := env.Vm() + // Depth check execution. Fail if we're trying to execute above the limit. + if env.Depth() > callCreateDepthMax { + caller.ReturnGas(gas, gasPrice) + + return nil, errCallCreateDepth + } + + if !env.CanTransfer(caller.Address(), value) { + caller.ReturnGas(gas, gasPrice) + + return nil, ValueTransferErr("insufficient funds to transfer value. Req %v, has %v", value, env.Db().GetBalance(caller.Address())) + } + + var ( + from = env.Db().GetAccount(caller.Address()) + to vm.Account + snapshot = env.SnapshotDatabase() + isAtlantis = env.RuleSet().IsAtlantis(env.BlockNumber()) + ) + if !env.Db().Exist(addr) { + precompiles := vm.PrecompiledPreAtlantis + if isAtlantis { + precompiles = vm.PrecompiledAtlantis + } + if precompiles[addr.Str()] == nil && isAtlantis && value.BitLen() == 0 { + caller.ReturnGas(gas, gasPrice) + return nil, nil + } + to = env.Db().CreateAccount(addr) + } else { + to = env.Db().GetAccount(addr) + } + env.Transfer(from, to, value) + // Initialise a new contract and set the code that is to be used by the EVM. + // The contract is a scoped environment for this execution context only. + contract := vm.NewContract(caller, to, value, gas, gasPrice) + contract.SetCallCode(&addr, env.Db().GetCodeHash(addr), env.Db().GetCode(addr)) + defer contract.Finalise() + + // Even if the account has no code, we need to continue because it might be a precompile + ret, err = evm.Run(contract, input, false) + + // When an error was returned by the EVM or when setting the creation code + // above we revert to the snapshot and consume any gas remaining. Additionally + // when we're in homestead this also counts for code storage gas errors. + if err != nil { + env.RevertToSnapshot(snapshot) + if err != vm.ErrRevert { + contract.UseGas(contract.Gas) + } + } return ret, err } // CallCode executes the given address' code as the given contract address func CallCode(env vm.Environment, caller vm.ContractRef, addr common.Address, input []byte, gas, gasPrice, value *big.Int) (ret []byte, err error) { - callerAddr := caller.Address() - ret, _, err = exec(env, caller, &callerAddr, &addr, env.Db().GetCodeHash(addr), input, env.Db().GetCode(addr), gas, gasPrice, value, false) + evm := env.Vm() + // Depth check execution. Fail if we're trying to execute above the limit. + if env.Depth() > callCreateDepthMax { + caller.ReturnGas(gas, gasPrice) + + return nil, errCallCreateDepth + } + + if !env.CanTransfer(caller.Address(), value) { + caller.ReturnGas(gas, gasPrice) + + return nil, ValueTransferErr("insufficient funds to transfer value. Req %v, has %v", value, env.Db().GetBalance(caller.Address())) + } + + var ( + to = env.Db().GetAccount(caller.Address()) + snapshot = env.SnapshotDatabase() + ) + // Initialise a new contract and set the code that is to be used by the EVM. + // The contract is a scoped environment for this execution context only. + contract := vm.NewContract(caller, to, value, gas, gasPrice) + contract.SetCallCode(&addr, env.Db().GetCodeHash(addr), env.Db().GetCode(addr)) + defer contract.Finalise() + + // Even if the account has no code, we need to continue because it might be a precompile + ret, err = evm.Run(contract, input, false) + + if err != nil { + env.RevertToSnapshot(snapshot) + if err != vm.ErrRevert { + contract.UseGas(contract.Gas) + } + } return ret, err } // DelegateCall is equivalent to CallCode except that sender and value propagates from parent scope to child scope func DelegateCall(env vm.Environment, caller vm.ContractRef, addr common.Address, input []byte, gas, gasPrice *big.Int) (ret []byte, err error) { - callerAddr := caller.Address() - originAddr := env.Origin() - callerValue := caller.Value() - ret, _, err = execDelegateCall(env, caller, &originAddr, &callerAddr, &addr, env.Db().GetCodeHash(addr), input, env.Db().GetCode(addr), gas, gasPrice, callerValue) + evm := env.Vm() + // Depth check execution. Fail if we're trying to execute above the limit. + if env.Depth() > callCreateDepthMax { + caller.ReturnGas(gas, gasPrice) + + return nil, errCallCreateDepth + } + + var ( + to vm.Account + snapshot = env.SnapshotDatabase() + ) + if !env.Db().Exist(caller.Address()) { + to = env.Db().CreateAccount(caller.Address()) + } else { + to = env.Db().GetAccount(caller.Address()) + } + + // Initialise a new contract and set the code that is to be used by the EVM. + // The contract is a scoped environment for this execution context only. + contract := vm.NewContract(caller, to, caller.Value(), gas, gasPrice).AsDelegate() + contract.SetCallCode(&addr, env.Db().GetCodeHash(addr), env.Db().GetCode(addr)) + defer contract.Finalise() + + // Even if the account has no code, we need to continue because it might be a precompile + ret, err = evm.Run(contract, input, false) + + // When an error was returned by the EVM or when setting the creation code + // above we revert to the snapshot and consume any gas remaining. Additionally + // when we're in homestead this also counts for code storage gas errors. + if err != nil { + env.RevertToSnapshot(snapshot) + if err != vm.ErrRevert { + contract.UseGas(contract.Gas) + } + } return ret, err } // StaticCall executes within the given contract and throws exception if state is attempted to be changed func StaticCall(env vm.Environment, caller vm.ContractRef, addr common.Address, input []byte, gas, gasPrice *big.Int) (ret []byte, err error) { - ret, _, err = exec(env, caller, &addr, &addr, env.Db().GetCodeHash(addr), input, env.Db().GetCode(addr), gas, gasPrice, new(big.Int), true) + evm := env.Vm() + // Depth check execution. Fail if we're trying to execute above the limit. + if env.Depth() > callCreateDepthMax { + caller.ReturnGas(gas, gasPrice) + + return nil, errCallCreateDepth + } + + var ( + to vm.Account + snapshot = env.SnapshotDatabase() + ) + if !env.Db().Exist(addr) { + to = env.Db().CreateAccount(addr) + } else { + to = env.Db().GetAccount(addr) + } + + // Initialise a new contract and set the code that is to be used by the EVM. + // The contract is a scoped environment for this execution context only. + contract := vm.NewContract(caller, to, new(big.Int), gas, gasPrice) + contract.SetCallCode(&addr, env.Db().GetCodeHash(addr), env.Db().GetCode(addr)) + defer contract.Finalise() + + // We do an AddBalance of zero here, just in order to trigger a touch. + // This is done to keep consensus with other clients since empty objects + // get touched to be deleted even in a StaticCall context + env.Db().AddBalance(addr, big.NewInt(0)) + + // Even if the account has no code, we need to continue because it might be a precompile + ret, err = evm.Run(contract, input, true) + + // When an error was returned by the EVM or when setting the creation code + // above we revert to the snapshot and consume any gas remaining. Additionally + // when we're in homestead this also counts for code storage gas errors. + if err != nil { + env.RevertToSnapshot(snapshot) + if err != vm.ErrRevert { + contract.UseGas(contract.Gas) + } + } return ret, err } // Create creates a new contract with the given code func Create(env vm.Environment, caller vm.ContractRef, code []byte, gas, gasPrice, value *big.Int) (ret []byte, address common.Address, err error) { - ret, address, err = exec(env, caller, nil, nil, crypto.Keccak256Hash(code), nil, code, gas, gasPrice, value, false) + ret, address, err = create(env, caller, crypto.Keccak256Hash(code), code, gas, gasPrice, value) // Here we get an error if we run into maximum stack depth, // See: https://github.com/ethereum/yellowpaper/pull/131 // and YP definitions for CREATE @@ -75,10 +239,9 @@ func Create(env vm.Environment, caller vm.ContractRef, code []byte, gas, gasPric return ret, address, err } -func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.Address, codeHash common.Hash, input, code []byte, gas, gasPrice, value *big.Int, readOnly bool) (ret []byte, addr common.Address, err error) { +func create(env vm.Environment, caller vm.ContractRef, codeHash common.Hash, code []byte, gas, gasPrice, value *big.Int) (ret []byte, address common.Address, err error) { evm := env.Vm() - // Depth check execution. Fail if we're trying to execute above the - // limit. + // Depth check execution. Fail if we're trying to execute above the limit. if env.Depth() > callCreateDepthMax { caller.ReturnGas(gas, gasPrice) @@ -91,39 +254,25 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A return nil, common.Address{}, ValueTransferErr("insufficient funds to transfer value. Req %v, has %v", value, env.Db().GetBalance(caller.Address())) } - var createAccount bool - if address == nil { - // Create a new account on the state - nonce := env.Db().GetNonce(caller.Address()) - env.Db().SetNonce(caller.Address(), nonce+1) - addr = crypto.CreateAddress(caller.Address(), nonce) - address = &addr - createAccount = true + // Create a new account on the state + nonce := env.Db().GetNonce(caller.Address()) + env.Db().SetNonce(caller.Address(), nonce+1) + address = crypto.CreateAddress(caller.Address(), nonce) + + // Ensure there's no existing contract already at the designated address + contractHash := env.Db().GetCodeHash(address) + if env.Db().GetNonce(address) != state.StartingNonce || (contractHash != (common.Hash{}) && contractHash != emptyCodeHash) { + return nil, common.Address{}, errContractAddressCollision } - snapshotPreTransfer := env.SnapshotDatabase() var ( - from = env.Db().GetAccount(caller.Address()) - to vm.Account + snapshot = env.SnapshotDatabase() + from = env.Db().GetAccount(caller.Address()) + to = env.Db().CreateAccount(address) ) - if createAccount { - to = env.Db().CreateAccount(*address) - - if env.RuleSet().IsAtlantis(env.BlockNumber()) { - env.Db().SetNonce(*address, 1) - } - } else { - if !env.Db().Exist(*address) { - //no account may change state from non-existent to existent-but-empty. Refund sender. - if vm.PrecompiledAtlantis[(*address).Str()] == nil && env.RuleSet().IsAtlantis(env.BlockNumber()) && value.BitLen() == 0 { - caller.ReturnGas(gas, gasPrice) - return nil, common.Address{}, nil - } - to = env.Db().CreateAccount(*address) - } else { - to = env.Db().GetAccount(*address) - } + if env.RuleSet().IsAtlantis(env.BlockNumber()) { + env.Db().SetNonce(address, state.StartingNonce+1) } env.Transfer(from, to, value) @@ -132,22 +281,22 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A // EVM. The contract is a scoped environment for this execution context // only. contract := vm.NewContract(caller, to, value, gas, gasPrice) - contract.SetCallCode(codeAddr, codeHash, code) + contract.SetCallCode(nil, codeHash, code) defer contract.Finalise() - ret, err = evm.Run(contract, input, readOnly) + ret, err = evm.Run(contract, nil, false) maxCodeSizeExceeded := len(ret) > maxCodeSize && env.RuleSet().IsAtlantis(env.BlockNumber()) // if the contract creation ran successfully and no errors were returned // calculate the gas required to store the code. If the code could not // be stored due to not enough gas set an error and let it be handled // by the error checking condition below. - if err == nil && createAccount && !maxCodeSizeExceeded { + if err == nil && !maxCodeSizeExceeded { dataGas := big.NewInt(int64(len(ret))) // create data gas - dataGas.Mul(dataGas, big.NewInt(200)) + dataGas.Mul(dataGas, params.CreateDataGas) if contract.UseGas(dataGas) { - env.Db().SetCode(*address, ret) + env.Db().SetCode(address, ret) } else { err = vm.CodeStoreOutOfGasError } @@ -156,8 +305,8 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A // When an error was returned by the EVM or when setting the creation code // above we revert to the snapshot and consume any gas remaining. Additionally // when we're in homestead this also counts for code storage gas errors. - if createAccount && maxCodeSizeExceeded || (err != nil && (env.RuleSet().IsHomestead(env.BlockNumber()) || err != vm.CodeStoreOutOfGasError)) { - env.RevertToSnapshot(snapshotPreTransfer) + if maxCodeSizeExceeded || (err != nil && (env.RuleSet().IsHomestead(env.BlockNumber()) || err != vm.CodeStoreOutOfGasError)) { + env.RevertToSnapshot(snapshot) if err != vm.ErrRevert { contract.UseGas(contract.Gas) } @@ -168,42 +317,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A err = errMaxCodeSizeExceeded } - return ret, addr, err -} - -func execDelegateCall(env vm.Environment, caller vm.ContractRef, originAddr, toAddr, codeAddr *common.Address, codeHash common.Hash, input, code []byte, gas, gasPrice, value *big.Int) (ret []byte, addr common.Address, err error) { - evm := env.Vm() - // Depth check execution. Fail if we're trying to execute above the - // limit. - if env.Depth() > callCreateDepthMax { - caller.ReturnGas(gas, gasPrice) - return nil, common.Address{}, errCallCreateDepth - } - - snapshot := env.SnapshotDatabase() - - var to vm.Account - if !env.Db().Exist(*toAddr) { - to = env.Db().CreateAccount(*toAddr) - } else { - to = env.Db().GetAccount(*toAddr) - } - - // Iinitialise a new contract and make initialise the delegate values - contract := vm.NewContract(caller, to, value, gas, gasPrice).AsDelegate() - contract.SetCallCode(codeAddr, codeHash, code) - defer contract.Finalise() - - ret, err = evm.Run(contract, input, false) - - if err != nil { - env.RevertToSnapshot(snapshot) - if err != vm.ErrRevert { - contract.UseGas(contract.Gas) - } - } - - return ret, addr, err + return ret, address, err } // generic transfer method diff --git a/core/state/state_object.go b/core/state/state_object.go index 7fd883f85..57068813b 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -28,6 +28,7 @@ import ( "github.com/eth-classic/go-ethereum/logger/glog" "github.com/eth-classic/go-ethereum/rlp" "github.com/eth-classic/go-ethereum/trie" + ) var emptyCodeHash = crypto.Keccak256(nil) @@ -93,7 +94,7 @@ type StateObject struct { // empty returns whether the account is considered empty. func (s *StateObject) empty() bool { - return s.data.Nonce == 0 && s.data.Balance.Sign() == 0 && bytes.Equal(s.data.CodeHash, emptyCodeHash) + return s.data.Nonce == StartingNonce && s.data.Balance.Sign() == 0 && bytes.Equal(s.data.CodeHash, emptyCodeHash) } // Account is the Ethereum consensus representation of accounts. diff --git a/core/state_transition.go b/core/state_transition.go index 96fa6cbfc..a88d2279c 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -17,7 +17,7 @@ package core import ( - "fmt" + "errors" "math/big" "github.com/eth-classic/go-ethereum/common" @@ -27,10 +27,11 @@ import ( ) var ( - TxGas = big.NewInt(21000) // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. - TxGasContractCreation = big.NewInt(53000) // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. - TxDataZeroGas = big.NewInt(4) // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. - TxDataNonZeroGas = big.NewInt(68) // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. + TxGas = big.NewInt(21000) // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. + TxGasContractCreation = big.NewInt(53000) // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. + TxDataZeroGas = big.NewInt(4) // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. + TxDataNonZeroGas = big.NewInt(68) // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. + errInsufficientBalanceForGas = errors.New("insufficient balance to pay for gas") ) /* @@ -134,83 +135,64 @@ func ApplyMessage(env vm.Environment, msg Message, gp *GasPool) ([]byte, *big.In return ret, gasUsed, failed, err } -func (self *StateTransition) from() (vm.Account, error) { - var ( - f common.Address - err error - ) - f, err = self.msg.From() - if err != nil { - return nil, err - } - if !self.state.Exist(f) { - return self.state.CreateAccount(f), nil +// to returns the recipient of the message. +func (st *StateTransition) to() common.Address { + if st.msg == nil || st.msg.To() == nil /* contract creation */ { + return common.Address{} } - return self.state.GetAccount(f), nil + return *st.msg.To() } -func (self *StateTransition) to() vm.Account { - if self.msg == nil { - return nil - } - to := self.msg.To() - if to == nil { - return nil // contract creation - } - - if !self.state.Exist(*to) { - return self.state.CreateAccount(*to) - } - return self.state.GetAccount(*to) -} - -func (self *StateTransition) useGas(amount *big.Int) error { - if self.gas.Cmp(amount) < 0 { +func (st *StateTransition) useGas(amount *big.Int) error { + if st.gas.Cmp(amount) < 0 { return vm.OutOfGasError } - self.gas.Sub(self.gas, amount) + st.gas.Sub(st.gas, amount) return nil } -func (self *StateTransition) addGas(amount *big.Int) { - self.gas.Add(self.gas, amount) +func (st *StateTransition) addGas(amount *big.Int) { + st.gas.Add(st.gas, amount) } -func (self *StateTransition) buyGas() error { - mgas := self.msg.Gas() - mgval := new(big.Int).Mul(mgas, self.gasPrice) +func (st *StateTransition) buyGas() error { + mgas := st.msg.Gas() + mgval := new(big.Int).Mul(mgas, st.gasPrice) - sender, err := self.from() + address, err := st.msg.From() if err != nil { return err } - if sender.Balance().Cmp(mgval) < 0 { - return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address().Bytes()[:4], mgval, sender.Balance()) + sender := st.state.GetAccount(address) + + if st.state.GetBalance(address).Cmp(mgval) < 0 { + return errInsufficientBalanceForGas } - if err = self.gp.SubGas(mgas); err != nil { + + if err = st.gp.SubGas(mgas); err != nil { return err } - self.addGas(mgas) - self.initialGas.Set(mgas) + st.addGas(mgas) + st.initialGas.Set(mgas) sender.SubBalance(mgval) return nil } -func (self *StateTransition) preCheck() (err error) { - msg := self.msg - sender, err := self.from() +func (st *StateTransition) preCheck() (err error) { + msg := st.msg + address, err := st.msg.From() if err != nil { return err } // Make sure this transaction's nonce is correct - if n := self.state.GetNonce(sender.Address()); n != msg.Nonce() { + if n := st.state.GetNonce(address); n != msg.Nonce() { return NonceError(msg.Nonce(), n) } // Pre-pay gas - if err = self.buyGas(); err != nil { + if err = st.buyGas(); err != nil { if IsGasLimitErr(err) { return err } @@ -221,27 +203,39 @@ func (self *StateTransition) preCheck() (err error) { } // TransitionDb will move the state by applying the message against the given environment. -func (self *StateTransition) TransitionDb() (ret []byte, gas *big.Int, failed bool, err error) { - if err = self.preCheck(); err != nil { +func (st *StateTransition) TransitionDb() (ret []byte, gas *big.Int, failed bool, err error) { + if err = st.preCheck(); err != nil { return } - msg := self.msg - sender, _ := self.from() // err checked in preCheck - - homestead := self.env.RuleSet().IsHomestead(self.env.BlockNumber()) + msg := st.msg + address, err := st.msg.From() + if err != nil { + return nil, nil, false, err + } + var sender vm.Account + if !st.state.Exist(address) { + sender = st.state.CreateAccount(address) + } else { + sender = st.state.GetAccount(address) + } + homestead := st.env.RuleSet().IsHomestead(st.env.BlockNumber()) contractCreation := MessageCreatesContract(msg) // Pay intrinsic gas - if err = self.useGas(IntrinsicGas(self.data, contractCreation, homestead)); err != nil { + if err = st.useGas(IntrinsicGas(st.data, contractCreation, homestead)); err != nil { return nil, nil, false, InvalidTxError(err) } - vmenv := self.env + vmenv := st.env //var addr common.Address var vmerr error if contractCreation { - ret, _, vmerr = vmenv.Create(sender, self.data, self.gas, self.gasPrice, self.value) + ret, _, vmerr = vmenv.Create(sender, st.data, st.gas, st.gasPrice, st.value) + + if vmerr == errContractAddressCollision { + st.gas = big.NewInt(0) + } if homestead && vmerr == vm.CodeStoreOutOfGasError { - self.gas = big.NewInt(0) + st.gas = big.NewInt(0) } if vmerr != nil { @@ -249,8 +243,8 @@ func (self *StateTransition) TransitionDb() (ret []byte, gas *big.Int, failed bo } } else { // Increment the nonce for the next transaction - self.state.SetNonce(sender.Address(), self.state.GetNonce(sender.Address())+1) - ret, vmerr = vmenv.Call(sender, self.to().Address(), self.data, self.gas, self.gasPrice, self.value) + st.state.SetNonce(address, st.state.GetNonce(sender.Address())+1) + ret, vmerr = vmenv.Call(sender, st.to(), st.data, st.gas, st.gasPrice, st.value) if vmerr != nil { glog.V(logger.Core).Infoln("VM call err:", vmerr) } @@ -262,29 +256,33 @@ func (self *StateTransition) TransitionDb() (ret []byte, gas *big.Int, failed bo return nil, nil, false, InvalidTxError(vmerr) } - self.refundGas() - self.state.AddBalance(self.env.Coinbase(), new(big.Int).Mul(self.gasUsed(), self.gasPrice)) + st.refundGas() + st.state.AddBalance(st.env.Coinbase(), new(big.Int).Mul(st.gasUsed(), st.gasPrice)) - return ret, self.gasUsed(), vmerr != nil, err + return ret, st.gasUsed(), vmerr != nil, err } -func (self *StateTransition) refundGas() { +func (st *StateTransition) refundGas() { // Return eth for remaining gas to the sender account, // exchanged at the original rate. - sender, _ := self.from() // err already checked - remaining := new(big.Int).Mul(self.gas, self.gasPrice) - sender.AddBalance(remaining) + address, err := st.msg.From() + if err != nil { + return + } + + remaining := new(big.Int).Mul(st.gas, st.gasPrice) + st.state.AddBalance(address, remaining) // Apply refund counter, capped to half of the used gas. - uhalf := remaining.Div(self.gasUsed(), common.Big2) - refund := common.BigMin(uhalf, self.state.GetRefund()) - self.gas.Add(self.gas, refund) - self.state.AddBalance(sender.Address(), refund.Mul(refund, self.gasPrice)) + uhalf := remaining.Div(st.gasUsed(), common.Big2) + refund := common.BigMin(uhalf, st.state.GetRefund()) + st.gas.Add(st.gas, refund) + st.state.AddBalance(address, refund.Mul(refund, st.gasPrice)) // Also return remaining gas to the block gas counter so it is // available for the next transaction. - self.gp.AddGas(self.gas) + st.gp.AddGas(st.gas) } -func (self *StateTransition) gasUsed() *big.Int { - return new(big.Int).Sub(self.initialGas, self.gas) +func (st *StateTransition) gasUsed() *big.Int { + return new(big.Int).Sub(st.initialGas, st.gas) } diff --git a/go.mod b/go.mod index 57846f8c1..b9f077a08 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 github.com/maruel/panicparse v1.2.0 // indirect github.com/mattn/go-colorable v0.1.2 // indirect + github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762 // indirect github.com/peterh/liner v1.1.0 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a github.com/rjeczalik/notify v0.9.1 diff --git a/go.sum b/go.sum index f8f22ac4b..b9be56278 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9 github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e h1:Vbib8wJAaMEF9jusI/kMSYMr/LtRzM7+F9MJgt/nH8k= github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= +github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762 h1:44Lv0bNi88GweB54TCjB/lEJgp+2Ze5WFpwNu0nh0ag= +github.com/nsf/termbox-go v0.0.0-20190624072549-eeb6cd0a1762/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= diff --git a/params/protocol_params.go b/params/protocol_params.go index 75d44d88e..b15b4f5c3 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -13,4 +13,5 @@ var ( DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. + CreateDataGas = big.NewInt(200) ) diff --git a/tests/files/StateTests/EIP150/Homestead/stCallCreateCallCodeTest.json b/tests/files/StateTests/EIP150/Homestead/stCallCreateCallCodeTest.json index 50a10ddef..1a8cf739a 100644 --- a/tests/files/StateTests/EIP150/Homestead/stCallCreateCallCodeTest.json +++ b/tests/files/StateTests/EIP150/Homestead/stCallCreateCallCodeTest.json @@ -2353,78 +2353,6 @@ "value" : "0x0186a0" } }, - "createJS_ExampleContract" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x0f4240", - "currentNumber" : "0x257da8", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "post" : { - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x061414", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x030d40", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x01" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e6b054c", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - } - }, - "postStateRoot" : "b2dfcdafc749ca42b433c9a2f0c9f1375867a776d6389631b83c56928fcc3adc", - "pre" : { - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x0186a0", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x54c98c81" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e72a000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "0x60406103ca600439600451602451336000819055506000600481905550816001819055508060028190555042600581905550336003819055505050610381806100496000396000f30060003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b505600000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000023", - "gasLimit" : "0x0927c0", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "", - "value" : "0x0186a0" - } - }, "createNameRegistratorPerTxs" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/StateTests/EIP150/Homestead/stSystemOperationsTest.json b/tests/files/StateTests/EIP150/Homestead/stSystemOperationsTest.json index 3b489624f..2ad86ca6e 100644 --- a/tests/files/StateTests/EIP150/Homestead/stSystemOperationsTest.json +++ b/tests/files/StateTests/EIP150/Homestead/stSystemOperationsTest.json @@ -6285,83 +6285,6 @@ "value" : "0x0186a0" } }, - "CreateHashCollision" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x989680", - "currentNumber" : "0xa7d8c0", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x", - "post" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7658689", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x01", - "storage" : { - "0x00" : "0xd2571607e241ecf590ed94b12d87c94babe36db6" - } - }, - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x0129d8", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7614f88", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x41", - "code" : "0x6000355415600957005b602035600035", - "nonce" : "0x00", - "storage" : { - } - } - }, - "postStateRoot" : "9ad1ffb51fe6f7a2dca6fd17ab366990af3f875137c82d2dc64ff6e8b1b9161e", - "pre" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x2a", - "code" : "0x60016001016055", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "", - "gasLimit" : "0x989680", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "0x0186a0" - } - }, "PostToReturn1" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/StateTests/Homestead/stCallCreateCallCodeTest.json b/tests/files/StateTests/Homestead/stCallCreateCallCodeTest.json index 4c5c45e7a..a9d0eda92 100755 --- a/tests/files/StateTests/Homestead/stCallCreateCallCodeTest.json +++ b/tests/files/StateTests/Homestead/stCallCreateCallCodeTest.json @@ -2450,78 +2450,6 @@ "value" : "0x0186a0" } }, - "createJS_ExampleContract" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x0f4240", - "currentNumber" : "0x0f4240", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "post" : { - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x061414", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x030d40", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x01" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e6b054c", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - } - }, - "postStateRoot" : "b2dfcdafc749ca42b433c9a2f0c9f1375867a776d6389631b83c56928fcc3adc", - "pre" : { - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x0186a0", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x54c98c81" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e72a000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "0x60406103ca600439600451602451336000819055506000600481905550816001819055508060028190555042600581905550336003819055505050610381806100496000396000f30060003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b505600000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000023", - "gasLimit" : "0x0927c0", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "", - "value" : "0x0186a0" - } - }, "createNameRegistratorPerTxs" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/StateTests/Homestead/stSystemOperationsTest.json b/tests/files/StateTests/Homestead/stSystemOperationsTest.json index 5981bd955..e3be9a35f 100755 --- a/tests/files/StateTests/Homestead/stSystemOperationsTest.json +++ b/tests/files/StateTests/Homestead/stSystemOperationsTest.json @@ -16434,83 +16434,6 @@ "value" : "0x0186a0" } }, - "CreateHashCollision" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x989680", - "currentNumber" : "0x00", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x", - "post" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7658689", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x01", - "storage" : { - "0x00" : "0xd2571607e241ecf590ed94b12d87c94babe36db6" - } - }, - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x0129d8", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7614f88", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x41", - "code" : "0x6000355415600957005b602035600035", - "nonce" : "0x00", - "storage" : { - } - } - }, - "postStateRoot" : "9ad1ffb51fe6f7a2dca6fd17ab366990af3f875137c82d2dc64ff6e8b1b9161e", - "pre" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x2a", - "code" : "0x60016001016055", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "", - "gasLimit" : "0x989680", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "0x0186a0" - } - }, "PostToReturn1" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/StateTests/stCallCreateCallCodeTest.json b/tests/files/StateTests/stCallCreateCallCodeTest.json index 236265a4b..50ef07fd6 100755 --- a/tests/files/StateTests/stCallCreateCallCodeTest.json +++ b/tests/files/StateTests/stCallCreateCallCodeTest.json @@ -2450,78 +2450,6 @@ "value" : "0x0186a0" } }, - "createJS_ExampleContract" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x0f4240", - "currentNumber" : "0x00", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "post" : { - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x059714", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x030d40", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x01" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e6b824c", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - } - }, - "postStateRoot" : "5500215cdbf8165ca47720ad088ae49c2441560cdf267f1c946ae7b9807cb1d4", - "pre" : { - "6295ee1b4f6dd65047762f924ecd367c17eabf8f" : { - "balance" : "0x0186a0", - "code" : "0x60003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b5056", - "nonce" : "0x00", - "storage" : { - "0x00" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x01" : "0x42", - "0x02" : "0x23", - "0x03" : "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", - "0x05" : "0x54c98c81" - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x09184e72a000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "0x60406103ca600439600451602451336000819055506000600481905550816001819055508060028190555042600581905550336003819055505050610381806100496000396000f30060003560e060020a9004806343d726d61461004257806391b7f5ed14610050578063d686f9ee14610061578063f5bade661461006f578063fcfff16f1461008057005b61004a6101de565b60006000f35b61005b6004356100bf565b60006000f35b610069610304565b60006000f35b61007a60043561008e565b60006000f35b6100886100f0565b60006000f35b600054600160a060020a031633600160a060020a031614156100af576100b4565b6100bc565b806001819055505b50565b600054600160a060020a031633600160a060020a031614156100e0576100e5565b6100ed565b806002819055505b50565b600054600160a060020a031633600160a060020a031614806101255750600354600160a060020a031633600160a060020a0316145b61012e57610161565b60016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a16101dc565b60045460011480610173575060015434105b6101b85760016004819055507f59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a560006000a142600581905550336003819055506101db565b33600160a060020a03166000346000600060006000848787f16101d757005b5050505b5b565b60006004546000146101ef576101f4565b610301565b600054600160a060020a031633600160a060020a031614801561022c5750600054600160a060020a0316600354600160a060020a0316145b61023557610242565b6000600481905550610301565b600354600160a060020a031633600160a060020a03161461026257610300565b600554420360025402905060015481116102c757600354600160a060020a0316600082600154036000600060006000848787f161029b57005b505050600054600160a060020a03166000826000600060006000848787f16102bf57005b5050506102ee565b600054600160a060020a031660006001546000600060006000848787f16102ea57005b5050505b60006004819055506000546003819055505b5b50565b6000600054600160a060020a031633600160a060020a031614156103275761032c565b61037e565b600554420360025402905060015481116103455761037d565b600054600160a060020a031660006001546000600060006000848787f161036857005b50505060006004819055506000546003819055505b5b505600000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000023", - "gasLimit" : "0x0927c0", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "", - "value" : "0x0186a0" - } - }, "createNameRegistratorPerTxs" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/files/StateTests/stSystemOperationsTest.json b/tests/files/StateTests/stSystemOperationsTest.json index ff381f9b6..9f23b7d41 100755 --- a/tests/files/StateTests/stSystemOperationsTest.json +++ b/tests/files/StateTests/stSystemOperationsTest.json @@ -16434,83 +16434,6 @@ "value" : "0x0186a0" } }, - "CreateHashCollision" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x0100", - "currentGasLimit" : "0x989680", - "currentNumber" : "0x00", - "currentTimestamp" : "0x01", - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" - }, - "logs" : [ - ], - "out" : "0x", - "post" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7658689", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x01", - "storage" : { - "0x00" : "0xd2571607e241ecf590ed94b12d87c94babe36db6" - } - }, - "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : { - "balance" : "0x0129d8", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7614f88", - "code" : "0x", - "nonce" : "0x01", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x41", - "code" : "0x6000355415600957005b602035600035", - "nonce" : "0x00", - "storage" : { - } - } - }, - "postStateRoot" : "9ad1ffb51fe6f7a2dca6fd17ab366990af3f875137c82d2dc64ff6e8b1b9161e", - "pre" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x7c601080600c6000396000f3006000355415600957005b60203560003555600052601d60036017f0600055", - "nonce" : "0x00", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "0x0de0b6b3a7640000", - "code" : "0x", - "nonce" : "0x00", - "storage" : { - } - }, - "d2571607e241ecf590ed94b12d87c94babe36db6" : { - "balance" : "0x2a", - "code" : "0x60016001016055", - "nonce" : "0x00", - "storage" : { - } - } - }, - "transaction" : { - "data" : "", - "gasLimit" : "0x989680", - "gasPrice" : "0x01", - "nonce" : "0x00", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "0x0186a0" - } - }, "PostToReturn1" : { "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", diff --git a/tests/state_test.go b/tests/state_test.go index ab315e90e..adcac9de1 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -689,19 +689,6 @@ func TestAllETH(t *testing.T) { skipTests["RevertPrecompiledTouch_storage.json/ConstantinopleFix/0"] = "Bug in Test" skipTests["RevertPrecompiledTouch_storage.json/ConstantinopleFix/3"] = "Bug in Test" - // EIP 684 Implementations - skipTests["TransactionCollisionToEmptyButCode.json"] = "Not Implemented" - skipTests["TransactionCollisionToEmpty.json"] = "Not Implemented" - skipTests["TransactionCollisionToEmptyButNonce.json"] = "Not Implemented" - skipTests["CreateCollisionToEmpty.json"] = "Not Implemented" - skipTests["CreateHashCollision.json"] = "Not Implemented" - skipTests["createJS_ExampleContract.json"] = "Not Implemented" - skipTests["RevertDepthCreateAddressCollision.json"] = "Not Implemented" - - // Random Test failures - skipTests["randomStatetest644.json"] = "random unimplemented" - skipTests["randomStatetest645.json"] = "random unimplemented" - unsupportedDirs := map[string]bool{ "stZeroKnowledge": true, "stZeroKnowledge2": true, diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 0e4beeb23..9bc710267 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -200,7 +200,7 @@ func runStateTest(ruleSet RuleSet, test VmTest) error { if balance, ok := new(big.Int).SetString(account.Balance, 0); !ok { panic("malformed test account balance") } else if balance.Cmp(obj.Balance()) != 0 { - return fmt.Errorf("(%x) balance failed. Expected: %v have: %v\n", obj.Address().Bytes()[:4], account.Balance, obj.Balance()) + return fmt.Errorf("(%x) balance failed. Expected: %v have: %v\n", obj.Address().Bytes()[:4], account.Balance, "0x"+obj.Balance().Text(16)) } if nonce, err := strconv.ParseUint(account.Nonce, 0, 64); err != nil {