diff --git a/common/types.go b/common/types.go index 48043788fd..e42239d8a8 100644 --- a/common/types.go +++ b/common/types.go @@ -205,6 +205,9 @@ func (a Address) Bytes() []byte { return a[:] } // Big converts an address to a big integer. func (a Address) Big() *big.Int { return new(big.Int).SetBytes(a[:]) } +// SetBig converts an address to a given big integer. +func (a Address) SetBig(int *big.Int) *big.Int { return int.SetBytes(a[:]) } + // Hash converts an address to a hash by left-padding it with zeros. func (a Address) Hash() Hash { return BytesToHash(a[:]) } diff --git a/core/vm/instructions.go b/core/vm/instructions.go index a1188848dc..04ecea4718 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -405,7 +405,7 @@ func opSha3(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory } func opAddress(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { - stack.push(contract.Address().Big()) + stack.push(contract.Address().SetBig(interpreter.intPool.get())) return nil, nil } @@ -416,12 +416,12 @@ func opBalance(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo } func opOrigin(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { - stack.push(interpreter.evm.Origin.Big()) + stack.push(interpreter.evm.Origin.SetBig(interpreter.intPool.get())) return nil, nil } func opCaller(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { - stack.push(contract.Caller().Big()) + stack.push(contract.Caller().SetBig(interpreter.intPool.get())) return nil, nil }