Skip to content
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

[do not merge] Release 11 vs 12 - just to know how much has changed #11035

Draft
wants to merge 89 commits into
base: release/core-contracts/11
Choose a base branch
from

Conversation

pahor167
Copy link
Contributor

Description

A few sentences describing the overall effects and goals of the pull request's commits.
What is the current behavior, and what is the updated/expected behavior with this PR?

Other changes

Describe any minor or "drive-by" changes here.

Tested

An explanation of how the changes were tested or an explanation as to why they don't need to be.

Related issues

  • Fixes #[issue number here]

Backwards compatibility

Brief explanation of why these changes are/are not backwards compatible.

Documentation

The set of community facing docs that have been added/modified because of this change

jcortejoso and others added 30 commits January 29, 2024 11:31
* Remove references to packages deleted

* Remove circleci dockerfiles and workflow

* Delete reference to patches folder
* fix & cleanup

* fixed resolved field in lock file
* fixed gold token actors

* ++ doubleSigningSlasher test

* ∆ conflicting function name

* set epochSize manually
* adding ignore files for docker files and github

* update to use new workflow with security restrictions on container builds

* updating 2.0 to 2.1 workflow
* adding ignore files for docker files and github

* update to use new workflow with security restrictions on container builds

* updating 2.0 to 2.1 workflow

* fixing container versions
)

* docs(SECURITY): deletes `SECURITY.md` to inherit the default file

Maintained in https://github.com/celo-org/.github/blob/main/SECURITY.md

---------

Co-authored-by: arthurgousset <[email protected]>
* upgrade celo deps from dt repo

* remove exchange env test. the Contract is defunkt and mento owns the replacement. no need for a test here

* exchange no longer exists so we dont need to freeze or thaw it
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Fee Handler Foundry

* adds some tests, getting node-gyp errors so can't test

* saving progress

* saving progress

* fix compiler errors

* fix up through distribute test

* saving progress

* saving progress

* fixes a couple tests

* removes TODO

* get rid of last TODO

* add README

* deletes old tests

* fix build

* address README feedback

* addresses some feedback

* follow revert naming convention

* clarify distribute when balance is zero

* add event tests

* Update packages/protocol/test-sol/common/FeeHandler.t.sol

Co-authored-by: soloseng <[email protected]>

---------

Co-authored-by: pahor167 <[email protected]>
Co-authored-by: soloseng <[email protected]>
* fix: update USDCUSD config

* chore: update docker image version

Co-authored-by: Nelson Taveras <[email protected]>

---------

Co-authored-by: Nelson Taveras <[email protected]>
Co-authored-by: Nelson Taveras <[email protected]>
* Load test refactor. Included ordinals loadtest case

* Trigger container build

* Using maxFeePerGas and maxPriorityFeePerGas for ordinals txs

* Fix gas config

* Fix linter

* Prepare load-test small improvements
* Election up till activate

* ElectionValidatorSigners mostly done

* ElectionValidatorSigners done

* Last test batch missing

* All tests are working

* removal of election ts tests

* compilation CI fix

* utils added

* constants added

* minor refactor

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/voting/Election.t.sol

Co-authored-by: soloseng <[email protected]>

* buildable

* PR comments 2

* Missing tests added

* Split of the tests

---------

Co-authored-by: soloseng <[email protected]>
* test init

* deployed successful with correct owner

* passing initialize test using a tunnel

* passing setMembershipHistoryLength tests

* ++ more test

* enable skip

* ++ constants; more tests; cleanup

* ++ address to pubkey helper

* stuck on invalid blspop during registration

* Pinned submodule to specific tag/commit

* ++ more tests

* ++ tests

* reworked layout + test

* ++ affiliate tests

* ++ deaffiliate

* remove submodule

* re add submodule

* removed secp256k1 submodule

* adding the library directly to repo, as foundry does not build it otherwise

* ++ dev note

* updated yarn

* update contract name

* ++ updateEcdsaPublicKey; updatePublicKeys

* format

* ++ registerValidatorGroup

* yarn install

* ++deregisterValidatorGroup tests

* cleanup

* ++ add members tests

* comment

* ++ removeMember test

* cleanup

* ++ reorder tests

* ++ SetNextCommissionUpdate tests

* ++ updateCommission tests

* ++ calculateEpochScore tests

* ++ calculateGroupEpochScore tests

* ++ updateValidatorScoreFromSigner tests

* clean up

* ++ updateMembershipHistory tests

* ++ getMembershipInLastEpoch tests

* ++ getEpochSize test

* ++ getAccountLockedGoldRequirement tests

* ++ passing test

* ++ distributeEpochPaymentsFromSigner tests ;
++ forceDeaffiliateIfValidator tests

* ++ groupMembershipInEpoch tests

* ++ all other tests

* revert debug chages to contract

* cleanup

* Updated `celo-foundry` git module to point to `v0.5.13` branch

* ++ suggestions

* updated test name format

* PR feedback

* fixed redundant code
* Batched pending withdrawals

* Update packages/protocol/test-sol/governance/voting/LockedGold.t.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

---------

Co-authored-by: soloseng <[email protected]>
* wip

* WIP: Failing last test

* removed shadowed var

* using foundry invariant on pragma ^0.8.0

* working invariant tests

* code cleanup

* delete js test

* added most test for 0.5.13 pragma version as well

* following naming convention

* re-org files to avoid migration conflict

* restricted version to 0.8.0 or above

* ++ vs code settings ∆

* PR feedback
* Some tests

* addressToPublicKey tests

* Authorization tests yet missing

* All tests

* Move of ReleaseGold.t.sol

* removal of truffle test

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/governance/voting/ReleaseGold.t.sol

Co-authored-by: soloseng <[email protected]>

* build fix

* PR comments

* PR comments 2

* Removal of secp reference

* Removal of CI step

---------

Co-authored-by: soloseng <[email protected]>
It will be moved to the developer tooling repo as its more used there than here.

The one function that is used here has been lined in the place its used.
* Remove codecov status badge

* Remove deprecated codecov integration
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Victoria <[email protected]>
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Victoria <[email protected]>
…hanging workflow (#10636)

Update celo-blockchain version in test, and trigger tests when changing workflow file
* deleted comment

* Revert "deleted comment"

This reverts commit 2d0da96.

* WIP

* Finished tests

* cleanup

* Fixed constants file

* small lint

* removed ts tests

* fixed constants

* added day to constant

* Rename BlockchainParameters.t.Sol to BlockchainParameters.t.sol

* packages/protocol/test-sol/governance/network/BlockchainParameters.t.sol

* Check for tests with wrong extensions

* Fixed tests

* lint

* fixed broken test

* bad comment

* naming

* Reformatting and tests

* Removed ganache test job from the CI

* Delete packages/protocol/test-sol/fail.t.sol

* fail with wrong extension

* More rename and lint

* More formatting

* cleanup

* renamed SortedListedLink mock

* more renaming

* Delete packages/protocol/test-sol/common/fail.SOl

* Moved ElectionMock

* Moving more staff around

* Rolled back mock election

* typo

* Changed LinkedList name

* Delete packages/protocol/test-sol/common/Integration.t.sol

* Refactor Registry

* Fix multisig

* fix

* typos

* pr comments

* version update

* foundry config update

* foundry version hardcoded

* test fix

---------

Co-authored-by: pahor167 <[email protected]>
* Release: Sorted oracles update (#10891)

* Sorted oracles update

* integration test fixes

* constants added

* Update packages/protocol/contracts/stability/SortedOracles.sol

Co-authored-by: Martín Volpe <[email protected]>

* Removal of Mento reference

* Update packages/protocol/test-sol/stability/SortedOracles.t.sol

Co-authored-by: soloseng <[email protected]>

* Update packages/protocol/test-sol/stability/SortedOracles.t.sol

Co-authored-by: soloseng <[email protected]>

* PR comments

* Equivalent tokens on top of updated sorted oracles  (Based of CR10) (#10904)

* Brought changes from https://github.com/celo-org/celo-monorepo/pull/10895/files#diff-ba272032c5f1b7e89d5777b3c886685b581324bdf22733ee272e2790f5d631df

* Fuzzy added

---------

Co-authored-by: pahor167 <[email protected]>

* prettify fix

---------

Co-authored-by: Martín Volpe <[email protected]>
Co-authored-by: soloseng <[email protected]>

* FeeCurrency Adapter (#10907)

* FeeCurrency Adapter

* PR comments

* Format documents

* gitmodules

* submodules added

* solidity version fix

* OZ contracts same commit as master

* Revert "OZ contracts same commit as master"

This reverts commit 8d8f2d6.

* OZ to same commit as master

* Getter&Setter for wrapped token

* Proxy added

* split of FeeCurrencyAdapter

* prettier fix

* refactor

* Update packages/protocol/test-sol/stability/FeeCurrencyAdapter.t.sol

Co-authored-by: Martín Volpe <[email protected]>

* PR comments

* PR comments

* Decimals + Total supply added

* Update packages/protocol/contracts-0.8/stability/FeeCurrencyAdapter.sol

* Update packages/protocol/contracts-0.8/stability/FeeCurrencyAdapter.sol

* Trigger

* Wrapper reference removed

* interface added

---------

Co-authored-by: Martín Volpe <[email protected]>
Co-authored-by: Tim Moreton <[email protected]>
Co-authored-by: alvarof2 <[email protected]>

* Calculation of unlockable gold (#10731)

* Fix for historical vote records

* contractkit fix

* lint fix

* Governance version update

* PR comments

* extended test

* Remove console.log

* Test

* lint fix

* version fix

* version fix

---------

Co-authored-by: Martín Volpe <[email protected]>

* Gas Price Minimum should never be zero (#10909)

* GasPriceMinimum backward compatibility fix (#10922)

* Update Dockerfiles (#10915)

* Remove references to packages deleted

* Remove circleci dockerfiles and workflow

* Delete reference to patches folder

* Update workload-id-provider in metadata-crawler-build job (#10916)

Use `master` workload-id-provider pool

* fix ganache dependency resolution (#10917)

* fix & cleanup

* fixed resolved field in lock file

* test

* Tooling fix

* lint fix

* revert of gas price minimum

* Update packages/protocol/lib/compatibility/ast-code.ts

Co-authored-by: Martín Volpe <[email protected]>

---------

Co-authored-by: Javier Cortejoso <[email protected]>
Co-authored-by: soloseng <[email protected]>
Co-authored-by: Martín Volpe <[email protected]>

* Storage gap for FeeCurrencyAdapter (#10933)

Storage gap

* Debit 0 value check (#10930)

* Removal of SortedOracle multiplier (#10931)

* Removal of SortedOracle multiplier

* removal of comment

* Make super of FeeCurrencyAdapterOwnable.sol explicit (#10944)

* Added note to FeeCurrencyAdapter.sol initializer (#10943)

* FeeAdapter debit round up (#10940)

* Round up of debit

* PR comments

* Code quality post audit (#10945)

Code quality

* SortedOracles sourced from Mento core for CR10 (#10946)

* SortedOracles sourced from Mento core

* PR comments

* Update gap size to follow 50 rule (#10948)

* CR11 fix verification (#10951)

* Force AddressSortedLinkedListWithMedian library redeploy for CR11

* CI fix

* PR comments

* yarn lock

* Updates specification of SrotedOracles (#10970)

* Update Natspec for FeeAdapter (#10969)

* dockerfile

---------

Co-authored-by: Martín Volpe <[email protected]>
Co-authored-by: soloseng <[email protected]>
Co-authored-by: Tim Moreton <[email protected]>
Co-authored-by: alvarof2 <[email protected]>
Co-authored-by: Javier Cortejoso <[email protected]>
* ++ @celo/dev-utils to dev dependencies

* - updated to use CR 11 instead of 10
- removed general test

* Bump lockedGold contract version

* revert version ∆

* removed unused env var

* bump contract versions
* L2 migration infra

* refactor

* refactor
soloseng and others added 4 commits June 18, 2024 10:27
* test: proof of concept 2e2 test using anvil devchain (#11020)

* chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..`

* test(test-sol/FeeCurrencyDirectory)): MVP e2e test

MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end.

* chore(foundry.toml): adds `@test-sol` remapping

* chore(test-sol/e2e): adds MVP `utils.sol`

Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain.

* test(FeeCurrencyDirectory): MVP test using `Devchain` class

* chore(migrations_sol): adds MVP script to run e2e tests

* style(test-sol/e2e): linting

* refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/`

* chore(migrations_sol): use `test-sol/e2e/*` path

* chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test

* style(test-sol/FeeCurrencyDirectory): linting

* chore(e2e/utils): removes unused imports and more

Cleans up
Adds `TODO` comments

* test(test-sol/e2e): renames contract with "E2E..."

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* chore(workflows/protocol_tests): excludes e2e test from workflow

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* style(test-sol/e2e): linting

* chore(e2e): temporarily renames contract with "E2E..."

In subsequent PRs, I'll rename this more accurately.

* set EpochSize on L2

* allow voting and activating

* move election test contract to vote dir

* updated test to allow testing of L2 with no reward distribution

* feat: add ReserveSpenderMultiSig to anvil migrations (#11028)

* feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs

* feat(migrations_sol): adds `migrateReserveSpenderMultiSig`

Also adds contract calls in `migrateReserve` function.
Not tested, and not sure this works yet. I might be missing some changes.

* chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol`

From the code comment:

  The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`.
  This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its
  artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations
  script, but because it's on Solidity 0.5 it can't be imported there directly.
  If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without
  this file, this file can confidently be deleted.

* feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig`

The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function.

* chore(migrations_sol): initialize `ReserveSpenderMultiSig`

* chore(migrations_sol): adds code comment for readability

* chore(migrations_sol): improves code comment, moves code block up

* chore(migrations_sol): fix typo

* style(migrations_sol): linting

* test: refactor foundry test directory into unit, e2e, and integration tests (#11023)

* chore(foundry.toml): adds `@mento-core/...` remapping

Also moves existing mappings into groups for better readability

* refactor(test-sol/common): moves files to `unit/common/`

Also updates imports respectively using remappings.

* refactor(test-sol/identity): moves files to `unit/identity/`

Also updates imports using remappings where necessary.

* refactor(test-sol/stability): moves files to `unit/stability/`

Also updates imports using remappings where necessary.

* refactor(test-sol/voting): moves files to `unit/voting/`

Also updates imports using remappings where necessary.

* refactor(test-sol/governance): moves files to `unit/governance/`

Also updates imports using remappings where necessary.

* chore(test-sol): update missing remappings

With these changes all contracts compile and resolve correctly.

* chore(workflows/protocol_tests): updates paths to `test-sol/unit`

* chore(workflows/protocol_tests): adds integration and e2e tests

* style(workflows/protocol_tests): refactors `forge test` for better readability

* chore(migrations_sol): moves scripts to `scripts/foundry/

Moves all bash scripts from `migrations_sol` to `scripts/foundry/`, and updates paths where necessary. We already have a directory for `scripts/truffle/` and `scripts/bash/`, so this makes it easier to find foundry-related bash scripts.

* test(governance/mock): move `MockGovernance` to `unit/` folder

* refactor(foundry.toml): rename `migrations-sol/` remapping

* refactor(workflows): refactor "run everything" step

Runs all tests in the `unit/` directory instead of all test files in the repo.
This makes sense from my perspective, because e2e tests (in the `e2e/` directory) and integration tests (in the `integration/` directory) require a connection to an anvil devchain serving at localhost.

The intent of this command is to ensure that no unit tests are forgotten, since unit tests are run explicitly by going through the directories above. But, the intention is not to run all tests in the repo generally.

* style(workflows/protocol-devchain-anvil): splits migration into 2 steps

This helps the script becoming more readable, and ensure error logs are clearly associated with a workflow step rather than a single bash script.

* chore(workflows): defines `ANVIL_PORT` env variable in workflow

Previously, the `$ANVIL_PORT` variable was exported and passed around as an env variable in a bash script.

But that required generating anvil migrations and running a devchain repeatedly.
Instead, the workflow does that once and different steps can access the devchain.

But, in that case the env variable is not passed around, so it has to be defined at the workflow level.

Source: https://docs.github.com/en/actions/learn-github-actions/variables

* chore(workflows/protocol_tests): removes code comment

* feat(scripts/foundry): adds `stop_anvil.sh`

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* feat(protocol/package.json): adds `anvil-devchain:...` (`start` and `stop`)

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* refactor(migrations_sol): update `@migrations-sol` remapping

Previous the remapping was called `@celo-migrations`.

* docs(migrations_sol/README): renames README file

Also changes title to match NPM package name. This is a matter of personal preference. IMO this is a small improvement in readability for 3rd party users.

* docs(scripts/foundry): adds more links to `package.json`

Adds `repository` and `directory` to `package.json`.
This ensures npmjs.org displays hyperlinks to the github repository.

* docs(migrations_sol/CONTRIBUTING): adds MVP dev docs

We can complete this doc with additional information regarding the anvil devchain and migrations going forward.

* docs(migrations_sol/README): adds "how we work" section

This is helpful for 3rd party developers that found this package on npmjs.org.
The links help developers take action and help improve the anvil devchain.

* lint: function order

* Soloseng/CHORE-update-workflow (#11029)

* update workflow to run on push to release branches

* ++ mintgoldschedule to migration test constants

* initial validators contract review

* Remove block gas limit flag for `governance/voting` CI tests

* bump version

* ++ tests && format

* removed comments

* getValidatorGroupSlashingMultiplier allowed only on L1

* reverting changes to test contract size issue

* minimal changes

* allow slashing multiplier reset on L2

---------

Co-authored-by: Arthur Gousset <[email protected]>
* Yaml file drafts

* Update COPUSD Config

* Update KESUSD and rename USDKES.yaml to KESUSD.yaml

* Rename USDCOP.yaml to COPUSD.yaml

* Adding KESUSD data source

* CELOKES and KESUSD config

* chore: test USDTUSD config

* fix: remove openexchangerates from kesusd

* chore: add pair constants

* chore: add alfajores & baklava kesusd and usdtusd addresses

* fix: use pnpm instead of yarn

* fix: update min oracles for CELOKES

* chore: add mainnet kes hsms

* USDTUSD config from Nadiem

* test: proof of concept 2e2 test using anvil devchain (#11020)

* chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..`

* test(test-sol/FeeCurrencyDirectory)): MVP e2e test

MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end.

* chore(foundry.toml): adds `@test-sol` remapping

* chore(test-sol/e2e): adds MVP `utils.sol`

Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain.

* test(FeeCurrencyDirectory): MVP test using `Devchain` class

* chore(migrations_sol): adds MVP script to run e2e tests

* style(test-sol/e2e): linting

* refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/`

* chore(migrations_sol): use `test-sol/e2e/*` path

* chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test

* style(test-sol/FeeCurrencyDirectory): linting

* chore(e2e/utils): removes unused imports and more

Cleans up
Adds `TODO` comments

* test(test-sol/e2e): renames contract with "E2E..."

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* chore(workflows/protocol_tests): excludes e2e test from workflow

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* style(test-sol/e2e): linting

* chore(e2e): temporarily renames contract with "E2E..."

In subsequent PRs, I'll rename this more accurately.

* chore: latest deployed images

* feat: add ReserveSpenderMultiSig to anvil migrations (#11028)

* feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs

* feat(migrations_sol): adds `migrateReserveSpenderMultiSig`

Also adds contract calls in `migrateReserve` function.
Not tested, and not sure this works yet. I might be missing some changes.

* chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol`

From the code comment:

  The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`.
  This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its
  artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations
  script, but because it's on Solidity 0.5 it can't be imported there directly.
  If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without
  this file, this file can confidently be deleted.

* feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig`

The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function.

* chore(migrations_sol): initialize `ReserveSpenderMultiSig`

* chore(migrations_sol): adds code comment for readability

* chore(migrations_sol): improves code comment, moves code block up

* chore(migrations_sol): fix typo

* style(migrations_sol): linting

* test: refactor foundry test directory into unit, e2e, and integration tests (#11023)

* chore(foundry.toml): adds `@mento-core/...` remapping

Also moves existing mappings into groups for better readability

* refactor(test-sol/common): moves files to `unit/common/`

Also updates imports respectively using remappings.

* refactor(test-sol/identity): moves files to `unit/identity/`

Also updates imports using remappings where necessary.

* refactor(test-sol/stability): moves files to `unit/stability/`

Also updates imports using remappings where necessary.

* refactor(test-sol/voting): moves files to `unit/voting/`

Also updates imports using remappings where necessary.

* refactor(test-sol/governance): moves files to `unit/governance/`

Also updates imports using remappings where necessary.

* chore(test-sol): update missing remappings

With these changes all contracts compile and resolve correctly.

* chore(workflows/protocol_tests): updates paths to `test-sol/unit`

* chore(workflows/protocol_tests): adds integration and e2e tests

* style(workflows/protocol_tests): refactors `forge test` for better readability

* chore(migrations_sol): moves scripts to `scripts/foundry/

Moves all bash scripts from `migrations_sol` to `scripts/foundry/`, and updates paths where necessary. We already have a directory for `scripts/truffle/` and `scripts/bash/`, so this makes it easier to find foundry-related bash scripts.

* test(governance/mock): move `MockGovernance` to `unit/` folder

* refactor(foundry.toml): rename `migrations-sol/` remapping

* refactor(workflows): refactor "run everything" step

Runs all tests in the `unit/` directory instead of all test files in the repo.
This makes sense from my perspective, because e2e tests (in the `e2e/` directory) and integration tests (in the `integration/` directory) require a connection to an anvil devchain serving at localhost.

The intent of this command is to ensure that no unit tests are forgotten, since unit tests are run explicitly by going through the directories above. But, the intention is not to run all tests in the repo generally.

* style(workflows/protocol-devchain-anvil): splits migration into 2 steps

This helps the script becoming more readable, and ensure error logs are clearly associated with a workflow step rather than a single bash script.

* chore(workflows): defines `ANVIL_PORT` env variable in workflow

Previously, the `$ANVIL_PORT` variable was exported and passed around as an env variable in a bash script.

But that required generating anvil migrations and running a devchain repeatedly.
Instead, the workflow does that once and different steps can access the devchain.

But, in that case the env variable is not passed around, so it has to be defined at the workflow level.

Source: https://docs.github.com/en/actions/learn-github-actions/variables

* chore(workflows/protocol_tests): removes code comment

* feat(scripts/foundry): adds `stop_anvil.sh`

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* feat(protocol/package.json): adds `anvil-devchain:...` (`start` and `stop`)

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* refactor(migrations_sol): update `@migrations-sol` remapping

Previous the remapping was called `@celo-migrations`.

* docs(migrations_sol/README): renames README file

Also changes title to match NPM package name. This is a matter of personal preference. IMO this is a small improvement in readability for 3rd party users.

* docs(scripts/foundry): adds more links to `package.json`

Adds `repository` and `directory` to `package.json`.
This ensures npmjs.org displays hyperlinks to the github repository.

* docs(migrations_sol/CONTRIBUTING): adds MVP dev docs

We can complete this doc with additional information regarding the anvil devchain and migrations going forward.

* docs(migrations_sol/README): adds "how we work" section

This is helpful for 3rd party developers that found this package on npmjs.org.
The links help developers take action and help improve the anvil devchain.

* Soloseng/CHORE-update-workflow (#11029)

* update workflow to run on push to release branches

* ++ mintgoldschedule to migration test constants

* set celo-foundry to 0.5

* force CI test after changing PR base

---------

Co-authored-by: Nadiem Sissouno <[email protected]>
Co-authored-by: Nadiem Sissouno <[email protected]>
Co-authored-by: Nelson Taveras <[email protected]>
Co-authored-by: Arthur Gousset <[email protected]>
Co-authored-by: soloseng <[email protected]>
* modified L2 CELO distribution logic

* rename functions

* ++ more name changes

* change more variable names

* ∆ gold to celo in contract

* contract rename

* forgotten names
* total supply update

* lint

* lint2

* hardcode L2toL1MessagePasser

* revert increaseSupply

* update goldtoken
@martinvol martinvol changed the title Release 11 vs 12 - just to know how much has changed [do not merge] Release 11 vs 12 - just to know how much has changed Jun 24, 2024
soloseng and others added 6 commits June 24, 2024 13:48
…ages (#11041)

* updated script to allow for versioning devchain-anvil package

* run in PR as well

* reorg workflow to install node

* fixed utils test

* ++ workflow dispatch
* use the existing `build_artifacts` arg to also fetch 0.8 contracts

* git force run tests
* Updated Using registry v2

* using ICeloToken interface in distribution

* updated contracts to use `getCeloToken` instead of `getGoldToken`

* Changed `GOLD_TOKEN_REGISTRY_ID` to `CELO_TOKEN_REGISTRY_ID` throughtout repo

* fix tests

* replaced gold with celo

* updated migrations

* Bump version

* ++ celoToken & lockedCelo to registry during migration

* removed celoToken and LockedCelo from bytecode check

* update interface

* fixed LockedGold migration

* fix test

* ∆ gold name
Copy link

openzeppelin-code bot commented Jul 1, 2024

[do not merge] Release 11 vs 12 - just to know how much has changed

Generated at commit: c5eff1cc2ab04ed3522241222e4267203e0606ae

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
2
3
0
15
41
61
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

soloseng and others added 4 commits July 2, 2024 12:03
* initial work

* accounting debug

* disable CELO transfers to celoDistribution schedule

* removed debug logs

* ++ celoDistributionSchedule to `usingRegistry` contract.

* Moved setting registry address to initialize function

* ∆ execution order

* updated release data

* updated variable name in test

* test fix

* ++ native transfer test
#11046)

refactor(workflows): reads supported Foundry version from env variable
* set override the default version

* ++ npm tag in workflow trigger

* PR feedback
* refactor(scripts/foundry): moves `run_e2e_tests...sh` file

Small house-keeping change to keep Foundry-related bash scripts organised in a single directory. This script doesn't seem to be called from anywhere, and doesn't have a yarn command in `package.json` so it was fine to move it without any changes in other files.

* feat(package.json): adds yarn commands for e2e and integration tests

Two helper commands to run two Foundry-related bash scripts during local development.

* refactor(migrations_sol): groups imports for better readability

* feat(scripts/foundry): adds MVP L2 migration script

Successfully deploys bytecode to `proxyAdminAddress`.
Does not yet dump state correctly, or call functions to active L2 correctly.

* feat(package.json): adds two helper yarn commands

1. `anvil-devchain:start-L2`: which creates and migrates an L2 devchain
2. `anvil-devchain:check-is-running`: which can be used to check that an anvil instance is running locally and serving at localhost:8546

* chore(migrations_sol): fix typo in function name

* chore(migrations_sol): nit simplifies code comment for better readability

* feat(scripts/foundry): activates CeloDistributionSchedule

Now successfully activates CeloDistributionSchedule.
Does not yet dump state correctly

* refactor(scripts/foundry): moves variables to `constants.sh`

Simplifies maintenance and readability of scripts.

* refactor(scripts/foundry): moves more variables to `constants.sh`

Simplifies maintenance and readability of scripts.

* refactor(constants.sh): read bytecode from Foundry instead of Truffle

* chore(scripts/foundry): adds TODO comment

At this point, the migration works as intended and the L2 is activated.
But, I haven't yet saved the devchain state file.
I'll need to refactor the way the L1 and L2 move the state file around.

* refactor(scripts/foundry): rename to `create_and_migrate_anvil_l2_devchain.sh`

To keep it consistent with the L1 script

* style(migrations_sol): linting

* chore(scripts/foundry): remove debugging statements

* refactor(constants): adds L1 and L2 state file names

* feat(scripts/foundry): successfully dumps L2 state

* refactor(constants): uses `$ANVIL_RPC_URL` instead of hardcoded URL

* refactor(constants): moves libraries to constants

* fix(constants): adds `$PWD` to prevent errors on CI

On CI it seems like `jq` doesn't find the artifacts without an explicit path

```sh
./scripts/foundry/create_and_migrate_anvil_devchain.sh
  shell: /usr/bin/bash -e {0}
  env:
    FOUNDRY_CACHE_KEY: 2
    SUPPORTED_FOUNDRY_VERSION: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9
    ANVIL_PORT: 8546
jq: error: Could not open file build/contracts/Registry.json: No such file or directory
jq: error: Could not open file build/contracts/Proxy.json: No such file or directory
```

Source: https://github.com/celo-org/celo-monorepo/actions/runs/9808280627/job/27083755032#step:18:9

* chore(workflows): debugging `jq` error on CI

Can't find build artifacts on CI, so trying to work out what might be wrong.

* fix(constants): moves bytecode operation back into scripts

Since the constants are read before any foundry compilation occured, the constants can't read from the Foundry artifacts. Locally, I missed this because I had existing artifacts from previous compilations.

* chore(workflows): debugging `jq` CI error

* fix(scripts/foundry): uses Foundry `out/` directory

Mistakenly read artifacts from Truffle's `build/` directory. Took a while to remember that Foundry write artifacts to `out/`.

Source: https://book.getfoundry.sh/reference/forge/forge-build#build-modes

* chore(scripts/foundry): removes debugging statement

* feat(package.json): updates yarn command names

* docs(CONTRIBUTING): updates yarn command docs

* chore(workflows): add back NPM install step

Not confident enough to remove it in this PR.

* chore(workflows): removes code comment

* feat(workflows): publishes L1 and L2 state

Also updates integration test to explicitly run against L1 devchain, and not L2 devchain.

* fix(scripts/foundry): remove unnecessary `stop_anvil` call

CI doesn't like `lsof` command in `stop_anvil.sh`

```sh
/runner/_work/celo-monorepo/celo-monorepo/packages/protocol/scripts/foundry/stop_anvil.sh: line 10: lsof: command not found
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
```

Source: https://github.com/celo-org/celo-monorepo/actions/runs/9811181588/job/27092901761?pr=11107#step:19:7073

* refactor(workflows): replace CI env with variable from `constants.sh`

Simplifies code and makes it easier to update ports in a single place.

* fix(workflows): adds back `stop_anvil.sh` and installs `lsof` explicitly

CI fails if I don't explicitly kill an existing anvil server, so I decided to install `lsof` which is used by `stop_anvil.sh` to kill processes.

```sh
error binding to 127.0.0.1:8546: error creating server listener: Address already in use (os error 98)
```

Source: https://github.com/celo-org/celo-monorepo/actions/runs/9811346558/job/27093342967?pr=11107#step:20:30

* chore(scripts/foundry): removes code comment

* fix(workflows): install `lsof` in the same step

Not sure if that's the bug, but the last run where the installation and use was in different steps didn't work.

* fix(workflows): hacky fix to run L2 anvil

I'm struggling to terminate the previous anvil server and re-start a new anvil server at the same address (local host 8546).

I tried to work around cumbersome CI environment issues (`lsof` which we use to identify the process is not available on CI).

For now, as a quick fix, I'll start anvil at an arbitrary different port 8547 and run the test against that localhost 8547.

I'll need to refactor this better.

* refactor(scripts/foundry): simplifying `lsof` query to find PID

* fix(workflows): try to terminate anvil server again

* fix(workflows): hacky workaround to prevent Anvil bug when loading state

Starting L1 from scratch instead of JSON state to circumvent this Anvil bug foundry-rs/foundry#7502.

* Update .github/workflows/protocol-devchain-anvil.yml

Co-authored-by: soloseng <[email protected]>

* Update .github/workflows/protocol-devchain-anvil.yml

Co-authored-by: soloseng <[email protected]>

* feat(constants): set CeloDistributionSchedule initial balance to 700M CELO

Arbitrary amount chosen to be approximately equal to `GoldToken.totalSupply()` on the L1 Mainnet (695,313,643 CELO as of this commit). During the real L2 genesis, the VM will calculate and set an appropriate balance.

```sh
# Get address of GoldToken
$ cast call \
0x000000000000000000000000000000000000ce10 \
"getAddressForStringOrDie(string calldata identifier)(address)" \
"GoldToken" \
--rpc-url https://forno.celo.org
0x471EcE3750Da237f93B8E339c536989b8978a438

# Call `totalSupply()` on `GoldToken.sol`
$ cast call \
0x471EcE3750Da237f93B8E339c536989b8978a438 \
"totalSupply()(uint256)" \
--rpc-url https://forno.celo.org
695313643195035937058427065 [6.953e26]

# Convert units from wei to ether
$ cast to-unit 695313643195035937058427065 ether
695313643.195035937058427065
```

* docs(README): improves README

More context, examples, background, files in the package.

---------

Co-authored-by: soloseng <[email protected]>
Copy link

gitguardian bot commented Jul 12, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
10538986 Triggered Generic High Entropy Secret 5c401a3 packages/protocol/scripts/foundry/constants.sh View secret
10538986 Triggered Generic High Entropy Secret 533ccd1 packages/protocol/scripts/foundry/constants.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

arthurgousset and others added 13 commits July 15, 2024 17:08
chore(constant): fix CeloDistributionSchedule initial balance
* lint: function ordering

* Deprecate L1 hotfix;
Implement L2 hotfix;

* BUMP version

* prepare hotfix on L2

* cleanup

* ++ setters and checks

* ++ more test cases

* PR feedback

* PR feedback

* PR feedback

* resetHotfix is public

* test: proof of concept 2e2 test using anvil devchain (#11020)

* chore(test-sol/FeeCurrencyDirectory)): use `@celo-...` remapping not `../..`

* test(test-sol/FeeCurrencyDirectory)): MVP e2e test

MVP demo of an e2e test using the devchain. This is not the pattern I'll suggest, but good to see the test passes end-to-end.

* chore(foundry.toml): adds `@test-sol` remapping

* chore(test-sol/e2e): adds MVP `utils.sol`

Idea is to have a Devchain class that can be inherited by Test contracts to have access to the deployed contracts on the devchain.

* test(FeeCurrencyDirectory): MVP test using `Devchain` class

* chore(migrations_sol): adds MVP script to run e2e tests

* style(test-sol/e2e): linting

* refactor(test-sol/FeeCurrencyDirectory): moves file to `.../e2e/`

* chore(migrations_sol): use `test-sol/e2e/*` path

* chore(test-sol/FeeCurrencyDirectory): match contract name in unit and e2e test

* style(test-sol/FeeCurrencyDirectory): linting

* chore(e2e/utils): removes unused imports and more

Cleans up
Adds `TODO` comments

* test(test-sol/e2e): renames contract with "E2E..."

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* chore(workflows/protocol_tests): excludes e2e test from workflow

I'm temporarily adding the "E2E..." prefix to the contract so I can exclude this test and the integration tests during the CI run.

In a separate PR, I'll refactor the tests into a directory structure like:

```
test-sol/unit/
test-sol/e2e/
test-sol/integration/
```

That way we could run tests with something like this:

```
# unit tests
forge test --match-path "*test-sol/unit/*"

# e2e tests
forge test --match-path "*test-sol/e2e/*"

# integration tests
forge test --match-path "*test-sol/integration/*"
```

* style(test-sol/e2e): linting

* chore(e2e): temporarily renames contract with "E2E..."

In subsequent PRs, I'll rename this more accurately.

* feat: add ReserveSpenderMultiSig to anvil migrations (#11028)

* feat(migrations_sol/migrationsConfig): adds `reserveSpenderMultiSig` configs

* feat(migrations_sol): adds `migrateReserveSpenderMultiSig`

Also adds contract calls in `migrateReserve` function.
Not tested, and not sure this works yet. I might be missing some changes.

* chore(test-sol/utils): adds `ReserveSpenderMultiSig.t.sol`

From the code comment:

  The purpose of this file is not to provide test coverage for `ReserveSpenderMultiSig.sol`.
  This is an empty test to force foundry to compile `ReserveSpenderMultiSig.sol`, and include its
  artifacts in the `/out` directory. `ReserveSpenderMultiSig.sol` is needed in the migrations
  script, but because it's on Solidity 0.5 it can't be imported there directly.
  If there is a better way to force foundry to compile `ReserveSpenderMultiSig.sol` without
  this file, this file can confidently be deleted.

* feat(migrations_sol/HelperInterFaces): adds `IReserveSpenderMultiSig`

The helper interface is used as a workaround to allow the migrations script (`Migrations.s.sol`) to be on Solidity 0.8, while the ReserveSpenderMultiSig contract is on Solidity 0.5. The migration script only needs to initialize the contract, which is why the helper interface only defines an `initialize` function.

* chore(migrations_sol): initialize `ReserveSpenderMultiSig`

* chore(migrations_sol): adds code comment for readability

* chore(migrations_sol): improves code comment, moves code block up

* chore(migrations_sol): fix typo

* style(migrations_sol): linting

* test: refactor foundry test directory into unit, e2e, and integration tests (#11023)

* chore(foundry.toml): adds `@mento-core/...` remapping

Also moves existing mappings into groups for better readability

* refactor(test-sol/common): moves files to `unit/common/`

Also updates imports respectively using remappings.

* refactor(test-sol/identity): moves files to `unit/identity/`

Also updates imports using remappings where necessary.

* refactor(test-sol/stability): moves files to `unit/stability/`

Also updates imports using remappings where necessary.

* refactor(test-sol/voting): moves files to `unit/voting/`

Also updates imports using remappings where necessary.

* refactor(test-sol/governance): moves files to `unit/governance/`

Also updates imports using remappings where necessary.

* chore(test-sol): update missing remappings

With these changes all contracts compile and resolve correctly.

* chore(workflows/protocol_tests): updates paths to `test-sol/unit`

* chore(workflows/protocol_tests): adds integration and e2e tests

* style(workflows/protocol_tests): refactors `forge test` for better readability

* chore(migrations_sol): moves scripts to `scripts/foundry/

Moves all bash scripts from `migrations_sol` to `scripts/foundry/`, and updates paths where necessary. We already have a directory for `scripts/truffle/` and `scripts/bash/`, so this makes it easier to find foundry-related bash scripts.

* test(governance/mock): move `MockGovernance` to `unit/` folder

* refactor(foundry.toml): rename `migrations-sol/` remapping

* refactor(workflows): refactor "run everything" step

Runs all tests in the `unit/` directory instead of all test files in the repo.
This makes sense from my perspective, because e2e tests (in the `e2e/` directory) and integration tests (in the `integration/` directory) require a connection to an anvil devchain serving at localhost.

The intent of this command is to ensure that no unit tests are forgotten, since unit tests are run explicitly by going through the directories above. But, the intention is not to run all tests in the repo generally.

* style(workflows/protocol-devchain-anvil): splits migration into 2 steps

This helps the script becoming more readable, and ensure error logs are clearly associated with a workflow step rather than a single bash script.

* chore(workflows): defines `ANVIL_PORT` env variable in workflow

Previously, the `$ANVIL_PORT` variable was exported and passed around as an env variable in a bash script.

But that required generating anvil migrations and running a devchain repeatedly.
Instead, the workflow does that once and different steps can access the devchain.

But, in that case the env variable is not passed around, so it has to be defined at the workflow level.

Source: https://docs.github.com/en/actions/learn-github-actions/variables

* chore(workflows/protocol_tests): removes code comment

* feat(scripts/foundry): adds `stop_anvil.sh`

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* feat(protocol/package.json): adds `anvil-devchain:...` (`start` and `stop`)

* refactor(scripts/foundry): use `stop_anvil.sh` to stop anvil

* refactor(migrations_sol): update `@migrations-sol` remapping

Previous the remapping was called `@celo-migrations`.

* docs(migrations_sol/README): renames README file

Also changes title to match NPM package name. This is a matter of personal preference. IMO this is a small improvement in readability for 3rd party users.

* docs(scripts/foundry): adds more links to `package.json`

Adds `repository` and `directory` to `package.json`.
This ensures npmjs.org displays hyperlinks to the github repository.

* docs(migrations_sol/CONTRIBUTING): adds MVP dev docs

We can complete this doc with additional information regarding the anvil devchain and migrations going forward.

* docs(migrations_sol/README): adds "how we work" section

This is helpful for 3rd party developers that found this package on npmjs.org.
The links help developers take action and help improve the anvil devchain.

* Soloseng/CHORE-update-workflow (#11029)

* update workflow to run on push to release branches

* ++ mintgoldschedule to migration test constants

* fixed inheritance

* added pretest check

---------

Co-authored-by: Arthur Gousset <[email protected]>
Co-authored-by: Leszek Stachowski <[email protected]>
* added check to activate function

* Updated function name

* changed the check to make sure that the address set in the goldToken contract is actually the celoDistributionSchedule contract address

* Use celoDistributionSchedule address set in registry instead of setting in CeloToken contract manually

* PR feedback

* ++ celo distribution schedule to registry

* updated path and added missing address to registry

* using 0.8 artifacts

* ++ comment
… anvil (#11148)

* test(devchain/e2e): moves e2e demo test into new `devchain/` directory

This allows us to exclude all tests in the `devchain/` directory when running `forge test`

* test(devchain/migration): renames migration test to Migration.t.sol

Previously this was called Integration.t.sol, but that's not super obvious naming.

* feat(foundry.toml): excludes `/devchain` directory when running `forge test`

* feat(foundry.toml): adds profile for tests that require a devchain

The configs of this profile extend or overwrite the default profile. That means we can customise the `match_path` and `no_match_path` configs in that profile and run `forge test` with that profile by passing an environment variable `FOUNDRY_PROFILE=devchain`.

For example, once a devchain is serving at localhost:

```sh
FOUNDRY_PROFILE=devchain forge test -vvv \
--match-path "test-sol/devchain/e2e/*" \
--fork-url $ANVIL_RPC_URL
[⠒] Compiling...
No files changed, compilation skipped

Ran 1 test for test-sol/devchain/e2e/common/FeeCurrencyDirectory.t.sol:E2EDemo
[PASS] test_ShouldAllowOwnerSetCurrencyConfig() (gas: 94493)
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 12.92ms (2.35ms CPU time)

Ran 1 test suite in 164.71ms (12.92ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
```

* docs(devchain/README): adds documentation for future reference

* feat(workflows): adds profile env variable to CI workflows

This ensures that the correct profile is consumed on CI and the correct tests are run.

* feat(workflows): adds profile env variable to CI workflows

This ensures that the correct profile is consumed on CI and the correct tests are run.

* Trigger Build

* docs(README): add note on devchain tests

Co-authored-by: Martín Volpe <[email protected]>

---------

Co-authored-by: alvarof2 <[email protected]>
Co-authored-by: Martín Volpe <[email protected]>
)

* feat(test-sol/constants): adds registryAddress and proxyAdminAddress

* style(test-sol/constants): improves code comment

* refactor(test-sol/e2e/utils): use `REGISTRY_ADDRESS`

* refactor(migrations_sol): rename to `MigrationsConstants`

To avoid import clashes when importing `TestConstants` from `test-sol` as well.
Previously, both classes were called `Constants`, which leads to import clashes.

* refactor(test-sol): rename to `TestConstants`

To avoid import clashes when importing `MigrationsConstants` from `migrations_sol` as well.
Previously, both classes were called `Constants`, which leads to import clashes.

* refactor(Integration.t.sol): use `REGISTRY_ADDRESS`

* refactor(RevokeCeloAfterL2Transition.sol): use `REGISTRY_ADDRESS`

* refactor(RevokeCeloAfterL2Transition.sol): use constants

* refactor(Accounts.t.sol): use constants

* refactor(CeloDistributionSchedule): use constants in `setUp()`

* refactor(CeloDistributionSchedule): use constants across file

* test(CeloDistributionSchedule): revert to previous variable in broken test

This test fails with this change

```diff
- celoDistributionSchedule.initialize(registryAddress);
+ celoDistributionSchedule.initialize(REGISTRY_ADDRESS);
```

```sh
forge test -vvv \
--match-path "test-sol/unit/*"

Failing tests:
Encountered 1 failing test in test-sol/unit/common/CeloDistributionSchedule.t.sol:CeloDistributionScheduleTest_activate
[FAIL. Reason: call reverted as expected, but without data] test_Reverts_WhenRegistryNotUpdated() (gas: 1877202)

Encountered a total of 1 failing tests, 2202 tests succeeded
```

But, passes with this change:

```diff
- celoDistributionSchedule.initialize(registryAddress);
+ celoDistributionSchedule.initialize(PROXY_ADMIN_ADDRESS);
```

```sh
$ forge test -vvv \
--match-path "test-sol/unit/*"

# ...
Ran 360 test suites in 4.60s (11.71s CPU time): 2203 tests passed, 0 failed, 0 skipped (2203 total tests)
```

I can sort of see why that's the case. In the current `setUp()` function the L2 is activated by arbitrarily deploying `Registry.sol` bytecode to the `proxyAdminAddress`.

https://github.com/celo-org/celo-monorepo/blob/9d0276d9fd47471667ff577165f92d45e76a18c8/packages/protocol/test-sol/unit/common/CeloDistributionSchedule.t.sol#L68-L75

My hunch is that this _empty_ Registry is then used in this test. Since it's empty these two `UsingRegistry()` getters fails as expected by this test

https://github.com/celo-org/celo-monorepo/blob/9d0276d9fd47471667ff577165f92d45e76a18c8/packages/protocol/contracts-0.8/common/CeloDistributionSchedule.sol#L77-L79

https://github.com/celo-org/celo-monorepo/blob/9d0276d9fd47471667ff577165f92d45e76a18c8/packages/protocol/contracts-0.8/common/UsingRegistry.sol#L82-L85

https://github.com/celo-org/celo-monorepo/blob/9d0276d9fd47471667ff577165f92d45e76a18c8/packages/protocol/contracts/common/Registry.sol#L49-L53

In my opinion, this is a janky way to test that the contract call reverts.

My reasoning and things I'd change:
1. `proxyAdminAddress` will not necessarily have `Registry` bytecode. _Any_ arbitrary bytecode activates the L2. So using that `proxyAdminAddress` is a valid `Registry` is not a good assumption.
2. I'd create a new purposely empty Registry in this test, so it's obvious to the reader why the test fails.
3. I'd update the test name since it's not obvious which contract the `Registry` is missing. Presumably it's the `CeloToken`, but it's not immediately obvious from the test name.

I'll probably fix this in a separate PR.

* refactor(FeeHandler.t.sol): use `REGISTRY_ADDRESS` constant

* refactor(GasPriceMinimum.t.sol): use constants

* refactor(GoldToken.t.sol): use `PROXY_ADMIN_ADDRESS`

* fix(test-sol): import forgotten `TestConstants`

All unit tests pass

```sh
forge test -vvv \
--match-path "test-sol/unit/*"
```

* refactor(IsL2Check.t.sol): use `PROXY_ADMIN_ADDRESS`

* refactor(BlockchainParamters.t.sol): use `PROXY_ADMIN_ADDRESS`

* refactor(EpochRewards.t.sol): use `PROXY_ADMIN_ADDRESS`

* refactor(GovernanceSlasher.t.sol): use constants

* refactor(DoubleSigningSlasher.t.sol): use constants

* refactor(DowntimeSlasher.t.sol): use constants

* refactor(Validators.t.sol): use constants

* refactor(Election.t.sol): use constants

* refactor(LockedGold.t.sol): use constants

* refactor(ReleaseGold.t.sol): use constants

* refactor(Escrow.t.sol): use constants

* refactor(FederatedAttestations.t.sol): use constants

* refactor(OdisPayments.t.sol): use constants

* style(GasPriceMinimum.t.sol): move import to top

* style(Random.t.sol): use constants

* feat(migrations_sol): import constants

To avoid redefining them and having a variable name clash at compilation:

```sh
Error (9097): Identifier already declared.
  --> test-sol/constants.sol:28:3:
   |
28 |   address constant REGISTRY_ADDRESS = 0x000000000000000000000000000000000000ce10;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note: The previous declaration is here:
  --> migrations_sol/constants.sol:33:3:
   |
33 |   address constant REGISTRY_ADDRESS = 0x000000000000000000000000000000000000ce10;
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ```

* style(test-sol): linting

* chore(Governance.t.sol): updates to `TestConstants`

* chore(Election.t.sol): uses named import `{ Utils }` for readability

* chore(Governance.t.sol): updates to `TestConstants` in Contract

* refactor(CeloDistributionSchedule.t.sol):  use `REGISTRY_ADDRESS`

* test(CeloDistributionSchedule.t.sol): fix failing test due to merge conflict

I made a mistake when resolving a conflict earlier and committed too much.
This should fix the error, the test is all green now.
* test(FeeHandlerSeller.t.sol): adds MVP contract outline

Test is currently failing

* test(FeeHandlerSeller.t.sol): use `GoldTokenMock` to work around missing transfer precompile

Test passes as expected ✅

* chore(FeeHandlerSeller.t.sol): remove unused code comments

* test(FeeHandlerSeller.t.sol): add test for revert when not owner

Test passes as expected ✅

* style(FeeHandlerSeller.t.sol): improve function naming

More explicit naming in compliance with VS code extension that suggests forge test naming.

* test(FeeHandlerSeller.t.sol): add test for setMinimumReports

Test passes as expected ✅

* test(FeeHandlerSeller.t.sol): refactor constants and simplify tests

All tests pass as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/FeeHandlerSeller.t.sol"
```

* test(FeeHandlerSeller.t.sol): remove unused imports

All tests pass as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/FeeHandlerSeller.t.sol"
```

* test(feehandlerseller.ts): deletes TS test

Fully migrated to foundry test.

* refactor(FeeHandlerSeller.t.sol): use arbitrary token address

All tests pass as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/FeeHandlerSeller.t.sol"
```
* test(UniswapFeeHandlerSeller.t.sol): adds MVP test outline

First test passes as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/UniswapFeeHandlerSeller.t.sol"
```

* test(UniswapFeeHandlerSeller.t.sol): adds test for non-owner `setRouter` test

All tests pass as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/UniswapFeeHandlerSeller.t.sol"
```

* test(UniswapFeeHandlerSeller.t.sol): adds test for setting router to zero address

All tests pass as expected ✅

```sh
forge test -vvvv \
--match-path "test-sol/unit/common/UniswapFeeHandlerSeller.t.sol"
```

* chore(UniswapFeeHandlerSeller.t.sol): debugging `expectRevert`

I can't seem to get the contract to revert when the max number of routers are set per token. Although limit is hardcoded to 3, the `setRouter` function seems to accept more tokens than the limit.

```sh
Logs:
  Setting router 0
  Setting router 1
  Setting router 2
  Setting router 3
  Setting router 4
  Setting router 5
  Setting router 6
  Setting router 7
  Setting router 8
  Setting router 9
  Routers for token: 1
  ```

* fix(FeeHandlerSeller.t.sol): use distinct router addressees

Fixes a bug in the test where I couldn't trigger the expected revert.

* style(FeeHandlerSeller.t.sol): linting

* test(FeeHandlerSeller.t.sol): adds test for large list and applies linting

* refactor(FeeHandlerSeller.t.sol): removes setup() to improve readability

* chore(FeeHandlerSeller.t.sol): adds code comment for context

* test(uniswapfeehandlerseller.ts): removes TS test

Fully covered by newly added Foundry test `UniswapFeeHandlerSeller.t.sol`
* refactor(Proxy.sol): remove unused code comments

This code change makes a test fail:
test-sol/unit/common/ProxyFactory08.t.sol > test_verifyArtifacts

```sh
$ forge test

Failing tests:
Encountered 1 failing test in test-sol/unit/common/ProxyFactory08.t.sol:ProxyFactoryTest
[FAIL. Reason: panic: assertion failed (0x01)] test_verifyArtifacts() (gas: 188341)
```

I'm not 100% certain but it's maybe because the `packages/protocol/artifacts/Proxy/proxyInitCode0.5.17+commit.d19bba13.hex` artifact is derived from the contract with the code comments.

* refactor(ProxyFactory08.t.sol): simplify `getCode` arguments

This is semantically equivalent, see https://book.getfoundry.sh/cheatcodes/get-code

* chore(artifacts/Proxy): adds `bytecode`

I simply copy/pasted the JSON value at `packages/protocol/out/Proxy.sol/Proxy.json` > `bytecode.object.`

* chore(artifacts/Proxy): adds `bytecode`

I simply copy/pasted the JSON value at `packages/protocol/out/Proxy.sol/Proxy.json` > `deployedBytecode.object.`

* docs(artifacts/Proxy/README): adds a note for future reference

* style(artifacts/Proxy/README): fix typo

* style(artifacts/Proxy/README): fix typo
…11177)

* refactor(constants.sh): renames target contract variable for better readability

* fix(interfaces/ICeloDistributionSchedule): removes 1 argument from `activate` function

As far as I can see, this interface was not defined correctly and had an argument too much.

* refactor(MigrationL2.s.sol): moves `activate` call to script and refactors bash file

Left two TODO comments.

* refactor(constants): uses `DEPLOYER_ACCOUNT`

* refactor(constant.sh): removes anvil private key (not used anymore)

* refactor(Migrations.s.sol): add `setupUsingRegistry()` to improve readability

* style(scripts/foundry): indent lines that don't start a command

* feat(IEpochRewards): adds new interface

* feat(UsingRegistry): adds EpochRewards

* refactor(MigrationL2): gets fractions from EpochRewards.sol

* chore(MigrationL2): delete console.log import

* chore(MigrationL2): deletes `TODO` comment

* style(protocol): linting

* Test celo-monorepo.yml trigger filters

* Remove useless workflow triggers

* Run on repository runners

---------

Co-authored-by: Javier Cortejoso <[email protected]>
* L2 devchain fix

* fixes

* artifact fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.