Repository navigation
feat(precompiles): add the configurable account precompile, unregistered - #8486
Conversation
…e block env Adds `multisigRecoveryFactory` to the genesis info and `TempoBlockEnv`, set by both `TempoEvmConfig` env builders, and `is_valid_native_account`. Nothing calls them yet. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…isting items Moves `TempoGenesisInfo::multisig_recovery_factory` to the bottom of its impl, drops the doc's mention of pool and RPC callers that main does not have, and puts the changelog entry in the past tense used by the other entries. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…overy factory Ports the reserved-address table from the stack's genesis rejection test onto `is_valid_native_account` directly, since main has no `try_from_genesis` to reach it, and ports the public-network `None` checks for the recovery factory. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ing fields Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…compile storage Adds config-commitment reads and writes to precompile storage, with the TIP-1108 write charges and an InvalidConfigCommitmentWrite error. Nothing calls them yet; only the in-memory provider stores commitments. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…he storage module patterns The write check had one caller, the in-memory provider, so it moves into it. The static-context override joins the test-utils fixture setters, imports join the existing storage imports, and the error message is capitalized like its neighbours. The EVM read test now also pins that a read touches the account it was asked about. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hie/multisig-recovery-factory-env' into joshie/native-multisig-precompile Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Adds `NativeMultisig` (deriveAccount, getConfigCommitment, updateConfig, upgradeAccount) with its transaction-authority seed. Nothing registers, dispatches to or seeds it yet. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ative multisig precompile The dispatch module is public and documented like every other precompile, the recovery factory override joins the test-utils fixture setters, and the tests read events through the existing accessor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ Changelog found on PR. |
📊 Tempo Precompiles Coverage |
…e other precompiles Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…e/native-multisig-precompile Conflicts in crates/chainspec/src/spec.rs and crates/primitives/src/block.rs resolved by taking the merged main side (the TODO lines from #8477). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
cyclops audit fast note="7510 is the PR for the TIPs. This Pr only adds the native multisig precompile, not registered at an address yet" |
✅ Cyclops Security Review: safe to mergeLast reviewed: e1e60d0 (latest) · no open findings |
| @@ -0,0 +1,35 @@ | |||
| //! ABI dispatch for the [`NativeMultisig`] precompile. | |||
|
|
|||
| use super::NativeMultisig; | |||
There was a problem hiding this comment.
i think product wants to name ConfigurableAccount, personally i prefer TempoAccount or NativeAccount haha
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| #[contract(addr = NATIVE_MULTISIG_ADDRESS)] | ||
| pub struct NativeMultisig { | ||
| tx_origin: Address, | ||
| directly_authorized_account: Address, | ||
| upgrade_eligibility: UpgradeEligibility, | ||
| } |
There was a problem hiding this comment.
can we document that all storage is transient in case that we ever add persistent storage?
right now the contract macro has a limitation that forces transient storage to always be at the end
| fn upgrade_account( | ||
| &mut self, | ||
| sender: Address, | ||
| threshold: u8, | ||
| owners: Vec<INativeMultisig::MultisigOwner>, | ||
| ) -> Result<B256> { |
There was a problem hiding this comment.
idk if u plan on adding tx_origin == sender in the handler, but i since u added the check in fn update_config(), i think it's missing here too
| { | ||
| return Err(NativeMultisigError::unauthorized_multisig_caller().into()); | ||
| } | ||
| self.factory()?; |
There was a problem hiding this comment.
is this check needed? (also in fn upgrade_account())
the result is discarded and clanker says neither TIP-1109 nor TIP-1113 mention it
| current.threshold, | ||
| ¤t.owners, | ||
| ); | ||
| current.validate_for_account(sender)?; |
There was a problem hiding this comment.
TIP-1109 says a stale current gets InvalidConfig, and applies the detailed error table to the new configuration.
since only validated configs are stored, we can skip the check and directly hash current and map any preimage error to InvalidConfig.
| let has_code = self | ||
| .storage | ||
| .with_account_info(sender, |info| Ok(!info.is_empty_code_hash()))?; | ||
| let commitment = self.storage.config_commitment(sender)?; | ||
| if has_code { | ||
| return Err(NativeMultisigError::account_has_code().into()); | ||
| } | ||
| if !commitment.is_zero() { | ||
| return Err(NativeMultisigError::account_already_configurable().into()); | ||
| } |
There was a problem hiding this comment.
this loads the account twice: once in with_account_info, then again inside config_commitment (an extra warm access). Ideally both values would come from a single account load.
There was a problem hiding this comment.
Agreed. On main, AccountInfo has no commitment field yet, so the commitment needs a second read. The stack already reads both in one load:
tempo/crates/precompiles/src/native_multisig/mod.rs
Lines 131 to 135 in 0008f1e
That version replaces this one when the stack lands. Until then the precompile isn't registered, so the extra read can't be hit.
| current.validate_for_account(sender)?; | ||
| let stored = self.get_config_commitment(sender)?; | ||
| let hash = self.storage.keccak256(¤t.commitment_preimage()?)?; | ||
| if stored.is_zero() || stored != hash { |
There was a problem hiding this comment.
nit: stored.is_zero() seems redundant here as stored != hash already covers it
| ) -> Result<Address> { | ||
| let factory = self.factory()?; | ||
| let config = config(salt, 0, threshold, owners); | ||
| config.validate()?; |
There was a problem hiding this comment.
nit: maybe worth explaining that we validate twice to avoid charging account proof gas for invalid configs
| let eligibility = self.upgrade_eligibility.t_read()?; | ||
| if eligibility == UpgradeEligibility::NotSoleCall { | ||
| return Err(NativeMultisigError::upgrade_must_be_only_call().into()); | ||
| } | ||
| if eligibility == UpgradeEligibility::NotPrimitiveRoot { | ||
| return Err(NativeMultisigError::primitive_root_required().into()); | ||
| } |
| fn config( | ||
| salt: B256, | ||
| version: u64, | ||
| threshold: u8, | ||
| owners: &[INativeMultisig::MultisigOwner], | ||
| ) -> MultisigConfig { | ||
| MultisigConfig { | ||
| salt, | ||
| version, | ||
| threshold, | ||
| owners: owners | ||
| .iter() | ||
| .map(|owner| MultisigOwner { | ||
| owner: owner.owner, | ||
| weight: owner.weight, | ||
| }) | ||
| .collect(), | ||
| } | ||
| } |
There was a problem hiding this comment.
nit: this can be reused on tests/native_multisig.rs
…ry accessor Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…multisig-precompile Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…gurable account Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…umns Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…able account tests Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Native account only means an address outside the precompile, virtual and zero ranges; it does not say which account type lives there. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The direct authority is only seeded with the transaction's quorum account, which validation binds to the caller, so it already implies the origin. Saves one transient read. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…multisig-precompile Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| // The wrapper rejects delegatecall. `directly_authorized_account` is seeded only with the | ||
| // account of the transaction's outer owner quorum, which validation binds to the | ||
| // transaction caller, so a match with `sender` already implies `sender` is the origin. | ||
| if sender.is_zero() || self.directly_authorized_account.t_read()? != sender { |
There was a problem hiding this comment.
🟡 (optional) If the handler ever seeds a direct authority that is not the tx origin, contract code running as that account can rewrite its owners mid-transaction. updateConfig now checks only directly_authorized_account == sender (mod.rs:88). The guarantee that this account is the origin is a comment, and set_authority does not enforce it: it takes origin and directly_authorized as separate inputs. Fix: keep the tx_origin.t_read()? == sender check, which is one warm TLOAD. Or make set_authority reject a non-zero directly_authorized that differs from origin, so the invariant holds inside this precompile.
Why this was flagged
The trigger is a handler, still unwritten because nothing calls set_authority yet, that seeds directly_authorized_account with account A while tx_origin is some other address. For A to be sender without being the origin, A must be executing code, for example code reached through a call chain. That code then calls updateConfig. The check at mod.rs:88 passes, and A's config commitment is replaced with new owners and threshold. The previous commit also required tx_origin == sender. Together with "a validated configurable account origin cannot have code", that limited authority to protocol-created top-level batch calls. The removed test case (account, EOA, account) covered exactly this, and the new test at configurable_account.rs:327-329 now asserts that origin=EOA with directly_authorized=account succeeds. The only safeguard left is the comment at mod.rs:85-87. set_authority (mod.rs:43-53) stores both values independently and does not check them.
Verification: At mod.rs:88, update_config checks only sender.is_zero() || self.directly_authorized_account.t_read()? != sender, and nothing reads tx_origin on that path. set_authority (mod.rs:42-53) takes origin and directly_authorized as separate parameters, writes both without comparing them, and enforces nothing. Against the base branch nothing regresses: the whole file is new in this diff.
|
Docker request accepted: Status: success · Build run · Attempt 1 Built commit: Images reported by the successful push step (the overall run result above also includes later steps):
Pull with |
Point the e2e at the image built from tempoxyz/tempo#8486, rename the genesis key to configurableAccountRecoveryFactory, and activate T14. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB
* chore: add configurable accounts Tempo sync plan Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB (cherry picked from commit b126168) * feat(tempo): sync configurable accounts with Tempo main Rename the configurable account hash domains to tempo:configurable-account:* (tempoxyz/tempo#8502) and pin Tempo's Rust vectors in tests. Add AccountConfig.fromUpgrade for TIP-1113 in-place migration, reject admin key authorizations signed by configurable accounts (TIP-1137), and stop passing empty or 3-byte simulation keyData the node rejects. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB (cherry picked from commit f52be77) * test(tempo): run configurable account e2e against the pr-8486 image Point the e2e at the image built from tempoxyz/tempo#8486, rename the genesis key to configurableAccountRecoveryFactory, and activate T14. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB (cherry picked from commit cf0b920) * fix(tempo): accept configurable key grants without an account binding The node binds a root-signed grant to its signer and only requires `account` on admin-signed grants (TIP-1049), so ox rejected valid grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB (cherry picked from commit 88a0e8d) * fix(tempo): allow unbound configurable grants in 0.x types 0.x also required `account` for configurable grants at the type level, in `KeyAuthorization.Input` and `KeyAuthorization.Rpc`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * ci: pin browser tests to ubuntu-24.04 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * fix(tempo): reject admin grants of configurable account keys Configurable key types only exist from T14, where TIP-1137 rejects every admin grant, so an isAdmin grant of a configurable key is always invalid, whoever signs it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB (cherry picked from commit 121d138) * docs: correct stale configurable accounts plan notes Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * feat(tempo): sync configurable accounts with the T14 devnet checkpoint Match tempoxyz/tempo joshie/configurable-t14-devnet-checkpoint: the RPC key type is configurableAccount and the request field is configurableAccountSimulation, the simulation spec carries an optional grant signer, and configurable accounts may be or authorize admin keys, so the TIP-1137 guard is removed. The e2e runs against image sha-04e67d3. (cherry picked from commit e7be197) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB --------- Co-authored-by: Claude <[email protected]>
* chore: add configurable accounts Tempo sync plan Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * feat(tempo): sync configurable accounts with Tempo main Rename the configurable account hash domains to tempo:configurable-account:* (tempoxyz/tempo#8502) and pin Tempo's Rust vectors in tests. Add AccountConfig.fromUpgrade for TIP-1113 in-place migration, reject admin key authorizations signed by configurable accounts (TIP-1137), and stop passing empty or 3-byte simulation keyData the node rejects. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * test(tempo): run configurable account e2e against the pr-8486 image Point the e2e at the image built from tempoxyz/tempo#8486, rename the genesis key to configurableAccountRecoveryFactory, and activate T14. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * test(tempo): update zod account operation hash for the new domains Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * fix(tempo): accept configurable key grants without an account binding The node binds a root-signed grant to its signer and only requires `account` on admin-signed grants (TIP-1049), so ox rejected valid grants. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * ci: pin browser tests to ubuntu-24.04 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * fix(tempo): reject configurable admin grants in the zod schemas The core KeyAuthorization conversions already reject them (TIP-1137); the Rpc, Domain and DomainToRpc schemas now enforce the same invariant. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * fix(tempo): reject admin grants of configurable account keys Configurable key types only exist from T14, where TIP-1137 rejects every admin grant, so an isAdmin grant of a configurable key is always invalid, whoever signs it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB * feat(tempo): sync configurable accounts with the T14 devnet checkpoint Match tempoxyz/tempo joshie/configurable-t14-devnet-checkpoint: the RPC key type is configurableAccount and the request field is configurableAccountSimulation, the simulation spec carries an optional grant signer, and configurable accounts may be or authorize admin keys, so the TIP-1137 guard is removed. The e2e runs against image sha-04e67d3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UUGrLTHJy3Rheqc2GoFoTB --------- Co-authored-by: Claude <[email protected]>
Stacked on #8502 (the configurable account rename); merge after it.
Adds the configurable account precompile (
IConfigurableAccount): account derivation, config updates andupgradeAccount, which installs a version-one config commitment through #8482's precompile storage. It is not registered at an address yet, so nothing on main can call it; the stack registers it at T14.