Skip to content

Commit

Permalink
fix: rename difficulty to prevrandao
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou authored and oguimbal committed Jan 8, 2024
1 parent b6b3ceb commit 41249cd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/HyVM.huff
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@
number
CONTINUE()

op_difficulty:
difficulty
op_prevrandao:
prevrandao
CONTINUE()

op_gaslimit:
Expand Down
2 changes: 1 addition & 1 deletion src/Jump-table.huff
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
op_lt op_gt op_slt op_sgt op_eq op_iszero op_and op_or op_xor op_not op_byte op_shl op_shr op_sar unused unused
op_sha3 unused unused unused unused unused unused unused unused unused unused unused unused unused unused unused
op_address op_balance op_origin op_caller op_callvalue op_calldataload op_calldatasize op_calldatacopy op_codesize op_codecopy op_gasprice op_extcodesize op_extcodecopy op_returndatasize op_returndatacopy op_extcodehash
op_blockhash op_coinbase op_timestamp op_number op_difficulty op_gaslimit op_chainid op_selfbalance op_basefee unused unused unused unused unused unused unused
op_blockhash op_coinbase op_timestamp op_number op_prevrandao op_gaslimit op_chainid op_selfbalance op_basefee unused unused unused unused unused unused unused
op_pop op_mload op_mstore op_mstore8 op_sload op_sstore op_jump op_jumpi op_pc op_msize op_gas op_jumpdest unused unused unused op_push0
op_push1 op_push2 op_push3 op_push4 op_push5 op_push6 op_push7 op_push8 op_push9 op_push10 op_push11 op_push12 op_push13 op_push14 op_push15 op_push16
op_push17 op_push18 op_push19 op_push20 op_push21 op_push22 op_push23 op_push24 op_push25 op_push26 op_push27 op_push28 op_push29 op_push30 op_push31 op_push32
Expand Down
10 changes: 10 additions & 0 deletions test/HyVM/Opcodes.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1147,4 +1147,14 @@ contract OpcodesTest is Test {
);
assertTrue(success, "expectRevert: call did not revert");
}

function testPrevrandao(uint256 prevrandao) public {
// bytecode generated using: easm test/opcodes/prevrandao
// EVM-Assembler does not implement it, so it is added manually
vm.prevrandao(bytes32(prevrandao));
(bool success, bytes memory data) = hyvm.delegatecall(hex"4460005260206000f3");
assertEq(success, true);
(uint256 result) = abi.decode(data, (uint256));
assertEq(result, prevrandao);
}
}
8 changes: 8 additions & 0 deletions test/HyVM/opcodes/prevrandao
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREVRANDAO

# return result
PUSH1 0x0
MSTORE
PUSH1 0x20
PUSH1 0x00
RETURN

0 comments on commit 41249cd

Please sign in to comment.