Commit ec4f0683 authored by clabby's avatar clabby

:broom:

parent 713e73a7
......@@ -31,7 +31,7 @@ var (
// BlockHashOracleMetaData contains all meta data concerning the BlockHashOracle contract.
var BlockHashOracleMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[],\"name\":\"BlockHashNotPresent\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BlockNumberOOB\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blockNumber\",\"type\":\"uint256\"}],\"name\":\"load\",\"outputs\":[{\"internalType\":\"Hash\",\"name\":\"blockHash_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blockNumber\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
Bin: "0x608060405234801561001057600080fd5b50610134806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e61004936600461010e565b610075565b005b61006361005e36600461010e565b6100c0565b60405190815260200160405180910390f35b8040806100ae576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b60008181526020819052604081205490819003610109576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012057600080fd5b503591905056fea164736f6c634300080f000a",
Bin: "0x608060405234801561001057600080fd5b50610138806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e610049366004610112565b610075565b005b61006361005e366004610112565b6100c4565b60405190815260200160405180910390f35b804060008190036100b2576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b6000818152602081905260408120549081900361010d576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012457600080fd5b503591905056fea164736f6c634300080f000a",
}
// BlockHashOracleABI is the input ABI used to generate the binding from.
......
......@@ -13,7 +13,7 @@ const BlockHashOracleStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contra
var BlockHashOracleStorageLayout = new(solc.StorageLayout)
var BlockHashOracleDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e61004936600461010e565b610075565b005b61006361005e36600461010e565b6100c0565b60405190815260200160405180910390f35b8040806100ae576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b60008181526020819052604081205490819003610109576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012057600080fd5b503591905056fea164736f6c634300080f000a"
var BlockHashOracleDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e610049366004610112565b610075565b005b61006361005e366004610112565b6100c4565b60405190815260200160405180910390f35b804060008190036100b2576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b6000818152602081905260408120549081900361010d576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012457600080fd5b503591905056fea164736f6c634300080f000a"
func init() {
if err := json.Unmarshal([]byte(BlockHashOracleStorageLayoutJSON), BlockHashOracleStorageLayout); err != nil {
......
This diff is collapsed.
......@@ -51,10 +51,12 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context
require.NoError(err)
// Deploy the block hash oracle
_, tx, blockHashOracle, err := bindings.DeployBlockHashOracle(opts, client)
_, tx, _, err = bindings.DeployBlockHashOracle(opts, client)
require.NoError(err)
blockHashOracleAddr, err := bind.WaitDeployed(ctx, client, tx)
require.NoError(err)
blockHashOracle, err := bindings.NewBlockHashOracle(blockHashOracleAddr, client)
require.NoError(err)
// Store the genesis block hash in the oracle
tx, err = blockHashOracle.Store(opts, big.NewInt(0))
......
......@@ -33,7 +33,7 @@ const (
StatusDefenderWins
)
var alphaExtraData = common.Hex2Bytes("0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
var alphaExtraData = common.Hex2Bytes("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
var alphabetVMAbsolutePrestate = common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000060")
var alphabetVMAbsolutePrestateClaim = crypto.Keccak256Hash(alphabetVMAbsolutePrestate)
var CorrectAlphabet = "abcdefghijklmnop"
......
......@@ -16,7 +16,7 @@ AssetReceiverTest:test_withdrawETHwithAmount_unauthorized_reverts() (gas: 10738)
AttestationStationTest:test_attest_bulk_succeeds() (gas: 703740)
AttestationStationTest:test_attest_individual_succeeds() (gas: 632078)
AttestationStationTest:test_attest_single_succeeds() (gas: 651316)
BlockHashOracle_Test:test_load_reverts() (gas: 10436)
BlockHashOracle_Test:test_load_noBlockHash_reverts() (gas: 10436)
Bytes_slice_Test:test_slice_acrossMultipleWords_works() (gas: 9413)
Bytes_slice_Test:test_slice_acrossWords_works() (gas: 1430)
Bytes_slice_Test:test_slice_fromNonZeroIdx_works() (gas: 17240)
......
......@@ -16,10 +16,7 @@ contract BlockHashOracle {
/// @return blockHash_ The block hash for the given block number.
function load(uint256 _blockNumber) external view returns (Hash blockHash_) {
blockHash_ = blockHashes[_blockNumber];
if (Hash.unwrap(blockHash_) == 0) {
revert BlockHashNotPresent();
}
if (Hash.unwrap(blockHash_) == 0) revert BlockHashNotPresent();
}
/// @notice Stores a block hash for a given block number, assuming that the block number
......@@ -27,11 +24,7 @@ contract BlockHashOracle {
/// @param _blockNumber The block number to persist the block hash for.
function store(uint256 _blockNumber) external {
bytes32 blockHash = blockhash(_blockNumber);
if (blockHash == bytes32(0)) {
revert BlockNumberOOB();
}
if (blockHash == 0) revert BlockNumberOOB();
blockHashes[_blockNumber] = Hash.wrap(blockHash);
}
}
......@@ -24,7 +24,7 @@ contract BlockHashOracle_Test is Test {
/// @notice Tests that loading a block hash for a block number outside the range of the
/// `BLOCKHASH` opcode fails.
function testFuzz_store_reverts(uint256 _blockNumber) public {
function testFuzz_store_oob_reverts(uint256 _blockNumber) public {
// Fast forward another 256 blocks.
vm.roll(block.number + 256);
// Bound the block number to the set { 0, ..., 255 } ∪ { 512, ..., type(uint256).max }
......@@ -39,7 +39,7 @@ contract BlockHashOracle_Test is Test {
/// @notice Tests that the `load` function reverts if the block hash for the given block
/// number has not been stored.
function test_load_reverts() public {
function test_load_noBlockHash_reverts() public {
vm.expectRevert(BlockHashNotPresent.selector);
oracle.load(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment