paritytech / paritytech/web3-storage
Replace the per-provider replay window with a per-owner agreement nonce
@danielbui12 is already working on this.
Since Sep 15, 2026.
- Dominant language
- Rust
- Stars
- 12
- Forks
- 3
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 33
Description
Problem
AgreementTerms.nonce is provider-chosen and checked against a per-provider
sliding replay window (ProviderReplayStates: StorageMap<AccountId, ReplayWindow>,
crates/primitives/storage/src/provider_replay_state.rs): a 1024-bit bitmap
anchored at the highest accepted nonce, with NonceAlreadyUsed / NonceTooOld
rejections (#105).
That is more machinery than the problem needs:
- Provider must keep durable nonce state. Reuse a nonce after a restart and
the quote is rejected; fall more than 1024 behind the newest redeemed quote and
it is rejected as too old. Neither failure exists for the party actually
submitting the transaction. - Ties replay protection to provider lifetime.
complete_deregisterclears
ProviderReplayStates, so a quote signed before deregistering could be
redeemed against a re-registration. Today this is what the
DeregisterAnnouncementPeriod > RequestTimeoutinvariant papers over, and it
is one of the obstacles to a one-stepderegister_provider. - 136 bytes per provider plus bit-shift logic for a check that is
structurally identical to the system account nonce.
Proposal
Model it on the system account nonce, keyed by the owner (already in the
signed terms; redemption already requires origin == terms.owner):
/// Next expected `AgreementTerms.nonce` per owner.
#[pallet::storage]
pub type AgreementNonces<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, u64, ValueQuery>;
// in both establish_* paths, after signature verification:
ensure!(terms.nonce == AgreementNonces::<T>::get(&owner), Error::<T>::NonceMismatch);
AgreementNonces::<T>::mutate(&owner, |n| *n = n.saturating_add(1));
Flow: owner reads AgreementNonces[owner], passes it in the quote request, the
provider signs the terms as given. Redemption checks equality and increments.
An owner with several quotes outstanding hands out consecutive nonces and
redeems them in that order, exactly as it would batch transfers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.