Skip to content

Provide detailed PR description for HopV2 implementation#41

Draft
Copilot wants to merge 28 commits intomasterfrom
copilot/sub-pr-36
Draft

Provide detailed PR description for HopV2 implementation#41
Copilot wants to merge 28 commits intomasterfrom
copilot/sub-pr-36

Conversation

Copy link

Copilot AI commented Dec 4, 2025

Responded to request for comprehensive PR documentation explaining the HopV2 protocol upgrade and architectural changes.

Response Content

Provided detailed technical overview covering:

  • Core architecture: Unified HopV2 base contract with namespaced storage (ERC-7201), inherited by both FraxtalHopV2 and RemoteHopV2
  • New interface: Extended sendOFT() to accept _dstGas and _data parameters for arbitrary cross-chain execution
  • Compose pattern: Recipients implement IHopComposer.hopCompose() to receive tokens + data and execute custom logic
  • Remote admin system: RemoteAdmin contracts enable Fraxtal multisig to configure destination chains via hop messages
  • Security enhancements: Message replay protection, trusted hop validation, pause controls
  • Dependency upgrade: OpenZeppelin 5.x for storage namespacing (prevents storage collisions during upgrades)

Interface Comparison

Old:

function sendOFT(address _oft, uint32 _dstEid, bytes32 _to, uint256 _amountLD)

New:

function sendOFT(
    address _oft,
    uint32 _dstEid,
    bytes32 _recipient,
    uint256 _amountLD,
    uint128 _dstGas,      // Gas for destination execution
    bytes memory _data    // Arbitrary payload
)

Recipients implementing IHopComposer receive callback:

function hopCompose(
    uint32 _srcEid,
    bytes32 _sender,
    address _oft,
    uint256 _amount,
    bytes memory _data
) external

No code changes were made - this was a documentation request addressed via PR comment response.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

denett and others added 28 commits September 23, 2025 16:17
* refactor: RemoteHopV2 composeMsg

* refactor: _sendLocal()

* refactor: FraxtalHopV2

* fix: compile

* revert: fee calculation

* revert: fee caluclations on FraxtalHop

* refactor: HopV2 with shared state

* refactor: _sendLocal()

* refactor: _sendToDestination()

* refactor: _isTrustedHopMessage

* docs: isTrustedHopMessage

* refactor: _validateComposeMessage()

* refactor: sendOFT()

* refactor: quote()

* refactor: localEid, endpoint to constructor

* refactor: successful HopMessage passing

* refactor: isTrustedHopMessage arg to hopCompose()

* build: upgrade frax-standard-solidity

* refactor: upgradeable HopV2

* fix: overwrite HopMessage from untrusted sender

* refactor: include data to HopMessage

* revert: hopCompose() remove _isTrustedHopMessage

* fix: replay on fraxtal of failing remoteHop.lzCompose()

* chore: docs

* nit: doc

* feat: remotely set admin funcs

* Revert "feat: remotely set admin funcs"

This reverts commit 0966000.

* chore: interfaces
* refactor: RemoteHopV2 composeMsg

* refactor: _sendLocal()

* refactor: FraxtalHopV2

* fix: compile

* revert: fee calculation

* revert: fee caluclations on FraxtalHop

* refactor: HopV2 with shared state

* refactor: _sendLocal()

* refactor: _sendToDestination()

* refactor: _isTrustedHopMessage

* docs: isTrustedHopMessage

* refactor: _validateComposeMessage()

* refactor: sendOFT()

* refactor: quote()

* refactor: localEid, endpoint to constructor

* refactor: successful HopMessage passing

* refactor: isTrustedHopMessage arg to hopCompose()

* build: upgrade frax-standard-solidity

* refactor: upgradeable HopV2

* fix: overwrite HopMessage from untrusted sender

* refactor: include data to HopMessage

* revert: hopCompose() remove _isTrustedHopMessage

* fix: replay on fraxtal of failing remoteHop.lzCompose()

* chore: docs

* nit: doc

* feat: remotely set admin funcs

* feat: remotely set admin funcs

* fix: only allow self-calls

* chore: interfaces

* feat: HopSetter

* scripts: deploy hop setter

* Revert "feat: remotely set admin funcs"

This reverts commit 0966000.

* chore: fmt

* refactor: add-back access control

* chore: rm warnings

* ops: deploy HopV2 on arb, base

* refactor: localEid to storage

* fix: HopSetter receive()

* fix: proxy addr instead of imp

* demo: set Solana executor options

* refactor: deploy checklist

* refactor: AccessControlEnumerableUpgradeable

* chore: fmt

* refactor: amount => amountLD

* fix: support oz 5.x

* ops: re-deploy hops, hopSetter

* feedback: @tom2o17

* feat: RemoteAdmin with Fraxtal registry (#38)

* feat: RemoteAdmin with Fraxtal registry

* chore: rm old hopCompose within HopV2

* chore: rm HopSetter scripts

* feedback: tom2o17

* refactor: rm REMOTE_ADMIN_ROLE

* chore: lint

* chore: add pauser roles to msig signers

* chore: lint

* chore: improve RemoteAdmin docs
Copilot AI mentioned this pull request Dec 4, 2025
Copilot AI changed the title [WIP] Add HopV2 protocol for sending arbitrary data Provide detailed PR description for HopV2 implementation Dec 4, 2025
Copilot AI requested a review from pegahcarter December 4, 2025 18:16
@pegahcarter
Copy link
Collaborator

@copilot also describe RemoteVault and it's functionality.

Copy link
Author

Copilot AI commented Dec 4, 2025

@copilot also describe RemoteVault and it's functionality.

RemoteVaultHop System

The RemoteVaultHop system enables users to deposit into and redeem from ERC-4626 vaults on remote chains using cross-chain token hops.

Architecture

1. RemoteVaultHop Contract

  • Core orchestrator implementing IHopComposer to handle vault operations across chains
  • Manages both local vaults (on the same chain) and remote vaults (on other chains)
  • Tracks user deposits via synthetic RemoteVaultDeposit ERC20 tokens

2. RemoteVaultDeposit Contract

  • ERC20 receipt token representing user deposits in remote vaults
  • Tracks price-per-share with linear interpolation over 100 blocks for smooth price updates
  • Provides convenience methods: deposit() and redeem() forward calls to RemoteVaultHop
  • Users interact with this token to manage their remote vault positions

Cross-Chain Vault Operations

Deposit Flow (Chain A → Vault on Chain B):

  1. User calls RemoteVaultDeposit.deposit(_amount) on Chain A
  2. Transfers tokens to RemoteVaultHop and calls HOP.sendOFT() with Action.Deposit message
  3. RemoteVaultHop on Chain B receives via hopCompose(), calls vault.deposit()
  4. Chain B sends Action.DepositReturn message back with shares received + vault price-per-share
  5. Chain A receives return message, mints RemoteVaultDeposit tokens to user, updates price

Redeem Flow (Chain A ← Vault on Chain B):

  1. User calls RemoteVaultDeposit.redeem(_amount) on Chain A (burns deposit tokens)
  2. Sends Action.Redeem message to Chain B
  3. Chain B calls vault.redeem(), sends tokens back with Action.RedeemReturn message
  4. Chain A receives underlying tokens, transfers to user

Key Features

Storage Mappings:

  • vaultShares: Maps local vault addresses to their share tokens (ERC-4626)
  • balance[vault][srcEid][srcAddress]: Tracks shares owned per vault per remote user
  • depositToken[eid][vault]: Maps remote vaults to their synthetic RemoteVaultDeposit tokens
  • remoteVaultHops[eid]: Registry of RemoteVaultHop addresses on other chains

Message Types (Actions enum):

  • Deposit: Initial deposit request to remote vault
  • DepositReturn: Confirmation with shares minted + price update
  • Redeem: Redemption request from remote vault
  • RedeemReturn: Underlying tokens returned + price update

Fee Calculation:
The quote() function calculates round-trip fees including:

  • A → Fraxtal (or A → Fraxtal → B for cross-remote deposits)
  • Return journey fees (Fraxtal → A or B → Fraxtal → A)
  • Accounts for 3-hop scenarios when neither chain is Fraxtal

Security:

  • Only RemoteVaultHop can mint/burn RemoteVaultDeposit tokens
  • Validates incoming messages are from registered RemoteVaultHops
  • recover() function for emergency fund rescue (added in commit a529d88)

Base automatically changed from FraxtalHopV2 to master February 18, 2026 16:58
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.

3 participants