Skip to content

Commit

Permalink
update the assembely as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Apr 12, 2024
1 parent a00d184 commit 149a923
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions EIPS/eip-2935.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,54 +69,34 @@ def resolve_blockhash(block: Block, state: State, arg: uint64):
Exact evm assembly that can be used for the blockhash contract:

```
// check for <=32 (<33) byte size or else revert
// check if inputsize>32 revert
push1 0x20
calldatasize
push1 0x21
gt
push1 0x0a
// jump and skip revert
push1 0x32
jumpi
push0
push0
revert
// check if blocknumber > input or else return 0
jumpdest
// check if input > blocknumber-1 then return 0
push1 0x1
number
sub
push0
calldataload
number
gt
push1 0x1a
push1 0x2a
jumpi
// return 0
push0
push0
mstore
push1 0x20
push0
return
// check if input + 8193 > blocknumber (input >= blocknumber - 8192) or else return 0
jumpdest
number
push2 0x2001
// check if blocknumber > input + 8192 then return 0
push0
calldataload
push2 0x2000
add
number
gt
push1 0x2e
push1 0x2a
jumpi
// return 0
push0
push0
mstore
push1 0x2e
push0
return
// mod 8192 and sload
jumpdest
push2 0x2000
Expand All @@ -132,6 +112,21 @@ push1 0x20
push0
return
// return 0
jumpdest
push0
push0
mstore
push1 0x20
push0
return
// revert
jumpdest
push0
push0
revert
stop
```

Expand Down

0 comments on commit 149a923

Please sign in to comment.