-
Notifications
You must be signed in to change notification settings - Fork 384
[Rebased] Migrate governance tests from Truffle to Foundry #11415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/core-contracts/13
Are you sure you want to change the base?
[Rebased] Migrate governance tests from Truffle to Foundry #11415
Conversation
Co-authored-by: pahor167 <[email protected]>
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keccak256(abi.encodePacked("EpochManagerEnabler")); | ||
bytes32 internal constant EPOCH_MANAGER_REGISTRY_ID = keccak256(abi.encodePacked("EpochManager")); | ||
bytes32 internal constant ESCROW_REGISTRY_ID = keccak256(abi.encodePacked("Escrow")); | ||
// bytes32 internal constant EXCHANGE_REGISTRY_ID = keccak256(abi.encodePacked("Exchange")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they have been commented since CR12, they can be removed as they are not being used. Since this file is only used for testing, It should be safe to remove.
// import { BlockchainParameters } from "@celo-contracts/governance/BlockchainParameters.sol"; | ||
import { ICeloUnreleasedTreasury } from "@celo-contracts/common/interfaces/ICeloUnreleasedTreasury.sol"; | ||
import { ICeloToken } from "@celo-contracts/common/interfaces/ICeloToken.sol"; | ||
// import { DoubleSigningSlasher } from "@celo-contracts/governance/DoubleSigningSlasher.sol"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why these were added since they are not being used in this file.
Also note:
DownTimeSlasher
,DoubleSigningSlasher
,BlockchainParameters
have been deprecated post L2.
uint256 threshold = abi.decode( | ||
constitutionJson.parseRaw(string.concat(".", contractName, ".", functionName)), | ||
(uint256) | ||
string.concat(" Setting constitution thresholds for function: ", loop_.functionName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -7,7 +7,8 @@ contract MigrationsConstants is TestConstants { | |||
address constant DEPLOYER_ACCOUNT = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; | |||
|
|||
// List of contracts that are expected to be in Registry.sol | |||
string[27] contractsInRegistry = [ | |||
// TODO: Probably should be synced with Migration.s.sol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// doubleSigningSlasher = DoubleSigningSlasher( | ||
// registryContract.getAddressForOrDie(DOUBLE_SIGNING_SLASHER_REGISTRY_ID) | ||
// ); // FIXME: DoubleSigningSlasher is not in UsingRegistry.sol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above as to why they are no longer in registry.
@@ -95,14 +110,47 @@ contract UsingRegistryV2NoMento { | |||
return IAccounts(registryContract.getAddressForOrDie(ACCOUNTS_REGISTRY_ID)); | |||
} | |||
|
|||
// FIXME: Deprecated? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safe to remove, it's a helper anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would maybe add somewhere else, maybe inside migrations_sol
, because this will likely be out of scope in the next audit, but if we ever use it in production following that, then it wont show up in the diff and thus will not be audited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't change it, but I try not to do linting in PRs doing something else as they get hard to review, just a nit
uint256 proposalId | ||
) external view returns (address, uint256, uint256, uint256, string memory, uint256, bool); | ||
|
||
// referendum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
@@ -7,7 +7,8 @@ contract MigrationsConstants is TestConstants { | |||
address constant DEPLOYER_ACCOUNT = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; | |||
|
|||
// List of contracts that are expected to be in Registry.sol | |||
string[27] contractsInRegistry = [ | |||
// TODO: Probably should be synced with Migration.s.sol | |||
string[26] contractsInRegistry = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out how to make the compiler come up with the number of items automatically, maybe we should move to json at some point
@@ -45,7 +45,7 @@ while ! nc -z localhost $ANVIL_PORT; do | |||
done | |||
|
|||
# enabled logging | |||
cast rpc anvil_setLoggingEnabled true --rpc-url $ANVIL_RPC_URL | |||
cast rpc anvil_setLoggingEnabled $ANVIL_LOGGING_ENABLED --rpc-url $ANVIL_RPC_URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the default as true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, but I freshly changed it to true based on @pahor167 request 😁
JsonFiles memory files_ = JsonFiles( | ||
vm.readFile("./governanceConstitution.json"), // constitution json | ||
vm.readFile("./.tmp/selectors/Proxy.json") // proxy selectors | ||
); | ||
FileProps memory props_ = FileProps( | ||
vm.parseJsonKeys(files_.constitutionJson, ""), // contract names | ||
vm.parseJsonKeys(files_.constitutionJson, ".Proxy"), // proxy names | ||
vm.parseJsonKeys(files_.proxySelectors, "") // proxy sigs | ||
); | ||
|
||
// vars for looping | ||
LoopVars memory loop_; | ||
string memory contractSelectors_; | ||
string[] memory functionsWithTypes_; | ||
string[] memory functionNames_; | ||
|
||
// loop over contract names | ||
for (uint256 i = 0; i < props_.contractNames.length; i++) { | ||
loop_.contractName = props_.contractNames[i]; | ||
if (loop_.contractName.equals("Proxy")) { | ||
// skip proxy address | ||
continue; | ||
} else { | ||
// set address from registry | ||
loop_.contractAddress = registryContract.getAddressForStringOrDie(loop_.contractName); | ||
} | ||
|
||
// load selectors for given contract from file | ||
contractSelectors_ = vm.readFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this block (and beyond) duplicated from Migrations.s.sol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It overlaps with Migrations.s.sol to some extent -> will check how much I can de-duplicate it tomorrow 👍
Rebased clone of #11402
Description
PR porting old governance integration tests from Truffle as new governance e2e tests in Foundry
Other changes
I needed to fix
Migrations.s.sol
scripts and additionally added ton of small improvements over the way - including disabling anvil rpc call logging with env varTested
With e2e testing.
Related issues
Backwards compatibility
Previous integration tests in Truffle were not running currently, so it brings some of them back.
Documentation
Internal tooling - no changes here