-
Notifications
You must be signed in to change notification settings - Fork 75
fix: polygon testnet fixes #128
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
Conversation
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
nicholaspai
left a comment
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.
Can you add a PR description explaining why we want to remove wrapping from the fallback functikn? LGTM otherwise I think allowing anyone to wrap this contracts ETH makes sense
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
contracts/PolygonTokenBridger.sol
Outdated
| * @notice Constructs Token Bridger contract. | ||
| * @param _destination Where to send tokens to for this network. | ||
| * @param _l1Weth Ethereum WETH address. | ||
| * @param _polygonRegistry L1 registry that stores updated addresses of polygon contracts. |
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.
Can you add a comment explaining how to set this on L2 since its described as an "L1 registry"
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.
Sure. Can do. It should still be the L1 address to ensure that this gets deployed at an identical address on both chains.
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.
Done.
| * @dev Matic sends via L1 -> L2 bridging actions don't call into the contract receiving the tokens, so wrapping | ||
| * must be done via a separate transaction. | ||
| */ | ||
| function wrap() public nonReentrant { |
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.
Should wrap be triggered on any other external functions like processMessageFromRoot for convenience?
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.
It could. Note: the functions that actually would need the tokens aren't triggered by processMessageFromRoot, though. Executing relayer refunds and slow relays are the ones that would require this, but to add it to those, they might need to be overridden.
Will think a little about how to do this with little overhead.
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.
Added this functionality in the last commit: 811ac20. PTAL.
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 perfect this is now consistent with how Optimism_SpokePool handles the same logic: https://github.com/across-protocol/contracts-v2/blob/master/contracts/Optimism_SpokePool.sol#L89
HOWEVER, you can probably save some gas by adding a check if (destinationToken == weth) ...
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 don't really think this extra check is worthwhile because:
- We already check
address(this).balance > 0, which is extremely cheap. It costs 5 gas according to https://ethereum.org/en/developers/docs/evm/opcodes/ to read the balance. Reading thewethvalue from the contract, by comparison, would cost 100 - 2100 gas. I think these checks are the only difference between the two, since we will likely run some matic execution step each time matic tokens are sent over to the spoke, meaning the number of wraps shouldn't really differ between the two. - Since this is on polygon, gas costs shouldn't really matter too much.
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.
As discussed offline, we'll leave this as is.
nicholaspai
left a comment
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, left some comments just requesting more detailed comments
nicholaspai
left a comment
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 left one suggestion on the use of _wrap but overall this looks good as before!
|
|
||
| contract PolygonRegistryMock { | ||
| // solhint-disable-next-line no-empty-blocks | ||
| function erc20Predicate() external returns (address predicate) {} |
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 know this is a mock, but it looks like using the "registry" from polygon's list may give the wrong value. The Registry is 0x33a02E6cC863D393d6Bf231B697b82F6e499cA71, and you can see that function erc20Predicate returns 0x158d5fa3Ef8e4dDA8a5367deCF76b94E7efFCe95. Just based on the tx's i see calling that contract, it's for exiting from Matic, but not bridging/depositing onto matic.
Again since this is a mock, you can have it return whatever value you want. So not a problem. But it might lead to someone thinking that the actual mainnet contract will return the "deposit" predicate, which it doesn't. I believe the deposit predicate is 0x40ec5b33f54e0e8a33a975908c5ba1c14e5bbbdf.
I'm thinking that Polygon_Adapter.sol is deployed on ETH mainnet, for transferring tokens over to Matic. If that's not true... this doesn't apply
This PR includes three changes related to testnet testing against mumbai:
Note: the bi-directional transfer of ERC20s, WETH, and Matic has been tested on mumbai.