risechain / pevm

Blazingly fast Parallel EVM
MIT License
234 stars 47 forks source link

Support block building mode #368

Open hai-rise opened 1 month ago

hai-rise commented 1 month ago

We need better solutions for these:

kien-rise commented 1 month ago

Commit https://github.com/kien-rise/pevm/commit/f9ec57dc1ce13426070369d0846c5560d35e38c7 is actually independent and good to merge. By returning PevmError::FallbackToSequential, the block builder can do the execution by itself. Also, it allows the block builder to call tracing::warn!(...) for logging purpose.

Shall I create a PR containing this commit alone?


For commit https://github.com/kien-rise/pevm/commit/bc95f3fb8cb57b4611866a4cf45e58daa011fb1c, I only remember it is there to avoid pevm from freezing. The underlying cause, I am not sure, but most likely the nonce issue (too low or too high), causing pevm to be stuck at tx K although all the txs 0, 1, ..., K-1 are executed.

Since the NonceTooLow issue has been fixed in the block building side, we might not need this commit anymore. To be sure, I think I should do a benchmark without this commit then see whether pevm freezes or not.

hai-rise commented 1 month ago

Wouldn't https://github.com/kien-rise/pevm/commit/f9ec57dc1ce13426070369d0846c5560d35e38c7 fail tests as now some mainnet blocks assert a fallback error against valid sequential results? We also need to understand why users like block builders need a sequential fallback in the first place. If the original problems have better solutions then we should avoid this expensive fallback. For instance, per the already checked-in comments, we should skip unsound-nonce transactions right within pevm in block-building mode. Even when falling back is the best option, we should return ownership of the TxEnvs (or even BlockEnv) so the callee wouldn't need to initially clone, or recalculate it during re-execution.

For https://github.com/kien-rise/pevm/commit/bc95f3fb8cb57b4611866a4cf45e58daa011fb1c, we should still inspect the actual problems and find a better solution than sequential fallback. Depending on the mempool or block builder's behaviors not to deadlock is not good. Ideally pevm itself should not deadlock for any input.

kien-rise commented 4 weeks ago

See https://github.com/risechain/pevm/pull/406

See https://github.com/risechain/pevm/pull/408