foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Have auto and interval mining at the same time

Open DefiCake opened this issue 9 months ago • 5 comments

Component

Anvil

Describe the feature you would like

Use case: Have fast transactions (= fast CI pipelines and tests) with automated software that reacts on events, like bots, indexers, etc

At the moment anvil allows either one mining mode or the other - auto, or interval. This is specifically signaled by the interval mining mode, that warns that auto is disabled.

Additional context

No response

DefiCake avatar May 09 '24 18:05 DefiCake

this should be possible to support by adding a new variant that combines both of these:

https://github.com/foundry-rs/foundry/blob/d7eac74cfd786447cec9650048e2d2fac63fba0c/crates/anvil/src/eth/miner.rs#L102-L108

mattsse avatar Jun 21 '24 11:06 mattsse

@mattsse is this high priority? I would like to work on it but it's my first time interacting with foundry so it will take some time to get this done

caiquejjx avatar Jun 25 '24 22:06 caiquejjx

not high priority, the task here would be to add a new variant that is

Mixed {
  auto: ReadyTransactionMiner,
  fixed: FixedBlockTimeMiner
}

and then polls both

mattsse avatar Jun 25 '24 23:06 mattsse

oh looks simple enough, thanks!

caiquejjx avatar Jun 25 '24 23:06 caiquejjx

@mattsse hey, I created a draft pr with the new variant + it's pooling but I'm wondering if I should also add RPC handler for setting the mixed mining mode and besides that I'm not sure how to test this feature, when you have some time can you take a look? Thank you

caiquejjx avatar Jun 27 '24 23:06 caiquejjx

Hi @caiquejjx thanks for picking this up, draft is looking good!

I think it makes sense to add RPC methods for this (anvil_setMixedmine(bool), anvil_getMixedmine(bool) matching anvil_setAutomine(bool) / anvil_getAutomine(bool)).

cc @mattsse

zerosnacks avatar Jul 15 '24 16:07 zerosnacks

thanks @zerosnacks, I'll follow up with the RPC methods implementation then

caiquejjx avatar Jul 16 '24 17:07 caiquejjx

Marking as resolved by https://github.com/foundry-rs/foundry/pull/8280

Thanks for your PR @caiquejjx!

zerosnacks avatar Jul 24 '24 12:07 zerosnacks