Skip to content

Commit

Permalink
store last block commitment timestamp in router storage
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx committed Nov 17, 2024
1 parent d1ea565 commit 5e9a5c3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ethexe/contracts/src/IRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ pragma solidity ^0.8.26;
interface IRouter {
/* Storage related structures */

// TODO (breathx): should we store here something about commitment and timestamp?
/// @custom:storage-location erc7201:router.storage.Router
struct Storage {
bytes32 genesisBlockHash;
address mirror;
address mirrorProxy;
address wrappedVara;
bytes32 lastBlockCommitmentHash;
uint48 lastBlockCommitmentTimestamp;
uint256 signingThresholdPercentage;
uint64 baseWeight;
uint128 valuePerWeight;
Expand Down Expand Up @@ -167,6 +167,8 @@ interface IRouter {

function lastBlockCommitmentHash() external view returns (bytes32);

function lastBlockCommitmentTimestamp() external view returns (uint48);

function wrappedVara() external view returns (address);

function mirrorProxy() external view returns (address);
Expand Down
6 changes: 6 additions & 0 deletions ethexe/contracts/src/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ contract Router is IRouter, OwnableUpgradeable, ReentrancyGuardTransient {
return router.lastBlockCommitmentHash;
}

function lastBlockCommitmentTimestamp() public view returns (uint48) {
Storage storage router = _getStorage();
return router.lastBlockCommitmentTimestamp;
}

function wrappedVara() public view returns (address) {
Storage storage router = _getStorage();
return router.wrappedVara;
Expand Down Expand Up @@ -355,6 +360,7 @@ contract Router is IRouter, OwnableUpgradeable, ReentrancyGuardTransient {
* @dev SECURITY: this settlement should be performed before any other calls to avoid reentrancy.
*/
router.lastBlockCommitmentHash = blockCommitment.blockHash;
router.lastBlockCommitmentTimestamp = blockCommitment.blockTimestamp;

bytes memory transitionsHashes;

Expand Down
2 changes: 1 addition & 1 deletion ethexe/ethereum/Mirror.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ethexe/ethereum/MirrorProxy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ethexe/ethereum/Router.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ethexe/ethereum/WrappedVara.json

Large diffs are not rendered by default.

0 comments on commit 5e9a5c3

Please sign in to comment.