This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: bun-types | |
jobs: | |
build: | |
name: build-app | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Install bun | |
uses: oven-sh/setup-bun@v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
// https://community.optimism.io/docs/developers/bedrock/differences/#l1-contracts | |
pragma solidity 0.8.10; | |
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | |
/** | |
* @title L2OutputOracle | |
* @notice The L2 state is committed to in this contract | |
* The payable keyword is used on appendL2Output to save gas on the msg.value check. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function verifyBlockHeader(block: IRawBlock): boolean { | |
const expected = block.hash; | |
const calculated = calculateBlockHeader(block); | |
return expected === calculated; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createKeccakHash from 'keccak'; | |
function calculateBlockHeader(block: IRawBlock): string { | |
const tuple = prepareBlockTuple(block); | |
const encoded = Buffer.from(encode(tuple)); | |
const calculated = createKeccakHash('keccak256').update(encoded).digest('hex'); | |
return '0x' + calculated; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Legacy Block (Block Number = 12 964 874) | |
[ | |
'0x4b0a0331740041e0a110fb20295878a56e3ff9c52b4fabddb3f9ebb56ed664e0', | |
'0x0eab1b145a087ad364aed20c2a313347afb5eb69ddaef3503f4d5b2c1be7c6c7', | |
'0xea674fdde714fd979de3edf0f56aa9716b898ec8', | |
'0xb51018a3b2723021f90de0c0461ea172c4d0477ccdf333d0bc0dad11b689e34c', | |
'0x9b66b32f7d4cf7f5a80614e27ae874879c04136e0a9400c1b59e0cff13f71bec', | |
'0x2922269aa89c5df859a38e168dbdce0e07a7ccb651f9ffcb6c6b1e74eaf7e069', | |
'0x2361a9b76107883d7089e585a3a1422374b21375b8168423507d70b2bccab1a10c5771c82882574255d25bb3c04747e9971ca844ed667b2407dbfb207a24ac5940985ec6f00a0b2c19baaaff217033b63ba7fc2467e64f816ace1764d9e90dd97f5098d2d383ae4951c21952e837eac70290d769b61b275e0a1f75d030382a06e890ef782655601487fc124d274a7626195724f7275409589d2f00e50a5b2914c3db2b5bb1de73284217e0d2f23fa4999a52fa4611e0a005292abd3e5b5d09ff13d12537398412f03416d82181fbb1939965568e078f2f1e65481b8eed3aea90f8f37e99c12fa02500ac1721c2409770d5b52440ab43c050277a2b93357970a7', | |
'0x1b315bd824e5e8', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function prepareBlockTuple(block: IRawBlock): ILegacyBlockTuple | IPost1559Tuple { | |
const blockNumber = parseInt(block.number, 16); | |
const tuple = [ | |
block.parentHash, | |
block.sha3Uncles, | |
block.miner, | |
block.stateRoot, | |
block.transactionsRoot, | |
block.receiptsRoot, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"baseFeePerGas":"0x2be5fed13e", | |
"difficulty":"0x281030ebe089b5", | |
"extraData":"0x6575726f70652d63656e7472616c322d676e7637", | |
"gasLimit":"0x1c9c380", | |
"gasUsed":"0x695d2c", | |
"hash":"0x01176f73081379cfd9d8bcee1c7e822b66f4d71160900d7f963619c42716cd83", | |
"logsBloom":"0x0004062c4100100084005220900000011029000028342020009504283640c340d095908023620024402a4d0900184d010a0020061a01a0308000080028a86c422100206024138a081c40181860201d00107a006f100981042888a406c40014a20068001352801028884020010028280842484c2001c80940120001320059000001c28002000003014049440c00026297c010080101ce8008091008312090322c1a0000b9108828042800c09108000c0248021049a9126190022c080a100cb858500c041605210080000000872a160052a2280002862a035210009144004020230010300140040040040c1022199408b0021000086900b0c0002a080210016401", | |
"miner":"0xea674fdde714fd979de3edf0f56aa9716b898ec8", | |
"mixHash":"0x151624c46d33ac76f36d3e365487ab78f0a9847f6b16b0775e36a9c9dbb3f520", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"difficulty":"0x1b315bd824e5e8", | |
"extraData":"0x65746865726d696e652d75732d7765737431", | |
"gasLimit":"0xe4e1b2", | |
"gasUsed":"0xe4dd4b", | |
"hash":"0x14687ccc4adfd2b0f0d530fc8f8c64dd29ac301ddea26e99087e11d0eae4f575", | |
"logsBloom":"0x2361a9b76107883d7089e585a3a1422374b21375b8168423507d70b2bccab1a10c5771c82882574255d25bb3c04747e9971ca844ed667b2407dbfb207a24ac5940985ec6f00a0b2c19baaaff217033b63ba7fc2467e64f816ace1764d9e90dd97f5098d2d383ae4951c21952e837eac70290d769b61b275e0a1f75d030382a06e890ef782655601487fc124d274a7626195724f7275409589d2f00e50a5b2914c3db2b5bb1de73284217e0d2f23fa4999a52fa4611e0a005292abd3e5b5d09ff13d12537398412f03416d82181fbb1939965568e078f2f1e65481b8eed3aea90f8f37e99c12fa02500ac1721c2409770d5b52440ab43c050277a2b93357970a7", | |
"miner":"0xea674fdde714fd979de3edf0f56aa9716b898ec8", | |
"mixHash":"0x7ae3558891959354b482938e5a61b1d7e371636e5a718137e16753f595531f6a", | |
"nonce":"0xb81e11f2cb22375e", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* If string supplied is prefixed with '0x' remove it and return the new string */ | |
function stripHexPrefix(input: string): string { | |
if (input.startsWith('0x')) { | |
input = input.slice(2); | |
} | |
return input; | |
} | |
/* Convert a hexadecimal string to an array of hexadecimal byte values (in preparation of inserting into a byte array) */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Input = string | number | bigint | Uint8Array | Array<Input> | null | undefined | any; | |
function encode(input: Input): Uint8Array { | |
/* (1) Non-value input */ | |
if (input === '' || input === false || input === null) { | |
const value = parseInt('0x80', 16); | |
return Uint8Array.from([value]); | |
} | |
/* (2) Empty list input */ |
NewerOlder