Yul interpreter: Return addresses of type u160 for create and create2 calls

This commit is contained in:
Bhargava Shastry 2020-07-13 14:23:43 +02:00
parent d808302c62
commit deffb7ffc8
3 changed files with 30 additions and 2 deletions

View File

@ -0,0 +1,13 @@
{
let u160max := 0xffffffffffffffffffffffffffffffffffffffff
let a := create(0, u160max, 0)
let b := and(u160max, create(0, u160max, 0))
mstore(0, eq(a, b))
}
// ----
// Trace:
// CREATE(0, 0xffffffffffffffffffffffffffffffffffffffff, 0)
// CREATE(0, 0xffffffffffffffffffffffffffffffffffffffff, 0)
// Memory dump:
// 0: 0000000000000000000000000000000000000000000000000000000000000001
// Storage dump:

View File

@ -0,0 +1,15 @@
{
let u160max := 0xffffffffffffffffffffffffffffffffffffffff
let a := create2(0, u160max, 0, 0)
let b := and(u160max, create2(0, u160max, 0, 0))
mstore(0, eq(a, b))
}
// ====
// EVMVersion: >=constantinople
// ----
// Trace:
// CREATE2(0, 0xffffffffffffffffffffffffffffffffffffffff, 0, 0)
// CREATE2(0, 0xffffffffffffffffffffffffffffffffffffffff, 0, 0)
// Memory dump:
// 0: 0000000000000000000000000000000000000000000000000000000000000001
// Storage dump:

View File

@ -303,11 +303,11 @@ u256 EVMInstructionInterpreter::eval(
case Instruction::CREATE:
accessMemory(arg[1], arg[2]);
logTrace(_instruction, arg);
return 0xcccccc + arg[1];
return u160(0xcccccc + arg[1]);
case Instruction::CREATE2:
accessMemory(arg[2], arg[3]);
logTrace(_instruction, arg);
return 0xdddddd + arg[1];
return u160(0xdddddd + arg[1]);
case Instruction::CALL:
case Instruction::CALLCODE:
// TODO assign returndata