Skip to content

feat(interface): typed vote and admin methods on MpcContractHandle - #3922

Open
kevindeforth wants to merge 3 commits into
mainfrom
kd/typed-vote-calls
Open

feat(interface): typed vote and admin methods on MpcContractHandle#3922
kevindeforth wants to merge 3 commits into
mainfrom
kd/typed-vote-calls

Conversation

@kevindeforth

@kevindeforth kevindeforth commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

resolves #3921, part of #3693

@kevindeforth
kevindeforth force-pushed the kd/typed-contract-updates branch 4 times, most recently from 586f5e8 to 2f5b732 Compare July 24, 2026 13:05
@kevindeforth
kevindeforth force-pushed the kd/typed-vote-calls branch from d100b5c to a5e813f Compare July 24, 2026 14:05
Base automatically changed from kd/typed-contract-updates to main July 24, 2026 20:20
@kevindeforth
kevindeforth force-pushed the kd/typed-vote-calls branch from e02ffa0 to 983363a Compare July 24, 2026 20:36
@kevindeforth
kevindeforth force-pushed the kd/typed-vote-calls branch from ff6c2c3 to afcab90 Compare July 24, 2026 20:47
Comment on lines +308 to +315
impl<E> From<PayloadBytesError> for MpcContractHandleError<E> {
fn from(value: PayloadBytesError) -> Self {
match value {
PayloadBytesError::Serialize(err) => MpcContractHandleError::Serialize(err),
PayloadBytesError::Overflow => MpcContractHandleError::Deposit(DepositOverflowError),
}
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kevindeforth
kevindeforth marked this pull request as ready for review July 24, 2026 20:59
@claude

This comment was marked as resolved.

…ant_url

The contract requires MINIMUM_NODE_MANAGEMENT_DEPOSIT on
update_participant_url like on register_backup_service and
start_node_migration; the handle attached nothing, failing the
update_participant_url e2e test.
@kevindeforth

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Jul 24, 2026

Copy link
Copy Markdown

Pull request overview

Follow-up review after the prior blocking finding on update_participant_url was addressed. The typed handle now correctly attaches MINIMUM_NODE_MANAGEMENT_DEPOSIT_YOCTONEAR on update_participant_url / register_backup_service / start_node_migration, the catalog snapshot has been regenerated (all three peer methods now show 1 yoctoNEAR), and the From<PayloadBytesError> impl replaces the inline match in propose_update.

Changes: unchanged from the earlier summary — the delta since is limited to the deposit fix on update_participant_url and the corresponding snapshot update.

Findings

Blocking: none — the prior update_participant_url deposit regression is resolved (see crates/near-mpc-contract-interface/src/client.rs:187-198 and .../catalog.snap:66-69, now 1 yoctoNEAR).

Non-blocking (nits, follow-ups):

  • crates/near-mpc-contract-interface/src/deposits.rs:14MINIMUM_NODE_MANAGEMENT_DEPOSIT_YOCTONEAR: u128 = 1 silently duplicates the contract's MINIMUM_NODE_MANAGEMENT_DEPOSIT = NearToken::from_yoctonear(1) at crates/contract/src/lib.rs:118. There's no test tying the two together — if a future change bumps the contract-side minimum, the interface would keep sending the old value and every #[payable] node-management call would revert at require_deposit(...). Compare STORAGE_BYTE_COST_YOCTONEAR__should_match_env_storage_byte_cost at .../deposits.rs:49, which does exactly this kind of drift-check. Consider either a small compile-time or runtime assert in the interface crate's tests, or a short doc comment on the constant noting the pairing.

  • crates/near-mpc-contract-interface/src/client.rs:309-315 — the new From<PayloadBytesError> for MpcContractHandleError<E> maps PayloadBytesError::Overflow (payload exceeds u128::MAX bytes) to MpcContractHandleError::Deposit(DepositOverflowError) whose message is "the required deposit exceeds u128::MAX yoctoNEAR". The two overflows are correlated in propose_update (huge payload ⇒ huge deposit) but not semantically the same, and the resulting error message would be misleading if it ever fired via a different call path. This isn't a regression (the previous inline match did the same thing), but now that this conversion is a reusable From impl it's worth either giving PayloadBytesError::Overflow its own MpcContractHandleError::PayloadTooLarge variant, or refining the DepositOverflowError message to cover both origins.

  • crates/near-mpc-contract-interface/src/client.rs:45VOTE_FOREIGN_CHAIN_GAS: NearGas = NearGas::from_tgas(30) is now a pub const on the interface (previously an e2e-only constant). Unlike SIGN_GAS / CKD_PV_GAS right next to it, there's no comment justifying the 30 Tgas figure. A one-liner noting that this covers the borsh-decode + threshold vote apply path would keep it consistent with its neighbors.

  • Follow-up from prior review still open: the suggested contract-side test update_participant_url__should_reject_when_no_deposit_attached alongside crates/contract/src/lib.rs:5080 / :5098 is not in this PR. Not blocking here, but worth tracking — this is exactly the regression that slipped through the earlier revision of this PR.

⚠️ Issues found (non-blocking)

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.

test(e2e): retire the raw contract-call helpers feat: typed vote and admin methods on MpcContractHandle

1 participant