make only initial session to be stored during the setup
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
6b081c522d
commit
7446a7e7f8
@ -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();
|
||||
bool initialSession = exodusSession == 0 && latestExodusSession == 0;
|
||||
if (!initialSession && exodusSession <= latestExodusSession) revert MalleableExodusSession();
|
||||
StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession);
|
||||
}
|
||||
|
||||
_aggregatedPublicKeys.push(exodusSession, uint256(newPublicKey));
|
||||
_exodusSessions[newPublicKey] = exodusSession;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user