From 7446a7e7f8f1d1b775f0371dd3b88419df74de87 Mon Sep 17 00:00:00 2001 From: Uncle Fatso Date: Sun, 25 Oct 2026 18:16:34 +0300 Subject: [PATCH] make only initial session to be stored during the setup Signed-off-by: Uncle Fatso --- src/Gatekeeper.sol | 14 ++++++-------- test/gatekeeper/Gatekeeper.t.sol | 2 +- test/gatekeeper/GatekeeperRecall.t.sol | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Gatekeeper.sol b/src/Gatekeeper.sol index dcafb11..520d61f 100644 --- a/src/Gatekeeper.sol +++ b/src/Gatekeeper.sol @@ -71,15 +71,14 @@ contract Gatekeeper is IGatekeeper, Weaver, ReentrancyGuard { _initialized = true; } - function updatePublicKeyMetadata(uint256 exodusSession, bytes32 publicKey) external { + function updatePublicKeyMetadata(bytes32 publicKey) external { require(msg.sender == deployer); // TODO: uncomment line below, needed only for testing purposes // and should push to hardcoded exodusSession 0 always // deployer = address(0); - StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession); - _aggregatedPublicKeys.push(exodusSession, uint256(publicKey)); - _exodusSessions[publicKey] = exodusSession; + _aggregatedPublicKeys.push(0, uint256(publicKey)); + _exodusSessions[publicKey] = 0; } function previousAddress() external override view returns (address) { @@ -202,10 +201,9 @@ contract Gatekeeper is IGatekeeper, Weaver, ReentrancyGuard { if (latestPublicKey != publicKeyAt) revert HistoricalRotation(); uint256 exodusSession = _extractExodusSession(packedBits, sessions); - if (exodusSession > 0) { - if (exodusSession <= latestExodusSession) revert MalleableExodusSession(); - StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession); - } + bool initialSession = exodusSession == 0 && latestExodusSession == 0; + if (!initialSession && exodusSession <= latestExodusSession) revert MalleableExodusSession(); + StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession); _aggregatedPublicKeys.push(exodusSession, uint256(newPublicKey)); _exodusSessions[newPublicKey] = exodusSession; diff --git a/test/gatekeeper/Gatekeeper.t.sol b/test/gatekeeper/Gatekeeper.t.sol index 4f1a5ac..363787a 100644 --- a/test/gatekeeper/Gatekeeper.t.sol +++ b/test/gatekeeper/Gatekeeper.t.sol @@ -293,7 +293,7 @@ contract GatekeeperTest is Test { staking.runGhost(bytes32(abi.encodePacked(ALICE)), type(uint104).max); vm.prank(ALICE); - gatekeeper.updatePublicKeyMetadata(0, 0xa2bc78dbf596f27949ae9a3cc680ce038a4830670b6e458b99424de55a77ca8b); + gatekeeper.updatePublicKeyMetadata(0xa2bc78dbf596f27949ae9a3cc680ce038a4830670b6e458b99424de55a77ca8b); (bytes32 prevPublicKey,) = gatekeeper.latestPublicKeyInfo(); diff --git a/test/gatekeeper/GatekeeperRecall.t.sol b/test/gatekeeper/GatekeeperRecall.t.sol index ef0a482..d725bc6 100644 --- a/test/gatekeeper/GatekeeperRecall.t.sol +++ b/test/gatekeeper/GatekeeperRecall.t.sol @@ -107,7 +107,7 @@ contract GatekeeperRecallTest is Test { function test_gasPriceCorrectDuringRecall() public { vm.startPrank(INITIALIZER); Gatekeeper gatekeeper = Gatekeeper(payable(staking.gatekeeper())); - gatekeeper.updatePublicKeyMetadata(0, 0xb5cd0d028a5e1b6a4eecb113b7e49c8176385eb77c8f134bc1db4bddd7654de6); + gatekeeper.updatePublicKeyMetadata(0xb5cd0d028a5e1b6a4eecb113b7e49c8176385eb77c8f134bc1db4bddd7654de6); vm.stopPrank(); vm.startPrank(ALICE); @@ -171,7 +171,7 @@ contract GatekeeperRecallTest is Test { function test_recallChainWorks() public { vm.startPrank(INITIALIZER); Gatekeeper gatekeeper = Gatekeeper(payable(staking.gatekeeper())); - gatekeeper.updatePublicKeyMetadata(0, 0xb5cd0d028a5e1b6a4eecb113b7e49c8176385eb77c8f134bc1db4bddd7654de6); + gatekeeper.updatePublicKeyMetadata(0xb5cd0d028a5e1b6a4eecb113b7e49c8176385eb77c8f134bc1db4bddd7654de6); vm.stopPrank(); vm.startPrank(ALICE);