feat: multi mcms per selector - #822
Closed
stackman27 wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds multi-MCM instance support per chain selector (proposal version v2), enabling operation attribution to a specific MCM contract instance and ensuring Merkle metadata, op counts, nonces, and root-setting behavior are computed per instance (not just per chain).
Changes:
- Introduces
mcmAddressattribution onOperation/BatchOperationandadditionalMCMsonChainMetadata, including merge/validation helpers. - Updates proposal hashing, nonce derivation, timelock conversion sequencing, and executable root-setting to work per (chain selector, MCM instance).
- Extends SDK executors/encoders with an optional per-instance root-setting path (
sdk.InstanceExecutor) to ensure on-chain root metadata matches per-instance Merkle leaves.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| types/operation.go | Adds optional mcmAddress to operation types for per-instance attribution. |
| types/chain.go | Adds AdditionalMCMs plus helpers for per-instance lookup/merge/validation. |
| types/chain_test.go | Adds unit tests for multi-MCM metadata helpers and merging. |
| timelock_proposal.go | Gates multi-MCM features on v2; resolves per-instance metadata and timelock address. |
| timelock_executable.go | Uses proposal helper to resolve the timelock address per batch op. |
| signable.go | Adds per-instance quorum checking and updates signature validation across instances. |
| sdk/ton/executor.go | Adds per-instance SetRoot path using explicit txCount for metadata encoding. |
| sdk/ton/encoder.go | Adds ToRootMetadataWithTxCount for per-instance postOpCount derivation. |
| sdk/sui/executor.go | Adds per-instance SetRoot path using explicit txCount. |
| sdk/solana/executor.go | Adds per-instance SetRoot path and threads txCount into metadata input. |
| sdk/executor.go | Introduces optional sdk.InstanceExecutor for per-instance SetRoot semantics. |
| sdk/evm/executor.go | Adds per-instance SetRoot path using explicit txCount. |
| sdk/evm/encoder.go | Adds ToGethRootMetadataWithTxCount for per-instance postOpCount derivation. |
| sdk/canton/executor.go | Adds per-instance SetRoot path using explicit txCount. |
| sdk/aptos/executor.go | Adds per-instance SetRoot path using explicit txCount. |
| proposal.go | Implements v2 + multi-MCM validation, per-instance metadata leaves, and per-instance nonces/encoders. |
| proposal_multimcm_test.go | Adds integration-style tests covering validation, Merkle determinism, conversion, and execution flows. |
| merge.go | Enhances timelock proposal merging to union compatible multi-MCM instance sets deterministically. |
| executable.go | Adds per-instance encoder usage and per-instance root-setting via sdk.InstanceExecutor. |
| executable_test.go | Adds EVM simulated test verifying SetRoot + Execute across two MCM instances. |
| builder.go | Adds builder helper for appending AdditionalMCMs entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+157
to
+161
| if bop.McmAddress == metadata.MCMAddress { | ||
| return m.TimelockAddresses[bop.ChainSelector] | ||
| } | ||
|
|
||
| return bop.McmAddress |
Comment on lines
+174
to
+179
| metadata, ok := s.proposal.ChainMetadata[chain].GetMCM(mcmAddress) | ||
| if !ok { | ||
| return false, fmt.Errorf( | ||
| "chain %d: mcmAddress %q does not match the chain's primary MCM or any additional MCM instance", | ||
| chain, mcmAddress) | ||
| } |
Comment on lines
+216
to
+220
| for chain, metadata := range s.proposal.ChainMetadata { | ||
| for _, instance := range metadata.AllMCMs() { | ||
| checkQuorum, err := s.CheckQuorumForMCM(ctx, chain, instance.MCMAddress) | ||
| if err != nil { | ||
| return false, err |
Comment on lines
+54
to
+56
| entry := b.baseProposal.ChainMetadata[selector] | ||
| entry.AdditionalMCMs = append(entry.AdditionalMCMs, metadata) | ||
| b.baseProposal.ChainMetadata[selector] = entry |
Comment on lines
+414
to
+420
| md, err := p.mcmMetadataForOp(o) | ||
| if err != nil { | ||
| counts[instanceKey{chainSelector: o.ChainSelector}]++ | ||
| continue | ||
| } | ||
| counts[instanceKey{chainSelector: o.ChainSelector, mcmAddress: md.MCMAddress}]++ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.