Skip to content

Conversation

@chrismaree
Copy link
Member

@chrismaree chrismaree commented Oct 18, 2024

This is a feature branch where we will place all changes needed to be applied to the EVM to support Solana within across.

This branch contains 4 main categories of changes (each of which was originally a separate PR before moving them into this feature branch):

  1. Change input props & internal data structures within SpokePool.sol to be bytes32. This is a somewhat opinionated change & was done to support bytes32 address types. We also changed internal data structures as it make things easier to reason about.
  2. CCTP <> Solana Adapter. This change facilitates EVM <> SVM communication over CCTP. It contains an amount of wiring to enable the hub (which does not support bytes32, for example) to interface with SVM.
  3. Relayer repayment address as part of fill method. As a relayer will now have a separate address on EVM & SVM, they need the ability to inform the data worker where to be re-paid on the new domain.
  4. Improve how relayer repayments work, supporting blacklisted relayer addresses to not block bundles. Due to change 3, it is now trivial to set a relayer repayment address to a recipient that is blacklisted by the repayment token. If a relayer did this, they would be able to effectively block the whole bundle from being executed. To work around this, a new data structure relayerRefund is added that stores refunds that could not be executed due to reverting transfers. Relayers can then claim these separately, provided they can prove they own the original blocked address.

Reinis-FRP and others added 10 commits October 18, 2024 11:58
* feat(chain-adapters): add solana adapter

Signed-off-by: Reinis Martinsons <reinis@umaproject.org>

* fix: comments

Signed-off-by: Reinis Martinsons <reinis@umaproject.org>

* test: solana adapter

Signed-off-by: Reinis Martinsons <reinis@umaproject.org>

* Update contracts/chain-adapters/Solana_Adapter.sol

Co-authored-by: Chris Maree <christopher.maree@gmail.com>

* fix: do not hash bytes32 svm address

Signed-off-by: Reinis Martinsons <reinis@umaproject.org>

---------

Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
* feat: add address to bytes32 contract changes

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: remove todos

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: imports

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* Update contracts/SpokePool.sol

Co-authored-by: Reinis Martinsons <77973553+Reinis-FRP@users.noreply.github.com>

* feat: bytes 32 comparisons

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: format code

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: tests

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: bytes 32 check

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: ts

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: reuse lib in cctp adapter

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: _preExecuteLeafHook

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* refactor: comments

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: _verifyUpdateV3DepositMessage

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: backward compatibility

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: backwards compatibility tests

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: change comparison casting address bytes32

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* fix: test

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: merkle tree leaf to bytes32

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* test: leaf type update fixes

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

* feat: remove helper

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>

---------

Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
Co-authored-by: Reinis Martinsons <77973553+Reinis-FRP@users.noreply.github.com>
* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

---------

Signed-off-by: chrismaree <christopher.maree@gmail.com>
* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

* WIP

Signed-off-by: chrismaree <christopher.maree@gmail.com>

---------

Signed-off-by: chrismaree <christopher.maree@gmail.com>
Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
Signed-off-by: chrismaree <christopher.maree@gmail.com>
@chrismaree chrismaree marked this pull request as ready for review November 5, 2024 15:22
Copy link
Member

@nicholaspai nicholaspai left a comment

Choose a reason for hiding this comment

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

This code is very clean, amazing work that you all should be very happy with. I left some questions and will take a second pass once we go through them all

Copy link
Contributor

@mrice32 mrice32 left a comment

Choose a reason for hiding this comment

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

Looks awesome! Left a few questions to start. Still working my way through

*/

// solhint-disable-next-line contract-name-camelcase
contract Solana_Adapter is AdapterInterface, CircleCCTPAdapter {
Copy link
Contributor

Choose a reason for hiding this comment

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

How much of this contract is specific to Solana vs could be used with any chain we connect to via CCTP?

I haven't gone deep on the specifics, but, for instance, can we build an adapter that could be used just as well with an EVM chain like BSC?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is quite specific in a sense that it must be aware of Solana token model where recipient SpokePool address needs to be translated to its corresponding vault token address.

Comment on lines +185 to +191
return
abi.encodeWithSignature(
"setEnableRoute(bytes32,uint64,bool)",
SOLANA_USDC_BYTES32,
uint64(destinationChainId),
enable
);
Copy link
Contributor

Choose a reason for hiding this comment

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

OOC, why not do this mapping on the Solana side?

In theory, could we not have a mapping (from truncated address to full address) exist on the Solana side that could be modified by an admin call. Then, the flow to add a new token would require no contract changes:

  1. Send admin call to update the mapping with a new element.
  2. Add the route to use the newly added element.

Side note: this is somewhat similar to something we have to do on arbitrum.

Copy link
Contributor

Choose a reason for hiding this comment

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

We still need to map truncated USDC address to Solana spoke pool vault here to support relayTokens method used when rebalancing from HubPool to Solana spoke via CCTP token bridge. So if we were to add new token we would anyways need to redeploy the adapter, hence it is easier to keep all related aliasing contained in this contract.

md0x added 2 commits November 7, 2024 10:35
Signed-off-by: Pablo Maldonado <pablomaldonadoturci@gmail.com>
@md0x md0x added the do not merge do not merge label Nov 7, 2024
Signed-off-by: chrismaree <christopher.maree@gmail.com>
…873)

* fix: update legacy event to match old event signature

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

---------

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
bmzig and others added 6 commits February 4, 2025 17:37
)

* fix: hash entire message when calculating relay hash for evm chains

Signed-off-by: bennett <bennett@umaproject.org>

* make getV3RelayHash public

Signed-off-by: bennett <bennett@umaproject.org>

* update fixture with relay hash change

Signed-off-by: bennett <bennett@umaproject.org>

---------

Signed-off-by: bennett <bennett@umaproject.org>
* feat(SpokePool): Permit historical fillDeadline on deposit

This removes a sharp edge for pre-fill deposits, where the deposit comes
after the fill. Permitting a historical fillDeadline gives more
flexibility to the relayer around when they submit the deposit on the
origin chain.

* fix test

* restore test

* Bump approvals
Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
* fix: L02 _destinationSettler Can Return Zero Address

* updated implementation to be in internal function

Signed-off-by: Chris Maree <christopher.maree@gmail.com>

---------

Signed-off-by: Chris Maree <christopher.maree@gmail.com>
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
Co-authored-by: nicholaspai <npai.nyc@gmail.com>
* fix: hash entire message when calculating relay hash for evm chains

Signed-off-by: bennett <bennett@umaproject.org>

* make getV3RelayHash public

Signed-off-by: bennett <bennett@umaproject.org>

* update fixture with relay hash change

Signed-off-by: bennett <bennett@umaproject.org>

* improve: Verify relay hashes are the same pre and post upgrade

Adds a simple unit test to check that the same data hash is constructed

* fix

* Update test/evm/hardhat/MerkleLib.Proofs.ts

* Update test/evm/hardhat/SpokePool.Relay.ts

* Update SpokePool.Relay.ts

---------

Signed-off-by: bennett <bennett@umaproject.org>
Co-authored-by: bennett <bennett@umaproject.org>
nicholaspai
nicholaspai previously approved these changes Feb 5, 2025
nicholaspai and others added 3 commits February 5, 2025 11:10
Signed-off-by: bennett <bennett@umaproject.org>
Signed-off-by: bennett <bennett@umaproject.org>
nicholaspai
nicholaspai previously approved these changes Feb 5, 2025
Signed-off-by: bennett <bennett@umaproject.org>
@socket-security
Copy link

socket-security bot commented Feb 5, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@bmzig bmzig requested a review from nicholaspai February 5, 2025 19:22
nicholaspai
nicholaspai previously approved these changes Feb 5, 2025
mrice32
mrice32 previously approved these changes Feb 5, 2025
@bmzig bmzig dismissed stale reviews from mrice32 and nicholaspai via 7eabc13 February 6, 2025 00:37
@bmzig bmzig requested review from mrice32 and nicholaspai February 6, 2025 00:37
@bmzig bmzig merged commit 3b23cfb into master Feb 6, 2025
9 checks passed
@bmzig bmzig deleted the svm-dev branch February 6, 2025 01:20
@mrice32 mrice32 restored the svm-dev branch February 6, 2025 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants