unify contract callsites#3727
Draft
kevindeforth wants to merge 10 commits into
Draft
Conversation
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.
Disclaimer: This is a proposal, subject to discussion, not intended for merge yet
Background
We currently have four different components that call the MPC contract:
Each component follows its own, unique call-pattern and constructs the json function call arguments.
This has two downsides:
This PR is a proposal on how to unify the pattern across our crates. It centralizes the MPC contract API in contract-interface/src/call_args and introduces a new trait
CallContract:The idea is to have a central source of truth for constructing contract call arguments, and allowing each component (devnet, e2e test, contract sandbox tests and MPC node), to implement
CallContractfor their own types. This way, no matter the crate, a call to the contract will always read similar:Examples
Currently, each one of these components has their own call-pattern. Some examples:
Propose Contract Update:
devenet:
mpc/crates/devnet/src/mpc.rs
Lines 505 to 523 in cd067dd
e2e test:
mpc/crates/e2e-tests/src/cluster.rs
Lines 940 to 951 in cd067dd
sandbox:
mpc/crates/contract/tests/sandbox/upgrade_from_current_contract.rs
Lines 59 to 69 in cd067dd
Signature Request:
devnet:
mpc/crates/devnet/src/loadtest.rs
Lines 289 to 333 in 0c217e0
e2e-test:
mpc/crates/e2e-tests/src/cluster.rs
Lines 779 to 789 in cd067dd
sandbox:
mpc/crates/contract/tests/sandbox/sign.rs
Lines 201 to 206 in cd067dd
The node follows an entirely different pattern, having a registry for the call patterns in indexer/types.rs
mpc/crates/node/src/indexer/types.rs
Lines 104 to 122 in cd067dd
and the call submission logic in tx_sender:
mpc/crates/node/src/indexer/tx_sender.rs
Lines 147 to 184 in cd067dd