core/vm: change Get -> GetCopy in vm memory access

This commit is contained in:
Martin Holst Swende 2019-10-30 12:46:10 +01:00
parent c9ff3e1680
commit 33b3c0583c
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
4 changed files with 7 additions and 7 deletions

View file

@ -689,7 +689,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor
var (
value = stack.pop()
offset, size = stack.pop(), stack.pop()
input = memory.Get(offset.Int64(), size.Int64())
input = memory.GetCopy(offset.Int64(), size.Int64())
gas = contract.Gas
)
if interpreter.evm.chainRules.IsEIP150 {
@ -723,7 +723,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
endowment = stack.pop()
offset, size = stack.pop(), stack.pop()
salt = stack.pop()
input = memory.Get(offset.Int64(), size.Int64())
input = memory.GetCopy(offset.Int64(), size.Int64())
gas = contract.Gas
)
@ -893,7 +893,7 @@ func makeLog(size int) executionFunc {
topics[i] = common.BigToHash(stack.pop())
}
d := memory.Get(mStart.Int64(), mSize.Int64())
d := memory.GetCopy(mStart.Int64(), mSize.Int64())
interpreter.evm.StateDB.AddLog(&types.Log{
Address: contract.Address(),
Topics: topics,

View file

@ -509,12 +509,12 @@ func TestOpMstore(t *testing.T) {
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
stack.pushN(new(big.Int).SetBytes(common.Hex2Bytes(v)), big.NewInt(0))
opMstore(&pc, evmInterpreter, nil, mem, stack)
if got := common.Bytes2Hex(mem.Get(0, 32)); got != v {
if got := common.Bytes2Hex(mem.GetCopy(0, 32)); got != v {
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
}
stack.pushN(big.NewInt(0x1), big.NewInt(0))
opMstore(&pc, evmInterpreter, nil, mem, stack)
if common.Bytes2Hex(mem.Get(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
if common.Bytes2Hex(mem.GetCopy(0, 32)) != "0000000000000000000000000000000000000000000000000000000000000001" {
t.Fatalf("Mstore failed to overwrite previous value")
}
poolOfIntPools.put(evmInterpreter.intPool)

View file

@ -70,7 +70,7 @@ func (m *Memory) Resize(size uint64) {
}
// Get returns offset + size as a new slice
func (m *Memory) Get(offset, size int64) (cpy []byte) {
func (m *Memory) GetCopy(offset, size int64) (cpy []byte) {
if size == 0 {
return nil
}

View file

@ -99,7 +99,7 @@ func (mw *memoryWrapper) slice(begin, end int64) []byte {
log.Warn("Tracer accessed out of bound memory", "available", mw.memory.Len(), "offset", begin, "size", end-begin)
return nil
}
return mw.memory.Get(begin, end-begin)
return mw.memory.GetCopy(begin, end-begin)
}
// getUint returns the 32 bytes at the specified address interpreted as a uint.