make only initial session to be stored during the setup

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-10-25 18:16:34 +03:00
parent 6b081c522d
commit 7446a7e7f8
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
3 changed files with 9 additions and 11 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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);