Skip to content

EIP2935 - Use system call instead of direct storage modification#8243

Merged
siladu merged 11 commits intobesu-eth:mainfrom
Gabriel-Trintinalia:eip29-25-as-system-call
Feb 5, 2025
Merged

EIP2935 - Use system call instead of direct storage modification#8243
siladu merged 11 commits intobesu-eth:mainfrom
Gabriel-Trintinalia:eip29-25-as-system-call

Conversation

@Gabriel-Trintinalia
Copy link
Copy Markdown
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented Feb 4, 2025

PR description

Changes PragueBlockHashProcessor to perform a system call to HISTORY_STORAGE_ADDRESS instead of changing the storage manually as defined here: ethereum/EIPs#8816

Passing both consume-rlp and consume-engine execution-spec-tests in pectra-devnet-6 v1.0.0

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Comment on lines +52 to +59
public Void process(final BlockProcessingContext context) {
super.process(context);
SystemCallProcessor processor =
new SystemCallProcessor(context.getProtocolSpec().getTransactionProcessor());

Bytes inputData = context.getBlockHeader().getParentHash();
processor.process(historyStorageAddress, context, inputData);
return null;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the important change of this PR. The rest is refactoring.

@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review February 4, 2025 09:40
@Gabriel-Trintinalia Gabriel-Trintinalia requested review from lu-pinto and siladu and removed request for lu-pinto February 4, 2025 09:40
@macfarla macfarla added the Prague label Feb 4, 2025
@Gabriel-Trintinalia Gabriel-Trintinalia changed the title EIP2935 - use system call instead of direct changing storage EIP2935 - Use system call instead of direct storage modification Feb 4, 2025
Copy link
Copy Markdown
Contributor

@matkt matkt left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
import org.hyperledger.besu.evm.blockhash.BlockHashLookup;
import org.hyperledger.besu.evm.tracing.OperationTracer;

public class BlockProcessingContext {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can be a record

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

RequestProcessingContext extends BlockProcessingContext

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I didn't notice that. So why do you extend a POJO then? This looks a code smell to me.
Why doesn't RequestProcessingContext use composition instead of inheritance? This is a preferred best practice BTW.

import org.hyperledger.besu.evm.tracing.OperationTracer;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.Deque;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this call just not called SystemCall instead of SystemCallProcessor ? What data is it processing? To me the name is a bit misleading.

Copy link
Copy Markdown
Contributor Author

@Gabriel-Trintinalia Gabriel-Trintinalia Feb 4, 2025

Choose a reason for hiding this comment

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

SystemCallProcessor is similar to the MessageCallProcessor, it performs a message call to the contract address with some rules and default values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well but you are not processing any message (which is what the MessageProcessor does) where an EOA sends a message to another EOA or a contract. In this case it is internal, you are creator of the call. See https://github.com/hyperledger/besu/pull/8243/files/6bc3fa87a7f3ab9f7ef69af600c67bf07fc63272#diff-1e7c7ef5c489c82232fb87d33704b19e4a7edb2c72a599a82293f22b79da32abL76-R76 a new MessageProcessor is created inside this function. Just the only we have to get the EVM to execute code right now, but it's an implementation detail.
Anyway I agree that it's subjective and it's a nit for sure.

@Override
public BlockHashLookup createBlockHashLookup(
final Blockchain blockchain, final ProcessableBlockHeader blockHeader) {
return new Eip7709BlockHashLookup(historyStorageAddress, historyServeWindow);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't you think this could change in the future? Having the BlockHashProcessor have a handle on the window size makes it more extendable in another fork if the window changes

public class Eip7709BlockHashLookup implements BlockHashLookup {
private static final Logger LOG = LoggerFactory.getLogger(Eip7709BlockHashLookup.class);
private static final long BLOCKHASH_SERVE_WINDOW = 256L;
private static final long HISTORY_SERVE_WINDOW = 8191;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: yes, making these constants static here means that we cannot easily change these values in a future fork just by creating another instance with different values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this constant was only moved from the processor class to the BlockHashLookup as it is not used by the Prague processor anymore

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok what about storing it in the Eip7709BlockHashLookup instead?

Copy link
Copy Markdown
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

LGTM - just minor comments

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@siladu siladu merged commit 630a8f7 into besu-eth:main Feb 5, 2025
pullurib pushed a commit to pullurib/besu that referenced this pull request Feb 6, 2025
…u-eth#8243)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants