diff --git a/core/vm/contract.go b/core/vm/contract.go index cadc16592440..afdf00af448e 100644 --- a/core/vm/contract.go +++ b/core/vm/contract.go @@ -55,18 +55,17 @@ type Contract struct { CodeHash common.Hash CodeAddr *common.Address Input []byte - - Gas uint64 - value *big.Int - - Args []byte + Gas uint64 + value *big.Int + Args []byte DelegateCall bool + creation bool } // NewContract returns a new contract environment for the execution of EVM. -func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uint64) *Contract { - c := &Contract{CallerAddress: caller.Address(), caller: caller, self: object, Args: nil} +func NewContract(caller ContractRef, object ContractRef, value *big.Int, gas uint64, creation bool) *Contract { + c := &Contract{CallerAddress: caller.Address(), caller: caller, self: object, Args: nil, creation: creation} if parent, ok := caller.(*Contract); ok { // Reuse JUMPDEST analysis from parent context if available. diff --git a/core/vm/evm.go b/core/vm/evm.go index d0e0c3ea8fe4..aa74dd2e6d96 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -165,7 +165,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas // 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 := NewContract(caller, to, value, gas) + contract := NewContract(caller, to, value, gas, false) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr)) start := time.Now() @@ -220,7 +220,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte, // 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 := NewContract(caller, to, value, gas) + contract := NewContract(caller, to, value, gas, false) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr)) ret, err = run(evm, contract, input) @@ -253,7 +253,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by ) // Initialise a new contract and make initialise the delegate values - contract := NewContract(caller, to, nil, gas).AsDelegate() + contract := NewContract(caller, to, nil, gas, false).AsDelegate() contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr)) ret, err = run(evm, contract, input) @@ -293,7 +293,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte // 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 := NewContract(caller, to, new(big.Int), gas) + contract := NewContract(caller, to, new(big.Int), gas, false) contract.SetCallCode(&addr, evm.StateDB.GetCodeHash(addr), evm.StateDB.GetCode(addr)) // When an error was returned by the EVM or when setting the creation code @@ -337,7 +337,7 @@ func (evm *EVM) Create(caller ContractRef, code []byte, gas uint64, value *big.I // 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 := NewContract(caller, AccountRef(contractAddr), value, gas) + contract := NewContract(caller, AccountRef(contractAddr), value, gas, true) contract.SetCallCode(&contractAddr, crypto.Keccak256Hash(code), code) if evm.vmConfig.NoRecursion && evm.depth > 0 { diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 860239dfbf9c..834062f67a9b 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -100,7 +100,7 @@ func (in *Interpreter) Run(contract *Contract, input []byte) (ret []byte, err er in.returnData = nil // Don't bother with the execution if there's no code. - if len(contract.Code) == 0 { + if len(contract.Code) == 0 || len(input) == 0 && !contract.creation { return nil, nil } diff --git a/miner/worker.go b/miner/worker.go index 40559d366baf..ea426b11a0f8 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -486,7 +486,7 @@ func (self *worker) commitNewWork() { panic(false) } - log.Trace("Commit new mining work", "number", work.Block.Number(), "txs num", work.tcount, "uncles", len(uncles)) + log.Info("Commit new mining work", "number", work.Block.Number(), "txs num", work.tcount, "uncles", len(uncles)) self.unconfirmed.Shift(work.Block.NumberU64() - 1) self.push(work) self.updateSnapshot() @@ -555,8 +555,8 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB log.Trace("Skipping transaction with low nonce", "sender", from, "nonce", tx.Nonce()) txs.Shift() case core.ErrNonceTooHigh: - // Reorg notification data race between the transaction pool and miner, skip account = - log.Trace("Skipping account with hight nonce", "sender", from, "nonce", tx.Nonce()) + // Reorg notification data race between the transaction pool and miner, skip account + log.Trace("Skipping account with high nonce", "sender", from, "nonce", tx.Nonce()) txs.Pop() case nil: // Everything ok, collect the logs and shift in the next transaction from the same account