-
Notifications
You must be signed in to change notification settings - Fork 28
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
Revert custom errors to require statements #59
Conversation
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.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two msg.sender checks that were removed that I didn't see earlier. Just want to confirm that they are no longer necessary.
contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol
Outdated
Show resolved
Hide resolved
contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol
Outdated
Show resolved
Hide resolved
revert InsufficientTotalAmount(totalAmount, primaryFeeAmount + secondaryFeeAmount); | ||
} | ||
require( | ||
totalAmount >= primaryFeeAmount + secondaryFeeAmount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be >
not >=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this to avoid us calling encodeMintBridgeTokensData
with 0 bridge amount? Should we add a check in mint
that the amount != 0 if this is the case?
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.
The check in mint
would be in the transaction receiving the Teleporter message, rather than the one sending it here. The idea being that the amount bridged excluding fees must be non-zero.
contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol
Outdated
Show resolved
Hide resolved
contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol
Outdated
Show resolved
Hide resolved
contracts/src/CrossChainApplications/ERC20Bridge/ERC20Bridge.sol
Outdated
Show resolved
Hide resolved
contracts/src/CrossChainApplications/ERC20Bridge/tests/ERC20BridgeTests.t.sol
Outdated
Show resolved
Hide resolved
Co-authored-by: Michael Kaplan <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]>
Co-authored-by: Michael Kaplan <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]>
Co-authored-by: Michael Kaplan <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]>
Co-authored-by: Michael Kaplan <[email protected]> Signed-off-by: minghinmatthewlam <[email protected]>
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.
LGTM!
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.
A couple of minor comments, but overall LGTM
@@ -24,5 +24,4 @@ jobs: | |||
# in subdirectories. The former only checks sol files in the current directory and directories one level down. | |||
- name: Run Lint | |||
run: | | |||
cd contracts/src | |||
npx solhint '**/*.sol' --config ./.solhint.json --ignore-path ./.solhintignore --max-warnings 0 | |||
./scripts/local/lint.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to either cd contracts/src
or modify the script to point to TELEPORTER_PATH/contracts/src/.solhint.json
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.
yup the lint script has cd $TELEPORTER_PATH/contracts/src
. Lint workflow was failing because of installing locally, and script using solhint
without npx. Looking online, when installing to use for command line we should install globally. https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation
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.
Ah I missed that cd
. Nice find
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.
LGTM!
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.
👍
Why this should be merged
We want to move back from custom errors to require statements because certain toolings are not compatible well with custom errors yet, for example snow trace, or when forge tests fail they're show a hash that needs to be decoded with the abi to be readable. This will cause an increase in contract size and deployment costs but the tradeoff is for easier debugging and integration with existing tools.
How this works
if
statements and using require statements in the form "{contract}: {error message}"scripts/local/lint.sh
scriptreceiveTeleporterMessage
How this was tested
BEFORE gas report:
AFTER gas report: