Skip to content

feat(precompiles): read and write account config commitments from precompile storage - #8482

Merged
joshieDo merged 3 commits into
mainfrom
joshie/precompile-config-commitment-storage
Oct 20, 2026
Merged

joshieDo merged 3 commits into
mainfrom
joshie/precompile-config-commitment-storage

Conversation

@joshieDo

Copy link
Copy Markdown
Member

Adds config_commitment and set_config_commitment to PrecompileStorageProvider and StorageCtx, so a precompile can read and write an account's config commitment. Writes need T14, a nonzero commitment and a non-static call, and an intrinsic write needs an empty commitment.

Main has no account extension yet, so the EVM provider reads zero and rejects every write; HashMapStorageProvider keeps commitments in a side map for tests. Nothing calls it yet: the native multisig precompile is the first user.

…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]>
@joshieDo

Copy link
Copy Markdown
Member Author

cyclops audit fast note="7510 is the PR for the TIPs. This Pr only adds account config commitment reads and writes to precompile storage"

@tempoxyz-bot

tempoxyz-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Cyclops Security Review: safe to merge

Last reviewed: 24b781f (latest) · no open findings

…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]>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📊 Tempo Precompiles Coverage

📦 Download full HTML report

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment on lines +45 to +59
Intrinsic,
/// Charge the explicit precompile operation here: the field write, plus TIP-1000's
/// new-account cost (regular and state gas) when the write finds the account still empty.
Precompile,
}

impl ConfigCommitmentWriteGas {
fn cost(self, previous: B256) -> Result<u64> {
match self {
Self::Intrinsic if previous.is_zero() => Ok(0),
Self::Intrinsic => Err(TempoPrecompileError::InvalidConfigCommitmentWrite),
Self::Precompile if previous.is_zero() => Ok(CONFIG_COMMITMENT_REGISTRATION_GAS),
Self::Precompile => Ok(CONFIG_COMMITMENT_UPDATE_GAS),
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 (optional) A precompile writing to a still-empty account would be undercharged, because the documented TIP-1000 new-account cost is never charged. The doc comment on ConfigCommitmentWriteGas::Precompile says that cost (regular and state gas) is included. cost() at mod.rs:55-56 returns only CONFIG_COMMITMENT_REGISTRATION_GAS (20,000) or 5,000. It never checks whether the account is empty. Fix: either charge the TIP-1000 new-account cost in the Precompile path when the account is empty, or change the doc so the planned multisig caller knows to charge it itself.

Why this was flagged

The doc comment at crates/precompiles/src/storage/mod.rs:46-47 says the Precompile variant charges "the field write, plus TIP-1000's new-account cost (regular and state gas) when the write finds the account still empty". ConfigCommitmentWriteGas::cost at mod.rs:51-59 looks only at previous. It returns 20,000 or 5,000 and never reads account emptiness or adds any new-account or state gas. The only implementation, HashMapStorageProvider::set_config_commitment at hashmap.rs:304-318, just calls deduct_gas(gas.cost(previous)?), and nothing else adds the cost. The PR says the native multisig precompile will be the first caller. If it trusts this doc, it will not charge new-account gas itself, so registering a commitment on an empty account would be underpriced compared with what TIP-1000 requires. There is no base behaviour to compare against because this API is new, and nothing guards against the doc and code disagreeing.

Verification: Trigger: a Precompile-mode write to an account that is still empty. The doc comment at crates/precompiles/src/storage/mod.rs:46-47 says the Precompile variant charges TIP-1000's new-account cost, but ConfigCommitmentWriteGas::cost (mod.rs:51-59) only looks at previous and never checks whether the account is empty. So the code charges less than its own documented contract.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The doc covers the whole Precompile charge, not just cost(). cost() is the field write; the TIP-1000 new-account cost is added by the EVM write path when the account is still empty. That path isn't on main yet (the EVM provider rejects every commitment write here) and lands with the stack:

self.deduct_gas(gas.cost(previous)?)?;
// The write makes an empty account permanent; an intrinsic write was priced with the
// transaction, creation included.
if creates_account && gas == ConfigCommitmentWriteGas::Precompile {
self.deduct_gas(self.gas_params.get(GasId::new_account_cost()))?;
self.deduct_state_gas(self.gas_params.new_account_state_gas())?;
}
. Keeping the doc as is so it doesn't need rewording back.

Comment on lines +250 to +269
/// Reads the commitment with normal account-access gas.
/// Providers that cannot store commitments report zero for every account.
fn config_commitment(&mut self, address: Address) -> Result<B256> {
self.with_account_info(address, &mut |_| {})?;
Ok(B256::ZERO)
}

/// Writes an authorized nonzero commitment through the account journal.
/// Callers must validate registration, rotation, or migration authority first.
/// Account-access gas belongs to that authorization read; this method charges
/// only what `gas` names, or nothing when registration was charged intrinsically.
/// Providers that cannot store commitments reject every write.
fn set_config_commitment(
&mut self,
_address: Address,
_commitment: B256,
_gas: ConfigCommitmentWriteGas,
) -> Result<()> {
Err(TempoPrecompileError::InvalidConfigCommitmentWrite)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note: would be nice to drop default impls once we enable revm's account-ext cfg and do the actual evm impl

@joshieDo
joshieDo added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 3eeb65a Oct 20, 2026
87 checks passed
@joshieDo
joshieDo deleted the joshie/precompile-config-commitment-storage branch October 20, 2026 16:02
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-tempoxyz__tempo that referenced this pull request Oct 21, 2026
…red (tempoxyz#8486)

Stacked on tempoxyz#8502 (the configurable
account rename); merge after it.

Adds the configurable account precompile (`IConfigurableAccount`):
account derivation, config updates and `upgradeAccount`, which installs
a version-one config commitment through tempoxyz#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.

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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