Skip to content

Commit

Permalink
refactor: change forwarder proxy bytecode to ERC-1167
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Jan 23, 2021
1 parent 4ac9e49 commit dca951b
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions vyper/functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,51 +1426,35 @@ def build_LLL(self, expr, context):


def get_create_forwarder_to_bytecode():
from vyper.compile_lll import assembly_to_evm, num_to_bytearray
from vyper.compile_lll import assembly_to_evm

code_a = [
"PUSH1",
0x33,
"PUSH1",
0x0C,
"PUSH1",
0x00,
"CODECOPY",
"PUSH1",
0x33,
"PUSH1",
0x00,
"RETURN",
"CALLDATASIZE",
"PUSH1",
0x00,
"PUSH1",
0x00,
"RETURNDATASIZE",
"RETURNDATASIZE",
"CALLDATACOPY",
"PUSH2",
num_to_bytearray(0x1000),
"PUSH1",
0x00,
"RETURNDATASIZE",
"RETURNDATASIZE",
"RETURNDATASIZE",
"CALLDATASIZE",
"PUSH1",
0x00,
"RETURNDATASIZE",
"PUSH20", # [address to delegate to]
]
code_b = [
"GAS",
"DELEGATECALL",
"RETURNDATASIZE",
"DUP3",
"DUP1",
"RETURNDATACOPY",
"SWAP1",
"RETURNDATASIZE",
"SWAP2",
"PUSH1",
0x2C, # jumpdest of whole program.
0x2B, # jumpdest of whole program.
"JUMPI",
"PUSH1",
0x0,
"DUP1",
"REVERT",
"JUMPDEST",
"PUSH2",
num_to_bytearray(0x1000),
"PUSH1",
0x00,
"RETURN",
]
return assembly_to_evm(code_a)[0] + (b"\x00" * 20) + assembly_to_evm(code_b)[0]
Expand Down

0 comments on commit dca951b

Please sign in to comment.