apply more strict rules for gatekeeper deployment
Signed-off-by: Uncle Fatso <uncle.fatso@ghostchain.io>
This commit is contained in:
parent
5f01391cb7
commit
3f4e6ff8f5
@ -101,10 +101,12 @@ GOVERNOR_VOTING_PERIOD=
|
|||||||
GOVERNOR_PROPOSAL_THRESHOLD=
|
GOVERNOR_PROPOSAL_THRESHOLD=
|
||||||
GOVERNOR_QUORUM_FRACTION=
|
GOVERNOR_QUORUM_FRACTION=
|
||||||
|
|
||||||
###################### Initial ghosted supply on gatekeeper ###########################
|
############################# Gatekeeper Deployment ##################################
|
||||||
## previousWeaver - previous weaver address if any to make linked list of weavers ##
|
## 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_WEAVER_ADDRESS=
|
||||||
|
PREVIOUS_STAKING_ADDRESS=
|
||||||
|
|
||||||
SEPOLIA_TEST_RPC_URL=
|
SEPOLIA_TEST_RPC_URL=
|
||||||
SEPOLIA_TEST_API_KEY=
|
SEPOLIA_TEST_API_KEY=
|
||||||
|
|||||||
@ -39,34 +39,31 @@ contract Gatekeeper is IGatekeeper, Weaver, ReentrancyGuard {
|
|||||||
Checkpoints.Trace256 private _aggregatedPublicKeys;
|
Checkpoints.Trace256 private _aggregatedPublicKeys;
|
||||||
mapping(bytes32 => uint256) private _packedRotationStates;
|
mapping(bytes32 => uint256) private _packedRotationStates;
|
||||||
|
|
||||||
constructor(address _storageHistory) {
|
constructor(address _storageHistory, address _staking) {
|
||||||
storageHistory = _storageHistory;
|
storageHistory = _storageHistory;
|
||||||
staking = msg.sender;
|
staking = _staking;
|
||||||
deployer = tx.origin;
|
deployer = tx.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
receive() external payable {}
|
receive() external payable {}
|
||||||
|
|
||||||
function initialize(address _previousGatekeeperAddress) external override {
|
function initialize(address _previousGatekeeperAddress) external override {
|
||||||
|
require(msg.sender == staking);
|
||||||
|
|
||||||
if (_previousGatekeeperAddress != address(0)) {
|
if (_previousGatekeeperAddress != address(0)) {
|
||||||
require(_initialized == false);
|
require(_initialized == false);
|
||||||
require(_previousGatekeeperAddress != address(this));
|
require(_previousGatekeeperAddress != address(this));
|
||||||
|
|
||||||
address previousStorage = IGatekeeper(_previousGatekeeperAddress).storageHistory();
|
address previousStorage = IGatekeeper(_previousGatekeeperAddress).storageHistory();
|
||||||
address previousStaking = IGatekeeper(_previousGatekeeperAddress).staking();
|
|
||||||
|
|
||||||
require(previousStorage != address(0));
|
require(previousStorage != address(0));
|
||||||
require(previousStaking != address(0));
|
|
||||||
|
|
||||||
storageHistory = previousStorage;
|
storageHistory = previousStorage;
|
||||||
staking = previousStaking;
|
|
||||||
deployer = IGatekeeper(_previousGatekeeperAddress).deployer();
|
deployer = IGatekeeper(_previousGatekeeperAddress).deployer();
|
||||||
Weaver._initialize(_previousGatekeeperAddress);
|
Weaver._initialize(_previousGatekeeperAddress);
|
||||||
|
|
||||||
_previousAddress = _previousGatekeeperAddress;
|
_previousAddress = _previousGatekeeperAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
require(msg.sender == staking);
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ contract GhostStaking is IStaking, GhostAccessControlled {
|
|||||||
|
|
||||||
GhostWarmup newWarmup = new GhostWarmup(_ghst);
|
GhostWarmup newWarmup = new GhostWarmup(_ghst);
|
||||||
StorageHistory newHistory = new StorageHistory();
|
StorageHistory newHistory = new StorageHistory();
|
||||||
Gatekeeper newGatekeeper = new Gatekeeper(address(newHistory));
|
Gatekeeper newGatekeeper = new Gatekeeper(address(newHistory), address(this));
|
||||||
|
|
||||||
IStorageHistory(newHistory).setOwner(address(newGatekeeper));
|
IStorageHistory(newHistory).setOwner(address(newGatekeeper));
|
||||||
IGatekeeper(newGatekeeper).initialize(address(0));
|
IGatekeeper(newGatekeeper).initialize(address(0));
|
||||||
|
|||||||
@ -147,7 +147,7 @@ contract MockStaking is Test {
|
|||||||
constructor() {
|
constructor() {
|
||||||
mockReserve = new WETH9();
|
mockReserve = new WETH9();
|
||||||
StorageHistory history = new StorageHistory();
|
StorageHistory history = new StorageHistory();
|
||||||
gatekeeper = new Gatekeeper(address(history));
|
gatekeeper = new Gatekeeper(address(history), address(this));
|
||||||
gatekeeper.initialize(address(0));
|
gatekeeper.initialize(address(0));
|
||||||
history.setOwner(address(gatekeeper));
|
history.setOwner(address(gatekeeper));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,13 +19,13 @@ contract MockStaking is Test {
|
|||||||
constructor() {
|
constructor() {
|
||||||
mockReserve = new WETH9();
|
mockReserve = new WETH9();
|
||||||
StorageHistory history = new StorageHistory();
|
StorageHistory history = new StorageHistory();
|
||||||
gatekeeper = new Gatekeeper(address(history));
|
gatekeeper = new Gatekeeper(address(history), address(this));
|
||||||
gatekeeper.initialize(address(0));
|
gatekeeper.initialize(address(0));
|
||||||
history.setOwner(address(gatekeeper));
|
history.setOwner(address(gatekeeper));
|
||||||
}
|
}
|
||||||
|
|
||||||
function redoGatekeeper() external {
|
function redoGatekeeper() external {
|
||||||
Gatekeeper newGatekeeper = new Gatekeeper(address(0));
|
Gatekeeper newGatekeeper = new Gatekeeper(address(0), address(this));
|
||||||
newGatekeeper.initialize(address(gatekeeper));
|
newGatekeeper.initialize(address(gatekeeper));
|
||||||
|
|
||||||
address storageHistory = IGatekeeper(gatekeeper).storageHistory();
|
address storageHistory = IGatekeeper(gatekeeper).storageHistory();
|
||||||
|
|||||||
@ -15,7 +15,7 @@ contract MockStaking {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
StorageHistory history = new StorageHistory();
|
StorageHistory history = new StorageHistory();
|
||||||
gatekeeper = new GatekeeperWeaver(address(history));
|
gatekeeper = new GatekeeperWeaver(address(history), address(this));
|
||||||
gatekeeper.initialize(address(0));
|
gatekeeper.initialize(address(0));
|
||||||
history.setOwner(address(gatekeeper));
|
history.setOwner(address(gatekeeper));
|
||||||
governor = msg.sender;
|
governor = msg.sender;
|
||||||
@ -29,7 +29,7 @@ contract MockStaking {
|
|||||||
function createNewGatekeeper() external {
|
function createNewGatekeeper() external {
|
||||||
require(msg.sender == governor);
|
require(msg.sender == governor);
|
||||||
|
|
||||||
GatekeeperWeaver newGatekeeper = new GatekeeperWeaver(address(0));
|
GatekeeperWeaver newGatekeeper = new GatekeeperWeaver(address(0), address(this));
|
||||||
newGatekeeper.initialize(address(gatekeeper));
|
newGatekeeper.initialize(address(gatekeeper));
|
||||||
|
|
||||||
address storageHistory = IGatekeeper(gatekeeper).storageHistory();
|
address storageHistory = IGatekeeper(gatekeeper).storageHistory();
|
||||||
@ -43,7 +43,7 @@ contract GatekeeperWeaver is Gatekeeper {
|
|||||||
using Checkpoints for Checkpoints.Trace256;
|
using Checkpoints for Checkpoints.Trace256;
|
||||||
using Checkpoints for Checkpoints.Trace160;
|
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) {
|
function filledEntries(uint256 session) public view returns (uint256) {
|
||||||
return _filledEntries[session];
|
return _filledEntries[session];
|
||||||
|
|||||||
@ -594,7 +594,7 @@ contract StakingTest is Test {
|
|||||||
vm.prank(address(previousGatekeeper));
|
vm.prank(address(previousGatekeeper));
|
||||||
IStorageHistory(storageHistory).trySetTransactionExecuted(34);
|
IStorageHistory(storageHistory).trySetTransactionExecuted(34);
|
||||||
|
|
||||||
Gatekeeper newGatekeeper = new Gatekeeper(address(0));
|
Gatekeeper newGatekeeper = new Gatekeeper(address(0), address(staking));
|
||||||
|
|
||||||
vm.prank(GOVERNOR);
|
vm.prank(GOVERNOR);
|
||||||
staking.updateGatekeeperAddress(address(newGatekeeper));
|
staking.updateGatekeeperAddress(address(newGatekeeper));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user