-
Notifications
You must be signed in to change notification settings - Fork 98
Cross-chain Strategy #2715
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
base: master
Are you sure you want to change the base?
Cross-chain Strategy #2715
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2715 +/- ##
==========================================
+ Coverage 39.40% 43.81% +4.40%
==========================================
Files 126 133 +7
Lines 5789 6131 +342
Branches 1537 1636 +99
==========================================
+ Hits 2281 2686 +405
+ Misses 3506 3441 -65
- Partials 2 4 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| pragma solidity ^0.8.0; | ||
|
|
||
| /** | ||
| * @title OUSD Yearn V3 Remote Strategy Mock - the Mainnet part |
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 Mainnet part" should probably be "- the L2 chain part"
contracts/contracts/mocks/crosschain/CrossChainRemoteStrategyMock.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
* fix deploy files * minor rename * add calls to Morpho Vault into a try catch * refactor hook wrapper * don't revert if withdraw from underlying fails * use checkBalance for deposit/withdrawal acknowledgment * update message in remote strategy * remove unneeded functions
sparrowDom
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.
Latest batch of review comments
contracts/contracts/strategies/crosschain/CrossChainMasterStrategy.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/AbstractCCTPIntegrator.sol
Outdated
Show resolved
Hide resolved
contracts/contracts/strategies/crosschain/CrossChainRemoteStrategy.sol
Outdated
Show resolved
Hide resolved
* use Strategizable * Add comment --------- Co-authored-by: Shahul Hameed <10547529+shahthepro@users.noreply.github.com>
| uint256 balance = checkBalance(usdcToken); | ||
| bytes memory message = CrossChainStrategyHelper | ||
| .encodeBalanceCheckMessage(lastTransferNonce, balance, false); | ||
| _sendMessage(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.
I know we emit a more generic "MessageTransmitted" here. It might be useful to also emit a separate BalanceCheck event here.
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.
Any reason why this would be necessary? As far as our offchain component is concerned it's not gonna care about the payload, it only needs to know if there's a pending transfer for it to poll CCTP API for attestation and relay it
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.
Also, if we add this here, we will need to emit this whenever we send the balance check as an acknowledgement as well to be consistent. It's not a big deal but I don't see any particular reason why this would be necessary
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 was thinking that it might be useful for an offchain analytics / Grafana to detect if a balanceUpdate messages are being triggered as expected and that the earnings from the Remote to Master are being reported.
sparrowDom
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.
Posting a couple more comments
contracts/contracts/strategies/crosschain/CrossChainMasterStrategy.sol
Outdated
Show resolved
Hide resolved
|
WIP - publishing partial review Pending PRs:RequirementsPull request implements a strategy with a novel concept where the strategy contract is split into 2 parts each part residing on a different chain. The 2 strategy contracts use CCTP for USDC token transfer and message relaying between the 2 strategy components. One contract is called the master strategy and the other the remote strategy. Master strategy is the one receiving and sending funds from the vault. The remote strategy is responsible for deploying and withdrawing funds to the underlying platform. Easy ChecksAuthentication
Ethereum
Cryptographic code
Gas problems
Black magic
Overflow
License
Proxy
Events
Medium ChecksRounding and casts
Dependencies
External calls
Tests
Deploy
Strategy SpecificRemove this section if the code being reviewed is not a strategy. Strategy checks
Downstream
ThinkingLogicThe logic correctly handles the syncing of the strategies in respect of accounting for underlying balances, and messages / tokens being transferred via bridge. Also it considers that messages/tokens can have delayed arrival and can be delivered out of order.
Deployment Considerations🟠 Yes we need to figure out how to use a shared (probably multisig deployer) utilising CreateX so that the Proxy addresses of our strategies are on the same address across chains. Also the multisig will deploy via a deployer salt protection, meaning no other account can deploy to the same addresses. We plan to do this during or after the audit Resource usage
Internal StateThe Master strategy must always correctly account for the shared funds between itself and the Remote strategy. Its accounting might be out of sync with the actual state, but it must eventually be correct. Any intermittent state should not over account or under account (except for accrued rewards) the total amount of funds. It is designed to be delayed, but not incorrect. AttackThe 2 peer strategies trust the CCTP bridge when delivering messages and funds. It trusts that funds & message transfers happen in the CCTP documented procedure. Any deviation in this respect could cause unpredictable and potentially critical consequences. The strategy contracts don't have failsafes for such occurrences. The strategy also trusts Yearn team will effectively manage the Morpho V2 Vault. And if any portion of the funds in the Vault is not liquid, the Yearn team will make them liquid upon our request. There are no on-chain assurances for this. These are the risks with this strategy that can not be solved on-chain. FlavorCode is clean and effectively separates the CCTP communication part and the strategy logic part. This will be extra useful when we have other strategies implemented using CCTP as those will just reuse the CCTP bridge communication portion. |
Code Changes
Check readme: https://github.com/OriginProtocol/origin-dollar/blob/shah/cross-chain-strategy-cctpv2/contracts/contracts/strategies/crosschain/crosschain-strategy.md