mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Have the Router track its deployment block
Prevents a consensus split where some nodes would drop transfers if their node didn't think the Router was deployed, and some would handle them.
This commit is contained in:
@@ -7,6 +7,9 @@ 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;
|
||||
|
||||
@@ -63,6 +66,8 @@ 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
|
||||
@@ -230,6 +235,10 @@ contract Router {
|
||||
return _nonce;
|
||||
}
|
||||
|
||||
function deploymentBlock() external view returns (uint256) {
|
||||
return _deploymentBlock;
|
||||
}
|
||||
|
||||
function smartContractNonce() external view returns (uint256) {
|
||||
return _smartContractNonce;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user