-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade Solidity to 0.8.20 and Fix Tests #29
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
Open
benzntech
wants to merge
7
commits into
bitbankinc:master
Choose a base branch
from
benzntech:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a797c3d
Upgrade Solidity to 0.8.20 and fix tests
d584f10
Merge remote master after Solidity upgrade
85d2fff
Update Actions
junderw 13db7d8
Fix Actions and deps
junderw 2cdd5f2
Fix: Resolve linting, coverage, formatting, and verification issues
77589ef
Optimize gas settings and resolve compiler warnings
c260ed3
Further optimize ExchangeDeposit by caching state variables
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,60 @@ | ||
| name: Run Tests | ||
|
|
||
| on: [push] | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| run-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: 12 | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install --legacy-peer-deps | ||
| - run: npm test | ||
| coverage-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: 12 | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install --legacy-peer-deps | ||
| - run: npm run coverage | ||
| lint-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: 12 | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install --legacy-peer-deps | ||
| - run: npm run lint | ||
| format-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: 12 | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install --legacy-peer-deps | ||
| - run: npm run format:ci | ||
| verify-bytecode: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v1 | ||
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | ||
| - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4 | ||
| with: | ||
| node-version: 12 | ||
| node-version: 22 | ||
| registry-url: https://registry.npmjs.org/ | ||
| - run: npm ci | ||
| - run: npm install --legacy-peer-deps | ||
| - run: npm run verify:ExchangeDeposit | ||
| - run: npm run verify:ProxyFactory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "plugins": ["prettier-plugin-solidity"], | ||
| "overrides": [ | ||
| { | ||
| "files": "*.sol", | ||
| "options": { | ||
| "parser": "solidity-parse", | ||
| "printWidth": 80, | ||
| "tabWidth": 4, | ||
| "useTabs": false, | ||
| "singleQuote": false, | ||
| "bracketSpacing": false | ||
| } | ||
| }, | ||
| { | ||
| "files": "*.js", | ||
| "options": { | ||
| "printWidth": 80, | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "singleQuote": true, | ||
| "trailingComma": "all", | ||
| "bracketSpacing": true | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ cold address. The gas cost for this should be somewhere in the 50k gas range. | |
| address... since we can't stop ERC20 deposits, we want to leave a path for | ||
| fund recovery if the user deposits to an old deposit address after it's been | ||
| killed. | ||
| - **Solidity Version:** ^0.8.20 | ||
|
|
||
| ## Structure | ||
|
|
||
|
|
@@ -32,11 +33,26 @@ assets given to the `Proxy` after the fact by changing `address implementation`. | |
| gatherErc20 and gatherEth will forward to the `address adminAddress`. | ||
| (Since we can't refuse ERC20 payments, and a `selfdestruct` somewhere could give funds to | ||
| a deposit address, and we should be able to recover it somehow. | ||
| ### Solidity 0.8 Upgrade Notes | ||
|
|
||
| This project was originally written for Solidity 0.6.11. It has been upgraded to ^0.8.20. Key changes included: | ||
|
|
||
| - Updated Solidity `pragma` statements in all contracts. | ||
| - Updated `hardhat.config.js` compiler version. | ||
| - Updated `@openzeppelin/contracts` dependency to `4.9.3`. | ||
| - Updated `prettier` dependency to `^2.8.8`. | ||
| - Fixed `address` to `address payable` explicit conversion errors introduced in Solidity 0.8+. | ||
| - Updated test file (`test/exchangedeposit.js`) assertions (`assert.rejects`) to match new revert reason string formats. | ||
| - Adjusted gas cost expectations in tests. | ||
| - **Note:** Due to older dependencies in the project structure, `npm install --legacy-peer-deps` is currently required to resolve peer dependency conflicts. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The I would appreciate it if you could fix the dependencies so that we don't need special install flags. |
||
|
|
||
|
|
||
|
|
||
| ### Run tests | ||
|
|
||
| ```bash | ||
| $ npm ci # Install from package-lock.json using npm ci | ||
| # Install dependencies (may need --legacy-peer-deps due to older package structure) | ||
| $ npm install --legacy-peer-deps | ||
| $ npm test | ||
| ``` | ||
|
|
||
|
|
@@ -53,39 +69,39 @@ $ npm run build | |
|
|
||
| `exchangeDepositor` is the main logic contract and `proxy` is the | ||
| customer deposit contract. It will take a few minutes to deploy. | ||
| Add `ROPSTEN_GASPRICE=100000000000` to the command to set the gasPrice | ||
| Add `SEPOLIA_GASPRICE=100000000000` to the command to set the gasPrice | ||
| to 100 gWei etc. (See hardhat.config.js for which ENV vars are set to which settings) | ||
|
|
||
| For Mainnet: | ||
| - Change all env vars from ROPSTEN_* to MAINNET_* | ||
| - Use npm run *:mainnet instead of npm run *:ropsten | ||
| - Change all env vars from SEPOLIA_* to MAINNET_* | ||
| - Use npm run *:mainnet instead of npm run *:sepolia | ||
|
|
||
| ```bash | ||
| # Use this command to get ENV vars without sending them to stdout | ||
| $ read -s -p "ENDPOINT? " ROPSTEN_ENDPOINT && \ | ||
| export ROPSTEN_ENDPOINT=$ROPSTEN_ENDPOINT && \ | ||
| $ read -s -p "ENDPOINT? " SEPOLIA_ENDPOINT && \ | ||
| export SEPOLIA_ENDPOINT=$SEPOLIA_ENDPOINT && \ | ||
| echo "" | ||
| $ read -s -p "MNEMONIC? " ROPSTEN_MNEMONIC && \ | ||
| export ROPSTEN_MNEMONIC=$ROPSTEN_MNEMONIC && \ | ||
| $ read -s -p "MNEMONIC? " SEPOLIA_MNEMONIC && \ | ||
| export SEPOLIA_MNEMONIC=$SEPOLIA_MNEMONIC && \ | ||
| echo "" | ||
|
|
||
| # ROPSTEN main contract | ||
| $ npm run deploy:ropsten -- \ | ||
| # Sepolia main contract | ||
| $ npm run deploy:sepolia -- \ | ||
| --contract ExchangeDeposit \ | ||
| --arguments '["COLDADDRESS","ADMINADDRESS"]' | ||
| # ROPSTEN ProxyFactory | ||
| $ npm run deploy:ropsten -- \ | ||
| # Sepolia ProxyFactory | ||
| $ npm run deploy:sepolia -- \ | ||
| --contract ProxyFactory \ | ||
| --arguments '["MAINCONTRACTADDRESS"]' | ||
| # ROPSTEN deploy proxy | ||
| $ npm run deploy-proxy:ropsten -- \ | ||
| # Sepolia deploy proxy | ||
| $ npm run deploy-proxy:sepolia -- \ | ||
| --factory "PROXYFACTORYADDRESS" | ||
|
|
||
| # Verify on etherscan | ||
| # Needs ETHERSCAN_APIKEY and ROPSTEN_ENDPOINT | ||
| $ npx hardhat verify --network ropsten "CONTRACTADDRESS" "CONSTRUCTOR ARG 1" "ARG 2" | ||
| # Please see documentation for the plugin for hardhat etherscan | ||
| # https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html | ||
| # Needs ETHERSCAN_APIKEY and SEPOLIA_ENDPOINT | ||
| $ npx hardhat verify --network sepolia CONTRACTADDRESS "CONSTRUCTOR ARG 1" "ARG 2" | ||
| # Note: Uses @nomicfoundation/hardhat-verify plugin (successor to @nomiclabs/hardhat-etherscan) | ||
| # See: https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify | ||
| ``` | ||
|
|
||
| ### usage | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is a goal.