-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from NethermindEth/anshu/task-manager-block-pr…
…oposal Add block proposals and lookahead posting
- Loading branch information
Showing
7 changed files
with
599 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
Submodule openzeppelin-contracts
added at
54b3f1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
eigenlayer-middleware/=lib/eigenlayer-middleware/src | ||
forge-std/=lib/forge-std/src/ | ||
openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/contracts |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.25; | ||
|
||
interface ITaikoL1 { | ||
struct BlockMetadata { | ||
bytes32 l1Hash; | ||
bytes32 difficulty; | ||
bytes32 blobHash; | ||
bytes32 extraData; | ||
bytes32 depositsHash; | ||
address coinbase; | ||
uint64 id; | ||
uint32 gasLimit; | ||
uint64 timestamp; | ||
uint64 l1Height; | ||
uint16 minTier; | ||
bool blobUsed; | ||
bytes32 parentMetaHash; | ||
address sender; | ||
} | ||
|
||
struct EthDeposit { | ||
address recipient; | ||
uint96 amount; | ||
uint64 id; | ||
} | ||
|
||
function proposeBlock(bytes calldata _params, bytes calldata _txList) | ||
external | ||
payable | ||
returns (BlockMetadata memory meta_, EthDeposit[] memory deposits_); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.25; | ||
|
||
library MerkleUtils { | ||
uint256 internal constant CHUNKS_LENGTH = 8; | ||
uint256 internal constant TMP_LENGTH = 4; | ||
|
||
function hash(bytes32 a, bytes32 b) internal pure returns (bytes32) { | ||
return sha256(abi.encodePacked(a, b)); | ||
} | ||
|
||
function merkleize(bytes32[CHUNKS_LENGTH] memory chunks) internal pure returns (bytes32) { | ||
bytes32[] memory tmp = new bytes32[](TMP_LENGTH); | ||
|
||
for (uint256 i; i < CHUNKS_LENGTH; ++i) { | ||
merge(tmp, i, chunks[i]); | ||
} | ||
|
||
return tmp[TMP_LENGTH - 1]; | ||
} | ||
|
||
function merge(bytes32[] memory tmp, uint256 index, bytes32 chunk) internal pure { | ||
bytes32 h = chunk; | ||
uint256 j = 0; | ||
while (true) { | ||
if (index & 1 << j == 0) { | ||
break; | ||
} else { | ||
h = hash(tmp[j], h); | ||
} | ||
j += 1; | ||
} | ||
tmp[j] = h; | ||
} | ||
|
||
function verifyProof(bytes32[] memory proof, bytes32 root, bytes32 leaf, uint256 leafIndex) | ||
internal | ||
pure | ||
returns (bool) | ||
{ | ||
bytes32 h = leaf; | ||
uint256 index = leafIndex; | ||
|
||
for (uint256 i = 0; i < proof.length; i++) { | ||
bytes32 proofElement = proof[i]; | ||
|
||
if (index % 2 == 0) { | ||
h = sha256(bytes.concat(h, proofElement)); | ||
} else { | ||
h = sha256(bytes.concat(proofElement, h)); | ||
} | ||
|
||
index = index / 2; | ||
} | ||
|
||
return h == root; | ||
} | ||
|
||
function toLittleEndian(uint256 n) public pure returns (bytes32) { | ||
uint256 v = n; | ||
v = ((v & 0xFF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00) >> 8) | ||
| ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8); | ||
v = ((v & 0xFFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000) >> 16) | ||
| ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16); | ||
v = ((v & 0xFFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000) >> 32) | ||
| ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32); | ||
v = ((v & 0xFFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF0000000000000000) >> 64) | ||
| ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64); | ||
v = (v >> 128) | (v << 128); | ||
return bytes32(v); | ||
} | ||
|
||
function mixInLength(bytes32 root, uint256 length) public pure returns (bytes32) { | ||
bytes32 littleEndianLength = toLittleEndian(length); | ||
return sha256(abi.encodePacked(root, littleEndianLength)); | ||
} | ||
} |