mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/vm: change Get -> GetCopy in vm memory access
This commit is contained in:
parent
c9ff3e1680
commit
33b3c0583c
4 changed files with 7 additions and 7 deletions
|
|
@ -689,7 +689,7 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor
|
||||||
var (
|
var (
|
||||||
value = stack.pop()
|
value = stack.pop()
|
||||||
offset, size = stack.pop(), 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
|
gas = contract.Gas
|
||||||
)
|
)
|
||||||
if interpreter.evm.chainRules.IsEIP150 {
|
if interpreter.evm.chainRules.IsEIP150 {
|
||||||
|
|
@ -723,7 +723,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo
|
||||||
endowment = stack.pop()
|
endowment = stack.pop()
|
||||||
offset, size = stack.pop(), stack.pop()
|
offset, size = stack.pop(), stack.pop()
|
||||||
salt = stack.pop()
|
salt = stack.pop()
|
||||||
input = memory.Get(offset.Int64(), size.Int64())
|
input = memory.GetCopy(offset.Int64(), size.Int64())
|
||||||
gas = contract.Gas
|
gas = contract.Gas
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -893,7 +893,7 @@ func makeLog(size int) executionFunc {
|
||||||
topics[i] = common.BigToHash(stack.pop())
|
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{
|
interpreter.evm.StateDB.AddLog(&types.Log{
|
||||||
Address: contract.Address(),
|
Address: contract.Address(),
|
||||||
Topics: topics,
|
Topics: topics,
|
||||||
|
|
|
||||||
|
|
@ -509,12 +509,12 @@ func TestOpMstore(t *testing.T) {
|
||||||
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
|
v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
|
||||||
stack.pushN(new(big.Int).SetBytes(common.Hex2Bytes(v)), big.NewInt(0))
|
stack.pushN(new(big.Int).SetBytes(common.Hex2Bytes(v)), big.NewInt(0))
|
||||||
opMstore(&pc, evmInterpreter, nil, mem, stack)
|
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)
|
t.Fatalf("Mstore fail, got %v, expected %v", got, v)
|
||||||
}
|
}
|
||||||
stack.pushN(big.NewInt(0x1), big.NewInt(0))
|
stack.pushN(big.NewInt(0x1), big.NewInt(0))
|
||||||
opMstore(&pc, evmInterpreter, nil, mem, stack)
|
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")
|
t.Fatalf("Mstore failed to overwrite previous value")
|
||||||
}
|
}
|
||||||
poolOfIntPools.put(evmInterpreter.intPool)
|
poolOfIntPools.put(evmInterpreter.intPool)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ func (m *Memory) Resize(size uint64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns offset + size as a new slice
|
// 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 {
|
if size == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
log.Warn("Tracer accessed out of bound memory", "available", mw.memory.Len(), "offset", begin, "size", end-begin)
|
||||||
return nil
|
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.
|
// getUint returns the 32 bytes at the specified address interpreted as a uint.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue