Don't track deployment block in the Router

This technically has a TOCTOU where we sync an Epoch's metadata (signifying we
did sync to that point), then check if the Router was deployed, yet at that
very moment the node resets to genesis. By ensuring the Router is deployed, we
avoid this (and don't need to track the deployment block in-contract).

Also uses a JoinSet to sync the 32 blocks in parallel.
This commit is contained in:
Luke Parker
2024-09-20 02:06:35 -04:00
parent 7e4c59a0a3
commit 554c5778e4
3 changed files with 50 additions and 64 deletions

View File

@@ -7,9 +7,6 @@ import "Schnorr.sol";
// _ is used as a prefix for internal functions and smart-contract-scoped variables
contract Router {
// The block at which this contract was deployed.
uint256 private _deploymentBlock;
// Nonce is incremented for each command executed, preventing replays
uint256 private _nonce;
@@ -66,8 +63,6 @@ contract Router {
}
constructor(bytes32 initialSeraiKey) _updateSeraiKeyAtEndOfFn(0, initialSeraiKey) {
_deploymentBlock = block.number;
// We consumed nonce 0 when setting the initial Serai key
_nonce = 1;
// Nonces are incremented by 1 upon account creation, prior to any code execution, per EIP-161
@@ -235,10 +230,6 @@ contract Router {
return _nonce;
}
function deploymentBlock() external view returns (uint256) {
return _deploymentBlock;
}
function smartContractNonce() external view returns (uint256) {
return _smartContractNonce;
}