From 9b0394beb84bbacb59e81b5aef70954e7999c40c Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:38:29 -0500 Subject: [PATCH 1/7] -- duplicated function --- .../test-sol/unit/governance/voting/Election.t.sol | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/protocol/test-sol/unit/governance/voting/Election.t.sol b/packages/protocol/test-sol/unit/governance/voting/Election.t.sol index 9cff990b32..296a402273 100644 --- a/packages/protocol/test-sol/unit/governance/voting/Election.t.sol +++ b/packages/protocol/test-sol/unit/governance/voting/Election.t.sol @@ -168,14 +168,6 @@ contract ElectionTest is Utils { deployCodeTo("Registry.sol", abi.encode(false), PROXY_ADMIN_ADDRESS); epochManager.initializeSystem(l1EpochNumber, block.number, _elected); } - - function travelNEpoch(uint256 n) public { - if (isL2()) { - epochManager.setCurrentEpochNumber(epochManager.getCurrentEpochNumber() + n); - } else { - blockTravel((n * ph.epochSize()) + 1); - } - } } contract TransitionToL2After is ElectionTest { From 932802450895f93e519ea25c4ff203fbbec82e13 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:26:39 -0500 Subject: [PATCH 2/7] general L2 tests --- .../unit/governance/network/Governance.t.sol | 168 +++++++++++++++--- 1 file changed, 139 insertions(+), 29 deletions(-) diff --git a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol index ae669e956f..e2b0d4cbfd 100644 --- a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol +++ b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol @@ -263,6 +263,13 @@ contract GovernanceTest is Test, TestConstants, Utils { } } +contract TransitionToL2After is GovernanceTest { + function setUp() public { + super.setUp(); + _whenL2(); + } +} + contract GovernanceTest_initialize is GovernanceTest { function test_SetsTheOwner() public { assertEq(governance.owner(), accOwner); @@ -368,6 +375,8 @@ contract GovernanceTest_setApprover is GovernanceTest { } } +contract GovernanceTest_setApprover_L2 is TransitionToL2After, GovernanceTest_setApprover {} + contract GovernanceTest_setMinDeposit is GovernanceTest { uint256 NEW_MINDEPOSIT = 45; event MinDepositSet(uint256 minDeposit); @@ -398,6 +407,8 @@ contract GovernanceTest_setMinDeposit is GovernanceTest { } } +contract GovernanceTest_setMinDeposit_L2 is TransitionToL2After, GovernanceTest_setMinDeposit {} + contract GovernanceTest_setConcurrentProposals is GovernanceTest { uint256 NEW_CONCURRENT_PROPOSALS = 45; event ConcurrentProposalsSet(uint256 concurrentProposals); @@ -434,6 +445,11 @@ contract GovernanceTest_setConcurrentProposals is GovernanceTest { } } +contract GovernanceTest_setConcurrentProposals_L2 is + TransitionToL2After, + GovernanceTest_setConcurrentProposals +{} + contract GovernanceTest_setQueueExpiry is GovernanceTest { event QueueExpirySet(uint256 queueExpiry); @@ -469,6 +485,8 @@ contract GovernanceTest_setQueueExpiry is GovernanceTest { } } +contract GovernanceTest_setQueueExpiry_L2 is TransitionToL2After, GovernanceTest_setQueueExpiry {} + contract GovernanceTest_setDequeueFrequency is GovernanceTest { event DequeueFrequencySet(uint256 dequeueFrequency); @@ -504,6 +522,11 @@ contract GovernanceTest_setDequeueFrequency is GovernanceTest { } } +contract GovernanceTest_setDequeueFrequency_L2 is + TransitionToL2After, + GovernanceTest_setDequeueFrequency +{} + contract GovernanceTest_setReferendumStageDuration is GovernanceTest { event ReferendumStageDurationSet(uint256 value); @@ -539,6 +562,11 @@ contract GovernanceTest_setReferendumStageDuration is GovernanceTest { } } +contract GovernanceTest_setReferendumStageDuration_L2 is + TransitionToL2After, + GovernanceTest_setReferendumStageDuration +{} + contract GovernanceTest_setExecutionStageDuration is GovernanceTest { event ExecutionStageDurationSet(uint256 dequeueFrequency); @@ -574,6 +602,11 @@ contract GovernanceTest_setExecutionStageDuration is GovernanceTest { } } +contract GovernanceTest_setExecutionStageDuration_L2 is + TransitionToL2After, + GovernanceTest_setExecutionStageDuration +{} + contract GovernanceTest_setParticipationFloor is GovernanceTest { event ParticipationFloorSet(uint256 value); @@ -604,6 +637,11 @@ contract GovernanceTest_setParticipationFloor is GovernanceTest { } } +contract GovernanceTest_setParticipationFloor_L2 is + TransitionToL2After, + GovernanceTest_setParticipationFloor +{} + contract GovernanceTest_setBaselineUpdateFactor is GovernanceTest { event ParticipationBaselineUpdateFactorSet(uint256 value); @@ -634,6 +672,11 @@ contract GovernanceTest_setBaselineUpdateFactor is GovernanceTest { } } +contract GovernanceTest_setBaselineUpdateFactor_L2 is + TransitionToL2After, + GovernanceTest_setBaselineUpdateFactor +{} + contract GovernanceTest_setBaselineQuorumFactor is GovernanceTest { event ParticipationBaselineQuorumFactorSet(uint256 value); @@ -664,6 +707,11 @@ contract GovernanceTest_setBaselineQuorumFactor is GovernanceTest { } } +contract GovernanceTest_setBaselineQuorumFactor_L2 is + TransitionToL2After, + GovernanceTest_setBaselineQuorumFactor +{} + contract GovernanceTest_setConstitution is GovernanceTest { event ConstitutionSet(address indexed destination, bytes4 indexed functionId, uint256 threshold); @@ -740,6 +788,8 @@ contract GovernanceTest_setConstitution is GovernanceTest { } } +contract GovernanceTest_setConstitution_L2 is TransitionToL2After, GovernanceTest_setConstitution {} + contract GovernanceTest_setSecurityCouncil is GovernanceTest { event SecurityCouncilSet(address indexed council); @@ -785,6 +835,11 @@ contract GovernanceTest_setSecurityCouncil is GovernanceTest { } } +contract GovernanceTest_setSecurityCouncil_L2 is + TransitionToL2After, + GovernanceTest_setSecurityCouncil +{} + contract GovernanceTest_setHotfixExecutionTimeWindow is GovernanceTest { event HotfixExecutionTimeWindowSet(uint256 timeDelta); @@ -815,6 +870,11 @@ contract GovernanceTest_setHotfixExecutionTimeWindow is GovernanceTest { } } +contract GovernanceTest_setHotfixExecutionTimeWindow_L2 is + TransitionToL2After, + GovernanceTest_setHotfixExecutionTimeWindow +{} + contract GovernanceTest_propose is GovernanceTest { event ProposalQueued( uint256 indexed proposalId, @@ -989,6 +1049,8 @@ contract GovernanceTest_propose is GovernanceTest { } } +contract GovernanceTest_propose_L2 is TransitionToL2After, GovernanceTest_propose {} + contract GovernanceTest_upvote is GovernanceTest { event ProposalUpvoted(uint256 indexed proposalId, address indexed account, uint256 upvotes); event ProposalExpired(uint256 indexed proposalId); @@ -1188,6 +1250,8 @@ contract GovernanceTest_upvote is GovernanceTest { } } +contract GovernanceTest_upvote_L2 is TransitionToL2After, GovernanceTest_upvote {} + contract GovernanceTest_revokeUpvote is GovernanceTest { event ProposalExpired(uint256 indexed proposalId); event ProposalUpvoteRevoked( @@ -1277,6 +1341,8 @@ contract GovernanceTest_revokeUpvote is GovernanceTest { } } +contract GovernanceTest_revokeUpvote_L2 is TransitionToL2After, GovernanceTest_revokeUpvote {} + contract GovernanceTest_withdraw is GovernanceTest { address accProposer; @@ -1314,6 +1380,8 @@ contract GovernanceTest_withdraw is GovernanceTest { } } +contract GovernanceTest_withdraw_L2 is TransitionToL2After, GovernanceTest_withdraw {} + contract GovernanceTest_approve is GovernanceTest { uint256 INDEX = 0; // first proposal index @@ -1488,6 +1556,8 @@ contract GovernanceTest_approve is GovernanceTest { } } +contract GovernanceTest_approve_L2 is TransitionToL2After, GovernanceTest_approve {} + contract GovernanceTest_revokeVotes is GovernanceTest { uint256 numVoted; @@ -1616,6 +1686,8 @@ contract GovernanceTest_revokeVotes is GovernanceTest { } } +contract GovernanceTest_revokeVotes_L2 is TransitionToL2After, GovernanceTest_revokeVotes {} + contract GovernanceTest_vote_WhenProposalIsApproved is GovernanceTest { event ProposalVotedV2( uint256 indexed proposalId, @@ -1854,6 +1926,11 @@ contract GovernanceTest_vote_WhenProposalIsApproved is GovernanceTest { } } +contract GovernanceTest_vote_WhenProposalIsApproved_L2 is + TransitionToL2After, + GovernanceTest_vote_WhenProposalIsApproved +{} + contract GovernanceTest_vote_WhenProposalIsApprovedAndHaveSigner is GovernanceTest { address accSigner; @@ -1933,6 +2010,11 @@ contract GovernanceTest_vote_WhenProposalIsApprovedAndHaveSigner is GovernanceTe } } +contract GovernanceTest_vote_WhenProposalIsApprovedAndHaveSigner_L2 is + TransitionToL2After, + GovernanceTest_vote_WhenProposalIsApprovedAndHaveSigner +{} + contract GovernanceTest_vote_WhenProposalIsNotApproved is GovernanceTest { event ProposalVotedV2( uint256 indexed proposalId, @@ -2013,6 +2095,11 @@ contract GovernanceTest_vote_WhenProposalIsNotApproved is GovernanceTest { } } +contract GovernanceTest_vote_WhenProposalIsNotApproved_L2 is + TransitionToL2After, + GovernanceTest_vote_WhenProposalIsNotApproved +{} + contract GovernanceTest_vote_WhenVotingOnDifferentProposalWithSameIndex is GovernanceTest { function test_IgnoreVotesFromPreviousProposal() public { uint256 proposalId1 = makeValidProposal(); @@ -2063,6 +2150,11 @@ contract GovernanceTest_vote_WhenVotingOnDifferentProposalWithSameIndex is Gover } } +contract GovernanceTest_vote_WhenVotingOnDifferentProposalWithSameIndex_L2 is + TransitionToL2After, + GovernanceTest_vote_WhenVotingOnDifferentProposalWithSameIndex +{} + contract GovernanceTest_vote_PartiallyWhenProposalIsApproved is GovernanceTest { event ProposalVotedV2( uint256 indexed proposalId, @@ -2291,6 +2383,11 @@ contract GovernanceTest_vote_PartiallyWhenProposalIsApproved is GovernanceTest { } } +contract GovernanceTest_vote_PartiallyWhenProposalIsApproved_L2 is + TransitionToL2After, + GovernanceTest_vote_PartiallyWhenProposalIsApproved +{} + contract GovernanceTest_votePartially_WhenProposalIsApprovedAndHaveSigner is GovernanceTest { address accSigner; @@ -2405,6 +2502,11 @@ contract GovernanceTest_votePartially_WhenProposalIsApprovedAndHaveSigner is Gov } } +contract GovernanceTest_votePartially_WhenProposalIsApprovedAndHaveSigner_L2 is + TransitionToL2After, + GovernanceTest_votePartially_WhenProposalIsApprovedAndHaveSigner +{} + contract GovernanceTest_votePartially_WhenProposalIsNotApproved is GovernanceTest { event ProposalVotedV2( uint256 indexed proposalId, @@ -2485,6 +2587,11 @@ contract GovernanceTest_votePartially_WhenProposalIsNotApproved is GovernanceTes } } +contract GovernanceTest_votePartially_WhenProposalIsNotApproved_L2 is + TransitionToL2After, + GovernanceTest_votePartially_WhenProposalIsNotApproved +{} + contract GovernanceTest_votePartially_WhenVotingOnDifferentProposalWithSameIndex is GovernanceTest { function test_IgnoreVotesFromPreviousProposal() public { uint256 proposalId1 = makeValidProposal(); @@ -2535,6 +2642,11 @@ contract GovernanceTest_votePartially_WhenVotingOnDifferentProposalWithSameIndex } } +contract GovernanceTest_votePartially_WhenVotingOnDifferentProposalWithSameIndex_L2 is + TransitionToL2After, + GovernanceTest_votePartially_WhenVotingOnDifferentProposalWithSameIndex +{} + contract GovernanceTest_execute is GovernanceTest { event ParticipationBaselineUpdated(uint256 participationBaseline); event ProposalExecuted(uint256 indexed proposalId); @@ -2966,6 +3078,8 @@ contract GovernanceTest_execute is GovernanceTest { } } +contract GovernanceTest_execute_L2 is TransitionToL2After, GovernanceTest_execute {} + contract GovernanceTest_approveHotfix is GovernanceTest { bytes32 constant HOTFIX_HASH = bytes32(uint256(0x123456789)); event HotfixApproved(bytes32 indexed hash, address approver); @@ -3088,7 +3202,7 @@ contract GovernanceTest_whitelistHotfix is GovernanceTest { governance.whitelistHotfix(HOTFIX_HASH); } - function test_Reverts_WhenCalledOnL2() public { + function test_Reverts_WhenL2() public { address validator = actor("validator1"); governance.addValidator(validator); _whenL2(); @@ -3164,7 +3278,7 @@ contract GovernanceTest_hotfixWhitelistValidatorTally is GovernanceTest { assertEq(governance.hotfixWhitelistValidatorTally(HOTFIX_HASH), 3); } - function test_Reverts_WhenCalledOnL2() public { + function test_Reverts_WhenL2() public { address validator = actor("validator1"); governance.addValidator(validator); _whenL2(); @@ -3207,7 +3321,7 @@ contract GovernanceTest_isHotfixPassing is GovernanceTest { assertTrue(governance.isHotfixPassing(HOTFIX_HASH)); } - function test_Reverts_WhenCalledOnL2() public { + function test_Reverts_WhenL2() public { _whenL2(); vm.expectRevert("This method is no longer supported in L2."); governance.isHotfixPassing(HOTFIX_HASH); @@ -3282,7 +3396,7 @@ contract GovernanceTest_prepareHotfix_L2 is GovernanceTest { governance.setSecurityCouncil(accCouncil); } - function test_markHotfixRecordExecutionTimeLimit_whenHotfixApproved() public { + function test_shouldMarkHotfixRecordExecutionTimeLimit_whenHotfixApproved() public { vm.prank(accOwner); governance.setHotfixExecutionTimeWindow(DAY); @@ -3408,8 +3522,10 @@ contract GovernanceTest_resetHotfix is GovernanceTest { vm.prank(accCouncil); governance.approveHotfix(HOTFIX_HASH); + vm.prank(accApprover); governance.approveHotfix(HOTFIX_HASH); + (bool approved, bool councilApproved, , uint256 _preparedTimeLimit) = governance .getL2HotfixRecord(HOTFIX_HASH); @@ -3612,22 +3728,14 @@ contract GovernanceTest_executeHotfix_L2 is GovernanceTest { } function test_ShouldExecuteHotfix_WhenApprovedByApproverAndSecurityCouncil() public { - vm.prank(accApprover); - governance.approveHotfix(hotfixHash); - vm.prank(accCouncil); - governance.approveHotfix(hotfixHash); - governance.prepareHotfix(hotfixHash); + approveAndPrepareHotfix(); executeHotfixTx(); assertEq(testTransactions.getValue(1), 1); } function test_ShouldMarkHotfixAsExecuted_WhenApprovedByApproverAndSecurityCouncil() public { - vm.prank(accApprover); - governance.approveHotfix(hotfixHash); - vm.prank(accCouncil); - governance.approveHotfix(hotfixHash); - governance.prepareHotfix(hotfixHash); + approveAndPrepareHotfix(); executeHotfixTx(); (, , bool executed, ) = governance.getL2HotfixRecord(hotfixHash); @@ -3635,11 +3743,7 @@ contract GovernanceTest_executeHotfix_L2 is GovernanceTest { } function test_Emits_HotfixExecutedEventWhenApprovedByApproverAndSecurityCouncil() public { - vm.prank(accApprover); - governance.approveHotfix(hotfixHash); - vm.prank(accCouncil); - governance.approveHotfix(hotfixHash); - governance.prepareHotfix(hotfixHash); + approveAndPrepareHotfix(); vm.expectEmit(true, true, true, true); emit HotfixExecuted(hotfixHash); @@ -3647,11 +3751,7 @@ contract GovernanceTest_executeHotfix_L2 is GovernanceTest { } function test_Reverts_WhenExecutingSameHotfixTwice() public { - vm.prank(accApprover); - governance.approveHotfix(hotfixHash); - vm.prank(accCouncil); - governance.approveHotfix(hotfixHash); - governance.prepareHotfix(hotfixHash); + approveAndPrepareHotfix(); executeHotfixTx(); vm.expectRevert("hotfix already executed"); @@ -3679,11 +3779,8 @@ contract GovernanceTest_executeHotfix_L2 is GovernanceTest { executeHotfixTx(); } function test_Reverts_WhenExecutedBeyondTheExecutionTimeLimit() public { - vm.prank(accApprover); - governance.approveHotfix(hotfixHash); - vm.prank(accCouncil); - governance.approveHotfix(hotfixHash); - governance.prepareHotfix(hotfixHash); + approveAndPrepareHotfix(); + timeTravel(2 * DAY); vm.expectRevert("Execution time limit has already been reached."); executeHotfixTx(); @@ -3698,6 +3795,14 @@ contract GovernanceTest_executeHotfix_L2 is GovernanceTest { SALT ); } + + function approveAndPrepareHotfix() private { + vm.prank(accApprover); + governance.approveHotfix(hotfixHash); + vm.prank(accCouncil); + governance.approveHotfix(hotfixHash); + governance.prepareHotfix(hotfixHash); + } } contract GovernanceTest_isVoting is GovernanceTest { @@ -4249,3 +4354,8 @@ contract GovernanceTest_removeVotesWhenRevokingDelegatedVotes is GovernanceTest assertVoteRecord(2, proposalIds[2], 0, 0, 51); } } + +contract GovernanceTest_removeVotesWhenRevokingDelegatedVotes_L2 is + TransitionToL2After, + GovernanceTest_removeVotesWhenRevokingDelegatedVotes +{} From eb37996f623799f50464dbfc08257f57f0533ddc Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:37:39 -0500 Subject: [PATCH 3/7] ++ L1 GovernanceTest_resetHotfix --- .../unit/governance/network/Governance.t.sol | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol index e2b0d4cbfd..2465db2660 100644 --- a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol +++ b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol @@ -3502,6 +3502,59 @@ contract GovernanceTest_resetHotfix is GovernanceTest { bytes32 hotfixHash; event HotfixRecordReset(bytes32 indexed hash); + function setUp() public { + super.setUp(); + + address val1 = actor("validator1"); + governance.addValidator(val1); + vm.prank(val1); + accounts.createAccount(); + + // _whenL2(); + vm.prank(accOwner); + governance.setSecurityCouncil(accCouncil); + + hotfixHash = governance.getHotfixHash( + okProp.values, + okProp.destinations, + okProp.data, + okProp.dataLengths, + SALT + ); + } + + function test_Reverts_whenCalledOnL1() public { + vm.prank(accOwner); + governance.setHotfixExecutionTimeWindow(DAY); + + vm.prank(accApprover); + governance.approveHotfix(HOTFIX_HASH); + + (bool approved, , ) = governance.getHotfixRecord(HOTFIX_HASH); + + assertTrue(approved); + + vm.roll(block.number + governance.getEpochSize()); + vm.prank(actor("validator1")); + governance.whitelistHotfix(HOTFIX_HASH); + + uint256 epoch = governance.getEpochNumber(); + + governance.prepareHotfix(HOTFIX_HASH); + + timeTravel(DAY + 1); + + vm.expectRevert("hotfix not prepared"); + governance.resetHotFixRecord(HOTFIX_HASH); + } +} + +contract GovernanceTest_resetHotfix_L2 is GovernanceTest { + bytes32 constant HOTFIX_HASH = bytes32(uint256(0x123456789)); + bytes32 constant SALT = 0x657ed9d64e84fa3d1af43b3a307db22aba2d90a158015df1c588c02e24ca08f0; + bytes32 hotfixHash; + event HotfixRecordReset(bytes32 indexed hash); + function setUp() public { super.setUp(); _whenL2(); From f7d886d4abf386beb8924c6f91dd522affa22ef8 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:42:16 -0500 Subject: [PATCH 4/7] ++ remaining tests --- .../unit/governance/network/Governance.t.sol | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol index 2465db2660..68a9eef38a 100644 --- a/packages/protocol/test-sol/unit/governance/network/Governance.t.sol +++ b/packages/protocol/test-sol/unit/governance/network/Governance.t.sol @@ -3912,6 +3912,8 @@ contract GovernanceTest_isVoting is GovernanceTest { } } +contract GovernanceTest_isVoting_L2 is TransitionToL2After, GovernanceTest_isVoting {} + contract GovernanceTest_isProposalPassing is GovernanceTest { address accSndVoter; @@ -3954,6 +3956,11 @@ contract GovernanceTest_isProposalPassing is GovernanceTest { } } +contract GovernanceTest_isProposalPassing_L2 is + TransitionToL2After, + GovernanceTest_isProposalPassing +{} + contract GovernanceTest_dequeueProposalsIfReady is GovernanceTest { function test_notUpdateLastDequeueWhenThereAreNoQueuedProposals() public { uint256 originalLastDequeue = governance.lastDequeue(); @@ -3987,6 +3994,11 @@ contract GovernanceTest_dequeueProposalsIfReady is GovernanceTest { } } +contract GovernanceTest_dequeueProposalsIfReady_L2 is + TransitionToL2After, + GovernanceTest_dequeueProposalsIfReady +{} + contract GovernanceTest_getProposalStage is GovernanceTest { function test_returnNoneStageWhenProposalDoesNotExists() public { assertEq(uint256(governance.getProposalStage(0)), uint256(Proposals.Stage.None)); @@ -4119,6 +4131,11 @@ contract GovernanceTest_getProposalStage is GovernanceTest { } } +contract GovernanceTest_getProposalStage_L2 is + TransitionToL2After, + GovernanceTest_getProposalStage +{} + contract GovernanceTest_getAmountOfGoldUsedForVoting is GovernanceTest { function test_showCorrectNumberOfVotes_whenVotingOn1ConcurrentProposal() public { makeAndApprove3ConcurrentProposals(); @@ -4247,6 +4264,11 @@ contract GovernanceTest_getAmountOfGoldUsedForVoting is GovernanceTest { } } +contract GovernanceTest_getAmountOfGoldUsedForVoting_L2 is + TransitionToL2After, + GovernanceTest_getAmountOfGoldUsedForVoting +{} + contract GovernanceTest_removeVotesWhenRevokingDelegatedVotes is GovernanceTest { uint256[] proposalIds; From 0ad41744c807151b31096e689bfd17577f1c6ebd Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:00:10 -0500 Subject: [PATCH 5/7] debuging --- packages/celotool/src/e2e-tests/governance_tests.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 3bdffa5fb7..39ef34b11e 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -310,7 +310,7 @@ describe('governance tests', () => { if (myceloAddress === groupAddress) { return '0x' + generatePrivateKey(mnemonic, AccountType.VALIDATOR_GROUP, 0) } - // Otherwise, the validator group key is encoded in its name (see 25_elect_validators.ts) + // Otherwise, the validator group key is encoded in its name (see 30_elect_validators.ts) const name = await accounts.methods.getName(groupAddress).call() const encryptedKeystore64 = name.split(' ')[1] const encryptedKeystore = JSON.parse(Buffer.from(encryptedKeystore64, 'base64').toString()) @@ -515,7 +515,7 @@ describe('governance tests', () => { assert.equal(validatorSetSize, groupMembership.length) } }) - + // TODO (soloseng) fix test such that it returns expected validators it('should always return a validator set equal to the signing keys of the group members at the end of the last epoch', async function (this: any) { this.timeout(0) for (const blockNumber of blockNumbers) { @@ -538,11 +538,13 @@ describe('governance tests', () => { // Fetch the round robin order if it hasn't already been set for this epoch. if (roundRobinOrder.length === 0 || blockNumber === lastEpochBlock + 1) { const validatorSet = await getValidatorSetSignersAtBlock(blockNumber) + console.log(`### validatorSet: ${validatorSet}`) roundRobinOrder = await Promise.all( validatorSet.map( async (_, i) => (await web3.eth.getBlock(lastEpochBlock + i + 1)).miner ) ) + console.log(`### roundRobinOrder: ${roundRobinOrder}`) assert.sameMembers(roundRobinOrder, validatorSet) } const indexInEpoch = blockNumber - lastEpochBlock - 1 From dd47374ee8b8cbcc72347bc67bd3d7208aefe501 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Wed, 13 Nov 2024 08:41:19 -0500 Subject: [PATCH 6/7] more debug logs --- packages/celotool/src/e2e-tests/governance_tests.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 39ef34b11e..f323499e78 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -521,11 +521,18 @@ describe('governance tests', () => { for (const blockNumber of blockNumbers) { const lastEpochBlock = getLastEpochBlock(blockNumber, epoch) const memberAccounts = await getValidatorGroupMembers(lastEpochBlock) + console.log(`### Got memberAccounts: ${memberAccounts}`) const memberSigners = await Promise.all( memberAccounts.map((v: string) => getValidatorSigner(v, lastEpochBlock)) ) + console.log(`### Got memberSigners: ${memberSigners}`) + const validatorSetSigners = await getValidatorSetSignersAtBlock(blockNumber) + console.log(`### Got validatorSetSigners: ${validatorSetSigners}`) + const validatorSetAccounts = await getValidatorSetAccountsAtBlock(blockNumber) + console.log(`### Got validatorSetAccounts: ${validatorSetAccounts}`) + assert.sameMembers(memberSigners, validatorSetSigners) assert.sameMembers(memberAccounts, validatorSetAccounts) } From b1f6ee6190d758ce509db0fac9e5fc4a4f51ad15 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Wed, 13 Nov 2024 16:16:50 -0500 Subject: [PATCH 7/7] more debug --- packages/celotool/src/e2e-tests/governance_tests.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index f323499e78..811eead623 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -442,18 +442,21 @@ describe('governance tests', () => { // groupKit uses a different node than kit does, so wait a second in case kit's node // got the new block before groupKit's node did. - await sleep(1) + await sleep(5) const txos = await (await groupKit.contracts.getElection()).activate(group) for (const txo of txos) { await txo.sendAndWaitForReceipt({ from: group }) } + const validatorSetSigners0 = await election.methods.getCurrentValidatorSigners().call() + console.log(`### Got _validatorSetSigners0: ${validatorSetSigners0}`) validators = await groupKit._web3Contracts.getValidators() const membersToSwap = [validatorAccounts[0], validatorAccounts[1]] const memberSwapper = await newMemberSwapper(groupKit, membersToSwap) // The memberSwapper makes a change when it's created, so we wait for epoch change so it takes effect await waitForEpochTransition(web3, epoch) - + const validatorSetSigners1 = await election.methods.getCurrentValidatorSigners().call() + console.log(`### Got _validatorSetSigners1: ${validatorSetSigners1}`) const handled: any = {} let errorWhileChangingValidatorSet = '' @@ -498,6 +501,7 @@ describe('governance tests', () => { const getValidatorSetAccountsAtBlock = async (blockNumber: number) => { const signingKeys = await getValidatorSetSignersAtBlock(blockNumber) + console.log(`### Got signingKeys: ${signingKeys}`) return Promise.all( signingKeys.map((address: string) => accounts.methods.signerToAccount(address).call({}, blockNumber)