Skip to content

supervisor and testing: interop: reorg-testing: reorg a chain with invalid exec msg#15662

Merged
protolambda merged 7 commits intodevelopfrom
nonsense/reorg-invalid-exec-msg
May 19, 2025
Merged

supervisor and testing: interop: reorg-testing: reorg a chain with invalid exec msg#15662
protolambda merged 7 commits intodevelopfrom
nonsense/reorg-invalid-exec-msg

Conversation

@nonsense
Copy link
Contributor

@nonsense nonsense commented May 2, 2025

Description

This PR is adding 3 changes - reorg tests, happy interop init/exec msg test and modification to DecodeExecutingMessageLog behavior.

1. Reorg test

Adding tests for the reorg functionality of the supervisor when it detects an invalid exec msg:

  1. We make an unsafe block that includes an invalid exec msg on chain A (the identifier of the exec msg points to unknown chain)
  2. We wait for the supervisor to trigger a reorg on the executing side (chain A), without change to the initiating side (chain B).

This implies the sequencer is malicious. To cover this scenario, we use the op-test-sequencer to force in the bad tx.

2. Modification to DecodeExecutingMessageLog behavior

DepSet now includes a reserved ChainIndex for an unknown chain. We make sure that no chain is using that index when hydrating/initialising the set from config.

Conversion of ChainID to ChainIndex within DecodeExecutingMessageLog remains, during parsing of ExecutingMessage (EM) but if we see an unknown chain, we convert ChainID to the reserved chain index for unknown chain, essentially losing the value within our internal database. Later that EM is discarded the same way we discard other EMs for other validation errors.

This way the supervisor correctly triggers a reorg of the chain, and issues a similar error as other validation problems (such as invalid block number, or invalid log index, etc.)

3. Happy-path interop init/exec msg test

Confirming the changes in behavior in point 2. are not affecting correctly formatted EMs

Metadata

Fixes: #15500

@nonsense nonsense changed the base branch from develop to nonsense/reorg-initiating-msg May 2, 2025 12:14
@wiz-inc-a178a98b5d
Copy link

wiz-inc-a178a98b5d bot commented May 2, 2025

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities
Data Finding Sensitive Data
Secret Finding Secrets
IaC Misconfiguration IaC Misconfigurations
Total

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from 634b813 to 84e2be5 Compare May 2, 2025 12:17
@nonsense nonsense marked this pull request as ready for review May 5, 2025 11:37
@nonsense nonsense requested a review from a team as a code owner May 5, 2025 11:37
@nonsense nonsense requested review from mslipper and removed request for a team May 5, 2025 11:37
@codecov
Copy link

codecov bot commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (83b7e9a) to head (298445e).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #15662       +/-   ##
============================================
- Coverage    81.40%        0   -81.41%     
============================================
  Files          161        0      -161     
  Lines         8812        0     -8812     
============================================
- Hits          7173        0     -7173     
+ Misses        1506        0     -1506     
+ Partials       133        0      -133     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

see 161 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nonsense nonsense force-pushed the nonsense/reorg-initiating-msg branch from 0d7179d to 45f199e Compare May 5, 2025 13:45
@nonsense nonsense requested a review from a team as a code owner May 5, 2025 13:45
@nonsense nonsense requested review from tynes and removed request for a team May 5, 2025 13:45
@nonsense nonsense marked this pull request as draft May 5, 2025 13:49
@nonsense nonsense force-pushed the nonsense/reorg-initiating-msg branch from 45f199e to 0083532 Compare May 5, 2025 14:15
@tynes
Copy link
Contributor

tynes commented May 5, 2025

An identifier that has a chain id not in the dep set should 100% trigger a reorg, it is a bug if it does not

@nonsense
Copy link
Contributor Author

nonsense commented May 6, 2025

@tynes thanks for the clarification, I will investigate further why no reorg is triggered and see how to fix this!

For reference, the relevant part of the code is: https://github.com/ethereum-optimism/optimism/pull/15662/files#diff-9a44438696e317ca53bc4a82b8bfc9fc1b6de6da787d3230aa4464ebf3ca79e8R157-R160

@nonsense nonsense force-pushed the nonsense/reorg-initiating-msg branch 2 times, most recently from dffc484 to bc0f703 Compare May 6, 2025 10:52
@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch 2 times, most recently from 291557a to 3cc0939 Compare May 6, 2025 14:31
@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from 446514d to 5bd6ece Compare May 6, 2025 18:50
@nonsense nonsense changed the title testing: interop: reorg-testing: reorg a chain with invalid exec msg supervisor and testing: interop: reorg-testing: reorg a chain with invalid exec msg May 6, 2025
Copy link
Contributor

@axelKingsley axelKingsley left a comment

Choose a reason for hiding this comment

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

Thank you for diving into this! I don't think we want to handle this in the Chain Processor, but rather the indexer should be permissive of adding Executing Messages with bad Chain IDs (it errors currently). It should allow those messages in, and then rely on the cross package to fail the interop invariants and issue invalidation/replacement like it does in other cases.

@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from da20c5c to 3d77432 Compare May 7, 2025 11:19
@nonsense nonsense marked this pull request as ready for review May 7, 2025 12:44
Base automatically changed from nonsense/reorg-initiating-msg to develop May 9, 2025 14:27
@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from 1e7787e to 58410aa Compare May 9, 2025 14:35
@nonsense
Copy link
Contributor Author

nonsense commented May 9, 2025

Following the merge of the parent PR, rebased this one onto develop and its ready for review / merge.

Copy link
Contributor

@protolambda protolambda left a comment

Choose a reason for hiding this comment

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

Good to see new testing, but I think this could really use some DSL for a more maintainable/readable test. I'm open to merging it like this, if you can create a github issue to track the needed DSL.

@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from 1b1b898 to 179c47c Compare May 12, 2025 13:56
@nonsense
Copy link
Contributor Author

nonsense commented May 12, 2025

Good to see new testing, but I think this could really use some DSL for a more maintainable/readable test. I'm open to merging it like this, if you can create a github issue to track the needed DSL.

Agree that tests can be more readable, but I'd rather we have a few more tests, before introducing more DSL, so that we avoid having DSL that is used once, and only introduces indirection.

Follow up issue: #15843

@ajsutton
Copy link
Contributor

Agree that tests can be more readable, but I'd rather we have a few more tests, before introducing more DSL, so that we avoid having DSL that is used once, and only introduces indirection.

I'd strongly suggest introducing DSL from the very start. Good DSL pays off even if it's only used once by making the test easier to read, and it's pretty rare for things to be refactored into a good DSL later - the verbose code just winds up being duplicated a lot (see the op-e2e tests...). It doesn't have to be complex DSL, but just enough to make the test high level and read more declaratively with the detail of how things actually work in the DSL.

@nonsense
Copy link
Contributor Author

I added a follow up ticket with a few TODOs / improvements to all of the new tests - #15843. I'd rather these fixes happen outside of this PR, in order to keep the scope limited to the fix with the depset check within the supervisor.

@protolambda protolambda added this pull request to the merge queue May 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 19, 2025
@nonsense nonsense force-pushed the nonsense/reorg-invalid-exec-msg branch from daec670 to 9723be3 Compare May 19, 2025 11:36
@protolambda protolambda enabled auto-merge May 19, 2025 11:46
@protolambda protolambda added this pull request to the merge queue May 19, 2025
Merged via the queue into develop with commit 112ffbf May 19, 2025
57 checks passed
@protolambda protolambda deleted the nonsense/reorg-invalid-exec-msg branch May 19, 2025 12:28
iquidus pushed a commit to Layr-Labs/optimism that referenced this pull request Jul 24, 2025
…valid exec msg (ethereum-optimism#15662)

* add test for reorging a chain with invalid exec msg

* change 1000 eth to 1 eth, and send transfers to 1 gwei

* annotate workers

* check for top bit

* additional check for types.ErrUnknownChain

* do not hydrate depset with chains with top bit set

* rebase on develop
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.

Test reorg of local-safe block with invalid message

6 participants