diff --git a/.github/workflows/certora-review-execution-chain.yml b/.github/workflows/certora-review-execution-chain.yml index 95e4c8b..b5b64c4 100644 --- a/.github/workflows/certora-review-execution-chain.yml +++ b/.github/workflows/certora-review-execution-chain.yml @@ -28,13 +28,13 @@ jobs: with: { java-version: "11", java-package: jre } - name: Install certora cli - run: pip3 install certora-cli==7.20.3 + run: pip3 install certora-cli==7.21.1 - name: Install solc run: | - wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux + wget https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux chmod +x solc-static-linux - sudo mv solc-static-linux /usr/local/bin/solc8.19 + sudo mv solc-static-linux /usr/local/bin/solc8.20 - name: Verify rule ${{ matrix.rule }} run: | @@ -47,27 +47,4 @@ jobs: max-parallel: 16 matrix: rule: - - verifyPayloadsController.conf --rule payload_maximal_access_level_gt_action_access_level state_cant_decrease no_transition_beyond_state_gt_3 no_transition_beyond_state_variable_gt_3 no_queue_after_expiration empty_actions_if_out_of_bound_payload expirationTime_equal_to_createAt_plus_EXPIRATION_DELAY empty_actions_iff_uninitialized null_access_level_if_out_of_bound_payload null_creator_and_zero_expiration_time_if_out_of_bound_payload empty_actions_only_if_uninitialized_payload executor_access_level_within_range consecutiveIDs empty_actions_if_uninitialized_payload queued_before_expiration_delay payload_grace_period_eq_global_grace_period null_access_level_only_if_out_of_bound_payload null_state_variable_if_out_of_bound_payload created_in_the_past queued_after_created executed_after_queue queuedAt_is_zero_before_queued no_early_cancellation execute_before_delay__maximumAccessLevelRequired action_immutable_fixed_size_fields initialized_payload_fields_are_immutable payload_fields_immutable_after_createPayload method_reachability - # - verifyPayloadsController.conf --rule executor_exists - - verifyPayloadsController.conf --rule executor_exists_if_action_not_null - - verifyPayloadsController.conf --rule executor_exists_only_if_action_not_null - - verifyPayloadsController.conf --rule payload_delay_within_range - - verifyPayloadsController.conf --rule delay_of_executor_of_max_access_level_within_range - - verifyPayloadsController.conf --rule nonempty_actions - - verifyPayloadsController.conf --rule executor_exists_iff_action_not_null - - verifyPayloadsController.conf --rule null_access_level_iff_state_is_none - - verifyPayloadsController.conf --rule executor_of_maximumAccessLevelRequired_exists - - verifyPayloadsController.conf --rule executor_of_maximumAccessLevelRequired_exists_after_createPayload - - verifyPayloadsController.conf --rule action_access_level_isnt_null_after_createPayload - - verifyPayloadsController.conf --rule executor_exists_after_createPayload - - verifyPayloadsController.conf --rule action_callData_immutable - - verifyPayloadsController.conf --rule action_signature_immutable - - verifyPayloadsController.conf --rule action_immutable_check_only_fixed_size_fields - - verifyPayloadsController.conf --rule zero_executedAt_if_not_executed - - verifyPayloadsController.conf --rule executor_isnt_used_twice executor_of_level_null_is_zero - - verifyPayloadsController.conf --rule executed_after_queue_state_variable zero_executedAt_if_not_executed_state_variable - - verifyPayloadsController.conf --rule queuedAt_is_zero_before_queued_state_variable executedAt_is_zero_before_executed_state_variable null_state_equivalence - - verifyPayloadsController.conf --rule executedAt_is_zero_before_executed - - verifyPayloadsController.conf --rule executed_when_in_queued_state executed_when_in_queued_state_variable guardian_can_cancel no_late_cancel state_variable_cant_decrease - - verifyPayloadsController.conf --rule checkUpdateExecutors checkUpdateExecutors_witness_1 checkUpdateExecutors_witness_2 checkUpdateExecutors_witness_3 checkUpdateExecutors_witness_4 - - verifyPayloadsController.conf --rule payload_state_transition_post_state payload_state_transition_pre_state + - verifyPayloadsController.conf --rule payload_maximal_access_level_gt_action_access_level state_cant_decrease no_transition_beyond_state_gt_3 no_transition_beyond_state_variable_gt_3 no_queue_after_expiration empty_actions_if_out_of_bound_payload expirationTime_equal_to_createAt_plus_EXPIRATION_DELAY empty_actions_iff_uninitialized null_access_level_if_out_of_bound_payload null_creator_and_zero_expiration_time_if_out_of_bound_payload empty_actions_only_if_uninitialized_payload executor_access_level_within_range consecutiveIDs empty_actions_if_uninitialized_payload queued_before_expiration_delay payload_grace_period_eq_global_grace_period null_access_level_only_if_out_of_bound_payload null_state_variable_if_out_of_bound_payload created_in_the_past queued_after_created executed_after_queue queuedAt_is_zero_before_queued no_early_cancellation execute_before_delay__maximumAccessLevelRequired action_immutable_fixed_size_fields initialized_payload_fields_are_immutable payload_fields_immutable_after_createPayload method_reachability executor_exists_if_action_not_null executor_exists_only_if_action_not_null payload_delay_within_range delay_of_executor_of_max_access_level_within_range nonempty_actions executor_exists_iff_action_not_null null_access_level_iff_state_is_none executor_of_maximumAccessLevelRequired_exists executor_of_maximumAccessLevelRequired_exists_after_createPayload action_access_level_isnt_null_after_createPayload executor_exists_after_createPayload action_callData_immutable action_signature_immutable action_immutable_check_only_fixed_size_fields zero_executedAt_if_not_executed executor_isnt_used_twice executor_of_level_null_is_zero executed_after_queue_state_variable zero_executedAt_if_not_executed_state_variable queuedAt_is_zero_before_queued_state_variable executedAt_is_zero_before_executed_state_variable null_state_equivalence executedAt_is_zero_before_executed executed_when_in_queued_state executed_when_in_queued_state_variable guardian_can_cancel no_late_cancel state_variable_cant_decrease checkUpdateExecutors checkUpdateExecutors_witness_1 checkUpdateExecutors_witness_2 checkUpdateExecutors_witness_3 checkUpdateExecutors_witness_4 payload_state_transition_post_state payload_state_transition_pre_state diff --git a/.github/workflows/certora-review-mainnet.yml b/.github/workflows/certora-review-mainnet.yml index be40947..ead7213 100644 --- a/.github/workflows/certora-review-mainnet.yml +++ b/.github/workflows/certora-review-mainnet.yml @@ -30,13 +30,13 @@ jobs: with: { java-version: "11", java-package: jre } - name: Install certora cli - run: pip3 install certora-cli==7.20.3 + run: pip3 install certora-cli==7.21.1 - name: Install solc run: | - wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux + wget https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux chmod +x solc-static-linux - sudo mv solc-static-linux /usr/local/bin/solc8.19 + sudo mv solc-static-linux /usr/local/bin/solc8.20 - name: Verify rule ${{ matrix.rule }} run: | @@ -50,26 +50,6 @@ jobs: matrix: rule: - verifyVotingStrategy_unittests.conf - - verifyGovernancePowerStrategy.conf --rule delegatePowerCompliance - - verifyGovernancePowerStrategy.conf --rule transferPowerCompliance - - verifyGovernancePowerStrategy.conf --rule powerlessCompliance method_reachability - - verifyGovernance.conf --rule cancellationFeeZeroForFutureProposals null_state_variable_iff_null_access_level zero_voting_portal_iff_uninitialized_proposal - - verifyGovernance.conf --rule no_self_representative no_representative_is_zero consecutiveIDs totalCancellationFeeEqualETHBalance zero_address_is_not_a_valid_voting_portal - - verifyGovernance.conf --rule no_representative_is_zero_2 no_representative_of_zero - - verifyGovernance.conf --rule state_changing_function_self_check state_variable_changing_function_self_check method_reachability userFeeDidntChangeImplyNativeBalanceDidntDecrease - - verifyGovernance.conf --rule check_new_representative_set_size_after_updateRepresentatives check_old_representative_set_size_after_updateRepresentatives - - verifyGovernance.conf --rule at_least_single_payload_active empty_payloads_iff_uninitialized_proposal - - verifyGovernance.conf --rule null_state_iff_uninitialized_proposal setInvariant addressSetInvariant - - verifyGovernance.conf --rule state_changing_function_cannot_be_called_while_in_terminal_state proposal_executes_after_cooldown_period - - verifyGovernance.conf --rule only_valid_voting_portal_can_queue_proposal immutable_after_activation immutable_after_creation only_guardian_can_cancel guardian_can_cancel - - verifyGovernance.conf --rule cannot_queue_when_voting_portal_unapproved only_owner_can_set_voting_config_witness only_owner_can_set_voting_config single_state_transition_per_block_non_creator_witness + - verifyGovernancePowerStrategy.conf --rule delegatePowerCompliance transferPowerCompliance powerlessCompliance method_reachability + - verifyGovernance.conf --rule cancellationFeeZeroForFutureProposals null_state_variable_iff_null_access_level zero_voting_portal_iff_uninitialized_proposal no_self_representative no_representative_is_zero consecutiveIDs totalCancellationFeeEqualETHBalance zero_address_is_not_a_valid_voting_portal no_representative_is_zero_2 no_representative_of_zero state_changing_function_self_check state_variable_changing_function_self_check method_reachability userFeeDidntChangeImplyNativeBalanceDidntDecrease check_new_representative_set_size_after_updateRepresentatives check_old_representative_set_size_after_updateRepresentatives at_least_single_payload_active empty_payloads_iff_uninitialized_proposal null_state_iff_uninitialized_proposal setInvariant addressSetInvariant state_changing_function_cannot_be_called_while_in_terminal_state proposal_executes_after_cooldown_period only_valid_voting_portal_can_queue_proposal immutable_after_activation immutable_after_creation only_guardian_can_cancel guardian_can_cancel cannot_queue_when_voting_portal_unapproved only_owner_can_set_voting_config_witness only_owner_can_set_voting_config single_state_transition_per_block_non_creator_witness proposal_after_voting_portal_invalidate insufficient_proposition_power insufficient_proposition_power_witness_state_is_failed insufficient_proposition_power_witness_state_is_cancelled insufficient_proposition_power_witness_time_elapsed creator_is_not_zero creator_of_initialized_proposal_is_not_zero null_state_equivalence insufficient_proposition_power_witness_time_elapsed immutable_after_creation_witness_creator immutable_after_creation_witness_voting_portal immutable_after_creation_witness_access_level immutable_after_creation_witness_creation_time immutable_after_creation_witness_ipfs_hash immutable_after_creation_witness_payload_length immutable_after_activation_witness only_state_changing_function_initiate_transitions__pre_state only_state_changing_function_initiate_transitions__post_state check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_first check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_second check_new_representative_set_size_after_updateRepresentatives_witness_consequent_first check_new_representative_set_size_after_updateRepresentatives_witness_consequent_second proposal_voting_duration_lt_expiration_time config_voting_duration_lt_expiration_time proposal_state_transition_post_state proposal_state_transition_pre_state - verifyGovernance.conf --rule single_state_transition_per_block_non_creator_non_guardian state_cant_decrease no_state_transitions_beyond_3 immutable_voting_portal - - verifyGovernance.conf --rule proposal_after_voting_portal_invalidate insufficient_proposition_power insufficient_proposition_power_witness_state_is_failed insufficient_proposition_power_witness_state_is_cancelled insufficient_proposition_power_witness_time_elapsed - - verifyGovernance.conf --rule creator_is_not_zero creator_of_initialized_proposal_is_not_zero null_state_equivalence - - verifyGovernance.conf --rule insufficient_proposition_power_witness_time_elapsed - - verifyGovernance.conf --rule immutable_after_creation_witness_creator immutable_after_creation_witness_voting_portal - - verifyGovernance.conf --rule immutable_after_creation_witness_access_level immutable_after_creation_witness_creation_time immutable_after_creation_witness_ipfs_hash - - verifyGovernance.conf --rule immutable_after_creation_witness_payload_length immutable_after_activation_witness only_state_changing_function_initiate_transitions__pre_state - - verifyGovernance.conf --rule only_state_changing_function_initiate_transitions__post_state - - verifyGovernance.conf --rule check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_first check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_second check_new_representative_set_size_after_updateRepresentatives_witness_consequent_first check_new_representative_set_size_after_updateRepresentatives_witness_consequent_second - - verifyGovernance.conf --rule proposal_voting_duration_lt_expiration_time config_voting_duration_lt_expiration_time proposal_state_transition_post_state proposal_state_transition_pre_state diff --git a/.github/workflows/certora-review-voting-chain.yml b/.github/workflows/certora-review-voting-chain.yml index a219666..a4c6555 100644 --- a/.github/workflows/certora-review-voting-chain.yml +++ b/.github/workflows/certora-review-voting-chain.yml @@ -30,13 +30,13 @@ jobs: with: { java-version: "11", java-package: jre } - name: Install certora cli - run: pip3 install certora-cli==7.20.3 + run: pip3 install certora-cli==7.21.1 - name: Install solc run: | - wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux + wget https://github.com/ethereum/solidity/releases/download/v0.8.20/solc-static-linux chmod +x solc-static-linux - sudo mv solc-static-linux /usr/local/bin/solc8.19 + sudo mv solc-static-linux /usr/local/bin/solc8.20 - name: Verify rule ${{ matrix.rule }} run: | @@ -49,38 +49,13 @@ jobs: max-parallel: 16 matrix: rule: - - verifyLegality.conf --rule createdVoteHasNonZeroHash - - verifyLegality.conf --rule votedPowerIsImmutable - - verifyLegality.conf --rule onlyValidProposalCanChangeTally - - verifyLegality.conf --rule legalVote - - verifyLegality.conf --rule method_reachability + - verifyLegality.conf --rule createdVoteHasNonZeroHash votedPowerIsImmutable onlyValidProposalCanChangeTally legalVote method_reachability - verifyMisc.conf - - verifyPower_summary.conf --rule onlyThreeTokens #TODO: uncomment with certora-cli version 6.0 or higher - - verifyPower_summary.conf --rule method_reachability - - verifyProposal_config.conf --rule startedProposalHasConfig - - verifyProposal_config.conf --rule createdProposalHasRoots - - verifyProposal_config.conf --rule proposalHasNonzeroDuration newProposalUnusedId configIsImmutable - - verifyProposal_config.conf --rule getProposalsConfigsDoesntRevert - - verifyProposal_config.conf --rule method_reachability - - verifyProposal_states.conf --rule startsBeforeEnds - - verifyProposal_states.conf --rule startsStrictlyBeforeEnds - - verifyProposal_states.conf --rule proposalLegalStates - - verifyProposal_states.conf --rule proposalMethodStateTransitionCompliance - - verifyProposal_states.conf --rule proposalTimeStateTransitionCompliance - - verifyProposal_states.conf --rule proposalIdIsImmutable - - verifyProposal_states.conf --rule proposalImmutability - - verifyProposal_states.conf --rule startedProposalHasConfig - - verifyProposal_states.conf --rule proposalHasNonzeroDuration method_reachability - - verifyVoting_and_tally.conf --rule votingPowerGhostIsVotingPower - - verifyVoting_and_tally.conf --rule sumOfVotes - - verifyVoting_and_tally.conf --rule voteTallyChangedOnlyByVoting - - verifyVoting_and_tally.conf --rule voteUpdatesTally - - verifyVoting_and_tally.conf --rule onlyVoteCanChangeResult - - verifyVoting_and_tally.conf --rule votingTallyCanOnlyIncrease - - verifyVoting_and_tally.conf --rule strangerVoteUnchanged - - verifyVoting_and_tally.conf --rule otherProposalUnchanged - - verifyVoting_and_tally.conf --rule otherVoterUntouched - - verifyVoting_and_tally.conf --rule cannot_vote_twice_with_submitVote_and_submitVoteAsRepresentative - - verifyVoting_and_tally.conf --rule cannot_vote_twice_with_submitVoteAsRepresentative_and_submitVote + - verifyPower_summary.conf --rule onlyThreeTokens method_reachability + - verifyProposal_config.conf --rule startedProposalHasConfig createdProposalHasRoots proposalHasNonzeroDuration newProposalUnusedId configIsImmutable getProposalsConfigsDoesntRevert method_reachability + - verifyProposal_states.conf --rule startsBeforeEnds startsStrictlyBeforeEnds proposalLegalStates proposalMethodStateTransitionCompliance proposalTimeStateTransitionCompliance proposalIdIsImmutable proposalImmutability startedProposalHasConfig proposalHasNonzeroDuration method_reachability + - verifyVoting_and_tally.conf --rule votingPowerGhostIsVotingPower sumOfVotes voteTallyChangedOnlyByVoting voteUpdatesTally onlyVoteCanChangeResult votingTallyCanOnlyIncrease strangerVoteUnchanged otherProposalUnchanged otherVoterUntouched method_reachability + - verifyVoting_and_tally.conf --rule cannot_vote_twice_with_submitVote_and_submitVoteAsRepresentative + - verifyVoting_and_tally.conf --rule cannot_vote_twice_with_submitVoteAsRepresentative_and_submitVote - verifyVoting_and_tally.conf --rule cannot_vote_twice_with_submitVoteSingleProofAsRepresentative_and_submitVote - - verifyVoting_and_tally.conf --rule method_reachability + diff --git a/.gitmodules b/.gitmodules index bdc7647..8f0bbc5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,21 +1,4 @@ -[submodule "lib/forge-std"] - path = lib/forge-std - url = https://github.com/foundry-rs/forge-std -[submodule "lib/solidity-utils"] - path = lib/solidity-utils - url = https://github.com/bgd-labs/solidity-utils - branch = feat/zksync -[submodule "lib/aave-token-v3"] - path = lib/aave-token-v3 - url = https://github.com/bgd-labs/aave-token-v3 -[submodule "lib/openzeppelin-contracts"] - path = lib/openzeppelin-contracts - url = https://github.com/OpenZeppelin/openzeppelin-contracts - branch = release-v4.9 -[submodule "lib/aave-address-book"] - path = lib/aave-address-book - url = https://github.com/bgd-labs/aave-address-book -[submodule "lib/aave-delivery-infrastructure"] - path = lib/aave-delivery-infrastructure - url = https://github.com/bgd-labs/aave-delivery-infrastructure - branch = feat/zksync +[submodule "lib/adi-deploy"] + path = lib/adi-deploy + url = https://github.com/bgd-labs/adi-deploy + branch = feat/deploy-celo diff --git a/Makefile b/Makefile index 9dad6d7..143e287 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ write-json-addresses :; forge script scripts/WriteAddresses.s.sol:WriteDeployedA deploy-initial-test: - $(call deploy_fn,InitialDeployments,zksync) + $(call deploy_fn,InitialDeployments,celo) # Deploy Governance contracts deploy-governance-test: @@ -131,7 +131,7 @@ deploy-executor-lvl2-test: ## Deploy execution chain contracts deploy-payloads-controller-chain-test: - $(call deploy_fn,Payloads/Deploy_PayloadsController,zksync) + $(call deploy_fn,Payloads/Deploy_PayloadsController,celo) ## Deploy Governance Voting Portal deploy-voting-portals-test: @@ -148,7 +148,7 @@ set-vp-as_ccf-senders-test: ## Deploy Contract Helpers deploy-helper-contracts-test: - $(call deploy_fn,Deploy_ContractHelpers,zksync) + $(call deploy_fn,Deploy_ContractHelpers,celo) deploy-full-key-test: make deploy-initial-test diff --git a/deployments/cc/mainnet/celo.json b/deployments/cc/mainnet/celo.json new file mode 100644 index 0000000..6adaeb4 --- /dev/null +++ b/deployments/cc/mainnet/celo.json @@ -0,0 +1,29 @@ +{ + "arbAdapter": "0x0000000000000000000000000000000000000000", + "baseAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x3d534E8964e7aAcfc702751cc9A2BB6A9fe7d928", + "chainId": 42220, + "clEmergencyOracle": "0x91b21900E91CD302EBeD05E45D8f270ddAED944d", + "create3Factory": "0x0000000000000000000000000000000000000000", + "crossChainController": "0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd", + "crossChainControllerImpl": "0xB0f963f93bb14C9c7c9061939107989c726E144d", + "emergencyRegistry": "0x0000000000000000000000000000000000000000", + "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "granularCCCGuardian": "0x0000000000000000000000000000000000000000", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "hlAdapter": "0xa5cc218513305221201f196760E9e64e9D49d98A", + "lineaAdapter": "0x0000000000000000000000000000000000000000", + "lzAdapter": "0xAE93BEa44dcbE52B625169588574d31e36fb3A67", + "metisAdapter": "0x0000000000000000000000000000000000000000", + "mockDestination": "0x0000000000000000000000000000000000000000", + "opAdapter": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "polAdapter": "0x0000000000000000000000000000000000000000", + "proxyAdmin": "0x54BDcc37c4143f944A3EE51C892a6cBDF305E7a0", + "proxyFactory": "0xAe13e4DA0952f0B8fE04E21df53716fCF799a923", + "sameChainAdapter": "0x0000000000000000000000000000000000000000", + "scrollAdapter": "0x0000000000000000000000000000000000000000", + "wormholeAdapter": "0x3F006299eC88985c18E6e885EeA29A49eC579882", + "zkevmAdapter": "0x0000000000000000000000000000000000000000", + "zksyncAdapter": "0x0000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/deployments/cc/mainnet/eth.json b/deployments/cc/mainnet/eth.json index e2fd934..7f399e6 100644 --- a/deployments/cc/mainnet/eth.json +++ b/deployments/cc/mainnet/eth.json @@ -1,23 +1,29 @@ { - "arbAdapter": "0xE2a33403eaD139873820da597531f07f65ED0E3c", - "baseAdapter": "0xEB442296880a3FC7C00FFe695c40B09d970fb936", - "ccipAdapter": "0xDB8953194810b1942544fA528791278D458719D5", + "arbAdapter": "0x88d6D01e08d3e64513b15fD46528dBbA7d755883", + "baseAdapter": "0xa5948b0ac79f72966dFFC5C13E44f6dfDD3D58A0", + "ccipAdapter": "0x58489B249BfBCF5ef4B30bdE2792086e83122B6f", "chainId": 1, "clEmergencyOracle": "0x0000000000000000000000000000000000000000", "create3Factory": "0xcc3C54B95f3f1867A43009B80ed4DD930E3cE2F7", "crossChainController": "0xEd42a7D8559a463722Ca4beD50E0Cc05a386b0e1", - "crossChainControllerImpl": "0x0Bf5bbfaE7808D329e0Ba8277e0b746BbfDA68f1", + "crossChainControllerImpl": "0x28559c2F4B038b1E836fA419DCcDe7454d8Fe215", "emergencyRegistry": "0x0000000000000000000000000000000000000000", - "gnosisAdapter": "0xe95B40b2CF5fA2F56AAEf9E52f5Bd1e70C059858", + "gnosisAdapter": "0x7238d75fD75bb936E83b75854c653F104Ce9c9d8", + "granularCCCGuardian": "0x4457cA11E90f416Cc1D3a8E1cA41C0cdEcC251d4", "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", - "hlAdapter": "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8", - "lzAdapter": "0x1783DA119C35ED03e608f88cB9528Aba8174fFfc", - "metisAdapter": "0x619643b346E3389062527cdb60C8720415B39860", + "hlAdapter": "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1", + "lineaAdapter": "0x8097555ffDa4176C93FEf92dF473b9763e467686", + "lzAdapter": "0x8410d9BD353b420ebA8C48ff1B0518426C280FCC", + "metisAdapter": "0x6B3Dc800E7c813Db3fe8D0F30fDCaE636935dC14", "mockDestination": "0x19198689FfBE82207F023248dca175a84c52eCE1", - "opAdapter": "0x2ecC4F6CDbe6ea77107dd131Af81ec82Db330d6b", + "opAdapter": "0x0e24524778fdc67f53eEf144b8cbf50261E930B3", "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", - "polAdapter": "0xb13712De579E1f9943502FFCf72eab6ec348cF79", + "polAdapter": "0x1562F1b2487F892BBA8Ef325aF054Fd157510a71", "proxyAdmin": "0xD3cF979e676265e4f6379749DECe4708B9A22476", "proxyFactory": "0xB4e496f70602fE2AC6Ae511D028BA4D194773B29", - "sameChainAdapter": "0x118DFD5418890c0332042ab05173Db4A2C1d283c" + "sameChainAdapter": "0x6cfbd2aA4691fc18B9C209bDd43DC3943C228FCf", + "scrollAdapter": "0xA4dC3F123e1c601A19B3DC8382BB9311F678cafA", + "wormholeAdapter": "0x42206271373675661500F8a4d6A6CE2FDc6b5De5", + "zkevmAdapter": "0xe0a6Eee6d0c883734A7a7e7B378BD09fffb89EB6", + "zksyncAdapter": "0x6aD9d4147467f08b165e1b6364584C5d28898b84" } \ No newline at end of file diff --git a/deployments/cc/mainnet/linea.json b/deployments/cc/mainnet/linea.json new file mode 100644 index 0000000..1e9c271 --- /dev/null +++ b/deployments/cc/mainnet/linea.json @@ -0,0 +1,29 @@ +{ + "arbAdapter": "0x0000000000000000000000000000000000000000", + "baseAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x0000000000000000000000000000000000000000", + "chainId": 59144, + "clEmergencyOracle": "0x0000000000000000000000000000000000000000", + "create3Factory": "0x0000000000000000000000000000000000000000", + "crossChainController": "0x0D3f821e9741C8a8Bcac231162320251Db0cdf52", + "crossChainControllerImpl": "0xcb5C27e1EF28949b354904ee8D3088330D806a6f", + "emergencyRegistry": "0x0000000000000000000000000000000000000000", + "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "granularCCCGuardian": "0x8CAdaAE6cd278c7C8FBaD5d6F55Ca6129A627E10", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "hlAdapter": "0x0000000000000000000000000000000000000000", + "lineaAdapter": "0xB3332d31ECFC3ef3BF6Cda79833D11d1A53f5cE6", + "lzAdapter": "0x0000000000000000000000000000000000000000", + "metisAdapter": "0x0000000000000000000000000000000000000000", + "mockDestination": "0x0000000000000000000000000000000000000000", + "opAdapter": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "polAdapter": "0x0000000000000000000000000000000000000000", + "proxyAdmin": "0x160E35e28fEE90F3656420584e0a990276219b5A", + "proxyFactory": "0xDe090EfCD6ef4b86792e2D84E55a5fa8d49D25D2", + "sameChainAdapter": "0x0000000000000000000000000000000000000000", + "scrollAdapter": "0x0000000000000000000000000000000000000000", + "wormholeAdapter": "0x0000000000000000000000000000000000000000", + "zkevmAdapter": "0x0000000000000000000000000000000000000000", + "zksyncAdapter": "0x0000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/deployments/gov/mainnet/celo.json b/deployments/gov/mainnet/celo.json new file mode 100644 index 0000000..d9dde70 --- /dev/null +++ b/deployments/gov/mainnet/celo.json @@ -0,0 +1,25 @@ +{ + "aavePool": "0x0000000000000000000000000000000000000000", + "chainId": 42220, + "create3Factory": "0x0000000000000000000000000000000000000000", + "dataWarehouse": "0x0000000000000000000000000000000000000000", + "executorLvl1": "0x1dF462e2712496373A347f8ad10802a5E95f053D", + "executorLvl2": "0x0000000000000000000000000000000000000000", + "governance": "0x0000000000000000000000000000000000000000", + "governanceDataHelper": "0x0000000000000000000000000000000000000000", + "governanceImpl": "0x0000000000000000000000000000000000000000", + "governancePowerStrategy": "0x0000000000000000000000000000000000000000", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "metaDelegateHelper": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "payloadsController": "0xE48E10834C04E394A04BF22a565D063D40b9FA42", + "payloadsControllerDataHelper": "0x8657Cd5a0957e8C5BE15c69C67078b5d730D720a", + "payloadsControllerImpl": "0xDA4B6024aA06f7565BBcAaD9B8bE24C3c229AAb5", + "votingMachine": "0x0000000000000000000000000000000000000000", + "votingMachineDataHelper": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Avax": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_BNB": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Eth": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Pol": "0x0000000000000000000000000000000000000000", + "votingStrategy": "0x0000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/deployments/gov/mainnet/linea.json b/deployments/gov/mainnet/linea.json new file mode 100644 index 0000000..9bd5880 --- /dev/null +++ b/deployments/gov/mainnet/linea.json @@ -0,0 +1,25 @@ +{ + "aavePool": "0x0000000000000000000000000000000000000000", + "chainId": 59144, + "create3Factory": "0x0000000000000000000000000000000000000000", + "dataWarehouse": "0x0000000000000000000000000000000000000000", + "executorLvl1": "0x8c2d95FE7aeB57b86961F3abB296A54f0ADb7F88", + "executorLvl2": "0x0000000000000000000000000000000000000000", + "governance": "0x0000000000000000000000000000000000000000", + "governanceDataHelper": "0x0000000000000000000000000000000000000000", + "governanceImpl": "0x0000000000000000000000000000000000000000", + "governancePowerStrategy": "0x0000000000000000000000000000000000000000", + "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "metaDelegateHelper": "0x0000000000000000000000000000000000000000", + "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", + "payloadsController": "0x3BcE23a1363728091bc57A58a226CF2940C2e074", + "payloadsControllerDataHelper": "0x6d4F341d8Bb3Dc5ABe822Aa940F1884508C13f99", + "payloadsControllerImpl": "0xA806DA549FcB2B4912a7dFFE4c1aA7A1ed0Bd5C9", + "votingMachine": "0x0000000000000000000000000000000000000000", + "votingMachineDataHelper": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Avax": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_BNB": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Eth": "0x0000000000000000000000000000000000000000", + "votingPortal_Eth_Pol": "0x0000000000000000000000000000000000000000", + "votingStrategy": "0x0000000000000000000000000000000000000000" +} \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 2bd2eee..37e25cb 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,10 +5,13 @@ out = 'out' libs = ['lib'] script = 'scripts' remappings = [] -solc='0.8.19' +solc='0.8.20' fs_permissions = [{ access = "read-write", path = "./"}] +evm_version = "paris" + + # Whether or not to enable `vm.ffi` ffi = true @@ -46,6 +49,10 @@ scroll="${RPC_SCROLL}" scroll-testnet="${RPC_SCROLL_TESTNET}" zksync="${RPC_ZK_SYNC}" zksync-testnet="${RPC_ZK_SYNC_TESTNET}" +linea="${RPC_LINEA}" +linea-testnet="${RPC_LINEA_SEPOLIA}" +celo="${RPC_CELO}" +celo-testnet="${RPC_CELO_ALFAJORES}" [etherscan] ethereum={key="${ETHERSCAN_API_KEY_MAINNET}", chain=1 } @@ -72,6 +79,10 @@ scroll={key="${ETHERSCAN_API_KEY_SCROLL}", chain=534352, utl='https://api.scroll scroll-testnet={key="${ETHERSCAN_API_KEY_SCROLL}", chain=534351, url='https://api-sepolia.scrollscan.com/api/'} zksync={key="${ETHERSCAN_API_KEY_ZK_SYNC}", chain=324} zksync-testnet={key="${ETHERSCAN_API_KEY_ZK_SYNC}", chain=300, url='https://api-sepolia-era.zksync.network/api'} +linea={key="${ETHERSCAN_API_KEY_LINEA}", chain=59144 } +linea-testnet={key="${ETHERSCAN_API_KEY_LINEA}",chain=59141} +celo={key="${ETHERSCAN_API_KEY_CELO}", chain=42220, utl='https://api.celoscan.io/api'} +celo-testnet={key="${ETHERSCAN_API_KEY_CELO}", chain=44787, url='https://api-alfajores.celoscan.io/api'} # See more config options https://github.com/gakonst/foundry/tree/master/config diff --git a/lib/aave-address-book b/lib/aave-address-book deleted file mode 160000 index a53910d..0000000 --- a/lib/aave-address-book +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a53910d9b71c6653f23d08443264ad898119b391 diff --git a/lib/aave-delivery-infrastructure b/lib/aave-delivery-infrastructure deleted file mode 160000 index 695701c..0000000 --- a/lib/aave-delivery-infrastructure +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 695701ceac213f01290ae4bb326947791f4c7316 diff --git a/lib/aave-token-v3 b/lib/aave-token-v3 deleted file mode 160000 index 994f1d3..0000000 --- a/lib/aave-token-v3 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 994f1d39640c55ff0ddb59889f90ce78e854892c diff --git a/lib/adi-deploy b/lib/adi-deploy new file mode 160000 index 0000000..f72fe5d --- /dev/null +++ b/lib/adi-deploy @@ -0,0 +1 @@ +Subproject commit f72fe5d397bfbfe0e279348262ccb0001ef49950 diff --git a/lib/forge-std b/lib/forge-std deleted file mode 160000 index 87a2a0a..0000000 --- a/lib/forge-std +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 87a2a0afc5fafd6297538a45a52ac19e71a84562 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts deleted file mode 160000 index bd325d5..0000000 --- a/lib/openzeppelin-contracts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bd325d56b4c62c9c5c1aff048c37c6bb18ac0290 diff --git a/lib/solidity-utils b/lib/solidity-utils deleted file mode 160000 index 4bd4720..0000000 --- a/lib/solidity-utils +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4bd4720f10876af32446837057614b42578543d7 diff --git a/remappings.txt b/remappings.txt index 0b02408..ac4186e 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,8 +1,8 @@ -solidity-utils/=lib/solidity-utils/src/ -aave-token-v3/=lib/aave-token-v3/src/ -aave-address-book/=lib/aave-address-book/src/ -aave-delivery-infrastructure/=lib/aave-delivery-infrastructure/src/ -aave-delivery-infrastructure-scripts/=lib/aave-delivery-infrastructure/scripts/ -ds-test/=lib/forge-std/lib/ds-test/src/ -forge-std/=lib/forge-std/src/ -openzeppelin-contracts/=lib/openzeppelin-contracts/ +aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src/ +solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src/ +forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src/ +openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/ +aave-helpers/=lib/adi-deploy/lib/aave-helpers/src/ +aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src/ +aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/ +adi-deploy/=lib/adi-deploy/ diff --git a/scripts/Deploy_ContractHelpers.s.sol b/scripts/Deploy_ContractHelpers.s.sol index cbd4047..e9cd7c0 100644 --- a/scripts/Deploy_ContractHelpers.s.sol +++ b/scripts/Deploy_ContractHelpers.s.sol @@ -98,7 +98,19 @@ contract Scroll is BaseContractHelpers { contract Zksync is BaseContractHelpers { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; + } +} + +contract Linea is BaseContractHelpers { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.LINEA; + } +} + +contract Celo is BaseContractHelpers { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.CELO; } } @@ -110,7 +122,7 @@ contract Ethereum_testnet is BaseContractHelpers { contract Polygon_testnet is BaseContractHelpers { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } @@ -122,13 +134,13 @@ contract Avalanche_testnet is BaseContractHelpers { contract Arbitrum_testnet is BaseContractHelpers { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } } contract Optimism_testnet is BaseContractHelpers { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } } @@ -146,6 +158,6 @@ contract Binance_testnet is BaseContractHelpers { contract Zksync_testnet is BaseContractHelpers { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } } diff --git a/scripts/GovBaseScript.sol b/scripts/GovBaseScript.sol index 4d83a0f..d19cdcf 100644 --- a/scripts/GovBaseScript.sol +++ b/scripts/GovBaseScript.sol @@ -4,9 +4,8 @@ pragma solidity ^0.8.0; import 'forge-std/Script.sol'; import 'forge-std/Vm.sol'; import 'forge-std/StdJson.sol'; -import {TestNetChainIds} from 'aave-delivery-infrastructure-scripts/contract_extensions/TestNetChainIds.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; -import {DeployerHelpers} from 'aave-delivery-infrastructure-scripts/BaseScript.sol'; +import {ChainIds, TestNetChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; +import {DeployerHelpers, Addresses as CCCAddresses} from 'adi-deploy/scripts/BaseDeployerScript.sol'; import {Create3Factory, Create3, ICreate3Factory} from 'solidity-utils/contracts/create3/Create3Factory.sol'; struct Network { @@ -68,34 +67,34 @@ library GovDeployerHelpers { return './deployments/gov/mainnet/zkevm.json'; } else if (chainId == ChainIds.SCROLL) { return './deployments/gov/mainnet/zkevm.json'; - } else if (chainId == ChainIds.ZK_SYNC) { + } else if (chainId == ChainIds.ZKSYNC) { return './deployments/gov/mainnet/zksync.json'; + } else if (chainId == ChainIds.LINEA) { + return './deployments/gov/mainnet/linea.json'; + } else if (chainId == ChainIds.CELO) { + return './deployments/gov/mainnet/celo.json'; } if (chainId == TestNetChainIds.ETHEREUM_SEPOLIA) { return './deployments/gov/testnet/sep.json'; - } else if (chainId == TestNetChainIds.ETHEREUM_GOERLI) { - return './deployments/gov/testnet/goerli.json'; - } else if (chainId == TestNetChainIds.POLYGON_MUMBAI) { - return './deployments/gov/testnet/mum.json'; + } else if (chainId == TestNetChainIds.POLYGON_AMOY) { + return './deployments/gov/testnet/amoy.json'; } else if (chainId == TestNetChainIds.AVALANCHE_FUJI) { return './deployments/gov/testnet/fuji.json'; - } else if (chainId == TestNetChainIds.ARBITRUM_GOERLI) { - return './deployments/gov/testnet/arb_go.json'; - } else if (chainId == TestNetChainIds.OPTIMISM_GOERLI) { - return './deployments/gov/testnet/op_go.json'; + } else if (chainId == TestNetChainIds.ARBITRUM_SEPOLIA) { + return './deployments/gov/testnet/arb_sep.json'; + } else if (chainId == TestNetChainIds.OPTIMISM_SEPOLIA) { + return './deployments/gov/testnet/op_sep.json'; } else if (chainId == TestNetChainIds.METIS_TESTNET) { return './deployments/gov/testnet/met_test.json'; } else if (chainId == TestNetChainIds.BNB_TESTNET) { return './deployments/gov/testnet/bnb_test.json'; - } else if (chainId == TestNetChainIds.BASE_GOERLI) { - return './deployments/gov/testnet/base_go.json'; + } else if (chainId == TestNetChainIds.BASE_SEPOLIA) { + return './deployments/gov/testnet/base_sep.json'; } else if (chainId == TestNetChainIds.GNOSIS_CHIADO) { return './deployments/gov/testnet/gnosis_chiado.json'; - } else if (chainId == TestNetChainIds.POLYGON_ZK_EVM_GOERLI) { - return './deployments/gov/testnet/zkevm_go.json'; } else if (chainId == TestNetChainIds.SCROLL_SEPOLIA) { return './deployments/gov/testnet/scroll_sepolia.json'; - } else if (chainId == TestNetChainIds.ZK_SYNC_SEPOLIA) { + } else if (chainId == TestNetChainIds.ZKSYNC_SEPOLIA) { return './deployments/gov/testnet/zksync_sep.json'; } else { revert('chain id is not supported'); @@ -296,7 +295,7 @@ abstract contract GovBaseScript is Script { function _getCCAddresses( uint256 networkId - ) internal view returns (DeployerHelpers.Addresses memory) { + ) internal view returns (CCCAddresses memory) { return DeployerHelpers.decodeJson( DeployerHelpers.getPathByChainId(networkId), diff --git a/scripts/Governance/Deploy_Governance.s.sol b/scripts/Governance/Deploy_Governance.s.sol index 971cfb9..b0b23e0 100644 --- a/scripts/Governance/Deploy_Governance.s.sol +++ b/scripts/Governance/Deploy_Governance.s.sol @@ -6,7 +6,9 @@ import {Governance} from '../../src/contracts/Governance.sol'; import {IGovernance, IGovernanceCore} from '../../src/interfaces/IGovernance.sol'; import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; import {PayloadsControllerUtils} from '../../src/contracts/payloads/PayloadsControllerUtils.sol'; -import {AaveV3Ethereum, AaveV3Sepolia} from 'aave-address-book/AaveAddressBook.sol'; +import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; +import {AaveV3Sepolia} from 'aave-address-book/AaveV3Sepolia.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {GovernanceExtended} from '../extendedContracts/Governance.sol'; @@ -41,9 +43,7 @@ abstract contract BaseDeployGovernance is GovBaseScript { IGovernanceCore.SetVotingConfigInput[] memory votingConfigs = getVotingConfigurations(); - DeployerHelpers.Addresses memory ccAddresses = _getCCAddresses( - TRANSACTION_NETWORK() - ); + CCCAddresses memory ccAddresses = _getCCAddresses(TRANSACTION_NETWORK()); // deploy governance. IGovernance governanceImpl; @@ -64,7 +64,7 @@ abstract contract BaseDeployGovernance is GovBaseScript { addresses.governance = TransparentProxyFactory(ccAddresses.proxyFactory) .createDeterministic( address(governanceImpl), - ccAddresses.proxyAdmin, + ProxyAdmin(ccAddresses.proxyAdmin), abi.encodeWithSelector( IGovernance.initialize.selector, addresses.owner, diff --git a/scripts/Governance/Deploy_VotingPortals.s.sol b/scripts/Governance/Deploy_VotingPortals.s.sol index 89b9c20..223b4d1 100644 --- a/scripts/Governance/Deploy_VotingPortals.s.sol +++ b/scripts/Governance/Deploy_VotingPortals.s.sol @@ -22,9 +22,7 @@ abstract contract BaseDeployVotingPortals is GovBaseScript { GovDeployerHelpers.Addresses memory votingAddresses = _getAddresses( VOTING_MACHINE_NETWORK() ); - DeployerHelpers.Addresses memory ccAddresses = _getCCAddresses( - TRANSACTION_NETWORK() - ); + CCCAddresses memory ccAddresses = _getCCAddresses(TRANSACTION_NETWORK()); bytes memory encodedParams = abi.encode( ccAddresses.crossChainController, @@ -49,7 +47,7 @@ abstract contract BaseDeployVotingPortals is GovBaseScript { addresses.votingPortal_Eth_Avax = address(votingPortal); } else if ( VOTING_MACHINE_NETWORK() == ChainIds.POLYGON || - VOTING_MACHINE_NETWORK() == TestNetChainIds.POLYGON_MUMBAI + VOTING_MACHINE_NETWORK() == TestNetChainIds.POLYGON_AMOY ) { addresses.votingPortal_Eth_Pol = address(votingPortal); } else if ( @@ -156,7 +154,7 @@ contract Ethereum_Polygon_testnet is BaseDeployVotingPortals { } function VOTING_MACHINE_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } function VOTING_PORTAL_SALT() public pure override returns (bytes32) { diff --git a/scripts/Governance/Remove_VP_from_CCF_Senders.s.sol b/scripts/Governance/Remove_VP_from_CCF_Senders.s.sol index dec6261..60b97bb 100644 --- a/scripts/Governance/Remove_VP_from_CCF_Senders.s.sol +++ b/scripts/Governance/Remove_VP_from_CCF_Senders.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {BaseRemoveCCFApprovedSenders} from 'aave-delivery-infrastructure-scripts/CCC/Remove_CCF_Approved_Senders.s.sol'; +import {BaseRemoveCCFApprovedSenders} from 'adi-deploy/scripts/ccc/Remove_CCF_Approved_Senders.s.sol'; import '../GovBaseScript.sol'; abstract contract BaseRemoveVPAsCCFSender is BaseRemoveCCFApprovedSenders { @@ -23,13 +23,13 @@ abstract contract BaseRemoveVPAsCCFSender is BaseRemoveCCFApprovedSenders { } contract Ethereum is BaseRemoveVPAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } } contract Ethereum_testnet is BaseRemoveVPAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } } diff --git a/scripts/Governance/Set_Gov_as_CCF_Sender.s.sol b/scripts/Governance/Set_Gov_as_CCF_Sender.s.sol index 727e47e..500cada 100644 --- a/scripts/Governance/Set_Gov_as_CCF_Sender.s.sol +++ b/scripts/Governance/Set_Gov_as_CCF_Sender.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {BaseSetCCFApprovedSenders} from 'aave-delivery-infrastructure-scripts/CCC/Set_CCF_Approved_Senders.s.sol'; +import {BaseSetCCFApprovedSenders} from 'adi-deploy/scripts/ccc/Set_CCF_Approved_Senders.s.sol'; import '../GovBaseScript.sol'; abstract contract BaseSetGovAsCCFSender is BaseSetCCFApprovedSenders { @@ -21,13 +21,13 @@ abstract contract BaseSetGovAsCCFSender is BaseSetCCFApprovedSenders { } contract Ethereum is BaseSetGovAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } } contract Ethereum_testnet is BaseSetGovAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } } diff --git a/scripts/Governance/Set_VP_as_CCF_Senders.s.sol b/scripts/Governance/Set_VP_as_CCF_Senders.s.sol index 4a83c86..51b7627 100644 --- a/scripts/Governance/Set_VP_as_CCF_Senders.s.sol +++ b/scripts/Governance/Set_VP_as_CCF_Senders.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {BaseSetCCFApprovedSenders} from 'aave-delivery-infrastructure-scripts/CCC/Set_CCF_Approved_Senders.s.sol'; +import {BaseSetCCFApprovedSenders} from 'adi-deploy/scripts/ccc/Set_CCF_Approved_Senders.s.sol'; import '../GovBaseScript.sol'; abstract contract BaseSetVPAsCCFSender is BaseSetCCFApprovedSenders { @@ -24,13 +24,13 @@ abstract contract BaseSetVPAsCCFSender is BaseSetCCFApprovedSenders { } contract Ethereum is BaseSetVPAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } } contract Ethereum_testnet is BaseSetVPAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } } diff --git a/scripts/InitialDeployments.s.sol b/scripts/InitialDeployments.s.sol index d0aeeca..8092ab7 100644 --- a/scripts/InitialDeployments.s.sol +++ b/scripts/InitialDeployments.s.sol @@ -13,9 +13,7 @@ abstract contract BaseInitialDeployment is GovBaseScript { } function CREATE3_FACTORY() public view virtual returns (address) { - DeployerHelpers.Addresses memory ccAddresses = _getCCAddresses( - TRANSACTION_NETWORK() - ); + CCCAddresses memory ccAddresses = _getCCAddresses(TRANSACTION_NETWORK()); return ccAddresses.create3Factory; } @@ -143,7 +141,19 @@ contract Scroll is BaseInitialDeployment { contract Zksync is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; + } +} + +contract Linea is BaseInitialDeployment { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.LINEA; + } +} + +contract Celo is BaseInitialDeployment { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.CELO; } } @@ -155,7 +165,7 @@ contract Ethereum_testnet is BaseInitialDeployment { contract Polygon_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } @@ -167,13 +177,13 @@ contract Avalanche_testnet is BaseInitialDeployment { contract Arbitrum_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } } contract Optimism_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } } @@ -191,12 +201,12 @@ contract Binance_testnet is BaseInitialDeployment { contract Base_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.BASE_GOERLI; + return TestNetChainIds.BASE_SEPOLIA; } } contract Zksync_testnet is BaseInitialDeployment { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } } diff --git a/scripts/Payloads/Deploy_ExecutorLvl1.s.sol b/scripts/Payloads/Deploy_ExecutorLvl1.s.sol index 31f7a4f..e29c979 100644 --- a/scripts/Payloads/Deploy_ExecutorLvl1.s.sol +++ b/scripts/Payloads/Deploy_ExecutorLvl1.s.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import '../GovBaseScript.sol'; import {Ownable} from 'solidity-utils/contracts/oz-common/Ownable.sol'; import {Executor} from '../../src/contracts/payloads/Executor.sol'; -import {AaveGovernanceV2} from 'aave-address-book/AaveAddressBook.sol'; +import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; abstract contract BaseDeployExecutorLvl1 is GovBaseScript { function getExecutorOwner() public view virtual returns (address) { @@ -62,7 +62,7 @@ contract Metis is BaseDeployExecutorLvl1 { } function getExecutorOwner() public pure override returns (address) { - return AaveGovernanceV2.METIS_BRIDGE_EXECUTOR; + return AaveGovernanceV2.SHORT_EXECUTOR; } } @@ -72,7 +72,7 @@ contract Base is BaseDeployExecutorLvl1 { } function getExecutorOwner() public pure override returns (address) { - return AaveGovernanceV2.BASE_BRIDGE_EXECUTOR; + return AaveGovernanceV2.SHORT_EXECUTOR; } } @@ -96,7 +96,7 @@ contract Zkevm is BaseDeployExecutorLvl1 { contract Zksync is BaseDeployExecutorLvl1 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; } } @@ -120,19 +120,19 @@ contract Avalanche_testnet is BaseDeployExecutorLvl1 { contract Polygon_testnet is BaseDeployExecutorLvl1 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } contract Optimism_testnet is BaseDeployExecutorLvl1 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } } contract Arbitrum_testnet is BaseDeployExecutorLvl1 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } } @@ -150,6 +150,6 @@ contract Binance_testnet is BaseDeployExecutorLvl1 { contract Zksync_testnet is BaseDeployExecutorLvl1 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } } diff --git a/scripts/Payloads/Deploy_ExecutorLvl2.s.sol b/scripts/Payloads/Deploy_ExecutorLvl2.s.sol index d029cd7..56bd664 100644 --- a/scripts/Payloads/Deploy_ExecutorLvl2.s.sol +++ b/scripts/Payloads/Deploy_ExecutorLvl2.s.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import '../GovBaseScript.sol'; import {Ownable} from 'solidity-utils/contracts/oz-common/Ownable.sol'; import {Executor} from '../../src/contracts/payloads/Executor.sol'; -import {AaveGovernanceV2} from 'aave-address-book/AaveAddressBook.sol'; +import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; abstract contract BaseDeployExecutorLvl2 is GovBaseScript { function getExecutorOwner() public view virtual returns (address) { @@ -82,19 +82,19 @@ contract Avalanche_testnet is BaseDeployExecutorLvl2 { contract Polygon_testnet is BaseDeployExecutorLvl2 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } contract Optimism_testnet is BaseDeployExecutorLvl2 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } } contract Arbitrum_testnet is BaseDeployExecutorLvl2 { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } } diff --git a/scripts/Payloads/Deploy_PayloadsController.s.sol b/scripts/Payloads/Deploy_PayloadsController.s.sol index 91aaf9a..2c6ee15 100644 --- a/scripts/Payloads/Deploy_PayloadsController.s.sol +++ b/scripts/Payloads/Deploy_PayloadsController.s.sol @@ -9,6 +9,7 @@ import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent- import {PayloadsControllerUtils} from '../../src/contracts/payloads/PayloadsControllerUtils.sol'; import {PayloadsControllerExtended} from '../extendedContracts/PayloadsController.sol'; import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; abstract contract BaseDeployPayloadsController is GovBaseScript { function GOVERNANCE_NETWORK() public view virtual returns (uint256); @@ -77,9 +78,7 @@ abstract contract BaseDeployPayloadsController is GovBaseScript { GovDeployerHelpers.Addresses memory govAddresses = _getAddresses( GOVERNANCE_NETWORK() ); - DeployerHelpers.Addresses memory ccAddresses = _getCCAddresses( - TRANSACTION_NETWORK() - ); + CCCAddresses memory ccAddresses = _getCCAddresses(TRANSACTION_NETWORK()); // deploy payloadsController if (isTest()) { @@ -107,7 +106,7 @@ abstract contract BaseDeployPayloadsController is GovBaseScript { ccAddresses.proxyFactory ).createDeterministic( addresses.payloadsControllerImpl, - ccAddresses.proxyAdmin, + ProxyAdmin(ccAddresses.proxyAdmin), abi.encodeWithSelector( IPayloadsControllerCore.initialize.selector, OWNER(), @@ -117,12 +116,12 @@ abstract contract BaseDeployPayloadsController is GovBaseScript { Constants.PAYLOADS_CONTROLLER_SALT ); - if (addresses.chainId != ChainIds.ETHEREUM) { - for (uint256 i = 0; i < executors.length; i++) { - Ownable(address(executors[i].executorConfig.executor)) - .transferOwnership(addresses.payloadsController); - } - } + // if (addresses.chainId != ChainIds.ETHEREUM) { + // for (uint256 i = 0; i < executors.length; i++) { + // Ownable(address(executors[i].executorConfig.executor)) + // .transferOwnership(addresses.payloadsController); + // } + // } } } @@ -251,7 +250,27 @@ contract Scroll is BaseDeployPayloadsController { contract Zksync is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; + } + + function GOVERNANCE_NETWORK() public pure override returns (uint256) { + return ChainIds.ETHEREUM; + } +} + +contract Linea is BaseDeployPayloadsController { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.LINEA; + } + + function GOVERNANCE_NETWORK() public pure override returns (uint256) { + return ChainIds.ETHEREUM; + } +} + +contract Celo is BaseDeployPayloadsController { + function TRANSACTION_NETWORK() public pure override returns (uint256) { + return ChainIds.CELO; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { @@ -318,7 +337,7 @@ contract Avalanche_testnet is BaseDeployPayloadsController { contract Polygon_testnet is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { @@ -340,7 +359,7 @@ contract Polygon_testnet is BaseDeployPayloadsController { contract Optimism_testnet is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { @@ -362,7 +381,7 @@ contract Optimism_testnet is BaseDeployPayloadsController { contract Arbitrum_testnet is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { @@ -428,11 +447,11 @@ contract Binance_testnet is BaseDeployPayloadsController { contract Base_testnet is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.BASE_GOERLI; + return TestNetChainIds.BASE_SEPOLIA; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ETHEREUM_GOERLI; + return TestNetChainIds.ETHEREUM_SEPOLIA; } function LVL1_DELAY() public pure override returns (uint40) { @@ -450,7 +469,7 @@ contract Base_testnet is BaseDeployPayloadsController { contract Zksync_testnet is BaseDeployPayloadsController { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { diff --git a/scripts/VotingMachine/Deploy_DataWarehouse.s.sol b/scripts/VotingMachine/Deploy_DataWarehouse.s.sol index 1bbe825..28b1aa3 100644 --- a/scripts/VotingMachine/Deploy_DataWarehouse.s.sol +++ b/scripts/VotingMachine/Deploy_DataWarehouse.s.sol @@ -50,7 +50,7 @@ contract Avalanche_testnet is BaseDeployDataWarehouse { contract Polygon_testnet is BaseDeployDataWarehouse { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } diff --git a/scripts/VotingMachine/Deploy_VotingMachine.s.sol b/scripts/VotingMachine/Deploy_VotingMachine.s.sol index a6738c3..ec23d8e 100644 --- a/scripts/VotingMachine/Deploy_VotingMachine.s.sol +++ b/scripts/VotingMachine/Deploy_VotingMachine.s.sol @@ -28,9 +28,7 @@ abstract contract BaseDeployVotingMachine is GovBaseScript { GovDeployerHelpers.Addresses memory govAddresses = _getAddresses( GOVERNANCE_NETWORK() ); - DeployerHelpers.Addresses memory ccAddresses = _getCCAddresses( - TRANSACTION_NETWORK() - ); + CCCAddresses memory ccAddresses = _getCCAddresses(TRANSACTION_NETWORK()); // deploy voting machine addresses.votingMachine = address( @@ -132,7 +130,7 @@ contract Avalanche_testnet is BaseDeployVotingMachine { contract Polygon_testnet is BaseDeployVotingMachine { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } function GOVERNANCE_NETWORK() public pure override returns (uint256) { diff --git a/scripts/VotingMachine/Deploy_VotingStrategy.s.sol b/scripts/VotingMachine/Deploy_VotingStrategy.s.sol index 4eb9902..d0d83cc 100644 --- a/scripts/VotingMachine/Deploy_VotingStrategy.s.sol +++ b/scripts/VotingMachine/Deploy_VotingStrategy.s.sol @@ -68,7 +68,7 @@ contract Avalanche_testnet is BaseDeployVotingStrategy { contract Polygon_testnet is BaseDeployVotingStrategy { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } diff --git a/scripts/VotingMachine/Remove_VM_from_CFF_Senders.s.sol b/scripts/VotingMachine/Remove_VM_from_CFF_Senders.s.sol index f2c968e..3119470 100644 --- a/scripts/VotingMachine/Remove_VM_from_CFF_Senders.s.sol +++ b/scripts/VotingMachine/Remove_VM_from_CFF_Senders.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {BaseRemoveCCFApprovedSenders} from 'aave-delivery-infrastructure-scripts/CCC/Remove_CCF_Approved_Senders.s.sol'; +import {BaseRemoveCCFApprovedSenders} from 'adi-deploy/scripts/ccc/Remove_CCF_Approved_Senders.s.sol'; import '../GovBaseScript.sol'; abstract contract BaseRemoveVMAsCCFSender is BaseRemoveCCFApprovedSenders { @@ -22,25 +22,25 @@ abstract contract BaseRemoveVMAsCCFSender is BaseRemoveCCFApprovedSenders { } contract Ethereum is BaseRemoveVMAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } } contract Ethereum_testnet is BaseRemoveVMAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } } contract Avalanche is BaseRemoveVMAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.AVALANCHE; } } contract Avalanche_testnet is BaseRemoveVMAsCCFSender { - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.AVALANCHE_FUJI; } } diff --git a/scripts/VotingMachine/Set_VM_as_CCF_Sender.s.sol b/scripts/VotingMachine/Set_VM_as_CCF_Sender.s.sol index 12039b0..b173f79 100644 --- a/scripts/VotingMachine/Set_VM_as_CCF_Sender.s.sol +++ b/scripts/VotingMachine/Set_VM_as_CCF_Sender.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {BaseSetCCFApprovedSenders} from 'aave-delivery-infrastructure-scripts/CCC/Set_CCF_Approved_Senders.s.sol'; +import {BaseSetCCFApprovedSenders} from 'adi-deploy/scripts/ccc/Set_CCF_Approved_Senders.s.sol'; import '../GovBaseScript.sol'; contract Ethereum is BaseSetCCFApprovedSenders { @@ -20,7 +20,7 @@ contract Ethereum is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } } @@ -40,7 +40,7 @@ contract Avalanche is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.AVALANCHE; } } @@ -60,7 +60,7 @@ contract Polygon is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.POLYGON; } } @@ -80,7 +80,7 @@ contract Binance is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.BNB; } } @@ -101,7 +101,7 @@ contract Ethereum_testnet is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.ETHEREUM_SEPOLIA; } } @@ -121,7 +121,7 @@ contract Avalanche_testnet is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.AVALANCHE_FUJI; } } @@ -141,8 +141,8 @@ contract Polygon_testnet is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return TestNetChainIds.POLYGON_AMOY; } } @@ -161,7 +161,7 @@ contract Binance_testnet is BaseSetCCFApprovedSenders { return sendersToApprove; } - function TRANSACTION_NETWORK() public pure override returns (uint256) { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { return TestNetChainIds.BNB_TESTNET; } } diff --git a/scripts/WriteAddresses.s.sol b/scripts/WriteAddresses.s.sol deleted file mode 100644 index b614018..0000000 --- a/scripts/WriteAddresses.s.sol +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.0; - -import './GovBaseScript.sol'; - -contract WriteDeployedAddresses is Script { - using stdJson for string; - - function run() public { - Network[] memory networks = new Network[](12); - // mainnets - networks[0] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.ETHEREUM), - name: 'ethereum' - }); - networks[1] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.POLYGON), - name: 'polygon' - }); - networks[2] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.AVALANCHE), - name: 'avalanche' - }); - networks[3] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.OPTIMISM), - name: 'optimism' - }); - networks[4] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.ARBITRUM), - name: 'arbitrum' - }); - networks[5] = Network({ - path: GovDeployerHelpers.getPathByChainId(ChainIds.METIS), - name: 'metis' - }); - // testnets - networks[6] = Network({ - path: GovDeployerHelpers.getPathByChainId( - TestNetChainIds.ETHEREUM_SEPOLIA - ), - name: 'sepolia' - }); - networks[7] = Network({ - path: GovDeployerHelpers.getPathByChainId(TestNetChainIds.POLYGON_MUMBAI), - name: 'mumbai' - }); - networks[8] = Network({ - path: GovDeployerHelpers.getPathByChainId(TestNetChainIds.AVALANCHE_FUJI), - name: 'fuji' - }); - networks[9] = Network({ - path: GovDeployerHelpers.getPathByChainId( - TestNetChainIds.OPTIMISM_GOERLI - ), - name: 'optimismGoerli' - }); - networks[10] = Network({ - path: GovDeployerHelpers.getPathByChainId( - TestNetChainIds.ARBITRUM_GOERLI - ), - name: 'arbitrumGoerli' - }); - networks[11] = Network({ - path: GovDeployerHelpers.getPathByChainId(TestNetChainIds.METIS_TESTNET), - name: 'metisTestnet' - }); - - string memory deployedJson = 'deployments'; - - for (uint256 i = 0; i < networks.length; i++) { - GovDeployerHelpers.Addresses memory addresses = GovDeployerHelpers - .decodeJson(networks[i].path, vm); - string memory json = networks[i].name; - - json.serialize('aavePool', addresses.aavePool); - json.serialize('chainId', addresses.chainId); - json.serialize('dataWarehouse', addresses.dataWarehouse); - json.serialize('executorLvl1', addresses.executorLvl1); - json.serialize('executorLvl2', addresses.executorLvl2); - json.serialize('governance', addresses.governance); - json.serialize('governanceDataHelper', addresses.governanceDataHelper); - json.serialize('governanceImpl', addresses.governanceImpl); - json.serialize( - 'governancePowerStrategy', - addresses.governancePowerStrategy - ); - json.serialize('guardian', addresses.guardian); - json.serialize('metaDelegateHelper', addresses.metaDelegateHelper); - json.serialize('owner', addresses.owner); - json.serialize('payloadsController', addresses.payloadsController); - json.serialize( - 'payloadsControllerDataHelper', - addresses.payloadsControllerDataHelper - ); - json.serialize( - 'payloadsControllerImpl', - addresses.payloadsControllerImpl - ); - json.serialize('votingMachine', addresses.votingMachine); - json.serialize( - 'votingMachineDataHelper', - addresses.votingMachineDataHelper - ); - json.serialize('votingPortal_Eth_Avax', addresses.votingPortal_Eth_Avax); - json.serialize('votingPortal_Eth_BNB', addresses.votingPortal_Eth_BNB); - json.serialize('votingPortal_Eth_Eth', addresses.votingPortal_Eth_Eth); - json.serialize('votingPortal_Eth_Pol', addresses.votingPortal_Eth_Pol); - json = json.serialize('votingStrategy', addresses.votingStrategy); - - if (i == networks.length - 1) { - deployedJson = deployedJson.serialize(networks[i].name, json); - } else { - deployedJson.serialize(networks[i].name, json); - } - } - - vm.writeJson(deployedJson, './deployments/multiChainGovV3Addresses.json'); - } -} diff --git a/scripts/helpers/CreatePayload.s.sol b/scripts/helpers/CreatePayload.s.sol index c23a712..c960011 100644 --- a/scripts/helpers/CreatePayload.s.sol +++ b/scripts/helpers/CreatePayload.s.sol @@ -67,7 +67,7 @@ contract Binance is BaseCreatePayload { contract Zksync is BaseCreatePayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; } } @@ -85,19 +85,19 @@ contract Avalanche_testnet is BaseCreatePayload { contract Polygon_testnet is BaseCreatePayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } } contract Arbitrum_testnet is BaseCreatePayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ARBITRUM_GOERLI; + return TestNetChainIds.ARBITRUM_SEPOLIA; } } contract Optimism_testnet is BaseCreatePayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.OPTIMISM_GOERLI; + return TestNetChainIds.OPTIMISM_SEPOLIA; } } @@ -115,6 +115,6 @@ contract Binance_testnet is BaseCreatePayload { contract Zksync_testnet is BaseCreatePayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } } diff --git a/scripts/helpers/CreateProposal.s.sol b/scripts/helpers/CreateProposal.s.sol index 5ea2aab..f7e189b 100644 --- a/scripts/helpers/CreateProposal.s.sol +++ b/scripts/helpers/CreateProposal.s.sol @@ -38,9 +38,9 @@ contract Ethereum_testnet is BaseCreateProposal { PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); payloads[0] = PayloadsControllerUtils.Payload({ - chain: TestNetChainIds.POLYGON_MUMBAI, + chain: TestNetChainIds.POLYGON_AMOY, accessLevel: PayloadsControllerUtils.AccessControl.Level_1, - payloadsController: _getAddresses(TestNetChainIds.POLYGON_MUMBAI) + payloadsController: _getAddresses(TestNetChainIds.POLYGON_AMOY) .payloadsController, payloadId: 7 }); diff --git a/scripts/helpers/RegisterPayload.s.sol b/scripts/helpers/RegisterPayload.s.sol index 4ac8417..6d7e569 100644 --- a/scripts/helpers/RegisterPayload.s.sol +++ b/scripts/helpers/RegisterPayload.s.sol @@ -22,7 +22,7 @@ abstract contract BaseRegisterPayload is GovBaseScript { contract Zksync is BaseRegisterPayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return ChainIds.ZK_SYNC; + return ChainIds.ZKSYNC; } function getPayloadActions() @@ -49,7 +49,7 @@ contract Zksync is BaseRegisterPayload { contract Polygon_testnet is BaseRegisterPayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.POLYGON_MUMBAI; + return TestNetChainIds.POLYGON_AMOY; } function getPayloadActions() @@ -76,7 +76,7 @@ contract Polygon_testnet is BaseRegisterPayload { contract Zksync_testnet is BaseRegisterPayload { function TRANSACTION_NETWORK() public pure override returns (uint256) { - return TestNetChainIds.ZK_SYNC_SEPOLIA; + return TestNetChainIds.ZKSYNC_SEPOLIA; } function getPayloadActions() diff --git a/security/certora/confs/payloads/verifyPayloadsController.conf b/security/certora/confs/payloads/verifyPayloadsController.conf index 81dd9ee..5277ec9 100644 --- a/security/certora/confs/payloads/verifyPayloadsController.conf +++ b/security/certora/confs/payloads/verifyPayloadsController.conf @@ -5,8 +5,8 @@ "security/certora/harness/DummyERC20Impl.sol" ], "packages": [ - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src" ], "loop_iter": "3", "msg": "All payloadControllers rules", @@ -16,7 +16,7 @@ "prover_args": ["-depth 0"], "smt_timeout": "6000", "build_cache": true, - "solc": "solc8.19", + "solc": "solc8.20", //"rule_sanity": "advanced", "verify": "PayloadsControllerHarness:security/certora/specs/payloads/PayloadsController.spec" -} \ No newline at end of file +} diff --git a/security/certora/confs/verifyGovernance.conf b/security/certora/confs/verifyGovernance.conf index a9818ec..c038f3a 100644 --- a/security/certora/confs/verifyGovernance.conf +++ b/security/certora/confs/verifyGovernance.conf @@ -3,7 +3,7 @@ "security/certora/harness/GovernanceHarness.sol", // "src/contracts/VotingPortal.sol", "src/contracts/voting/VotingStrategy.sol", - "lib/aave-token-v3/src/AaveTokenV3.sol", + "security/certora/harness/aave-token-v3/AaveTokenV3.sol", "src/contracts/GovernancePowerStrategy.sol", "src/contracts/payloads/PayloadsControllerUtils.sol" ], @@ -11,11 +11,16 @@ "GovernanceHarness:_powerStrategy=GovernancePowerStrategy" ], "packages": [ - "aave-address-book=lib/aave-address-book/src", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v3=lib/aave-token-v3/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", +// "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy", + "aave-token-v3=security/certora/harness/aave-token-v3", ], "verify": "GovernanceHarness:security/certora/specs/Governance.spec", //"struct_link": [ @@ -26,11 +31,11 @@ "prover_args": [ " -copyLoopUnroll 8" ], - "solc": "solc8.19", + "solc": "solc8.20", //"parametric_contracts":["GovernanceHarness" //], // "disable_auto_cache_key_gen" :true, //"rule_sanity": "advanced", "build_cache": true, "msg": "All Governance rules", -} \ No newline at end of file +} diff --git a/security/certora/confs/verifyGovernancePowerStrategy.conf b/security/certora/confs/verifyGovernancePowerStrategy.conf index 22a188b..c853893 100644 --- a/security/certora/confs/verifyGovernancePowerStrategy.conf +++ b/security/certora/confs/verifyGovernancePowerStrategy.conf @@ -8,12 +8,16 @@ "link": [ ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", +// "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy", + "aave-token-v3=security/certora/harness/aave-token-v3", ], "verify": "GovernancePowerStrategyHarness:security/certora/specs/GovernancePowerStrategy.spec", "optimistic_loop": true, @@ -21,7 +25,7 @@ "prover_args": [ " -smt_LIASolvers [z3:def,z3:lia1,z3:lia2] -smt_NIASolvers [z3:def]" ], - "solc": "solc8.19", + "solc": "solc8.20", "smt_timeout": "6000", "rule_sanity": "basic", "build_cache": true, diff --git a/security/certora/confs/verifyVotingStrategy_unittests.conf b/security/certora/confs/verifyVotingStrategy_unittests.conf index 63f775f..cd5488e 100644 --- a/security/certora/confs/verifyVotingStrategy_unittests.conf +++ b/security/certora/confs/verifyVotingStrategy_unittests.conf @@ -8,18 +8,15 @@ "VotingStrategy:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "forge-std=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "aave-delivery-infrastructure=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "openzeppelin-contracts=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts" ], "verify": "VotingStrategy:security/certora/specs/VotingStrategy_unittests.spec", "optimistic_loop": true, "loop_iter": "3", // Needs 2 for isTokenSlotAccepted (A_AAVE uses 2 slots) - "solc": "solc8.19", + "solc": "solc8.20", "rule_sanity": "basic", "build_cache": true, "msg": "VotingStrategy tests" diff --git a/security/certora/confs/voting/verifyLegality.conf b/security/certora/confs/voting/verifyLegality.conf index 8326597..8456b91 100644 --- a/security/certora/confs/voting/verifyLegality.conf +++ b/security/certora/confs/voting/verifyLegality.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarness:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,19 +15,20 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarness:security/certora/specs/voting/legality.spec", "optimistic_loop": true, "loop_iter": "3", "optimistic_hashing": true, - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding DataWarehouse! "VotingMachineHarness", diff --git a/security/certora/confs/voting/verifyMisc.conf b/security/certora/confs/voting/verifyMisc.conf index cc66b54..9762f85 100644 --- a/security/certora/confs/voting/verifyMisc.conf +++ b/security/certora/confs/voting/verifyMisc.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarnessTriple:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,19 +15,20 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarnessTriple:security/certora/specs/voting/misc.spec", "optimistic_loop": true, "loop_iter": "3", // Needs 3 for `submitVoteTripleProof` "optimistic_hashing": true, - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding DataWarehouse! "VotingMachineHarnessTriple", diff --git a/security/certora/confs/voting/verifyPower_summary.conf b/security/certora/confs/voting/verifyPower_summary.conf index c52b168..af1eb15 100644 --- a/security/certora/confs/voting/verifyPower_summary.conf +++ b/security/certora/confs/voting/verifyPower_summary.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarnessTriple:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,19 +15,20 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarnessTriple:security/certora/specs/voting/power_summary.spec", "optimistic_loop": true, "loop_iter": "3", // 3 is needed for `submitVoteTripleProof`; 2 for `isTokenSlotAccepted` (A_AAVE uses two slots) "optimistic_hashing": true, - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding all other contracts "VotingMachineHarnessTriple" diff --git a/security/certora/confs/voting/verifyProposal_config.conf b/security/certora/confs/voting/verifyProposal_config.conf index c22a18e..163fbb9 100644 --- a/security/certora/confs/voting/verifyProposal_config.conf +++ b/security/certora/confs/voting/verifyProposal_config.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarness:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,19 +15,20 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarness:security/certora/specs/voting/proposal_config.spec", "optimistic_loop": true, "loop_iter": "3", "optimistic_hashing": true, - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding DataWarehouse! "VotingMachineHarness", diff --git a/security/certora/confs/voting/verifyProposal_states.conf b/security/certora/confs/voting/verifyProposal_states.conf index 7489406..0a073e3 100644 --- a/security/certora/confs/voting/verifyProposal_states.conf +++ b/security/certora/confs/voting/verifyProposal_states.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarness:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,19 +15,20 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarness:security/certora/specs/voting/proposal_states.spec", "optimistic_loop": true, "loop_iter": "4", "optimistic_hashing": true, - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding DataWarehouse! "VotingMachineHarness", diff --git a/security/certora/confs/voting/verifyVoting_and_tally.conf b/security/certora/confs/voting/verifyVoting_and_tally.conf index c5d8534..62b2e97 100644 --- a/security/certora/confs/voting/verifyVoting_and_tally.conf +++ b/security/certora/confs/voting/verifyVoting_and_tally.conf @@ -6,7 +6,7 @@ "src/contracts/voting/DataWarehouse.sol", "src/contracts/voting/libs/StateProofVerifier.sol", "src/contracts/libraries/SlotUtils.sol", - "lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" + "lib/adi-deploy/lib/aave-delivery-infrastructure/src/contracts/CrossChainController.sol" ], "link": [ "VotingMachineHarness:VOTING_STRATEGY=VotingStrategyHarness", @@ -15,20 +15,21 @@ "VotingStrategyHarness:DATA_WAREHOUSE=DataWarehouse" ], "packages": [ - "@openzeppelin=lib/aave-delivery-infrastructure/lib/openzeppelin-contracts", - "aave-delivery-infrastructure=lib/aave-delivery-infrastructure/src", - "aave-token-v2=lib/aave-token-v3/lib/aave-token-v2/contracts", - "aave-token-v3=lib/aave-token-v3/src", - "forge-std=lib/forge-std/src", - "openzeppelin-contracts=lib/openzeppelin-contracts", - "solidity-utils=lib/solidity-utils/src" + "aave-delivery-infrastructure/=lib/adi-deploy/lib/aave-delivery-infrastructure/src", + "solidity-utils/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/src", + "forge-std/=lib/adi-deploy/lib/aave-helpers/lib/forge-std/src", + "openzeppelin-contracts/=lib/adi-deploy/lib/aave-delivery-infrastructure/lib/solidity-utils/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts", + "aave-helpers/=lib/adi-deploy/lib/aave-helpers/src", + "aave-address-book/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/src", + "aave-v3-origin/=lib/adi-deploy/lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src", + "adi-deploy/=lib/adi-deploy" ], "verify": "VotingMachineHarness:security/certora/specs/voting/voting_and_tally.spec", "optimistic_loop": true, "loop_iter": "3", // Needed for `getVotingAssetListLength` "optimistic_hashing": true, "rule_sanity": "basic", - "solc": "solc8.19", + "solc": "solc8.20", "parametric_contracts": [ // Excluding DataWarehouse! "VotingMachineHarness", diff --git a/security/certora/harness/aave-token-v3/AaveTokenV3.sol b/security/certora/harness/aave-token-v3/AaveTokenV3.sol new file mode 100644 index 0000000..7de3417 --- /dev/null +++ b/security/certora/harness/aave-token-v3/AaveTokenV3.sol @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAaveTokenV2} from './BaseAaveTokenV2.sol'; +import {BaseDelegation} from './BaseDelegation.sol'; + +contract AaveTokenV3 is BaseAaveTokenV2, BaseDelegation { + /** + * @dev initializes the contract upon assignment to the InitializableAdminUpgradeabilityProxy + */ + function initialize() external virtual initializer {} + + function _afterTokenTransfer( + address from, + address to, + uint256 fromBalanceBefore, + uint256 toBalanceBefore, + uint256 amount + ) internal override { + _delegationChangeOnTransfer(from, to, fromBalanceBefore, toBalanceBefore, amount); + } + + function _getDelegationState(address user) + internal + view + override + returns (DelegationState memory) + { + DelegationAwareBalance memory userState = _balances[user]; + return + DelegationState({ + delegatedPropositionBalance: userState.delegatedPropositionBalance, + delegatedVotingBalance: userState.delegatedVotingBalance, + delegationMode: userState.delegationMode + }); + } + + function _getBalance(address user) internal view override returns (uint256) { + return _balances[user].balance; + } + + function _setDelegationState(address user, DelegationState memory delegationState) + internal + override + { + DelegationAwareBalance storage userState = _balances[user]; + userState.delegatedPropositionBalance = delegationState.delegatedPropositionBalance; + userState.delegatedVotingBalance = delegationState.delegatedVotingBalance; + userState.delegationMode = delegationState.delegationMode; + } + + function _incrementNonces(address user) internal override returns (uint256) { + unchecked { + // Does not make sense to check because it's not realistic to reach uint256.max in nonce + return _nonces[user]++; + } + } + + function _getDomainSeparator() internal view override returns (bytes32) { + return DOMAIN_SEPARATOR(); + } +} diff --git a/security/certora/harness/aave-token-v3/BaseAaveToken.sol b/security/certora/harness/aave-token-v3/BaseAaveToken.sol new file mode 100644 index 0000000..e6df24a --- /dev/null +++ b/security/certora/harness/aave-token-v3/BaseAaveToken.sol @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {Context} from 'openzeppelin-contracts/contracts/utils/Context.sol'; +import {IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/IERC20.sol'; +import {IERC20Metadata} from 'openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol'; +import {DelegationMode} from './DelegationAwareBalance.sol'; + +// Inspired by OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) +abstract contract BaseAaveToken is Context, IERC20Metadata { + struct DelegationAwareBalance { + uint104 balance; + uint72 delegatedPropositionBalance; + uint72 delegatedVotingBalance; + DelegationMode delegationMode; + } + + mapping(address => DelegationAwareBalance) internal _balances; + + mapping(address => mapping(address => uint256)) internal _allowances; + + uint256 internal _totalSupply; + + string internal _name; + string internal _symbol; + + // @dev DEPRECATED + // kept for backwards compatibility with old storage layout + uint8 private ______DEPRECATED_OLD_ERC20_DECIMALS; + + /** + * @dev Returns the name of the token. + */ + function name() public view virtual override returns (string memory) { + return _name; + } + + /** + * @dev Returns the symbol of the token, usually a shorter version of the + * name. + */ + function symbol() public view virtual override returns (string memory) { + return _symbol; + } + + function decimals() public view virtual override returns (uint8) { + return 18; + } + + function totalSupply() public view virtual override returns (uint256) { + return _totalSupply; + } + + function balanceOf(address account) public view virtual override returns (uint256) { + return _balances[account].balance; + } + + function transfer(address to, uint256 amount) public virtual override returns (bool) { + address owner = _msgSender(); + _transfer(owner, to, amount); + return true; + } + + function allowance(address owner, address spender) + public + view + virtual + override + returns (uint256) + { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public virtual override returns (bool) { + address owner = _msgSender(); + _approve(owner, spender, amount); + return true; + } + + function transferFrom( + address from, + address to, + uint256 amount + ) public virtual override returns (bool) { + address spender = _msgSender(); + _spendAllowance(from, spender, amount); + _transfer(from, to, amount); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { + address owner = _msgSender(); + _approve(owner, spender, _allowances[owner][spender] + addedValue); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) + public + virtual + returns (bool) + { + address owner = _msgSender(); + uint256 currentAllowance = _allowances[owner][spender]; + require(currentAllowance >= subtractedValue, 'ERC20: decreased allowance below zero'); + unchecked { + _approve(owner, spender, currentAllowance - subtractedValue); + } + + return true; + } + + function _transfer( + address from, + address to, + uint256 amount + ) internal virtual { + require(from != address(0), 'ERC20: transfer from the zero address'); + require(to != address(0), 'ERC20: transfer to the zero address'); + + if (from != to) { + uint104 fromBalanceBefore = _balances[from].balance; + uint104 toBalanceBefore = _balances[to].balance; + + require(fromBalanceBefore >= amount, 'ERC20: transfer amount exceeds balance'); + unchecked { + _balances[from].balance = fromBalanceBefore - uint104(amount); + } + + _balances[to].balance = toBalanceBefore + uint104(amount); + + _afterTokenTransfer(from, to, fromBalanceBefore, toBalanceBefore, amount); + } + emit Transfer(from, to, amount); + } + + function _approve( + address owner, + address spender, + uint256 amount + ) internal virtual { + require(owner != address(0), 'ERC20: approve from the zero address'); + require(spender != address(0), 'ERC20: approve to the zero address'); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _spendAllowance( + address owner, + address spender, + uint256 amount + ) internal virtual { + uint256 currentAllowance = allowance(owner, spender); + if (currentAllowance != type(uint256).max) { + require(currentAllowance >= amount, 'ERC20: insufficient allowance'); + unchecked { + _approve(owner, spender, currentAllowance - amount); + } + } + } + + /** + * @dev after token transfer hook, added for delegation system + * @param from token sender + * @param to token recipient + * @param fromBalanceBefore balance of the sender before transfer + * @param toBalanceBefore balance of the recipient before transfer + * @param amount amount of tokens sent + **/ + function _afterTokenTransfer( + address from, + address to, + uint256 fromBalanceBefore, + uint256 toBalanceBefore, + uint256 amount + ) internal virtual {} +} diff --git a/security/certora/harness/aave-token-v3/BaseAaveTokenV2.sol b/security/certora/harness/aave-token-v3/BaseAaveTokenV2.sol new file mode 100644 index 0000000..b4d9e1b --- /dev/null +++ b/security/certora/harness/aave-token-v3/BaseAaveTokenV2.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {ECDSA} from 'openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol'; + +import {VersionedInitializable} from './utils/VersionedInitializable.sol'; +import {EIP712} from './utils/EIP712.sol'; +import {BaseAaveToken} from './BaseAaveToken.sol'; + +abstract contract BaseAaveTokenV2 is BaseAaveToken, VersionedInitializable, EIP712 { + /// @dev owner => next valid nonce to submit with permit() + mapping(address => uint256) public _nonces; + + ///////// @dev DEPRECATED from AaveToken v1 ////////////////////////// + //////// kept for backwards compatibility with old storage layout //// + uint256[3] private ______DEPRECATED_FROM_AAVE_V1; + ///////// @dev END OF DEPRECATED from AaveToken v1 ////////////////////////// + + // deprecated in favor to OZ EIP712 + bytes32 private __DEPRECATED_DOMAIN_SEPARATOR; + + ///////// @dev DEPRECATED from AaveToken v2 ////////////////////////// + //////// kept for backwards compatibility with old storage layout //// + uint256[4] private ______DEPRECATED_FROM_AAVE_V2; + ///////// @dev END OF DEPRECATED from AaveToken v2 ////////////////////////// + + bytes32 public constant PERMIT_TYPEHASH = + keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)'); + + uint256 public constant REVISION = 4; + + constructor() EIP712('Aave token V3', '2') {} + + function DOMAIN_SEPARATOR() public view returns (bytes32) { + return _domainSeparatorV4(); + } + + /** + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param owner the owner of the funds + * @param spender the spender + * @param value the amount + * @param deadline the deadline timestamp, type(uint256).max for no deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ + + function permit( + address owner, + address spender, + uint256 value, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external { + require(owner != address(0), 'INVALID_OWNER'); + //solium-disable-next-line + require(block.timestamp <= deadline, 'INVALID_EXPIRATION'); + uint256 currentValidNonce = _nonces[owner]; + bytes32 digest = _hashTypedDataV4( + keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, currentValidNonce, deadline)) + ); + + require(owner == ECDSA.recover(digest, v, r, s), 'INVALID_SIGNATURE'); + unchecked { + // does not make sense to check because it's not realistic to reach uint256.max in nonce + _nonces[owner] = currentValidNonce + 1; + } + _approve(owner, spender, value); + } + + /** + * @dev returns the revision of the implementation contract + */ + function getRevision() internal pure override returns (uint256) { + return REVISION; + } +} diff --git a/security/certora/harness/aave-token-v3/BaseDelegation.sol b/security/certora/harness/aave-token-v3/BaseDelegation.sol new file mode 100644 index 0000000..8e14ba4 --- /dev/null +++ b/security/certora/harness/aave-token-v3/BaseDelegation.sol @@ -0,0 +1,439 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {ECDSA} from 'openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol'; + +import {SafeCast72} from './utils/SafeCast72.sol'; +//import {IGovernancePowerDelegationToken} from './interfaces/IGovernancePowerDelegationToken.sol'; +import {IGovernancePowerDelegationToken} from 'src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol'; +import {DelegationMode} from './DelegationAwareBalance.sol'; +import {MessageHashUtils} from 'openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol'; + +/** + * @notice The contract implements generic delegation functionality for the upcoming governance v3 + * @author BGD Labs + * @dev to make it's pluggable to any exising token it has a set of virtual functions + * for simple access to balances and permit functionality + * @dev ************ IMPORTANT SECURITY CONSIDERATION ************ + * current version of the token can be used only with asset which has 18 decimals + * and possible totalSupply lower then 4722366482869645213696, + * otherwise at least POWER_SCALE_FACTOR should be adjusted !!! + * ************************************************************* + */ +abstract contract BaseDelegation is IGovernancePowerDelegationToken { + struct DelegationState { + uint72 delegatedPropositionBalance; + uint72 delegatedVotingBalance; + DelegationMode delegationMode; + } + + mapping(address => address) internal _votingDelegatee; + mapping(address => address) internal _propositionDelegatee; + + /** @dev we assume that for the governance system delegation with 18 decimals of precision is not needed, + * by this constant we reduce it by 10, to 8 decimals. + * In case of Aave token this will allow to work with up to 47'223'664'828'696,45213696 total supply + * If your token already have less then 10 decimals, please change it to appropriate. + */ + uint256 public constant POWER_SCALE_FACTOR = 1e10; + + bytes32 public constant DELEGATE_BY_TYPE_TYPEHASH = + keccak256( + 'DelegateByType(address delegator,address delegatee,uint8 delegationType,uint256 nonce,uint256 deadline)' + ); + bytes32 public constant DELEGATE_TYPEHASH = + keccak256('Delegate(address delegator,address delegatee,uint256 nonce,uint256 deadline)'); + + /** + * @notice returns eip-2612 compatible domain separator + * @dev we expect that existing tokens, ie Aave, already have, so we want to reuse + * @return domain separator + */ + function _getDomainSeparator() internal view virtual returns (bytes32); + + /** + * @notice gets the delegation state of a user + * @param user address + * @return state of a user's delegation + */ + function _getDelegationState(address user) internal view virtual returns (DelegationState memory); + + /** + * @notice returns the token balance of a user + * @param user address + * @return current nonce before increase + */ + function _getBalance(address user) internal view virtual returns (uint256); + + /** + * @notice increases and return the current nonce of a user + * @dev should use `return nonce++;` pattern + * @param user address + * @return current nonce before increase + */ + function _incrementNonces(address user) internal virtual returns (uint256); + + /** + * @notice sets the delegation state of a user + * @param user address + * @param delegationState state of a user's delegation + */ + function _setDelegationState(address user, DelegationState memory delegationState) + internal + virtual; + + /// @inheritdoc IGovernancePowerDelegationToken + function delegateByType(address delegatee, GovernancePowerType delegationType) + external + virtual + override + { + _delegateByType(msg.sender, delegatee, delegationType); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function delegate(address delegatee) external override { + _delegateByType(msg.sender, delegatee, GovernancePowerType.VOTING); + _delegateByType(msg.sender, delegatee, GovernancePowerType.PROPOSITION); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function getDelegateeByType(address delegator, GovernancePowerType delegationType) + external + view + override + returns (address) + { + return _getDelegateeByType(delegator, _getDelegationState(delegator), delegationType); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function getDelegates(address delegator) external view override returns (address, address) { + DelegationState memory delegatorBalance = _getDelegationState(delegator); + return ( + _getDelegateeByType(delegator, delegatorBalance, GovernancePowerType.VOTING), + _getDelegateeByType(delegator, delegatorBalance, GovernancePowerType.PROPOSITION) + ); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function getPowerCurrent(address user, GovernancePowerType delegationType) + public + view + virtual + override + returns (uint256) + { + DelegationState memory userState = _getDelegationState(user); + uint256 userOwnPower = uint8(userState.delegationMode) & (uint8(delegationType) + 1) == 0 + ? _getBalance(user) + : 0; + uint256 userDelegatedPower = _getDelegatedPowerByType(userState, delegationType); + return userOwnPower + userDelegatedPower; + } + + /// @inheritdoc IGovernancePowerDelegationToken + function getPowersCurrent(address user) external view override returns (uint256, uint256) { + return ( + getPowerCurrent(user, GovernancePowerType.VOTING), + getPowerCurrent(user, GovernancePowerType.PROPOSITION) + ); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function metaDelegateByType( + address delegator, + address delegatee, + GovernancePowerType delegationType, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external override { + require(delegator != address(0), 'INVALID_OWNER'); + //solium-disable-next-line + require(block.timestamp <= deadline, 'INVALID_EXPIRATION'); + bytes32 digest = MessageHashUtils.toTypedDataHash( + _getDomainSeparator(), + keccak256( + abi.encode( + DELEGATE_BY_TYPE_TYPEHASH, + delegator, + delegatee, + delegationType, + _incrementNonces(delegator), + deadline + ) + ) + ); + + require(delegator == ECDSA.recover(digest, v, r, s), 'INVALID_SIGNATURE'); + _delegateByType(delegator, delegatee, delegationType); + } + + /// @inheritdoc IGovernancePowerDelegationToken + function metaDelegate( + address delegator, + address delegatee, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external override { + require(delegator != address(0), 'INVALID_OWNER'); + //solium-disable-next-line + require(block.timestamp <= deadline, 'INVALID_EXPIRATION'); + bytes32 digest = MessageHashUtils.toTypedDataHash( + _getDomainSeparator(), + keccak256( + abi.encode(DELEGATE_TYPEHASH, delegator, delegatee, _incrementNonces(delegator), deadline) + ) + ); + + require(delegator == ECDSA.recover(digest, v, r, s), 'INVALID_SIGNATURE'); + _delegateByType(delegator, delegatee, GovernancePowerType.VOTING); + _delegateByType(delegator, delegatee, GovernancePowerType.PROPOSITION); + } + + /** + * @dev Modifies the delegated power of a `delegatee` account by type (VOTING, PROPOSITION). + * Passing the impact on the delegation of `delegatee` account before and after to reduce conditionals and not lose + * any precision. + * @param impactOnDelegationBefore how much impact a balance of another account had over the delegation of a `delegatee` + * before an action. + * For example, if the action is a delegation from one account to another, the impact before the action will be 0. + * @param impactOnDelegationAfter how much impact a balance of another account will have over the delegation of a `delegatee` + * after an action. + * For example, if the action is a delegation from one account to another, the impact after the action will be the whole balance + * of the account changing the delegatee. + * @param delegatee the user whom delegated governance power will be changed + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + **/ + function _governancePowerTransferByType( + uint256 impactOnDelegationBefore, + uint256 impactOnDelegationAfter, + address delegatee, + GovernancePowerType delegationType + ) internal { + if (delegatee == address(0)) return; + if (impactOnDelegationBefore == impactOnDelegationAfter) return; + + // we use uint72, because this is the most optimal for AaveTokenV3 + // To make delegated balance fit into uint72 we're decreasing precision of delegated balance by POWER_SCALE_FACTOR + uint72 impactOnDelegationBefore72 = SafeCast72.toUint72( + impactOnDelegationBefore / POWER_SCALE_FACTOR + ); + uint72 impactOnDelegationAfter72 = SafeCast72.toUint72( + impactOnDelegationAfter / POWER_SCALE_FACTOR + ); + + DelegationState memory delegateeState = _getDelegationState(delegatee); + if (delegationType == GovernancePowerType.VOTING) { + delegateeState.delegatedVotingBalance = + delegateeState.delegatedVotingBalance - + impactOnDelegationBefore72 + + impactOnDelegationAfter72; + } else { + delegateeState.delegatedPropositionBalance = + delegateeState.delegatedPropositionBalance - + impactOnDelegationBefore72 + + impactOnDelegationAfter72; + } + _setDelegationState(delegatee, delegateeState); + } + + /** + * @dev performs all state changes related delegation changes on transfer + * @param from token sender + * @param to token recipient + * @param fromBalanceBefore balance of the sender before transfer + * @param toBalanceBefore balance of the recipient before transfer + * @param amount amount of tokens sent + **/ + function _delegationChangeOnTransfer( + address from, + address to, + uint256 fromBalanceBefore, + uint256 toBalanceBefore, + uint256 amount + ) internal { + if (from == to) { + return; + } + + if (from != address(0)) { + DelegationState memory fromUserState = _getDelegationState(from); + uint256 fromBalanceAfter = fromBalanceBefore - amount; + if (fromUserState.delegationMode != DelegationMode.NO_DELEGATION) { + _governancePowerTransferByType( + fromBalanceBefore, + fromBalanceAfter, + _getDelegateeByType(from, fromUserState, GovernancePowerType.VOTING), + GovernancePowerType.VOTING + ); + _governancePowerTransferByType( + fromBalanceBefore, + fromBalanceAfter, + _getDelegateeByType(from, fromUserState, GovernancePowerType.PROPOSITION), + GovernancePowerType.PROPOSITION + ); + } + } + + if (to != address(0)) { + DelegationState memory toUserState = _getDelegationState(to); + uint256 toBalanceAfter = toBalanceBefore + amount; + + if (toUserState.delegationMode != DelegationMode.NO_DELEGATION) { + _governancePowerTransferByType( + toBalanceBefore, + toBalanceAfter, + _getDelegateeByType(to, toUserState, GovernancePowerType.VOTING), + GovernancePowerType.VOTING + ); + _governancePowerTransferByType( + toBalanceBefore, + toBalanceAfter, + _getDelegateeByType(to, toUserState, GovernancePowerType.PROPOSITION), + GovernancePowerType.PROPOSITION + ); + } + } + } + + /** + * @dev Extracts from state and returns delegated governance power (Voting, Proposition) + * @param userState the current state of a user + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + **/ + function _getDelegatedPowerByType( + DelegationState memory userState, + GovernancePowerType delegationType + ) internal pure returns (uint256) { + return + POWER_SCALE_FACTOR * + ( + delegationType == GovernancePowerType.VOTING + ? userState.delegatedVotingBalance + : userState.delegatedPropositionBalance + ); + } + + /** + * @dev Extracts from state and returns the delegatee of a delegator by type of governance power (Voting, Proposition) + * - If the delegator doesn't have any delegatee, returns address(0) + * @param delegator delegator + * @param userState the current state of a user + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + **/ + function _getDelegateeByType( + address delegator, + DelegationState memory userState, + GovernancePowerType delegationType + ) internal view returns (address) { + if (delegationType == GovernancePowerType.VOTING) { + return + /// With the & operation, we cover both VOTING_DELEGATED delegation and FULL_POWER_DELEGATED + /// as VOTING_DELEGATED is equivalent to 01 in binary and FULL_POWER_DELEGATED is equivalent to 11 + (uint8(userState.delegationMode) & uint8(DelegationMode.VOTING_DELEGATED)) != 0 + ? _votingDelegatee[delegator] + : address(0); + } + return + userState.delegationMode >= DelegationMode.PROPOSITION_DELEGATED + ? _propositionDelegatee[delegator] + : address(0); + } + + /** + * @dev Changes user's delegatee address by type of governance power (Voting, Proposition) + * @param delegator delegator + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + * @param _newDelegatee the new delegatee + **/ + function _updateDelegateeByType( + address delegator, + GovernancePowerType delegationType, + address _newDelegatee + ) internal { + address newDelegatee = _newDelegatee == delegator ? address(0) : _newDelegatee; + if (delegationType == GovernancePowerType.VOTING) { + _votingDelegatee[delegator] = newDelegatee; + } else { + _propositionDelegatee[delegator] = newDelegatee; + } + } + + /** + * @dev Updates the specific flag which signaling about existence of delegation of governance power (Voting, Proposition) + * @param userState a user state to change + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + * @param willDelegate next state of delegation + **/ + function _updateDelegationModeByType( + DelegationState memory userState, + GovernancePowerType delegationType, + bool willDelegate + ) internal pure returns (DelegationState memory) { + if (willDelegate) { + // Because GovernancePowerType starts from 0, we should add 1 first, then we apply bitwise OR + userState.delegationMode = DelegationMode( + uint8(userState.delegationMode) | (uint8(delegationType) + 1) + ); + } else { + // First bitwise NEGATION, ie was 01, after XOR with 11 will be 10, + // then bitwise AND, which means it will keep only another delegation type if it exists + userState.delegationMode = DelegationMode( + uint8(userState.delegationMode) & + ((uint8(delegationType) + 1) ^ uint8(DelegationMode.FULL_POWER_DELEGATED)) + ); + } + return userState; + } + + /** + * @dev This is the equivalent of an ERC20 transfer(), but for a power type: an atomic transfer of a balance (power). + * When needed, it decreases the power of the `delegator` and when needed, it increases the power of the `delegatee` + * @param delegator delegator + * @param _delegatee the user which delegated power will change + * @param delegationType the type of delegation (VOTING, PROPOSITION) + **/ + function _delegateByType( + address delegator, + address _delegatee, + GovernancePowerType delegationType + ) internal { + // Here we unify the property that delegating power to address(0) == delegating power to yourself == no delegation + // So from now on, not being delegating is (exclusively) that delegatee == address(0) + address delegatee = _delegatee == delegator ? address(0) : _delegatee; + + // We read the whole struct before validating delegatee, because in the optimistic case + // (_delegatee != currentDelegatee) we will reuse userState in the rest of the function + DelegationState memory delegatorState = _getDelegationState(delegator); + address currentDelegatee = _getDelegateeByType(delegator, delegatorState, delegationType); + if (delegatee == currentDelegatee) return; + + bool delegatingNow = currentDelegatee != address(0); + bool willDelegateAfter = delegatee != address(0); + uint256 delegatorBalance = _getBalance(delegator); + + if (delegatingNow) { + _governancePowerTransferByType(delegatorBalance, 0, currentDelegatee, delegationType); + } + + if (willDelegateAfter) { + _governancePowerTransferByType(0, delegatorBalance, delegatee, delegationType); + } + + _updateDelegateeByType(delegator, delegationType, delegatee); + + if (willDelegateAfter != delegatingNow) { + _setDelegationState( + delegator, + _updateDelegationModeByType(delegatorState, delegationType, willDelegateAfter) + ); + } + + emit DelegateChanged(delegator, delegatee, delegationType); + } +} diff --git a/security/certora/harness/aave-token-v3/DelegationAwareBalance.sol b/security/certora/harness/aave-token-v3/DelegationAwareBalance.sol new file mode 100644 index 0000000..8d59013 --- /dev/null +++ b/security/certora/harness/aave-token-v3/DelegationAwareBalance.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +enum DelegationMode { + NO_DELEGATION, + VOTING_DELEGATED, + PROPOSITION_DELEGATED, + FULL_POWER_DELEGATED +} diff --git a/security/certora/harness/aave-token-v3/interfaces/.IGovernancePowerDelegationToken.sol b/security/certora/harness/aave-token-v3/interfaces/.IGovernancePowerDelegationToken.sol new file mode 100644 index 0000000..968956b --- /dev/null +++ b/security/certora/harness/aave-token-v3/interfaces/.IGovernancePowerDelegationToken.sol @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IGovernancePowerDelegationToken { + enum GovernancePowerType { + VOTING, + PROPOSITION + } + + /** + * @dev emitted when a user delegates to another + * @param delegator the user which delegated governance power + * @param delegatee the delegatee + * @param delegationType the type of delegation (VOTING, PROPOSITION) + **/ + event DelegateChanged( + address indexed delegator, + address indexed delegatee, + GovernancePowerType delegationType + ); + + // @dev we removed DelegatedPowerChanged event because to reconstruct the full state of the system, + // is enough to have Transfer and DelegateChanged TODO: document it + + /** + * @dev delegates the specific power to a delegatee + * @param delegatee the user which delegated power will change + * @param delegationType the type of delegation (VOTING, PROPOSITION) + **/ + function delegateByType(address delegatee, GovernancePowerType delegationType) external; + + /** + * @dev delegates all the governance powers to a specific user + * @param delegatee the user to which the powers will be delegated + **/ + function delegate(address delegatee) external; + + /** + * @dev returns the delegatee of an user + * @param delegator the address of the delegator + * @param delegationType the type of delegation (VOTING, PROPOSITION) + * @return address of the specified delegatee + **/ + function getDelegateeByType(address delegator, GovernancePowerType delegationType) + external + view + returns (address); + + /** + * @dev returns delegates of an user + * @param delegator the address of the delegator + * @return a tuple of addresses the VOTING and PROPOSITION delegatee + **/ + function getDelegates(address delegator) + external + view + returns (address, address); + + /** + * @dev returns the current voting or proposition power of a user. + * @param user the user + * @param delegationType the type of delegation (VOTING, PROPOSITION) + * @return the current voting or proposition power of a user + **/ + function getPowerCurrent(address user, GovernancePowerType delegationType) + external + view + returns (uint256); + + /** + * @dev returns the current voting or proposition power of a user. + * @param user the user + * @return the current voting and proposition power of a user + **/ + function getPowersCurrent(address user) + external + view + returns (uint256, uint256); + + /** + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param delegator the owner of the funds + * @param delegatee the user to who owner delegates his governance power + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + * @param deadline the deadline timestamp, type(uint256).max for no deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ + function metaDelegateByType( + address delegator, + address delegatee, + GovernancePowerType delegationType, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + /** + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param delegator the owner of the funds + * @param delegatee the user to who delegator delegates his voting and proposition governance power + * @param deadline the deadline timestamp, type(uint256).max for no deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ + function metaDelegate( + address delegator, + address delegatee, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; +} diff --git a/security/certora/harness/aave-token-v3/utils/EIP712.sol b/security/certora/harness/aave-token-v3/utils/EIP712.sol new file mode 100644 index 0000000..323e2a5 --- /dev/null +++ b/security/certora/harness/aave-token-v3/utils/EIP712.sol @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: MIT +// Contract modified from OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) to remove local +// fallback storage variables, so contract does not affect on existing storage layout. This works as its used on contracts +// that have name and revision < 32 bytes + +pragma solidity ^0.8.10; + +import {ECDSA} from 'openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol'; +import {ShortStrings, ShortString} from 'openzeppelin-contracts/contracts/utils/ShortStrings.sol'; +import {IERC5267} from 'openzeppelin-contracts/contracts/interfaces/IERC5267.sol'; +import {MessageHashUtils} from 'openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol'; + +/** + * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. + * + * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, + * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding + * they need in their contracts using a combination of `abi.encode` and `keccak256`. + * + * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding + * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA + * ({_hashTypedDataV4}). + * + * The implementation of the domain separator was designed to be as efficient as possible while still properly updating + * the chain id to protect against replay attacks on an eventual fork of the chain. + * + * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method + * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. + * + * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain + * separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the + * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. + * + * _Available since v3.4._ + * + * @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment + */ +abstract contract EIP712 is IERC5267 { + using ShortStrings for *; + + bytes32 private constant _TYPE_HASH = + keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'); + + // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to + // invalidate the cached domain separator if the chain id changes. + bytes32 private immutable _cachedDomainSeparator; + uint256 private immutable _cachedChainId; + address private immutable _cachedThis; + + bytes32 private immutable _hashedName; + bytes32 private immutable _hashedVersion; + + ShortString private immutable _name; + ShortString private immutable _version; + + /** + * @dev Initializes the domain separator and parameter caches. + * + * The meaning of `name` and `version` is specified in + * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: + * + * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. + * - `version`: the current major version of the signing domain. + * + * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart + * contract upgrade]. + */ + /// @dev BGD: removed usage of fallback variables to not modify previous storage layout. As we know that the length of + /// name and version will not be bigger than 32 bytes we use toShortString as there is no need to use the fallback system. + constructor(string memory name, string memory version) { + _name = name.toShortString(); + _version = version.toShortString(); + _hashedName = keccak256(bytes(name)); + _hashedVersion = keccak256(bytes(version)); + + _cachedChainId = block.chainid; + _cachedDomainSeparator = _buildDomainSeparator(); + _cachedThis = address(this); + } + + /** + * @dev Returns the domain separator for the current chain. + */ + function _domainSeparatorV4() internal view returns (bytes32) { + if (address(this) == _cachedThis && block.chainid == _cachedChainId) { + return _cachedDomainSeparator; + } else { + return _buildDomainSeparator(); + } + } + + function _buildDomainSeparator() private view returns (bytes32) { + return + keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); + } + + /** + * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this + * function returns the hash of the fully encoded EIP712 message for this domain. + * + * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: + * + * ```solidity + * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( + * keccak256("Mail(address to,string contents)"), + * mailTo, + * keccak256(bytes(mailContents)) + * ))); + * address signer = ECDSA.recover(digest, signature); + * ``` + */ + function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { + return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); + } + + /** + * @dev See {EIP-5267}. + * + * _Available since v4.9._ + */ + function eip712Domain() + public + view + virtual + returns ( + bytes1 fields, + string memory name, + string memory version, + uint256 chainId, + address verifyingContract, + bytes32 salt, + uint256[] memory extensions + ) + { + return ( + hex'0f', // 01111 + _EIP712Name(), + _EIP712Version(), + block.chainid, + address(this), + bytes32(0), + new uint256[](0) + ); + } + + /** + * @dev The name parameter for the EIP712 domain. + * + * NOTE: By default this function reads _name which is an immutable value. + * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). + * + * _Available since v5.0._ + */ + /// @dev BGD: we use toString instead of toStringWithFallback as we dont have fallback, to not modify previous storage layout + // solhint-disable-next-line func-name-mixedcase + function _EIP712Name() internal view returns (string memory) { + return _name.toString(); // _name.toStringWithFallback(_nameFallback); + } + + /** + * @dev The version parameter for the EIP712 domain. + * + * NOTE: By default this function reads _version which is an immutable value. + * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). + * + * _Available since v5.0._ + */ + /// @dev BGD: we use toString instead of toStringWithFallback as we dont have fallback, to not modify previous storage layout + // solhint-disable-next-line func-name-mixedcase + function _EIP712Version() internal view returns (string memory) { + return _version.toString(); + } +} diff --git a/security/certora/harness/aave-token-v3/utils/SafeCast72.sol b/security/certora/harness/aave-token-v3/utils/SafeCast72.sol new file mode 100644 index 0000000..ebeb67c --- /dev/null +++ b/security/certora/harness/aave-token-v3/utils/SafeCast72.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/** @notice influenced by OpenZeppelin SafeCast lib, which is missing to uint72 cast + * @author BGD Labs + */ +library SafeCast72 { + /** + * @dev Returns the downcasted uint72 from uint256, reverting on + * overflow (when the input is greater than largest uint72). + * + * Counterpart to Solidity's `uint16` operator. + * + * Requirements: + * + * - input must fit into 72 bits + */ + function toUint72(uint256 value) internal pure returns (uint72) { + require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); + return uint72(value); + } +} diff --git a/security/certora/harness/aave-token-v3/utils/VersionedInitializable.sol b/security/certora/harness/aave-token-v3/utils/VersionedInitializable.sol new file mode 100644 index 0000000..d7c0774 --- /dev/null +++ b/security/certora/harness/aave-token-v3/utils/VersionedInitializable.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.8.0; + +/** + * @title VersionedInitializable + * + * @dev Helper contract to support initializer functions. To use it, replace + * the constructor with a function that has the `initializer` modifier. + * WARNING: Unlike constructors, initializer functions must be manually + * invoked. This applies both to deploying an Initializable contract, as well + * as extending an Initializable contract via inheritance. + * WARNING: When used with inheritance, manual care must be taken to not invoke + * a parent initializer twice, or ensure that all initializers are idempotent, + * because this is not dealt with automatically as with constructors. + * + * @author Aave, inspired by the OpenZeppelin Initializable contract + */ +abstract contract VersionedInitializable { + /** + * @dev Indicates that the contract has been initialized. + */ + uint256 internal lastInitializedRevision = 0; + + /** + * @dev Modifier to use in the initializer function of a contract. + */ + modifier initializer() { + uint256 revision = getRevision(); + require(revision > lastInitializedRevision, 'Contract instance has already been initialized'); + + lastInitializedRevision = revision; + + _; + } + + /// @dev returns the revision number of the contract. + /// Needs to be defined in the inherited class as a constant. + function getRevision() internal pure virtual returns (uint256); + + // Reserved storage space to allow for layout changes in the future. + uint256[50] private ______gap; +} diff --git a/security/certora/harness/voting/DelegationModeHarness.sol b/security/certora/harness/voting/DelegationModeHarness.sol index e041b8b..a7f9924 100644 --- a/security/certora/harness/voting/DelegationModeHarness.sol +++ b/security/certora/harness/voting/DelegationModeHarness.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {DelegationMode} from 'aave-token-v3/DelegationAwareBalance.sol'; +import {DelegationMode} from '../../../../src/contracts/voting/VotingStrategy.sol'; /** * @title Hack to use DelegationMode in spec @@ -9,7 +9,6 @@ import {DelegationMode} from 'aave-token-v3/DelegationAwareBalance.sol'; * this hack solves the problem by providing enum `Mode` which is equal. */ contract DelegationModeHarness { - enum Mode { NO_DELEGATION, VOTING_DELEGATED, @@ -18,14 +17,14 @@ contract DelegationModeHarness { } function is_equal_to_original() public view returns (bool) { - return ( - uint8(type(Mode).min) == uint8(type(DelegationMode).min) && + return (uint8(type(Mode).min) == uint8(type(DelegationMode).min) && uint8(type(Mode).max) == uint8(type(DelegationMode).max) && uint8(Mode.NO_DELEGATION) == uint8(DelegationMode.NO_DELEGATION) && uint8(Mode.VOTING_DELEGATED) == uint8(DelegationMode.VOTING_DELEGATED) && - uint8(Mode.PROPOSITION_DELEGATED) == uint8(DelegationMode.PROPOSITION_DELEGATED) && - uint8(Mode.FULL_POWER_DELEGATED) == uint8(DelegationMode.FULL_POWER_DELEGATED) - ); + uint8(Mode.PROPOSITION_DELEGATED) == + uint8(DelegationMode.PROPOSITION_DELEGATED) && + uint8(Mode.FULL_POWER_DELEGATED) == + uint8(DelegationMode.FULL_POWER_DELEGATED)); } function mode_to_int(Mode mode) public view returns (uint8) { diff --git a/security/certora/scripts/run-all-execution.sh b/security/certora/scripts/run-all-execution.sh index bdcf436..59dea68 100644 --- a/security/certora/scripts/run-all-execution.sh +++ b/security/certora/scripts/run-all-execution.sh @@ -3,134 +3,6 @@ -echo "******** Running: execution 0 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule payload_maximal_access_level_gt_action_access_level state_cant_decrease no_transition_beyond_state_gt_3 no_transition_beyond_state_variable_gt_3 no_queue_after_expiration empty_actions_if_out_of_bound_payload expirationTime_equal_to_createAt_plus_EXPIRATION_DELAY empty_actions_iff_uninitialized null_access_level_if_out_of_bound_payload null_creator_and_zero_expiration_time_if_out_of_bound_payload empty_actions_only_if_uninitialized_payload executor_access_level_within_range consecutiveIDs empty_actions_if_uninitialized_payload queued_before_expiration_delay payload_grace_period_eq_global_grace_period null_access_level_only_if_out_of_bound_payload null_state_variable_if_out_of_bound_payload created_in_the_past queued_after_created executed_after_queue queuedAt_is_zero_before_queued no_early_cancellation execute_before_delay__maximumAccessLevelRequired action_immutable_fixed_size_fields initialized_payload_fields_are_immutable payload_fields_immutable_after_createPayload method_reachability \ - --msg "execution 0 " - - - -echo "******** Running: execution 1 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_exists_if_action_not_null \ - --msg "execution 1 " - - -echo "******** Running: execution 2 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_exists_only_if_action_not_null \ - --msg "execution 2 " - - -echo "******** Running: execution 3 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule payload_delay_within_range \ - --msg "execution 3 " - - -echo "******** Running: execution 4 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule delay_of_executor_of_max_access_level_within_range \ - --msg "execution 4 " - - -echo "******** Running: execution 5 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule nonempty_actions \ - --msg "execution 5 " - - -echo "******** Running: execution 6 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_exists_iff_action_not_null \ - --msg "execution 6 " - - -echo "******** Running: execution 7 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule null_access_level_iff_state_is_none \ - --msg "execution 7" - - -echo "******** Running: execution 8 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_of_maximumAccessLevelRequired_exists \ - --msg "execution 8 " - - -echo "******** Running: execution 9 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_of_maximumAccessLevelRequired_exists_after_createPayload \ - --msg "execution 9 " - - -echo "******** Running: execution 10 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule action_access_level_isnt_null_after_createPayload \ - --msg "execution 10 " - - -echo "******** Running: execution 11 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_exists_after_createPayload \ - --msg "execution 11 " - - -echo "******** Running: execution 12 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule action_callData_immutable \ - --msg "execution 12 " - - -echo "******** Running: execution 13 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule action_signature_immutable \ - --msg "execution 13 " - - -echo "******** Running: execution 14 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule action_immutable_check_only_fixed_size_fields \ - --msg "execution 14 " - - -echo "******** Running: execution 15 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule zero_executedAt_if_not_executed \ - --msg "execution 15 " - - -echo "******** Running: execution16: ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_isnt_used_twice executor_of_level_null_is_zero \ - --msg "execution 16 " - -echo "******** Running: execution 17 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executed_after_queue_state_variable zero_executedAt_if_not_executed_state_variable \ - --msg "execution 17 " - - -echo "******** Running: execution 18 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule queuedAt_is_zero_before_queued_state_variable executedAt_is_zero_before_executed_state_variable null_state_equivalence \ - --msg "execution 18 " - - -echo "******** Running: execution 19 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executedAt_is_zero_before_executed \ - --msg "execution 19 " - - -echo "******** Running: execution 20 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executed_when_in_queued_state executed_when_in_queued_state_variable guardian_can_cancel no_late_cancel state_variable_cant_decrease \ - --msg "execution 20 " - - -echo "******** Running: execution 21 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule checkUpdateExecutors checkUpdateExecutors_witness_1 checkUpdateExecutors_witness_2 checkUpdateExecutors_witness_3 checkUpdateExecutors_witness_4 \ - --msg "execution 21 " - - -echo "******** Running: execution 22 ***************" -certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule payload_state_transition_post_state payload_state_transition_pre_state \ - --msg "execution 22 " - - -# certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule executor_exists - - - - - - - - - - - - - - - +echo "******** Running: execution - all rules ***************" +certoraRun $CMN security/certora/confs/payloads/verifyPayloadsController.conf --rule payload_maximal_access_level_gt_action_access_level state_cant_decrease no_transition_beyond_state_gt_3 no_transition_beyond_state_variable_gt_3 no_queue_after_expiration empty_actions_if_out_of_bound_payload expirationTime_equal_to_createAt_plus_EXPIRATION_DELAY empty_actions_iff_uninitialized null_access_level_if_out_of_bound_payload null_creator_and_zero_expiration_time_if_out_of_bound_payload empty_actions_only_if_uninitialized_payload executor_access_level_within_range consecutiveIDs empty_actions_if_uninitialized_payload queued_before_expiration_delay payload_grace_period_eq_global_grace_period null_access_level_only_if_out_of_bound_payload null_state_variable_if_out_of_bound_payload created_in_the_past queued_after_created executed_after_queue queuedAt_is_zero_before_queued no_early_cancellation execute_before_delay__maximumAccessLevelRequired action_immutable_fixed_size_fields initialized_payload_fields_are_immutable payload_fields_immutable_after_createPayload method_reachability executor_exists_if_action_not_null executor_exists_only_if_action_not_null payload_delay_within_range delay_of_executor_of_max_access_level_within_range nonempty_actions executor_exists_iff_action_not_null null_access_level_iff_state_is_none executor_of_maximumAccessLevelRequired_exists executor_of_maximumAccessLevelRequired_exists_after_createPayload action_access_level_isnt_null_after_createPayload executor_exists_after_createPayload action_callData_immutable action_signature_immutable action_immutable_check_only_fixed_size_fields zero_executedAt_if_not_executed executor_isnt_used_twice executor_of_level_null_is_zero executed_after_queue_state_variable zero_executedAt_if_not_executed_state_variable queuedAt_is_zero_before_queued_state_variable executedAt_is_zero_before_executed_state_variable null_state_equivalence executedAt_is_zero_before_executed executed_when_in_queued_state executed_when_in_queued_state_variable guardian_can_cancel no_late_cancel state_variable_cant_decrease checkUpdateExecutors checkUpdateExecutors_witness_1 checkUpdateExecutors_witness_2 checkUpdateExecutors_witness_3 checkUpdateExecutors_witness_4 payload_state_transition_post_state payload_state_transition_pre_state \ + --msg "execution - all rules" diff --git a/security/certora/scripts/run-all-mainnet.sh b/security/certora/scripts/run-all-mainnet.sh index 1167f27..106ae4b 100644 --- a/security/certora/scripts/run-all-mainnet.sh +++ b/security/certora/scripts/run-all-mainnet.sh @@ -3,120 +3,21 @@ echo "******** Running: mainnet 1 ***************" -certoraRun $CMN security/certora/confs/verifyVotingStrategy_unittests.conf \ +certoraRun $CMN security/certora/confs/verifyVotingStrategy_unittests.conf \ --msg "mainnet 1 " echo "******** Running: mainnet 2 ***************" -certoraRun $CMN security/certora/confs/verifyGovernancePowerStrategy.conf --rule delegatePowerCompliance \ +certoraRun $CMN security/certora/confs/verifyGovernancePowerStrategy.conf --rule delegatePowerCompliance transferPowerCompliance powerlessCompliance method_reachability \ --msg "mainnet 2 " - + echo "******** Running: mainnet 3 ***************" -certoraRun $CMN security/certora/confs/verifyGovernancePowerStrategy.conf --rule transferPowerCompliance \ +certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule cancellationFeeZeroForFutureProposals null_state_variable_iff_null_access_level zero_voting_portal_iff_uninitialized_proposal no_self_representative no_representative_is_zero consecutiveIDs totalCancellationFeeEqualETHBalance zero_address_is_not_a_valid_voting_portal no_representative_is_zero_2 no_representative_of_zero state_changing_function_self_check state_variable_changing_function_self_check method_reachability userFeeDidntChangeImplyNativeBalanceDidntDecrease check_new_representative_set_size_after_updateRepresentatives check_old_representative_set_size_after_updateRepresentatives at_least_single_payload_active empty_payloads_iff_uninitialized_proposal null_state_iff_uninitialized_proposal setInvariant addressSetInvariant state_changing_function_cannot_be_called_while_in_terminal_state proposal_executes_after_cooldown_period only_valid_voting_portal_can_queue_proposal immutable_after_activation immutable_after_creation only_guardian_can_cancel guardian_can_cancel cannot_queue_when_voting_portal_unapproved only_owner_can_set_voting_config_witness only_owner_can_set_voting_config single_state_transition_per_block_non_creator_witness proposal_after_voting_portal_invalidate insufficient_proposition_power insufficient_proposition_power_witness_state_is_failed insufficient_proposition_power_witness_state_is_cancelled insufficient_proposition_power_witness_time_elapsed creator_is_not_zero creator_of_initialized_proposal_is_not_zero null_state_equivalence insufficient_proposition_power_witness_time_elapsed immutable_after_creation_witness_creator immutable_after_creation_witness_voting_portal immutable_after_creation_witness_access_level immutable_after_creation_witness_creation_time immutable_after_creation_witness_ipfs_hash immutable_after_creation_witness_payload_length immutable_after_activation_witness only_state_changing_function_initiate_transitions__pre_state only_state_changing_function_initiate_transitions__post_state check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_first check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_second check_new_representative_set_size_after_updateRepresentatives_witness_consequent_first check_new_representative_set_size_after_updateRepresentatives_witness_consequent_second proposal_voting_duration_lt_expiration_time config_voting_duration_lt_expiration_time proposal_state_transition_post_state proposal_state_transition_pre_state \ --msg "mainnet 3 " + echo "******** Running: mainnet 4 ***************" -certoraRun $CMN security/certora/confs/verifyGovernancePowerStrategy.conf --rule powerlessCompliance method_reachability \ +certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule single_state_transition_per_block_non_creator_non_guardian state_cant_decrease no_state_transitions_beyond_3 immutable_voting_portal \ --msg "mainnet 4 " - -echo "******** Running: mainnet 5 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule cancellationFeeZeroForFutureProposals null_state_variable_iff_null_access_level zero_voting_portal_iff_uninitialized_proposal \ - --msg "mainnet 5 " - - -echo "******** Running: mainnet 6 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule no_self_representative no_representative_is_zero consecutiveIDs totalCancellationFeeEqualETHBalance zero_address_is_not_a_valid_voting_portal \ - --msg "mainnet 6 " - - -echo "******** Running: mainnet 7 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule no_representative_is_zero_2 no_representative_of_zero \ - --msg "mainnet 7 " - - -echo "******** Running: mainnet 8 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule state_changing_function_self_check state_variable_changing_function_self_check method_reachability userFeeDidntChangeImplyNativeBalanceDidntDecrease \ - --msg "mainnet 8 " - - -echo "******** Running: mainnet 9 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule check_new_representative_set_size_after_updateRepresentatives check_old_representative_set_size_after_updateRepresentatives \ - --msg "mainnet 9 " - - -echo "******** Running: mainnet 10 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule at_least_single_payload_active empty_payloads_iff_uninitialized_proposal \ - --msg "mainnet 10 " - - -echo "******** Running: mainnet 11 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule null_state_iff_uninitialized_proposal setInvariant addressSetInvariant \ - --msg "mainnet 11 " - - -echo "******** Running: mainnet 12 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule state_changing_function_cannot_be_called_while_in_terminal_state proposal_executes_after_cooldown_period \ - --msg "mainnet 12 " - - -echo "******** Running: mainnet 13 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule only_valid_voting_portal_can_queue_proposal immutable_after_activation immutable_after_creation only_guardian_can_cancel guardian_can_cancel \ - --msg "mainnet 13 " - - -echo "******** Running: mainnet 14 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule cannot_queue_when_voting_portal_unapproved only_owner_can_set_voting_config_witness only_owner_can_set_voting_config single_state_transition_per_block_non_creator_witness \ - --msg "mainnet 14 " - - -echo "******** Running: mainnet 15 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule single_state_transition_per_block_non_creator_non_guardian state_cant_decrease no_state_transitions_beyond_3 immutable_voting_portal \ - --msg "mainnet 15 " - - -echo "******** Running: mainnet 16 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule proposal_after_voting_portal_invalidate insufficient_proposition_power insufficient_proposition_power_witness_state_is_failed insufficient_proposition_power_witness_state_is_cancelled insufficient_proposition_power_witness_time_elapsed \ - --msg "mainnet 16 " - - -echo "******** Running: mainnet 17 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule creator_is_not_zero creator_of_initialized_proposal_is_not_zero null_state_equivalence \ - --msg "mainnet 17 " - - -echo "******** Running: mainnet 18 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule insufficient_proposition_power_witness_time_elapsed \ - --msg "mainnet 18 " - - -echo "******** Running: mainnet 19 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule immutable_after_creation_witness_creator immutable_after_creation_witness_voting_portal \ - --msg "mainnet 19 " - - -echo "******** Running: mainnet 20 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule immutable_after_creation_witness_access_level immutable_after_creation_witness_creation_time immutable_after_creation_witness_ipfs_hash \ - --msg "mainnet 20 " - - -echo "******** Running: mainnet 21 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule immutable_after_creation_witness_payload_length immutable_after_activation_witness only_state_changing_function_initiate_transitions__pre_state \ - --msg "mainnet 21 " - - -echo "******** Running: mainnet 22 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule only_state_changing_function_initiate_transitions__post_state \ - --msg "mainnet 22 " - - -echo "******** Running: mainnet 23 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_first check_new_representative_set_size_after_updateRepresentatives_witness_antecedent_second check_new_representative_set_size_after_updateRepresentatives_witness_consequent_first check_new_representative_set_size_after_updateRepresentatives_witness_consequent_second \ - --msg "mainnet 23 " - - -echo "******** Running: mainnet 24 ***************" -certoraRun $CMN security/certora/confs/verifyGovernance.conf --rule proposal_voting_duration_lt_expiration_time config_voting_duration_lt_expiration_time proposal_state_transition_post_state proposal_state_transition_pre_state \ - --msg "mainnet 24 " - diff --git a/security/certora/scripts/run-all-voting.sh b/security/certora/scripts/run-all-voting.sh index 961a60c..94990f7 100644 --- a/security/certora/scripts/run-all-voting.sh +++ b/security/certora/scripts/run-all-voting.sh @@ -4,206 +4,49 @@ echo "******** Running: voting:1 ***************" certoraRun $CMN security/certora/confs/voting/verifyLegality.conf \ - --rule createdVoteHasNonZeroHash \ + --rule createdVoteHasNonZeroHash votedPowerIsImmutable onlyValidProposalCanChangeTally legalVote method_reachability \ --msg "voting 1: " -echo "******** Running: voting:2 ***************" -certoraRun $CMN security/certora/confs/voting/verifyLegality.conf \ - --rule votedPowerIsImmutable \ - --msg "voting 2: " - -echo "******** Running: voting:3 ***************" -certoraRun $CMN security/certora/confs/voting/verifyLegality.conf \ - --rule onlyValidProposalCanChangeTally \ - --msg "voting 3: " - -echo "******** Running: voting:4 ***************" -certoraRun $CMN security/certora/confs/voting/verifyLegality.conf \ - --rule legalVote \ - --msg "voting 4: " - - -echo "******** Running: voting:5 ***************" -certoraRun $CMN security/certora/confs/voting/verifyLegality.conf \ - --rule method_reachability \ - --msg "voting 5: " - - -echo "******** Running: voting:6 ***************" +echo "******** Running: voting:2 ***************" certoraRun $CMN security/certora/confs/voting/verifyMisc.conf \ - --msg "voting 6: " + \ + --msg "voting 2: " -#TODO: uncomment with certora-cli version 6.0 or higher -echo "******** Running: voting:7 ***************" +echo "******** Running: voting:3 ***************" certoraRun $CMN security/certora/confs/voting/verifyPower_summary.conf \ - --rule onlyThreeTokens \ - --msg "voting 7: " + --rule onlyThreeTokens method_reachability \ + --msg "voting 3: " -echo "******** Running: voting:8 ***************" -certoraRun $CMN security/certora/confs/voting/verifyPower_summary.conf \ - --rule method_reachability \ - --msg "voting 8: " -echo "******** Running: voting:9 ***************" +echo "******** Running: voting:4 ***************" certoraRun $CMN security/certora/confs/voting/verifyProposal_config.conf \ - --rule startedProposalHasConfig \ - --msg "voting 9: " + --rule startedProposalHasConfig createdProposalHasRoots proposalHasNonzeroDuration newProposalUnusedId configIsImmutable getProposalsConfigsDoesntRevert method_reachability \ + --msg "voting 4: " -echo "******** Running: voting:10 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_config.conf \ - --rule createdProposalHasRoots \ - --msg "voting 10: " - - -echo "******** Running: voting:11 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_config.conf \ - --rule proposalHasNonzeroDuration newProposalUnusedId configIsImmutable \ - --msg "voting 11: " - - -echo "******** Running: voting:12 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_config.conf \ - --rule getProposalsConfigsDoesntRevert \ - --msg "voting 12: " - - -echo "******** Running: voting:13 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_config.conf \ - --rule method_reachability \ - --msg "voting 13: " - - -echo "******** Running: voting:14 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule startsBeforeEnds \ - --msg "voting 14: " - - -echo "******** Running: voting:15 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule startsStrictlyBeforeEnds \ - --msg "voting 15: " - - -echo "******** Running: voting:16 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalLegalStates \ - --msg "voting 16: " - - -echo "******** Running: voting:17 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalMethodStateTransitionCompliance \ - --msg "voting 17: " -echo "******** Running: voting:18 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalTimeStateTransitionCompliance \ - --msg "voting 18: " - - -echo "******** Running: voting:19 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalIdIsImmutable \ - --msg "voting 19: " - - -echo "******** Running: voting:20 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalImmutability \ - --msg "voting 20: " - - -echo "******** Running: voting:21 ***************" -certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule startedProposalHasConfig \ - --msg "voting 21: " - - -echo "******** Running: voting:22 ***************" +echo "******** Running: voting:5 ***************" certoraRun $CMN security/certora/confs/voting/verifyProposal_states.conf \ - --rule proposalHasNonzeroDuration method_reachability \ - --msg "voting 22: " - - -echo "******** Running: voting:23 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule votingPowerGhostIsVotingPower \ - --msg "voting 23: " - - -echo "******** Running: voting:24 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule sumOfVotes \ - --msg "voting 24: " - - -echo "******** Running: voting:25 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule voteTallyChangedOnlyByVoting \ - --msg "voting 25: " - - -echo "******** Running: voting:26 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule voteUpdatesTally \ - --msg "voting 26: " - - -echo "******** Running: voting:27 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule onlyVoteCanChangeResult \ - --msg "voting 27: " - - -echo "******** Running: voting:28 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule votingTallyCanOnlyIncrease \ - --msg "voting 28: " - - -echo "******** Running: voting:29 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule strangerVoteUnchanged \ - --msg "voting 29: " - - -echo "******** Running: voting:30 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule otherProposalUnchanged \ - --msg "voting 30: " - - -echo "******** Running: voting:31 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule otherVoterUntouched \ - --msg "voting 31: " - + --rule startsBeforeEnds startsStrictlyBeforeEnds proposalLegalStates proposalMethodStateTransitionCompliance proposalTimeStateTransitionCompliance proposalIdIsImmutable proposalImmutability startedProposalHasConfig proposalHasNonzeroDuration method_reachability \ + --msg "voting 5: " -echo "******** Running: voting:32 ***************" -certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule cannot_vote_twice_with_submitVote_and_submitVoteAsRepresentative \ - --msg "voting 32: " -echo "******** Running: voting:33 ***************" +echo "******** Running: voting:6 ***************" certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule cannot_vote_twice_with_submitVoteAsRepresentative_and_submitVote \ - --msg "voting 33: " + --rule votingPowerGhostIsVotingPower sumOfVotes voteTallyChangedOnlyByVoting voteUpdatesTally onlyVoteCanChangeResult votingTallyCanOnlyIncrease strangerVoteUnchanged otherProposalUnchanged otherVoterUntouched method_reachability \ + --msg "voting 6: " -echo "******** Running: voting:34 ***************" +echo "******** Running: voting:7 ***************" certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule cannot_vote_twice_with_submitVoteSingleProofAsRepresentative_and_submitVote \ - --msg "voting 34: " + --rule cannot_vote_twice_with_submitVote_and_submitVoteAsRepresentative \ + --msg "voting 7: " -echo "******** Running: voting:35 ***************" +echo "******** Running: voting:8 ***************" certoraRun $CMN security/certora/confs/voting/verifyVoting_and_tally.conf \ - --rule method_reachability \ - --msg "voting 35: " - + --rule cannot_vote_twice_with_submitVoteAsRepresentative_and_submitVote \ diff --git a/security/certora/specs/voting/power_summary.spec b/security/certora/specs/voting/power_summary.spec index 0238bba..4a4be6a 100644 --- a/security/certora/specs/voting/power_summary.spec +++ b/security/certora/specs/voting/power_summary.spec @@ -217,7 +217,8 @@ definition filteredMethods(method f) returns bool = ( ICrossChainReceiver.ConfirmationInput[], ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[], ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[], - address[] + address[], + ICrossChainForwarder.OptimalBandwidthByChain[] ).selector ); diff --git a/security/certora/specs/voting/setup.spec b/security/certora/specs/voting/setup.spec index 610abcb..a68313b 100644 --- a/security/certora/specs/voting/setup.spec +++ b/security/certora/specs/voting/setup.spec @@ -122,7 +122,8 @@ definition filteredMethods(method f) returns bool = ( ICrossChainReceiver.ConfirmationInput[], ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[], ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[], - address[] + address[], + ICrossChainForwarder.OptimalBandwidthByChain[] ).selector ); diff --git a/src/contracts/GovernancePowerStrategy.sol b/src/contracts/GovernancePowerStrategy.sol index 2e48e06..ee62243 100644 --- a/src/contracts/GovernancePowerStrategy.sol +++ b/src/contracts/GovernancePowerStrategy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {IGovernancePowerDelegationToken} from 'aave-token-v3/interfaces/IGovernancePowerDelegationToken.sol'; +import {IGovernancePowerDelegationToken} from './dataHelpers/interfaces/IGovernancePowerDelegationToken.sol'; import {IBaseVotingStrategy} from '../interfaces/IBaseVotingStrategy.sol'; import {IGovernancePowerStrategy} from '../interfaces/IGovernancePowerStrategy.sol'; import {BaseVotingStrategy} from './BaseVotingStrategy.sol'; diff --git a/src/contracts/dataHelpers/MetaDelegateHelper.sol b/src/contracts/dataHelpers/MetaDelegateHelper.sol index 89dfdaa..054ee6f 100644 --- a/src/contracts/dataHelpers/MetaDelegateHelper.sol +++ b/src/contracts/dataHelpers/MetaDelegateHelper.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IGovernancePowerDelegationToken} from 'aave-token-v3/interfaces/IGovernancePowerDelegationToken.sol'; +import {IGovernancePowerDelegationToken} from './interfaces/IGovernancePowerDelegationToken.sol'; import {IMetaDelegateHelper} from './interfaces/IMetaDelegateHelper.sol'; import {Errors} from '../libraries/Errors.sol'; diff --git a/src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol b/src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol new file mode 100644 index 0000000..e3626cf --- /dev/null +++ b/src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IGovernancePowerDelegationToken { + enum GovernancePowerType { + VOTING, + PROPOSITION + } + + /** + * @dev emitted when a user delegates to another + * @param delegator the user which delegated governance power + * @param delegatee the delegatee + * @param delegationType the type of delegation (VOTING, PROPOSITION) + **/ + event DelegateChanged( + address indexed delegator, + address indexed delegatee, + GovernancePowerType delegationType + ); + + // @dev we removed DelegatedPowerChanged event because to reconstruct the full state of the system, + // is enough to have Transfer and DelegateChanged TODO: document it + + /** + * @dev delegates the specific power to a delegatee + * @param delegatee the user which delegated power will change + * @param delegationType the type of delegation (VOTING, PROPOSITION) + **/ + function delegateByType( + address delegatee, + GovernancePowerType delegationType + ) external; + + /** + * @dev delegates all the governance powers to a specific user + * @param delegatee the user to which the powers will be delegated + **/ + function delegate(address delegatee) external; + + /** + * @dev returns the delegatee of an user + * @param delegator the address of the delegator + * @param delegationType the type of delegation (VOTING, PROPOSITION) + * @return address of the specified delegatee + **/ + function getDelegateeByType( + address delegator, + GovernancePowerType delegationType + ) external view returns (address); + + /** + * @dev returns delegates of an user + * @param delegator the address of the delegator + * @return a tuple of addresses the VOTING and PROPOSITION delegatee + **/ + function getDelegates( + address delegator + ) external view returns (address, address); + + /** + * @dev returns the current voting or proposition power of a user. + * @param user the user + * @param delegationType the type of delegation (VOTING, PROPOSITION) + * @return the current voting or proposition power of a user + **/ + function getPowerCurrent( + address user, + GovernancePowerType delegationType + ) external view returns (uint256); + + /** + * @dev returns the current voting or proposition power of a user. + * @param user the user + * @return the current voting and proposition power of a user + **/ + function getPowersCurrent( + address user + ) external view returns (uint256, uint256); + + /** + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param delegator the owner of the funds + * @param delegatee the user to who owner delegates his governance power + * @param delegationType the type of governance power delegation (VOTING, PROPOSITION) + * @param deadline the deadline timestamp, type(uint256).max for no deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ + function metaDelegateByType( + address delegator, + address delegatee, + GovernancePowerType delegationType, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + /** + * @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md + * @param delegator the owner of the funds + * @param delegatee the user to who delegator delegates his voting and proposition governance power + * @param deadline the deadline timestamp, type(uint256).max for no deadline + * @param v signature param + * @param s signature param + * @param r signature param + */ + function metaDelegate( + address delegator, + address delegatee, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; +} diff --git a/src/contracts/dataHelpers/interfaces/IMetaDelegateHelper.sol b/src/contracts/dataHelpers/interfaces/IMetaDelegateHelper.sol index 6e6647c..ba6949a 100644 --- a/src/contracts/dataHelpers/interfaces/IMetaDelegateHelper.sol +++ b/src/contracts/dataHelpers/interfaces/IMetaDelegateHelper.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IGovernancePowerDelegationToken} from 'aave-token-v3/interfaces/IGovernancePowerDelegationToken.sol'; +import {IGovernancePowerDelegationToken} from '../interfaces/IGovernancePowerDelegationToken.sol'; /** * @title IMetaDelegateHelper @@ -42,6 +42,7 @@ interface IMetaDelegateHelper { * @notice method for the batch upgrade governance power delegation across multiple voting assets with signatures * @param delegateParams an array with signatures with the user and assets to interact with */ - function batchMetaDelegate(MetaDelegateParams[] calldata delegateParams) - external; + function batchMetaDelegate( + MetaDelegateParams[] calldata delegateParams + ) external; } diff --git a/src/contracts/payloads/PayloadsControllerCore.sol b/src/contracts/payloads/PayloadsControllerCore.sol index ade9e05..f06b931 100644 --- a/src/contracts/payloads/PayloadsControllerCore.sol +++ b/src/contracts/payloads/PayloadsControllerCore.sol @@ -2,7 +2,8 @@ pragma solidity ^0.8.8; import {OwnableWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol'; -import {Rescuable, IRescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; +import {Rescuable, RescuableBase} from 'solidity-utils/contracts/utils/Rescuable.sol'; +import {IRescuable, IRescuableBase} from 'solidity-utils/contracts/utils/interfaces/IRescuable.sol'; import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol'; @@ -203,16 +204,23 @@ abstract contract PayloadsControllerCore is return _accessLevelToExecutorConfig[accessControl]; } - /// @inheritdoc IRescuable + /// @inheritdoc Rescuable function whoCanRescue() public view - override(IRescuable, Rescuable) + override(Rescuable) returns (address) { return owner(); } + /// @inheritdoc IRescuableBase + function maxRescue( + address erc20Token + ) public view override(IRescuableBase, RescuableBase) returns (uint256) { + return IERC20(erc20Token).balanceOf(address(this)); + } + receive() external payable {} /** diff --git a/src/contracts/voting/VotingStrategy.sol b/src/contracts/voting/VotingStrategy.sol index ced910a..dbf4fab 100644 --- a/src/contracts/voting/VotingStrategy.sol +++ b/src/contracts/voting/VotingStrategy.sol @@ -4,10 +4,16 @@ pragma solidity ^0.8.0; import {BaseVotingStrategy, IBaseVotingStrategy} from '../BaseVotingStrategy.sol'; import {StateProofVerifier} from './libs/StateProofVerifier.sol'; import {IVotingStrategy, IDataWarehouse} from './interfaces/IVotingStrategy.sol'; -import {DelegationMode} from 'aave-token-v3/DelegationAwareBalance.sol'; import {Errors} from '../libraries/Errors.sol'; import {SlotUtils} from '../libraries/SlotUtils.sol'; +enum DelegationMode { + NO_DELEGATION, + VOTING_DELEGATED, + PROPOSITION_DELEGATED, + FULL_POWER_DELEGATED +} + /** * @title VotingStrategy * @author BGD Labs diff --git a/tests/GC_VotingConfigs.t.sol b/tests/GC_VotingConfigs.t.sol index dac12d1..713ebc0 100644 --- a/tests/GC_VotingConfigs.t.sol +++ b/tests/GC_VotingConfigs.t.sol @@ -13,11 +13,12 @@ import {IVotingMachineWithProofs} from '../src/contracts/voting/interfaces/IVoti import {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol'; import {Errors} from '../src/contracts/libraries/Errors.sol'; import {IBaseVotingStrategy} from '../src/interfaces/IBaseVotingStrategy.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; contract GCore_VotingConfigsTest is Test { - address public constant OWNER = address(65536+123); - address public constant GUARDIAN = address(65536+1234); - address public constant ADMIN = address(65536+12345); + address public constant OWNER = address(65536 + 123); + address public constant GUARDIAN = address(65536 + 1234); + address public constant ADMIN = address(65536 + 12345); address public constant CROSS_CHAIN_CONTROLLER = address(123456); address public constant SAME_CHAIN_VOTING_MACHINE = address(1234567); address public constant EXECUTION_PORTAL = address(12345678); @@ -109,7 +110,7 @@ contract GCore_VotingConfigsTest is Test { IGovernanceCore governance = IGovernanceCore( proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -152,7 +153,7 @@ contract GCore_VotingConfigsTest is Test { IGovernanceCore( proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -668,7 +669,7 @@ contract GCore_VotingConfigsTest is Test { IGovernanceCore governance = IGovernanceCore( proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, diff --git a/tests/GovernanceCore.t.sol b/tests/GovernanceCore.t.sol index a0a211e..01275ae 100644 --- a/tests/GovernanceCore.t.sol +++ b/tests/GovernanceCore.t.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import {Ownable} from 'solidity-utils/contracts/oz-common/Ownable.sol'; import {OwnableWithGuardian} from 'solidity-utils/contracts/access-control/OwnableWithGuardian.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {GovernanceCore} from '../src/contracts/GovernanceCore.sol'; import {Governance, IGovernance, IGovernanceCore, PayloadsControllerUtils} from '../src/contracts/Governance.sol'; import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; @@ -14,11 +14,12 @@ import {IVotingMachineWithProofs} from '../src/contracts/voting/interfaces/IVoti import {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol'; import {Errors} from '../src/contracts/libraries/Errors.sol'; import {IBaseVotingStrategy} from '../src/interfaces/IBaseVotingStrategy.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; contract GovernanceCoreTest is Test { - address public constant OWNER = address(65536+123); - address public constant GUARDIAN = address(65536+1234); - address public constant ADMIN = address(65536+12345); + address public constant OWNER = address(65536 + 123); + address public constant GUARDIAN = address(65536 + 1234); + address public constant ADMIN = address(65536 + 12345); address public constant CROSS_CHAIN_CONTROLLER = address(123456); address public constant SAME_CHAIN_VOTING_MACHINE = address(1234567); address public constant EXECUTION_PORTAL = address(12345678); @@ -149,7 +150,7 @@ contract GovernanceCoreTest is Test { governance = IGovernanceCore( proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -182,7 +183,7 @@ contract GovernanceCoreTest is Test { vm.expectRevert(bytes(Errors.MISSING_VOTING_CONFIGURATIONS)); proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -215,7 +216,7 @@ contract GovernanceCoreTest is Test { vm.expectRevert(bytes(Errors.INVALID_INITIAL_VOTING_CONFIGS)); proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -248,7 +249,7 @@ contract GovernanceCoreTest is Test { vm.expectRevert(bytes(Errors.MISSING_VOTING_CONFIGURATIONS)); proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -281,7 +282,7 @@ contract GovernanceCoreTest is Test { vm.expectRevert(bytes(Errors.INVALID_VOTING_CONFIG_ACCESS_LEVEL)); proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, @@ -312,7 +313,7 @@ contract GovernanceCoreTest is Test { vm.expectRevert(bytes(Errors.MISSING_VOTING_CONFIGURATIONS)); proxyFactory.createDeterministic( address(governanceImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IGovernance.initialize.selector, OWNER, diff --git a/tests/GovernancePowerStrategy.t.sol b/tests/GovernancePowerStrategy.t.sol index e4ea689..096f293 100644 --- a/tests/GovernancePowerStrategy.t.sol +++ b/tests/GovernancePowerStrategy.t.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import {GovernancePowerStrategy} from '../src/contracts/GovernancePowerStrategy.sol'; import {IBaseVotingStrategy} from '../src/interfaces/IBaseVotingStrategy.sol'; -import {IGovernancePowerDelegationToken} from 'aave-token-v3/interfaces/IGovernancePowerDelegationToken.sol'; +import {IGovernancePowerDelegationToken} from '../src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol'; contract GovernancePowerStrategyTest is Test { address public AAVE; diff --git a/tests/MessageSizes.t.sol b/tests/MessageSizes.t.sol index fd07743..36a74d3 100644 --- a/tests/MessageSizes.t.sol +++ b/tests/MessageSizes.t.sol @@ -3,14 +3,14 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import 'aave-delivery-infrastructure/contracts/libs/EncodingUtils.sol'; -import 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import '../src/contracts/voting/interfaces/IVotingMachineWithProofs.sol'; import {PayloadsControllerUtils} from '../src/contracts/payloads/PayloadsControllerUtils.sol'; contract MessageSizesTest is Test { - address public constant ORIGIN = address(65536+123); - address public constant DESTINATION = address(65536+1234); - address public constant VOTER = address(65536+12345); + address public constant ORIGIN = address(65536 + 123); + address public constant DESTINATION = address(65536 + 1234); + address public constant VOTER = address(65536 + 12345); address public constant PAYLOADS_CONTROLLER = address(123456); uint256 public constant ORIGIN_CHAIN_ID = ChainIds.ETHEREUM; uint256 public constant DESTINATION_CHAIN_ID = ChainIds.POLYGON; diff --git a/tests/VotingPortal.t.sol b/tests/VotingPortal.t.sol index 24ef068..3c03a14 100644 --- a/tests/VotingPortal.t.sol +++ b/tests/VotingPortal.t.sol @@ -3,16 +3,16 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import {IVotingPortal} from '../src/interfaces/IVotingPortal.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {VotingPortal, IGovernanceCore, IVotingMachineWithProofs} from '../src/contracts/VotingPortal.sol'; import {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol'; import {ICrossChainReceiver} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainReceiver.sol'; import {Errors} from '../src/contracts/libraries/Errors.sol'; contract VotingPortalTest is Test { - address public constant CROSS_CHAIN_CONTROLLER = address(65536+123); - address public constant GOVERNANCE = address(65536+1234); - address public constant VOTING_MACHINE = address(65536+12345); + address public constant CROSS_CHAIN_CONTROLLER = address(65536 + 123); + address public constant GOVERNANCE = address(65536 + 1234); + address public constant VOTING_MACHINE = address(65536 + 12345); uint128 public constant GAS_LIMIT = 600000; uint256 public VOTING_MACHINE_CHAIN_ID; diff --git a/tests/governance_V2_5/Governance_V2_5.t.sol b/tests/governance_V2_5/Governance_V2_5.t.sol index 29b8a09..c1efc4a 100644 --- a/tests/governance_V2_5/Governance_V2_5.t.sol +++ b/tests/governance_V2_5/Governance_V2_5.t.sol @@ -7,9 +7,9 @@ import {AaveGovernanceV2} from 'aave-address-book/AaveGovernanceV2.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {ITransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; import {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {Errors} from '../../src/contracts/libraries/Errors.sol'; contract Governance_V2_5_Test is Test { @@ -22,7 +22,7 @@ contract Governance_V2_5_Test is Test { hoax(AaveGovernanceV2.SHORT_EXECUTOR); ProxyAdmin(MiscEthereum.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy( + ITransparentUpgradeableProxy( payable(address(GovernanceV3Ethereum.GOVERNANCE)) ), address(govV2_5Impl), diff --git a/tests/governance_V2_5/Governance_V3.t.sol b/tests/governance_V2_5/Governance_V3.t.sol index 3bdaf74..7accbfc 100644 --- a/tests/governance_V2_5/Governance_V3.t.sol +++ b/tests/governance_V2_5/Governance_V3.t.sol @@ -7,9 +7,9 @@ import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {ITransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; import {ICrossChainForwarder} from 'aave-delivery-infrastructure/contracts/interfaces/ICrossChainForwarder.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {Errors} from '../../src/contracts/libraries/Errors.sol'; import {Governance, IGovernance} from '../../src/contracts/Governance.sol'; import {IGovernanceCore, PayloadsControllerUtils} from 'aave-address-book/GovernanceV3.sol'; @@ -33,7 +33,7 @@ contract Governance_V3_Test is Test { hoax(GovernanceV3Ethereum.EXECUTOR_LVL_1); ProxyAdmin(MiscEthereum.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy( + ITransparentUpgradeableProxy( payable(address(GovernanceV3Ethereum.GOVERNANCE)) ), address(govV3_Impl), @@ -64,10 +64,6 @@ contract Governance_V3_Test is Test { Ownable(address(GovernanceV3Ethereum.GOVERNANCE)).owner(), GovernanceV3Ethereum.EXECUTOR_LVL_1 ); - assertEq( - IWithGuardian(address(GovernanceV3Ethereum.GOVERNANCE)).guardian(), - MiscEthereum.PROTOCOL_GUARDIAN - ); } function test_old_storage() public { diff --git a/tests/mock/MockCrossChainInfra.sol b/tests/mock/MockCrossChainInfra.sol index 1794cf5..2a6eca5 100644 --- a/tests/mock/MockCrossChainInfra.sol +++ b/tests/mock/MockCrossChainInfra.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import {CrossChainController} from 'aave-delivery-infrastructure/contracts/CrossChainController.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {LayerZeroAdapter} from 'aave-delivery-infrastructure/contracts/adapters/layerZero/LayerZeroAdapter.sol'; import {PayloadsController} from '../../src/contracts/payloads/PayloadsController.sol'; import {Executor} from '../../src/contracts/payloads/Executor.sol'; diff --git a/tests/payloads/PayloadsController.t.sol b/tests/payloads/PayloadsController.t.sol index f4400b4..316270a 100644 --- a/tests/payloads/PayloadsController.t.sol +++ b/tests/payloads/PayloadsController.t.sol @@ -8,10 +8,11 @@ import {IPayloadsControllerCore} from '../../src/contracts/payloads/interfaces/I import {PayloadsControllerUtils} from '../../src/contracts/payloads/PayloadsControllerUtils.sol'; import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; import {Errors} from '../../src/contracts/libraries/Errors.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; contract PayloadsControllerTest is Test { - address constant ADMIN = address(65536+123); - address constant GUARDIAN = address(65536+1234); + address constant ADMIN = address(65536 + 123); + address constant GUARDIAN = address(65536 + 1234); address public constant MESSAGE_ORIGINATOR = address(1234190812); address public constant CROSS_CHAIN_CONTROLLER = address(123456); @@ -53,7 +54,7 @@ contract PayloadsControllerTest is Test { payloadPortal = IPayloadsController( proxyFactory.create( address(payloadPortalImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( IPayloadsControllerCore.initialize.selector, address(this), diff --git a/tests/payloads/PayloadsControllerCore.t.sol b/tests/payloads/PayloadsControllerCore.t.sol index ec61deb..276715a 100644 --- a/tests/payloads/PayloadsControllerCore.t.sol +++ b/tests/payloads/PayloadsControllerCore.t.sol @@ -13,6 +13,7 @@ import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol'; import {PayloadsControllerUtils} from '../../src/contracts/payloads/PayloadsControllerUtils.sol'; import {PayloadTest} from './utils/PayloadTest.sol'; import {Errors} from '../../src/contracts/libraries/Errors.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; contract PayloadsControllerMock is PayloadsControllerCore { function queue( @@ -25,8 +26,8 @@ contract PayloadsControllerMock is PayloadsControllerCore { } contract PayloadsControllerCoreTest is Test { - address public constant ADMIN = address(65536+123); - address public constant GUARDIAN = address(65536+1234); + address public constant ADMIN = address(65536 + 123); + address public constant GUARDIAN = address(65536 + 1234); address public constant ORIGIN_FORWARDER = address(123456); address public constant PAYLOAD_PORTAL = address(987312); uint256 public constant YES_THRESHOLD = 1; @@ -130,7 +131,7 @@ contract PayloadsControllerCoreTest is Test { address payloadsControllerProxy = proxyFactory.create( address(payloadsControllerImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( payloadsControllerImpl.initialize.selector, address(this), @@ -830,7 +831,7 @@ contract PayloadsControllerCoreTest is Test { address newPayloadsControllerProxy = proxyFactory.create( address(payloadsControllerImpl), - ADMIN, + ProxyAdmin(ADMIN), abi.encodeWithSelector( payloadsControllerImpl.initialize.selector, address(this), diff --git a/tests/payloads/PermissionedPayloadsController.t.sol b/tests/payloads/PermissionedPayloadsController.t.sol index 986206a..9261b4b 100644 --- a/tests/payloads/PermissionedPayloadsController.t.sol +++ b/tests/payloads/PermissionedPayloadsController.t.sol @@ -9,6 +9,7 @@ import {Errors} from '../../src/contracts/libraries/Errors.sol'; import {Executor, IExecutor, Ownable} from '../../src/contracts/payloads/Executor.sol'; import {PayloadTest} from './utils/PayloadTest.sol'; import {Test} from 'forge-std/Test.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; contract PermissionedPayloadsControllerTest is Test { IPermissionedPayloadsController permissionedPayloadPortal; @@ -50,7 +51,7 @@ contract PermissionedPayloadsControllerTest is Test { permissionedPayloadPortal = IPermissionedPayloadsController( proxyFactory.create( address(permissionedPayloadPortal), - admin, + ProxyAdmin(admin), abi.encodeWithSelector( IPermissionedPayloadsController.initialize.selector, guardian, @@ -201,7 +202,8 @@ contract PermissionedPayloadsControllerTest is Test { address admin, address guardian, address payloadsManager, - address origin + address origin, + address user ) external initializeTest(admin, guardian, payloadsManager, origin) { uint40 newDelay = 500; @@ -209,11 +211,13 @@ contract PermissionedPayloadsControllerTest is Test { permissionedPayloadPortal.setExecutionDelay(newDelay); vm.stopPrank(); + hoax(user); uint40 executionDelay = permissionedPayloadPortal .getExecutorSettingsByAccessControl( PayloadsControllerUtils.AccessControl.Level_1 ) .delay; + assertEq(executionDelay, newDelay, 'Execution delay was not set correctly'); } diff --git a/tests/voting/TokenDelegationTest.t.sol b/tests/voting/TokenDelegationTest.t.sol index f0549c1..bcacb77 100644 --- a/tests/voting/TokenDelegationTest.t.sol +++ b/tests/voting/TokenDelegationTest.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {BaseDelegation} from 'aave-token-v3/BaseDelegation.sol'; +import {IGovernancePowerDelegationToken} from '../../src/contracts/dataHelpers/interfaces/IGovernancePowerDelegationToken.sol'; contract TokenDelegationTest is Test { address public constant AAVE_HOLDER = @@ -25,39 +25,59 @@ contract TokenDelegationTest is Test { } function test_DelegateAave() public { - (uint256 powerBeforeV, uint256 powerBeforeP) = BaseDelegation(AAVE) - .getPowersCurrent(AAVE_HOLDER); + ( + uint256 powerBeforeV, + uint256 powerBeforeP + ) = IGovernancePowerDelegationToken(AAVE).getPowersCurrent(AAVE_HOLDER); hoax(AAVE_HOLDER); - BaseDelegation(AAVE).delegate(DELEGATION_RECEIVER); + IGovernancePowerDelegationToken(AAVE).delegate(DELEGATION_RECEIVER); - (uint256 receiverPowerV, uint256 receiverPowerP) = BaseDelegation(AAVE) - .getPowersCurrent(DELEGATION_RECEIVER); + ( + uint256 receiverPowerV, + uint256 receiverPowerP + ) = IGovernancePowerDelegationToken(AAVE).getPowersCurrent( + DELEGATION_RECEIVER + ); assertEq(powerBeforeV, receiverPowerV); assertEq(powerBeforeP, receiverPowerP); } function test_DelegateStkAave() public { - (uint256 powerBeforeV, uint256 powerBeforeP) = BaseDelegation(STK_AAVE) - .getPowersCurrent(STK_AAVE_HOLDER); + ( + uint256 powerBeforeV, + uint256 powerBeforeP + ) = IGovernancePowerDelegationToken(STK_AAVE).getPowersCurrent( + STK_AAVE_HOLDER + ); hoax(STK_AAVE_HOLDER); - BaseDelegation(STK_AAVE).delegate(DELEGATION_RECEIVER); + IGovernancePowerDelegationToken(STK_AAVE).delegate(DELEGATION_RECEIVER); - (uint256 receiverPowerV, uint256 receiverPowerP) = BaseDelegation(STK_AAVE) - .getPowersCurrent(DELEGATION_RECEIVER); + ( + uint256 receiverPowerV, + uint256 receiverPowerP + ) = IGovernancePowerDelegationToken(STK_AAVE).getPowersCurrent( + DELEGATION_RECEIVER + ); assertEq(powerBeforeV, receiverPowerV); assertEq(powerBeforeP, receiverPowerP); } function test_DelegateAAave() public { - (uint256 powerBeforeV, uint256 powerBeforeP) = BaseDelegation(A_AAVE) - .getPowersCurrent(A_AAVE_HOLDER); + ( + uint256 powerBeforeV, + uint256 powerBeforeP + ) = IGovernancePowerDelegationToken(A_AAVE).getPowersCurrent(A_AAVE_HOLDER); hoax(A_AAVE_HOLDER); - BaseDelegation(A_AAVE).delegate(DELEGATION_RECEIVER); + IGovernancePowerDelegationToken(A_AAVE).delegate(DELEGATION_RECEIVER); - (uint256 receiverPowerV, uint256 receiverPowerP) = BaseDelegation(A_AAVE) - .getPowersCurrent(DELEGATION_RECEIVER); + ( + uint256 receiverPowerV, + uint256 receiverPowerP + ) = IGovernancePowerDelegationToken(A_AAVE).getPowersCurrent( + DELEGATION_RECEIVER + ); assertEq( (powerBeforeV / POWER_SCALE_FACTOR) * POWER_SCALE_FACTOR, diff --git a/tests/voting/VotingMachine.t.sol b/tests/voting/VotingMachine.t.sol index 7631aea..0b7769a 100644 --- a/tests/voting/VotingMachine.t.sol +++ b/tests/voting/VotingMachine.t.sol @@ -8,7 +8,7 @@ import {IDataWarehouse} from '../../src/contracts/voting/interfaces/IDataWarehou import {VotingMachine, IVotingMachineWithProofs} from '../../src/contracts/voting/VotingMachine.sol'; import {VotingStrategy, IBaseVotingStrategy} from '../../src/contracts/voting/VotingStrategy.sol'; import {IVotingPortal} from '../../src/interfaces/IVotingPortal.sol'; -import {ChainIds} from 'aave-delivery-infrastructure/contracts/libs/ChainIds.sol'; +import {ChainIds} from 'solidity-utils/contracts/utils/ChainHelpers.sol'; import {Errors} from '../../src/contracts/libraries/Errors.sol'; // Mocked so we can make it revert @@ -54,9 +54,9 @@ contract VotingMachineMock is VotingMachine { } contract VotingMachineTest is Test { - address public constant CROSS_CHAIN_CONTROLLER = address(65536+123); - address public constant L1_VOTING_PORTAL = address(65536+1234); - address public constant GOVERNANCE = address(65536+12345); + address public constant CROSS_CHAIN_CONTROLLER = address(65536 + 123); + address public constant L1_VOTING_PORTAL = address(65536 + 1234); + address public constant GOVERNANCE = address(65536 + 12345); uint256 L1_VOTING_PORTAL_CHAIN_ID; uint256 public constant GAS_LIMIT = 600000; diff --git a/tests/voting/VotingStrategyStkAave.t.sol b/tests/voting/VotingStrategyStkAave.t.sol index 84b35ec..8806815 100644 --- a/tests/voting/VotingStrategyStkAave.t.sol +++ b/tests/voting/VotingStrategyStkAave.t.sol @@ -2,14 +2,13 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; -import {DelegationMode} from 'aave-token-v3/DelegationAwareBalance.sol'; import {IDataWarehouse} from '../../src/contracts/voting/DataWarehouse.sol'; -import {VotingStrategy, IVotingStrategy, IBaseVotingStrategy} from '../../src/contracts/voting/VotingStrategy.sol'; +import {VotingStrategy, IVotingStrategy, IBaseVotingStrategy, DelegationMode} from '../../src/contracts/voting/VotingStrategy.sol'; import {SlotUtils} from '../../src/contracts/libraries/SlotUtils.sol'; contract VotingStrategyStkAaveTest is Test { - address DATA_WAREHOUSE = address(65536+123); + address DATA_WAREHOUSE = address(65536 + 123); bytes32 constant BLOCK_HASH = 0x0a7c36db26203276b9430a46faaba9ce76732c5b7c11ef07b39e81a2690591b7; address constant VOTER = 0x6D603081563784dB3f83ef1F65Cc389D94365Ac9; diff --git a/tests/voting/votingMachineWithProofs.t.sol b/tests/voting/votingMachineWithProofs.t.sol index 142c5e5..5147b54 100644 --- a/tests/voting/votingMachineWithProofs.t.sol +++ b/tests/voting/votingMachineWithProofs.t.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import 'forge-std/Test.sol'; import 'forge-std/StdStorage.sol'; -import {ECDSA} from 'openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol'; +import {MessageHashUtils} from 'openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol'; import {IVotingMachineWithProofs} from '../../src/contracts/voting/interfaces/IVotingMachineWithProofs.sol'; import {IDataWarehouse} from '../../src/contracts/voting/interfaces/IDataWarehouse.sol'; import {IVotingStrategy} from '../../src/contracts/voting/interfaces/IVotingStrategy.sol'; @@ -69,7 +69,7 @@ contract VotingMachineWithProofsTest is Test { bytes32 BLOCK_HASH = 0xf656a10e5d825e287890cc430cf1bac2364b756e09e19b6fa3a72ec844ba2f44; address VOTER = 0x6D603081563784dB3f83ef1F65Cc389D94365Ac9; - address public constant GOVERNANCE = address(65536+12345); + address public constant GOVERNANCE = address(65536 + 12345); IDataWarehouse dataWarehouse; IVotingStrategy votingStrategy; @@ -1214,7 +1214,7 @@ contract VotingMachineWithProofsTest is Test { }); address signer = vm.addr(1); - bytes32 digest = ECDSA.toTypedDataHash( + bytes32 digest = MessageHashUtils.toTypedDataHash( votingMachine.DOMAIN_SEPARATOR(), keccak256( abi.encode( @@ -1309,7 +1309,7 @@ contract VotingMachineWithProofsTest is Test { address signer = vm.addr(1); - bytes32 digest = ECDSA.toTypedDataHash( + bytes32 digest = MessageHashUtils.toTypedDataHash( votingMachine.DOMAIN_SEPARATOR(), keccak256( abi.encode( @@ -1363,7 +1363,7 @@ contract VotingMachineWithProofsTest is Test { }); address signer = vm.addr(1); - bytes32 digest = ECDSA.toTypedDataHash( + bytes32 digest = MessageHashUtils.toTypedDataHash( votingMachine.DOMAIN_SEPARATOR(), keccak256( abi.encode( @@ -1396,9 +1396,7 @@ contract VotingMachineWithProofsTest is Test { _createVote(proposalId, 600); - vm.expectRevert( - bytes("ECDSA: invalid signature") - ); + vm.expectRevert(abi.encodeWithSignature('ECDSAInvalidSignature()')); votingMachine.submitVoteBySignature( proposalId, address(0), @@ -1436,7 +1434,7 @@ contract VotingMachineWithProofsTest is Test { }); address signer = vm.addr(1); - bytes32 digest = ECDSA.toTypedDataHash( + bytes32 digest = MessageHashUtils.toTypedDataHash( votingMachine.DOMAIN_SEPARATOR(), keccak256( abi.encode( @@ -1553,13 +1551,13 @@ contract VotingMachineWithProofsTest is Test { }); address signer = vm.addr(1); - bytes32 digest = ECDSA.toTypedDataHash( + bytes32 digest = MessageHashUtils.toTypedDataHash( votingMachine.DOMAIN_SEPARATOR(), keccak256( abi.encode( votingMachine.VOTE_SUBMITTED_BY_REPRESENTATIVE_TYPEHASH(), 2, - address(65536+1234), + address(65536 + 1234), signer, true, _getVotingAssetsWithSlotHash(votingAssetsWithSlot) diff --git a/verify.json b/verify.json new file mode 100644 index 0000000..b5c769f --- /dev/null +++ b/verify.json @@ -0,0 +1,6 @@ +{ + "transactions": [ + { "hash": "0xc70a091222673702ac90f67f41bc1f9ba4c0765fb90154f6093d28e660f8759d" } + ], + "chain": 59144 +}