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 - post L2] Deprecate isReserveLow on L2 #11290

Open
wants to merge 75 commits into
base: master
Choose a base branch
from

Conversation

m-chrzan
Copy link
Contributor

@m-chrzan m-chrzan commented Dec 6, 2024

Description

EpochRewards.isReserveLow was a function used during L1 epoch rewards calculation within celo-blockchain. The L2 epoch system (which has moved to smart contracts) will no longer rely on this, and so this function can be deprecated on L2, slated to be removed after the L2 transition.

Tested

Unit test.

Related issues

soloseng and others added 30 commits June 12, 2024 11:38
* 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

* update GH WF

---------

Co-authored-by: Arthur Gousset <[email protected]>
* 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
…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
* 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]>
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
martinvol and others added 19 commits October 31, 2024 15:01
* removed L2 duplicated test code

* -- compiltation warning

* Removed duplicated L2 election test code
### Description

Using test contract inheritance to minimize duplicated code during L2 testing

### Other changes

removed unused var

### Tested

unit tested

### 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_

* Revert "Removed duplicated L2 election test code"

This reverts commit b0058c5.

* basic L2 setup

* -- duplicate

* -- duplicate test

* moved whenL2 to utils

* uncommented validator test

* initial test working

* -- duplicate call

* passing L2 validators test

* Remove unnecessary comment

* Add whitespace

* Add missing whitespace

* Fix whitespace

* Remove unnecessary registry set

EpochManager is already set in the Registry in setupEpochManager.

* Remove unnecessary inherit

Utils already inherits from TestConstants

* Propagate error from Validators tunnel

* Move setCommissionUpdateDelay to own test contract

* Move setDowntimeGracePeriod to own test contracts

* Move registerValidator L2 test to own test contract

* Fix test contract name

* Move L1 NoBls test to separate test contract

* Use L2 helper for NoBls_L2 test

* Fix log absence check

* Split Affiliate test into L1/L2 test contracts

* Split deaffiliate tests into L1/L2 contracts

* Remove test case already covered by L2 test contract

* Split updatePublicKeys into L1/L2 contracts

* Remove duplicated test case

* Split updateBlsPublicKey into L1/L2 contracts

* Remove test case already covered by L2 contract

* Split updateCommission test into L1/L2 contracts

* Split CalculateEpochScore into L1/L2 contracts

* Split calculateGroupEpochScore test into L1/L2 contracts

* Split updateValidatorScoreFromSigner into L1/L2 contracts

* Split getMemebershipInLastEpoch into L1/L2 contracts

* Remove test case covered by L2 contract

* Split getTopGroupValidatorsAccounts into L1/L2 contracts

* Split distributeEpochPaymentFromSigner into L1/L2 test contracts

* Split mintStableToEpochManager into L1/L2 contracts

* Split forceDeaffiliateIfValidator into L1/L2 contracts

* Add L2 test contract for groupMembershipInEpoch

* Remove test case covered by L2 contract

* Create L2 test contract for resetSlashingMultiplier

* Create L2 test contract for resetSlashingMultiplier

* Remove unnecessary whenL2

* Remove test cases covered by L2 test contracts

* Split setValidatorScoreParameters into L1/L2 test contracts

* Fix typo

* Remove unnecessary inheritance

TransitionToL2AfterL1 already inherits from ValidatorsTest.

* Use helper function

* Remove unnecessary function call

* Remove unnecessary imports

* Import IsL2Check directly

* Add a V2 version of PrecompilesOverride

* Use getEpochNumber logic from PrecompileOverride

* Set up Registry and EpochManager in Utils

* Use new util contract for L2 transition in Validators

* Use WhenL2 in Election test

---------

Co-authored-by: Marcin Chrzanowski <[email protected]>
* running all tests in L2

* using registry from utils

* using WhenL2 utils contract
* -- duplicated function

* general L2 tests

* ++ L1 GovernanceTest_resetHotfix

* ++ remaining tests

* debuging

* more debug logs

* revert debug logs

* change inheritance order

* renaming of contract

* PR feedback

* -- commented code

* -- unused imports

* using WhenL2 utils contract

* separate L2 tests for functions that revert on L2

* PR feedback
passing proposal L2 test
* Passing test using registry from utils

* most L2 test passing

* using _setup contract

* -- L2 duplicates
* passing test using utils

* setup all L2 test
* ++ L2 setup;
renamed local registry contract;
passing L1 test

* ++ left over tests

* PR feedback
reworked CeloToken test
* initial tests

* fixed EpochRewardsTest_getRewardsMultiplier_L2 tests

* using whenL2 utils contract

* removed duplicated test

* fixed rest of failing tests

* renamed function
* renamed utils contract

* capitalize
* added L2 testing

* updated filename
* -- console logs

* passing L1 test using Utils contract

* updated filename

* Passing L2 test

* -- duplicate test
* Passing L1 test using TestWithUtils

* passing L2 tests

* -- unused contract

* -- commented line
* Update delegation when slashing

* tests fixed

* PR comments

* lint
* ++ events

* PR feedback

* updated & fixed tests
@m-chrzan m-chrzan requested review from a team as code owners December 6, 2024 11:50
@m-chrzan m-chrzan requested a review from alvarof2 December 6, 2024 11:50
@m-chrzan m-chrzan changed the base branch from master to release/core-contracts/12 December 6, 2024 11:50
Copy link

gitguardian bot commented Dec 6, 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.

@m-chrzan m-chrzan removed request for a team and alvarof2 December 6, 2024 11:51
Copy link

Deprecate isReserveLow on L2

Generated at commit: 1ec7eaed62e204a3e3d5eae84cc6063022e8ba44

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
2
0
14
43
62
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@m-chrzan m-chrzan changed the title Deprecate isReserveLow on L2 [DO NOT MERGE - post L2] Deprecate isReserveLow on L2 Dec 6, 2024
@martinvol martinvol changed the base branch from release/core-contracts/12 to master December 6, 2024 14:15
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.

Remove isReserveLow function from EpochRewards
8 participants