diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index ac9dfe221e6..0c69c9c1c1d 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -24,7 +24,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.WithdrawalsValidatorProvider.getWithdrawalsValidator; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; -import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.BlobGas; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.RequestType; @@ -222,20 +221,8 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) blockParam.getTransactions().stream() .map(Bytes::fromHexString) .map(in -> TransactionDecoder.decodeOpaqueBytes(in, EncodingContext.BLOCK_BODY)) - .collect(Collectors.toList()); - transactions.forEach( - transaction -> - mergeCoordinator - .getEthScheduler() - .scheduleTxWorkerTask( - () -> { - Address sender = transaction.getSender(); - LOG.atTrace() - .setMessage("The sender for transaction {} is calculated : {}") - .addArgument(transaction::getHash) - .addArgument(sender) - .log(); - })); + .toList(); + precomputeSenders(transactions); } catch (final RLPException | IllegalArgumentException e) { return respondWithInvalid( reqId, @@ -392,6 +379,47 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) } } + private void precomputeSenders(final List transactions) { + transactions.forEach( + transaction -> { + mergeCoordinator + .getEthScheduler() + .scheduleTxWorkerTask( + () -> { + final var sender = transaction.getSender(); + LOG.atTrace() + .setMessage("The sender for transaction {} is calculated : {}") + .addArgument(transaction::getHash) + .addArgument(sender) + .log(); + }); + if (transaction.getType().supportsDelegateCode()) { + precomputeAuthorities(transaction); + } + }); + } + + private void precomputeAuthorities(final Transaction transaction) { + final var codeDelegations = transaction.getCodeDelegationList().get(); + int index = 0; + for (final var codeDelegation : codeDelegations) { + final var constIndex = index++; + mergeCoordinator + .getEthScheduler() + .scheduleTxWorkerTask( + () -> { + final var authority = codeDelegation.authorizer(); + LOG.atTrace() + .setMessage( + "The code delegation authority at index {} for transaction {} is calculated : {}") + .addArgument(constIndex) + .addArgument(transaction::getHash) + .addArgument(authority) + .log(); + }); + } + } + JsonRpcResponse respondWith( final Object requestId, final EnginePayloadParameter param, diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java index ef38a982224..ecf1da973f3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/CodeDelegation.java @@ -42,8 +42,8 @@ public class CodeDelegation implements org.hyperledger.besu.datatypes.CodeDelega private final Address address; private final long nonce; private final SECPSignature signature; - private Optional
authorizer = Optional.empty(); - private boolean isAuthorityComputed = false; + private final Supplier> authorizerSupplier = + Suppliers.memoize(this::computeAuthority); /** * An access list entry as defined in EIP-7702 @@ -107,12 +107,7 @@ public SECPSignature signature() { @Override public Optional
authorizer() { - if (!isAuthorityComputed) { - authorizer = computeAuthority(); - isAuthorityComputed = true; - } - - return authorizer; + return authorizerSupplier.get(); } @Override diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransaction.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransaction.java index ee5c40a3f4f..e6a84f69fa4 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransaction.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransaction.java @@ -430,7 +430,7 @@ public interface MemorySize { int ACCESS_LIST_ENTRY_SHALLOW_SIZE = 248; int OPTIONAL_ACCESS_LIST_SHALLOW_SIZE = 40; int OPTIONAL_CODE_DELEGATION_LIST_SHALLOW_SIZE = 40; - int CODE_DELEGATION_ENTRY_SIZE = 432; + int CODE_DELEGATION_ENTRY_SIZE = 472; int VERSIONED_HASH_SIZE = 96; int LIST_SHALLOW_SIZE = 48; int OPTIONAL_SHALLOW_SIZE = 16;