Skip to content

Conversation

@ipatka
Copy link
Contributor

@ipatka ipatka commented Jun 28, 2023

Motivation

Post merge TD is set to prevrandao. Anvil was adding prevrandao to fork difficulty causing overflows

Relevant dependency in REVM https://github.com/bluealloy/revm/blob/1839b3fce8eaeebb85025576f2519b80615aca1e/crates/interpreter/src/instructions/host_env.rs#L27

Solution

Check for post merge and don't add difficulty

Comment on lines 850 to 852
// Difficulty is removed and not used after Paris (aka TheMerge). Value is replaced with prevrandao.
// https://github.com/bluealloy/revm/blob/1839b3fce8eaeebb85025576f2519b80615aca1e/crates/interpreter/src/instructions/host_env.rs#L27
if self.is_eip3675() {
Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, this makes sense.

nice find.
we can simplify this by only using the else branch, we don't need to update the ttd if eip3675

I think it's even debatable if we should increase ttd at all if me mining a block

however this is the first time that this has been raised so I'm ok with increasing it pre merge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good! just made the requested change

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

very nice catch. With the changes applied this lgtm!

@Evalir
Copy link
Member

Evalir commented Jun 28, 2023

btw, just needs cargo +nightly fmt so ci passes @ipatka

@mattsse
Copy link
Member

mattsse commented Jun 28, 2023

just pushed fmt changes

@Evalir Evalir merged commit f9fc929 into foundry-rs:master Jun 28, 2023
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.

3 participants