-
Notifications
You must be signed in to change notification settings - Fork 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
Gho ccip bridge (#7) #347
base: master
Are you sure you want to change the base?
Gho ccip bridge (#7) #347
Conversation
|
||
### Deployed Addresses | ||
|
||
Mainnet: [0x5648f519b2064ff30385828e76fefda749749ac2](https://etherscan.io/address/0x5648f519b2064ff30385828e76fefda749749ac2), Arbitrum: [0x03f589a825ee129c5c6d2f6ef5c259870019567b](https://arbiscan.io/address/0x03f589a825ee129c5c6d2f6ef5c259870019567b) |
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.
Update with final deployment addresses
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's not deployed yet for production and these addresses are deployed address to test main functionality
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.
will update this address after fix all feedbacks
Can you clarify why all issues are considered resolved, although the code is not updated and does not compile with current versions? We just don't understand a little, if the changes are in another PR, can you send a link? |
@pavelvm5 maybe you should run |
the problem is not yarn, it's that the new version has a You either need to set the commit in the solidity-utils library to the old one in foundry.toml config, or write an implementation for the new version. I recommend doing the second version, solidity-utils will not be updated anytime soon. The same goes for the chainlink dependency, which now requires 9 arguments instead of 6. And the same about guardians, their addresses exist in address-book for now. |
Can you try after run chainlink packages updated and this updates only applied for testnet. so we should use prev persion and I configured this on package.json correctly now. |
eebbcd2
to
83f6ab5
Compare
d288da4
to
64631dc
Compare
Tests fail
There is a custom error on There is another error as well, please check the above |
data: '', | ||
tokenAmounts: tokenAmounts, | ||
extraArgs: '', | ||
feeToken: GHO |
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.
Imposing the fee in GHO
can be problematic if GHO is not supported in that specific lane.
In other words, if GHO is not supported as fee token, bridge won't work.
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.
This bridge won't be deployed on such network that doesn't support GHO. actually it's built for ARB -> ETH GHO bridge
/// @inheritdoc IAaveCcipGhoBridge | ||
function getInvalidMessage( | ||
bytes32 messageId | ||
) external view checkInvalidMessage(messageId) returns (Client.Any2EVMMessage memory message) { |
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 getter only works for invalid messages, rather than a general getter for messages, which can be helpful
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.
we don't save another messages on contract. it will burn gas
/// @inheritdoc IAaveCcipGhoBridge | ||
function handleInvalidMessage( | ||
bytes32 messageId | ||
) external onlyRole(DEFAULT_ADMIN_ROLE) checkInvalidMessage(messageId) { |
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.
unclear to me what this function does. Interface docs are not very descriptive neither.
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.
This is probably based on this receiver example. It is meant to rescue tokens for messages that might not ever be executable. This means that even if the message is somehow malformed, the funds attached to it can always be recovered.
data: '', | ||
tokenAmounts: tokenAmounts, | ||
extraArgs: Client._argsToBytes( | ||
Client.EVMExtraArgsV2({gasLimit: gasLimit, allowOutOfOrderExecution: true}) |
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 allowOutOfOrderExecution
flag is not set in the other branch
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'm not sure how can I set this value if gasLimit
is not set.
@RensR could you check this?
} | ||
|
||
/// @inheritdoc CCIPReceiver | ||
function ccipReceive(Client.Any2EVMMessage calldata message) external override onlyRouter { |
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 are we overriding this instead of overriding _ccipReceive
internal function, which is the recommendation as far as I see.
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.
calldata can be used for storage, but memory can't be used for storage.
In definition of _ccipReceive, message type is memory, so can't use this to save on storage
/// @inheritdoc CCIPReceiver | ||
function ccipReceive(Client.Any2EVMMessage calldata message) external override onlyRouter { | ||
try this.processMessage(message) {} catch { | ||
emit FailedToDecodeMessage(); |
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 this catch not be used to set the message in the failed state? See this example receiver code
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 don't need to save failed status. we just need save failed or no.
mapping(uint64 selector => address bridge) public bridges; | ||
|
||
/// @dev Saves invalid message | ||
mapping(bytes32 messageId => Client.Any2EVMMessage message) private messageContents; |
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.
Depending on what you aim to do with this message, you could consider storing only the relevant part of the message. The entire message is pretty large and would take hundreds of thousands of gas to store, which might not be ideal on chains like Ethereum. Also note that this gas would come out of the message ccip specified gasLimit. Say you always send a msg with a gasLimit of 100k, the storing of failed messages would always run out of gas and you end up needing to manually execute the tx with a higher gas limit to properly store it as a failed message. Only then you can run handleInvalidMessage
to release the funds.
If you only need the tokens and amounts it's probably best to store those and potentially some context if required. With the messageID as key you could always get that context from CCIP as well but that would be an "external" dependency.
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.
from where, can I get context of message with message Id?
AaveCcipGhoBridge Smart Contract
Overview
The
AaveCcipGhoBridge
smart contract facilitates the secure bridging of GHO tokens across different blockchain networks using Chainlink's Cross-Chain Interoperability Protocol (CCIP). By leveraging Chainlink's decentralized infrastructure, it ensures reliable and transparent cross-chain token transfers while using GHO tokens exclusively for fees.Key Components
Router and GHO Addresses:
ROUTER
: The Chainlink CCIP router address for cross-chain communication.GHO
: Address of the GHO token, which the contract bridges across chains.Bridges Mapping:
Main Functionalities
Token Transfers:
checkDestination
modifier ensures that the destination chain and bridge are properly configured before any transfer.Fee Payment:
Cross-Chain Message Handling:
_ccipReceive
function.Quote Transfer:
quoteTransfer
function allows users to estimate the GHO fee required for a transfer without executing the transfer.Setting Destination Bridges:
setDestinationBridge
function.Security Features
Role-Based Access Control:
Uses
AccessControl
to manage permissions:DEFAULT_ADMIN_ROLE
: Grants administrative rights.BRIDGER_ROLE
: Restricts who can initiate bridging operations.This ensures that only authorized users can perform critical functions.
Destination Validation:
The
checkDestination
modifier ensures that the destination chain and bridge address are properly configured before executing transfers.Token Approval Management:
Securely handles GHO token approvals for the router, mitigating over-approval risks.
Rescue Functionality:
Implements a
Rescuable
mechanism, allowing theEXECUTOR
to rescue funds in emergencies while maintaining security boundaries.CCIP Sender and Receiver Validation:
Events
Error Handling
Deployed Addresses
Mainnet: 0x5648f519b2064ff30385828e76fefda749749ac2, Arbitrum: 0x03f589a825ee129c5c6d2f6ef5c259870019567b
Confirmed Bridges:
Conclusion
The
AaveCcipGhoBridge
smart contract provides a robust mechanism for bridging GHO tokens across multiple chains via Chainlink's CCIP. It offers flexibility in fee payments, supports secure cross-chain transfers, and allows for easy configuration of destination bridges.