Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to simulate a reorg for a local fork mode #1799

Closed
krasi-georgiev opened this issue Jun 1, 2022 · 10 comments
Closed

Option to simulate a reorg for a local fork mode #1799

krasi-georgiev opened this issue Jun 1, 2022 · 10 comments
Assignees
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature

Comments

@krasi-georgiev
Copy link

Component

Anvil

Describe the feature you would like

Add an api to simulate a block reorg for local fork mode

Additional context

When writing tests for bots and libraries It would help to simulate reorgs to see how the library/bot handles it.

@krasi-georgiev krasi-georgiev added the T-feature Type: feature label Jun 1, 2022
@onbjerg onbjerg added this to Foundry Jun 1, 2022
@onbjerg onbjerg moved this to Todo in Foundry Jun 1, 2022
@mattsse
Copy link
Member

mattsse commented Jun 1, 2022

I think this some hybrid of reset and snapshot perhaps?

what should anvil do on a reorg(block) call?

@krasi-georgiev
Copy link
Author

Something like this?

head block is 1, calling reors(1) would create block 2 with block 1 as an uncle including all TX from block 1

later could even expand it as
head block is 1, calling reors(1,[]txs{1,2}) would create block 2 with block 1 as an uncle including only TX 1 and 2 from block 1

@sambacha
Copy link
Contributor

sambacha commented Jun 1, 2022

you can do this with the admin commands as well see https://github.com/spalladino/reorg-tester

@krasi-georgiev
Copy link
Author

krasi-georgiev commented Jun 2, 2022

@sambacha thanks for sharing.
@mattsse what do you think would it be possible to do the same in Anvil?

@onbjerg onbjerg added Cmd-forge-test Command: forge test C-forge Command: forge labels Jun 2, 2022
@krasi-georgiev
Copy link
Author

@mattsse what do you think?

@krasi-georgiev
Copy link
Author

ping

@mattsse
Copy link
Member

mattsse commented Jun 23, 2022

sorry, missed this update,

head block is 1, calling reors(1) would create block 2 with block 1 as an uncle including all TX from block 1

that should be possible

so we need:

  • reorg rpc call that accepts
    • block where to reorg (default 1)
    • tx filter object

I think we can start with 1 block reorg, but how should it behave if we're on block 5 and want to do a 3 block reorg for example?

@krasi-georgiev
Copy link
Author

krasi-georgiev commented Jun 24, 2022

maybe to keep things simple can just start by allowing to reorg only the last block and if there is a request for bigger reorgs can revisit again.

@mattsse mattsse self-assigned this Jun 29, 2022
@agnarsong
Copy link

There hasn't been any follow-up on this issue for 22 years. It seems to have been forgotten.

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Aug 30, 2023
@ameya-deshmukh
Copy link

@mattsse any chance I could take this up? This would be very helpful for a lot of applications imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

6 participants