Skip to content

fix(precompile-storage): clear stale dynamic tails after Cobalt#3987

Open
arjun-dureja wants to merge 1 commit into
mainfrom
arjundureja/bop-339-24-dynamic-storage-shrink-overwrites-leave-stale-tail-slots
Open

fix(precompile-storage): clear stale dynamic tails after Cobalt#3987
arjun-dureja wants to merge 1 commit into
mainfrom
arjundureja/bop-339-24-dynamic-storage-shrink-overwrites-leave-stale-tail-slots

Conversation

@arjun-dureja

Copy link
Copy Markdown

Summary

  • clear retired backing slots when shorter Bytes, String, or Vec<T> values overwrite longer values
  • preserve legacy storage and gas behavior before Cobalt
  • route zero writes through normal SSTORE accounting so EIP-2200/EIP-3529 refunds propagate

Implementation

  • add typed StorageSemantics::{Legacy, Cobalt} selected by BasePrecompiles
  • thread the selected semantics through direct and dynamically looked-up B-20 precompiles
  • clear long bytes/string chunks before writing new metadata
  • clear fully retired packed vector slots and recursively delete retired unpacked elements
  • preserve handler-based vector pushes so reused pre-Cobalt dynamic slots are cleaned correctly
  • reject static writes before preparatory cleanup SLOADs

Scope

This prevents new stale tails at and after Cobalt and cleans legacy tails when their metadata remains reachable. Historical orphaned slots whose old length metadata was already overwritten cannot be discovered without a separate state migration or high-water metadata.

Testing

  • cargo +nightly fmt --all -- --check
  • cargo test -p base-precompile-storage --all-features
  • cargo test -p base-common-precompiles
  • cargo test -p base-common-evm
  • cargo check -p base-precompile-storage --no-default-features
  • RISC0_SKIP_BUILD_KERNELS=1 BASE_SUCCINCT_ELF_STUB=1 cargo clippy -p base-precompile-storage -p base-common-precompiles -p base-common-evm --all-targets -- -D warnings

References

Co-authored-by: OpenCode <opencode-noreply@coinbase.com>
@linear

linear Bot commented Jul 16, 2026

Copy link
Copy Markdown

BOP-339

@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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.

2 participants