apply more strict rules for gatekeeper deployment

Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
Uncle Fatso 2026-09-24 17:02:03 +03:00
parent 5f01391cb7
commit 3f4e6ff8f5
Signed by: f4ts0
GPG Key ID: 565F4F2860226EBB
7 changed files with 17 additions and 18 deletions

View File

@ -101,10 +101,12 @@ GOVERNOR_VOTING_PERIOD=
GOVERNOR_PROPOSAL_THRESHOLD=
GOVERNOR_QUORUM_FRACTION=
###################### Initial ghosted supply on gatekeeper ###########################
############################# Gatekeeper Deployment ##################################
## previousWeaver - previous weaver address if any to make linked list of weavers ##
#######################################################################################
## previousStaking - previous staking address that will initialize the gatekeeper ##
######################################################################################
PREVIOUS_WEAVER_ADDRESS=
PREVIOUS_STAKING_ADDRESS=
SEPOLIA_TEST_RPC_URL=
SEPOLIA_TEST_API_KEY=

View File

@ -39,34 +39,31 @@ contract Gatekeeper is IGatekeeper, Weaver, ReentrancyGuard {
Checkpoints.Trace256 private _aggregatedPublicKeys;
mapping(bytes32 => uint256) private _packedRotationStates;
constructor(address _storageHistory) {
constructor(address _storageHistory, address _staking) {
storageHistory = _storageHistory;
staking = msg.sender;
staking = _staking;
deployer = tx.origin;
}
receive() external payable {}
function initialize(address _previousGatekeeperAddress) external override {
require(msg.sender == staking);
if (_previousGatekeeperAddress != address(0)) {
require(_initialized == false);
require(_previousGatekeeperAddress != address(this));
address previousStorage = IGatekeeper(_previousGatekeeperAddress).storageHistory();
address previousStaking = IGatekeeper(_previousGatekeeperAddress).staking();
require(previousStorage != address(0));
require(previousStaking != address(0));
storageHistory = previousStorage;
staking = previousStaking;
deployer = IGatekeeper(_previousGatekeeperAddress).deployer();
Weaver._initialize(_previousGatekeeperAddress);
_previousAddress = _previousGatekeeperAddress;
}
require(msg.sender == staking);
_initialized = true;
}

View File

@ -62,7 +62,7 @@ contract GhostStaking is IStaking, GhostAccessControlled {
GhostWarmup newWarmup = new GhostWarmup(_ghst);
StorageHistory newHistory = new StorageHistory();
Gatekeeper newGatekeeper = new Gatekeeper(address(newHistory));
Gatekeeper newGatekeeper = new Gatekeeper(address(newHistory), address(this));
IStorageHistory(newHistory).setOwner(address(newGatekeeper));
IGatekeeper(newGatekeeper).initialize(address(0));

View File

@ -147,7 +147,7 @@ contract MockStaking is Test {
constructor() {
mockReserve = new WETH9();
StorageHistory history = new StorageHistory();
gatekeeper = new Gatekeeper(address(history));
gatekeeper = new Gatekeeper(address(history), address(this));
gatekeeper.initialize(address(0));
history.setOwner(address(gatekeeper));
}

View File

@ -19,13 +19,13 @@ contract MockStaking is Test {
constructor() {
mockReserve = new WETH9();
StorageHistory history = new StorageHistory();
gatekeeper = new Gatekeeper(address(history));
gatekeeper = new Gatekeeper(address(history), address(this));
gatekeeper.initialize(address(0));
history.setOwner(address(gatekeeper));
}
function redoGatekeeper() external {
Gatekeeper newGatekeeper = new Gatekeeper(address(0));
Gatekeeper newGatekeeper = new Gatekeeper(address(0), address(this));
newGatekeeper.initialize(address(gatekeeper));
address storageHistory = IGatekeeper(gatekeeper).storageHistory();

View File

@ -15,7 +15,7 @@ contract MockStaking {
constructor() {
StorageHistory history = new StorageHistory();
gatekeeper = new GatekeeperWeaver(address(history));
gatekeeper = new GatekeeperWeaver(address(history), address(this));
gatekeeper.initialize(address(0));
history.setOwner(address(gatekeeper));
governor = msg.sender;
@ -29,7 +29,7 @@ contract MockStaking {
function createNewGatekeeper() external {
require(msg.sender == governor);
GatekeeperWeaver newGatekeeper = new GatekeeperWeaver(address(0));
GatekeeperWeaver newGatekeeper = new GatekeeperWeaver(address(0), address(this));
newGatekeeper.initialize(address(gatekeeper));
address storageHistory = IGatekeeper(gatekeeper).storageHistory();
@ -43,7 +43,7 @@ contract GatekeeperWeaver is Gatekeeper {
using Checkpoints for Checkpoints.Trace256;
using Checkpoints for Checkpoints.Trace160;
constructor(address storageHistory) Gatekeeper(storageHistory) {}
constructor(address storageHistory, address staking) Gatekeeper(storageHistory, staking) {}
function filledEntries(uint256 session) public view returns (uint256) {
return _filledEntries[session];

View File

@ -594,7 +594,7 @@ contract StakingTest is Test {
vm.prank(address(previousGatekeeper));
IStorageHistory(storageHistory).trySetTransactionExecuted(34);
Gatekeeper newGatekeeper = new Gatekeeper(address(0));
Gatekeeper newGatekeeper = new Gatekeeper(address(0), address(staking));
vm.prank(GOVERNOR);
staking.updateGatekeeperAddress(address(newGatekeeper));