Skip to content
This repository was archived by the owner on Jun 9, 2026. It is now read-only.

feat(hook): add allowlist hooks for pre-block transaction and contract filtering#233

Merged
ARR4N merged 7 commits into
mainfrom
powerslider/152-libevm-tx-and-contract-hooks
Feb 26, 2026
Merged

feat(hook): add allowlist hooks for pre-block transaction and contract filtering#233
ARR4N merged 7 commits into
mainfrom
powerslider/152-libevm-tx-and-contract-hooks

Conversation

@powerslider

@powerslider powerslider commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Extend hook.Points with CanExecuteTransaction, mirroring params.RulesAllowlistHooks so consumers can use a single concrete type for both SAE and libevm hooks. Call CanExecuteTransaction via hooks in worstcase.ApplyTx() to exclude hook-rejected transactions before block inclusion, preventing fatal errors in the execution
loop.

  • Add CanExecuteTransaction to hook.Points and hookstest.Stub.
  • Call CanExecuteTransaction in worstcase.State.ApplyTx() instead of through libevm rules hooks.
  • Remove dead rules field from worstcase.State.
  • Add TestCanExecuteTransactionHook in worstcase package verifying blocked senders are excluded and state is not modified.
  • Add TestCanCreateContractSoftError confirming CanCreateContract rejection produces a failed receipt, not a fatal crash.

Signed-off-by: Tsvetan Dimitrov (tsvetan.dimitrov@avalabs.org)

@powerslider

Copy link
Copy Markdown
Contributor Author

@ARR4N @StephenButtolph I am open to all types of comments and feedback here since this was my first time developing logic around libevm hooks and running them on the SAE side. I've tried my best to simulate the hook validation scenarios and I think that it is correct, but I might be missing something so your feedback here would be invaluable 🙏

@ARR4N

ARR4N commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

We can't register any libevm extras in SAE because that precludes consumers from doing the same themselves. Even if we provided "piggyback" hooks to allow registration via SAE, every single change to libevm would have to be replicated here.

I recommend extending hook.Points to replicate the two allowlist hooks identically (the provider of the implementation can then use the exact same concrete implementation for both libevm and SAE hooks).

Why this should be merged

Check #152

Please don't refer to GitHub-specific entities in PR descriptions in lieu of details. It's OK to include them to trigger events (e.g. Closes <#>) but the descriptions become git commits and need to be self-contained.

@powerslider

Copy link
Copy Markdown
Contributor Author

@ARR4N yes now I recalled that you mentioned that SAE should not register libevm hooks. It slipped my radar, sorry. I will adapt the implemntation via hook.Points.

@powerslider powerslider force-pushed the powerslider/152-libevm-tx-and-contract-hooks branch 2 times, most recently from cf56218 to fb07dc3 Compare February 24, 2026 17:38
@powerslider powerslider changed the title feat(sae): register libevm extras and handle CanExecuteTransaction/CanCreateContract hooks feat(hook): add allowlist hooks to hook.Points for pre-block transaction and contract filtering Feb 24, 2026
Comment thread hook/hook.go Outdated
Comment thread hook/hookstest/stub.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread worstcase/state_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread saexec/saexec_test.go
Comment thread worstcase/state.go
Comment thread hook/hook.go Outdated
@powerslider powerslider force-pushed the powerslider/152-libevm-tx-and-contract-hooks branch 2 times, most recently from 2976741 to 4a49643 Compare February 25, 2026 12:35
…tion filtering

Extend `hook.Points` with `CanExecuteTransaction`, mirroring
`params.RulesAllowlistHooks` so consumers can use a single concrete
type for both SAE and `libevm` hooks. Call `CanExecuteTransaction` via
hooks in `worstcase.ApplyTx()` to exclude hook-rejected transactions
before block inclusion, preventing fatal errors in the execution
loop.

- Add `CanExecuteTransaction` to `hook.Points` and `hookstest.Stub`.
- Call `CanExecuteTransaction` in `worstcase.State.ApplyTx()` instead of
  through libevm rules hooks.
- Remove dead rules field from `worstcase.State`.
- Add `TestCanExecuteTransactionHook` in `worstcase` package verifying
  blocked senders are excluded and state is not modified.
- Add `TestCanCreateContractSoftError` confirming `CanCreateContract`
  rejection produces a failed receipt, not a fatal crash.

Signed-off-by: Tsvetan Dimitrov (tsvetan.dimitrov@avalabs.org)
@powerslider powerslider force-pushed the powerslider/152-libevm-tx-and-contract-hooks branch from 4a49643 to 6eb7be5 Compare February 25, 2026 15:12
Comment thread worstcase/state_test.go Outdated
Comment thread worstcase/state_test.go Outdated
Comment thread worstcase/state_test.go Outdated
Comment thread worstcase/state_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread sae/vm_test.go Outdated
Comment thread sae/vm_test.go Outdated
@powerslider powerslider changed the title feat(hook): add allowlist hooks to hook.Points for pre-block transaction and contract filtering feat(hook): add allowlist hooks for pre-block transaction and contract filtering Feb 26, 2026
Comment thread worstcase/state_test.go Outdated
Signed-off-by: Arran Schlosberg <519948+ARR4N@users.noreply.github.com>
@ARR4N ARR4N enabled auto-merge (squash) February 26, 2026 12:15
@ARR4N ARR4N merged commit 6e7c13d into main Feb 26, 2026
19 checks passed
@ARR4N ARR4N deleted the powerslider/152-libevm-tx-and-contract-hooks branch February 26, 2026 14:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Safe handling of libevm CanCreateContract() and CanExecuteTransaction() hooks

3 participants