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

CMTAT release v2.3.1 #210

Merged
merged 72 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7a89832
Add FAQ, update doc audit
rya-sge Jul 19, 2023
0819ac6
Add mintBatch with tests
rya-sge Jul 20, 2023
0f830ba
Add burn batch with tests
rya-sge Jul 24, 2023
4e27c75
Batch functions: update doc modules
rya-sge Jul 25, 2023
edb2ff6
Merge pull request #207 from CMTA/master
rya-sge Jul 26, 2023
0d34ac0
Mint and burn batch: improve and comments
rya-sge Jul 27, 2023
d0ce1de
Add function transferBatch
rya-sge Jul 27, 2023
85151a0
Update doc + adapt arg name to the new OZ version
rya-sge Jul 28, 2023
a004795
ERC20BaseModule improvement + doc
rya-sge Jul 31, 2023
eb50966
Improve doc
rya-sge Jul 31, 2023
583202a
Add ERC20 decimals as an argument of the initialize function
rya-sge Aug 2, 2023
4b4cdea
faq review
veorq Aug 3, 2023
d2cd181
decimals comments
veorq Aug 3, 2023
2b88d16
Merge pull request #213 from CMTA/decimals
rya-sge Aug 4, 2023
92fe346
Custom errors and Gas optimizations (#1)
mariogutval May 31, 2023
ce870ca
Add proxy test script in package.json
rya-sge Aug 7, 2023
7faeda7
Merge conflicts
rya-sge Aug 7, 2023
fe73847
Merge branch 'dev' into coherence-name
rya-sge Aug 7, 2023
a4c660f
Merge pull request #211 from CMTA/coherence-name
rya-sge Aug 7, 2023
9f40618
Merge conflicts
rya-sge Aug 7, 2023
11307e4
Update OpenZeppelin version to the latest commit (~5.0.0), update Sol…
rya-sge Aug 9, 2023
197331b
BurnModule: support of custom errors with test through Hardhat
rya-sge Aug 11, 2023
7d3c92b
MintModule: support of custom errors with test through Hardhat
rya-sge Aug 11, 2023
751d857
ERC20Module: support of custom errors with test through Hardhat
rya-sge Aug 14, 2023
767c406
ERC20Module: support of custom errors with test through Hardhat
rya-sge Aug 14, 2023
8b67467
BaseModule: support of custom errors with test through Hardhat
rya-sge Aug 14, 2023
d90a906
CreditEventsModule&PauseModule: support of custom errors with test th…
rya-sge Aug 14, 2023
125bb89
ValidationModule&AuthorizationModule: support of custom errors with t…
rya-sge Aug 16, 2023
b0158f9
CLI: use Hardhat instead of Truffle to run the tests
rya-sge Aug 16, 2023
dfde276
Rename CLI Hardhat
rya-sge Aug 16, 2023
3c6f747
Proxy test: adaptation to Hardhat and support of custom errors
rya-sge Aug 21, 2023
c678ee0
EnforcementModule: support of custom errors with test through Hardhat
rya-sge Aug 21, 2023
a5af55d
Deployment test: support of custom errors with test through Hardhat
rya-sge Aug 21, 2023
80a2cac
Clean up test code + MetaTxModule: support of custom errors with test…
rya-sge Aug 22, 2023
1265b3f
SnapshotModule - reschedule snasphot: improve test with custom errors…
rya-sge Aug 22, 2023
299dc17
SnapshotModule, ERC20BaseModule, DelegateCallModule: improve test wi…
rya-sge Aug 23, 2023
b6c6129
Format the code
rya-sge Aug 23, 2023
3eef3bd
Add hardhat gas reporter
rya-sge Aug 23, 2023
68d3ccb
Switch to 0.8.20 for library Errors
rya-sge Aug 23, 2023
b28ef33
Add hardhat contract size
rya-sge Aug 29, 2023
bc082bb
Merge pull request #217 from CMTA/custom-error-hardhat
rya-sge Aug 29, 2023
4ad7819
Add hardhat contract size in hardhat config
rya-sge Aug 29, 2023
f76b445
AuthorizationModule: add AccessControlDefaultAdminRules and update th…
rya-sge Aug 31, 2023
96d066d
Remove function kill + add function deactivateContract in PauseModule
rya-sge Sep 1, 2023
2eee537
PauseModule: add function to get the value of isDeactivated
rya-sge Sep 1, 2023
41edba6
Merge pull request #220 from CMTA/add-admin-rule
rya-sge Sep 1, 2023
d896f57
Merge
rya-sge Sep 4, 2023
2572a22
Update test for EnforcementModule
rya-sge Sep 4, 2023
50ddea2
Improve comments for PauseModule
rya-sge Sep 4, 2023
2565334
Update .gitignore
rya-sge Sep 4, 2023
4b11c22
Merge pull request #221 from CMTA/remove-kill
rya-sge Sep 4, 2023
9b99a84
Architecture refactoring
rya-sge Sep 4, 2023
ed66e3d
Merge pull request #222 from CMTA/refactoringV2
rya-sge Sep 11, 2023
917a91c
Add test for AccessControlDefaultAdminRules + add functiont transferA…
rya-sge Sep 11, 2023
5d51cd5
Rename contract and init function for ERC20BurnModule, ERC20MintModul…
rya-sge Sep 12, 2023
28301d0
AuthorizationModule: improve test
rya-sge Sep 12, 2023
198e869
AuthorizationModule: improve test
rya-sge Sep 12, 2023
b43c0d6
Add contract version with tests
rya-sge Sep 12, 2023
21a2584
Merge pull request #226 from CMTA/access-rule-test
rya-sge Sep 12, 2023
d6588a7
Merge pull request #229 from CMTA/version
rya-sge Sep 12, 2023
95fef65
Update doc
rya-sge Sep 13, 2023
166fe25
Add slither report for the version 2.3.1
rya-sge Sep 13, 2023
a68378a
Update doc, comment in Solidity files and add missing tests detected …
rya-sge Sep 20, 2023
1b454e8
Prettier the files
rya-sge Sep 20, 2023
0cb5a11
Update readme and remove useless doc files
rya-sge Sep 20, 2023
9b3ddb2
Upgrade OpenZeppelin to v5.0.0-rc.0, rename tests to be coherent with…
rya-sge Sep 21, 2023
c4b0d3b
Update audit doc
rya-sge Sep 22, 2023
b420e4c
Update test
rya-sge Sep 25, 2023
d13df6e
update architecture
rya-sge Sep 25, 2023
8b85928
Doc small update
rya-sge Sep 25, 2023
95c53e5
Update CHANGELOG.md
rya-sge Sep 25, 2023
50ab0f7
Merge pull request #233 from CMTA/docv2-v2.3.1
rya-sge Sep 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Truffle CI
name: Hardhat CI

on:
push:
Expand Down Expand Up @@ -27,5 +27,5 @@ jobs:
- name: Install Project Dependencies
run: npm install

- name: Run Truffle Test
run: npx truffle test
- name: Run Hardhat Test
run: npx hardhat test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
build
coverage
coverage.json
bin/*
#exception
!doc/general/test/coverage
/.openzeppelin
Expand All @@ -15,3 +16,5 @@ artifacts
cache
#manticore
mcore_*
#secrets
.env
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

Please follow <https://changelog.md/> conventions.

## 2.3.1-rc.0 - 20230925

### Summary
**Architecture**
- The directory `mandatory` is renamed in `core` ([#222](https://github.com/CMTA/CMTAT/pull/222))
- The directory `optional` is renamed in `extensions` ([#222](https://github.com/CMTA/CMTAT/pull/222))
- Creation of a directory `controllers` which for the moment contains only the ValidationModule ([#222](https://github.com/CMTA/CMTAT/pull/222))
- Rename contract and init function for `ERC20BurnModule`, `ERC20MintModule`, `ERC20SnapshotModule` to clearly indicate the inheritance from ERC20 interface ([#226](https://github.com/CMTA/CMTAT/pull/226))

**Gas optimization**

- Add a batch version for the burn, mint and transfer functions (see [#51](https://github.com/CMTA/CMTAT/pull/51))
- Use custom error instead of string error message ([#217](https://github.com/CMTA/CMTAT/pull/217))

See [Defining Industry Standards for Custom Error Messages](https://blog.openzeppelin.com/defining-industry-standards-for-custom-error-messages-to-improve-the-web3-developer-experience)

**Other**

- Add ERC20 decimals as an argument of the initialize function ([#213](https://github.com/CMTA/CMTAT/pull/213))
Until now, the number of decimal was set inside the code to the value 0
This release changes this behavior to use instead a parameter supplied by the deployer inside the function initialize.
- Add a constant VERSION to indicate the current version of the token ([#229](https://github.com/CMTA/CMTAT/pull/229))
- Implement an alternative to the kill function ([#221](https://github.com/CMTA/CMTAT/pull/221))

The alternative function is the function `deactivateContract` inside the PauseModule, to deactivate the contract. This function set a boolean state variable `isDeactivated` to true and puts the contract in the pause state. The function `unpause`is updated to revert if the previous variable is set to true, thus the contract is in the pause state "forever".

The consequences are the following:

In standalone mode, this operation is irreversible, it is not possible to rollback.

With a proxy, it is still possible to rollback by deploying a new implementation.

**Tools**

- Update the Solidity version to 0.8.20, which is a requirement for the new OpenZeppelin version (5.0.0)
- Run tests with Hardhat instead of Truffle since Truffle does not support custom errors ([#217](https://github.com/CMTA/CMTAT/pull/51))
- Update OpenZeppelin to the version [v5.0.0-rc.0](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/releases/tag/v5.0.0-rc.0)

**Security**
- Add new control on the DEFAULT_ADMIN_ROLE by inheriting `AccessControlDefaultAdminRules` ([#220](https://github.com/CMTA/CMTAT/pull/220))
This contract implements the following risk mitigations on top of [AccessControl](https://docs.openzeppelin.com/contracts/4.x/api/access#AccessControl):

Only one account holds the DEFAULT_ADMIN_ROLE since deployment until it’s potentially renounced.

Enforces a 2-step process to transfer the DEFAULT_ADMIN_ROLE to another account.

Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.

- Add a function `transferadminshipDirectly` ([#226](https://github.com/CMTA/CMTAT/pull/226))
- Remove the module `OnlyDelegateCallModule` since it was used to protect the function `kill`, which has been removed in this version ([#221](https://github.com/CMTA/CMTAT/pull/221)).

## 2.3.0 - 20230609

- Add Truffle CI workflow (Contributor: [diego-G](https://github.com/diego-G) / [21.co](https://github.com/amun))
Expand Down
104 changes: 104 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# FAQ

This FAQ is intended to developers familiar with smart contracts
development.

## Toolkit support

> Which is the main development tool you use ?

Until the version v.2.3.1, we used `Truffle` with `web3js` as our main development tool and testing library. Since this version, we use *custom errors* to generate errors inside our smart contracts and this type of errors are not supported by `Truffle` for testing.

Therefore, we use `Hardhat` with `web3js` to run our tests, but you can compile the contracts with Truffle or Hardhat.

Regarding [Foundry](https://book.getfoundry.sh/):

- The plugin "upgrades plugin" by OpenZeppelin is not available with Foundry and it is a very good tool to check the proxy implementation and perform automatic tests. See [https://docs.openzeppelin.com/upgrades-plugins/1.x/](https://docs.openzeppelin.com/upgrades-plugins/1.x/)
- The tests for the gasless module (MetaTx) would be difficult to write
in Solidity, as Foundry requires, see [https://github.com/CMTA/CMTAT/blob/master/test/common/MetaTxModuleCommon.js](https://github.com/CMTA/CMTAT/blob/master/test/common/MetaTxModuleCommon.js)
- The OpenZeppelin libraries that we use have their tests mainly written in JavaScript, which provides a good basis for our tests
- We have a repository [CMTA/CMTAT-Foundry](https://github.com/CMTA/CMTAT-foundry) that provides experimental support for Foundry, but it does not provide complete support and testing for the latest CMTAT version.


> Do you plan to fully support Foundry in the near future?

For the foreseeable future, we plan to keep Hardhat/Truffle as the main
development and testing suite.

We have not planned to export all the tests from the Truffle/Hardhat suite to
their Solidity version equivalent suitable to Foundry, though some tests
are already available.

The CMTAT-Foundry repository uses CMTAT as a submodule, whose version is
documented in its
[README](https://github.com/CMTA/CMTAT-Foundry/blob/main/README.md#cmtat---using-the-foundry-suite).


> Can Truffle be used to run tests?

No. Since the version v.2.31 and the use of `custom errors`, the tests no longer work with Truffle.

You can only run the tests with `Hardhat`.


## Modules

> What is the reason the Snapshot module wasn't audited in version v2.3.0?

This module was left out of scope because it is not used yet (and not
included in a default deployment) and will be
subject to changes soon.

> What is the status of [ERC1404](https://erc1404) compatibility?

We have not planned to be fully compatible with ERC1404 (which, in fact,
is only an EIP at the time of writing).
CMTAT includes the two functions defind by ERC1404, namely
`detectTransferRestriction` and `messageForTransferRestriction`.
Thus CMTAT can provide the same functionality as ERC1404.

However, from a pure technical perspective, CMTAT is not fully compliant
with the ERC1404 specification, due the way it inherits the ERC20
interface.

> What is the purpose of the flag parameter in the Base module?

It is just a variable to include some additional information under the form of bit fields.
It is not used inside the code because it is destined to provide more
information on the tokens to the "outside", for example for the token
owners.


> Is the Validation module optional?

Generally, for a CMTAT token, the Validation functionality is optional
from the legal perspective (please contact [email protected] for detailed
information).

However, in order to use the functions from the Pause and Enforcement
modules, our CMTAT implementation requires the Validation module
Therefore, the Validation module is effectively required *in this
implementation*.

If you remove the Validation module and want to use the Pause or the
Enforcement module, you have to call the functions of modules inside the
main contracts. It was initially the case but we have changed this
behavior when addressing an issue reported by a security audit.
Here is an old version:
[https://github.com/CMTA/CMTAT/blob/ed23bfc69cfacc932945da751485c6472705c975/contracts/CMTAT.sol#L205](https://github.com/CMTA/CMTAT/blob/ed23bfc69cfacc932945da751485c6472705c975/contracts/CMTAT.sol#L205),
and the relevant Pull [Request](https://github.com/CMTA/CMTAT/pull/153).


## Documentation

> What is the code coverage of the test suite?

A [code coverage report](https://github.com/CMTA/CMTAT/blob/master/doc/general/test/coverage/index.html)
is available.

Normally, you can run the test suite and generate a code coverage report with `npx hardhat coverage`.

Please clone the repository and open the file inside your browser.

You will find a summary of all automatic tests in
[test.pdf](https://github.com/CMTA/CMTAT/blob/master/doc/general/test/test.pdf).
Loading