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

Fix/baseline conflicts #52

Closed
wants to merge 3 commits into from
Closed

Fix/baseline conflicts #52

wants to merge 3 commits into from

Conversation

0xng
Copy link
Member

@0xng 0xng commented Sep 11, 2024

No description provided.

agusduha and others added 3 commits September 11, 2024 16:16
* feat: add superchain erc20 baseline

* feat: make superchain ERC20 simpler

* fix: small version fix and tests

* test: fix test name
Copy link

@0xDiscotech 0xDiscotech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far! Left some small suggestion and questions

Comment on lines 44 to 46
struct OptimismSuperchainERC20Metadata {
/// @notice Address of the corresponding version of this token on the remote chain.
address remoteToken;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just have a storage slot for the address instead of defining a struct for that contains only 1 field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that can be done at well, i actually like it better, good suggestion

@@ -127,11 +131,11 @@ contract OptimismSuperchainERC20Test is Test {
uint256 _toBalanceBefore = superchainERC20.balanceOf(_to);

// Look for the emit of the `Transfer` event
vm.expectEmit(true, true, true, true, address(superchainERC20));
vm.expectEmit(address(superchainERC20));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the true, true, true, true doesn't alter the way the cheatcode checks the emitted args are done properly and in order?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same as if they were there, it's shorthand way of writing it

/// @title SuperchainERC20Test
/// @notice Contract for testing the SuperchainERC20 contract.
contract SuperchainERC20Test is Test {
address internal constant ZERO_ADDRESS = address(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
address internal constant ZERO_ADDRESS = address(0);
address internal constant ZERO_ADDRESS;

Comment on lines +632 to +636
{
"inputs": [],
"name": "ZeroAddress",
"type": "error"
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are repeated below, were them autogenerated? Are we sure we need them or could be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is autogenerated, but if this is repeated then we may have the error in both the SuperchainERC20 and the OptimismSuperchainERC20, will check and remove accordingly

}

/// @notice Tests the `relayERC20` function reverts when the `_to` address is the zero address.
function testFuzz_relayERC20_zeroAddressTo_reverts(uint256 _amount) public {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This should go above testFuzz_relayERC20_notCrossDomainSender_reverts

Copy link

@0xParticle 0xParticle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I'm not entirely sure about is the zero address check in both sendERC20 and relayERC20 functions. Those are not part of the invariants in the specs, so this might not be the most general implementation.
https://github.com/ethereum-optimism/specs/blob/main/specs/interop/token-bridging.md#invariants

/// @param _to Address to relay tokens to.
/// @param _amount Amount of tokens to relay.
function relayERC20(address _from, address _to, uint256 _amount) external virtual {
if (_to == address(0)) revert ZeroAddress();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this check redundant? the _to == address(0) is already checked on sendERC20. Since only messages initiated in sendERC20 can bypass the following checks, this might be removed, even if gas-wise its very cheap.

@0xng
Copy link
Member Author

0xng commented Sep 12, 2024

Comments addressed in new PR due to having to rebase again: #55

@0xng 0xng closed this Sep 12, 2024
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.

4 participants