Skip to content

fix: reentrancy.Guard() panic on static call#284

Merged
StephenButtolph merged 2 commits into
mainfrom
arr4n/reentrancy-guard-fix
Apr 30, 2026
Merged

fix: reentrancy.Guard() panic on static call#284
StephenButtolph merged 2 commits into
mainfrom
arr4n/reentrancy-guard-fix

Conversation

@ARR4N
Copy link
Copy Markdown
Collaborator

@ARR4N ARR4N commented Apr 30, 2026

Why this should be merged

Could cause a panic on a live chain. This isn't in production anywhere so no upgrade is required.

How this works

Checks for a read-only environment before using the state DB, which would otherwise result in a nil-pointer dereference.

This actually points to a deeper code smell about vm.PrecompileEnvironment in that it's too easy to misuse the StateDB() method. It should probably have its return signature changed to (*state.StateDB, error) and return vm.ErrWriteProtection instead of a nil DB when in read-only contexts.

How this was tested

Extended existing integration test to perform a static call to the guarded precompile, asserting a vm.ErrWriteProtection.

@ARR4N ARR4N requested a review from StephenButtolph April 30, 2026 06:54
@StephenButtolph StephenButtolph merged commit 63a0b4c into main Apr 30, 2026
12 checks passed
@StephenButtolph StephenButtolph deleted the arr4n/reentrancy-guard-fix branch April 30, 2026 13:33
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