Skip to content

Commit

Permalink
Merge branch 'main' into debug-trace-with-pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamlat authored Jan 8, 2025
2 parents 50a50b7 + fa9ca9c commit 0d17286
Show file tree
Hide file tree
Showing 49 changed files with 289 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static BlockHeader createBlockHeader(
null,
null,
null,
null,
blockHeaderFunctions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ public void miningParametersBlockPeriodSecondsIsUpdatedOnTransition() {
null,
null,
null,
null,
getBlockHeaderFunctions());
final Block block1 = new Block(header1, BlockBody.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public void miningParametersBlockPeriodSecondsIsUpdatedOnTransition() {
null,
null,
null,
null,
new CliqueBlockHeaderFunctions());
final Block block1 = new Block(header1, BlockBody.empty());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private void setSyncTarget() {
mock(EthPeer.class),
new org.hyperledger.besu.ethereum.core.BlockHeader(
null, null, null, null, null, null, null, null, 1, 1, 1, 1, null, null, null, 1, null,
null, null, null, null, null, null));
null, null, null, null, null));
}

private void clearSyncTarget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,6 @@ public String getParentBeaconBlockRoot() {
"0x0000000000000000000000000000000000000000000000000000000000000000");
}

/**
* Gets target blobs per block.
*
* @return the target blobs per block
*/
public Optional<String> getTargetBlobsPerBlock() {
// TODO SLD EIP-7742 not sure if we should use a default value here or enforce any
// "pragueAtGenesis" genesis file (used in devnets) to have this value
return JsonUtil.getValueAsString(genesisRoot, "targetblobsperblock");
}

/**
* Gets coinbase.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ public String getProvider() {
return PROVIDER;
}

@Override
public ECDomainParameters getCurve() {
return curve;
}

/**
* Gets K calculator.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.bouncycastle.math.ec.ECPoint;

/** The interface Signature algorithm. */
Expand Down Expand Up @@ -124,6 +125,13 @@ SECPSignature normaliseSignature(
*/
String getCurveName();

/**
* Bouncy castle ECDomainParameters representing the curve.
*
* @return instance of ECDomainParameters
*/
ECDomainParameters getCurve();

/**
* Create secp private key.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ public enum JsonRpcResponseKey {
TRANSACTION_ROOT,
BASEFEE,
WITHDRAWALS_ROOT,
REQUESTS_HASH,
TARGET_BLOBS_PER_BLOCK
REQUESTS_HASH
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.units.bigints.UInt256;
import org.apache.tuweni.units.bigints.UInt64;

public class JsonRpcResponseUtils {

Expand Down Expand Up @@ -107,10 +106,6 @@ public JsonRpcResponse response(
values.containsKey(WITHDRAWALS_ROOT) ? hash(values.get(WITHDRAWALS_ROOT)) : null;
final Hash requestsHash =
values.containsKey(REQUESTS_HASH) ? hash(values.get(REQUESTS_HASH)) : null;
final UInt64 targetBlobsPerBlock =
values.containsKey(JsonRpcResponseKey.TARGET_BLOBS_PER_BLOCK)
? UInt64.fromHexString(values.get(JsonRpcResponseKey.TARGET_BLOBS_PER_BLOCK))
: null;
final List<JsonNode> ommers = new ArrayList<>();

final BlockHeader header =
Expand All @@ -136,7 +131,6 @@ public JsonRpcResponse response(
null, // ToDo 4844: set with the value of excess_blob_gas field
null, // TODO 4788: set with the value of the parent beacon block root field
requestsHash,
targetBlobsPerBlock,
blockHeaderFunctions);

return new JsonRpcSuccessResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
: BlobGas.fromHexString(blockParam.getExcessBlobGas()),
maybeParentBeaconBlockRoot.orElse(null),
maybeRequests.map(BodyValidation::requestsHash).orElse(null),
null, // TODO SLD EIP-7742 wiring in future PR
headerFunctions);

// ensure the block hash matches the blockParam hash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public class BlockResult implements JsonRpcResult {
private final String blobGasUsed;
private final String excessBlobGas;
private final String parentBeaconBlockRoot;
private final String targetBlobsPerBlock;
private final List<CallProcessingResult> callProcessingResults;

public BlockResult(
Expand Down Expand Up @@ -153,7 +152,6 @@ public BlockResult(
this.excessBlobGas = header.getExcessBlobGas().map(Quantity::create).orElse(null);
this.parentBeaconBlockRoot =
header.getParentBeaconBlockRoot().map(Bytes32::toHexString).orElse(null);
this.targetBlobsPerBlock = header.getTargetBlobsPerBlock().map(Quantity::create).orElse(null);
}

@JsonGetter(value = "number")
Expand Down Expand Up @@ -292,11 +290,6 @@ public String getParentBeaconBlockRoot() {
return parentBeaconBlockRoot;
}

@JsonGetter(value = "targetBlobsPerBlock")
public String getTargetBlobsPerBlock() {
return targetBlobsPerBlock;
}

@JsonGetter(value = "calls")
public List<CallProcessingResult> getTransactionProcessingResults() {
return callProcessingResults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ private Block createFakeBlock(
null,
null,
null,
null,
null),
new BlockBody(
IntStream.range(0, txsNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ private Block createFakeBlock(
null,
null,
null,
null,
null),
new BlockBody(
IntStream.range(0, txsNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ private BlockHeader createBlockHeader(final Hash blockHash, final long blockNumb
null,
null,
null,
null,
new BlockHeaderFunctions() {
@Override
public Hash hash(final BlockHeader header) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public void setup() {
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
final BlockBody fakeBody = new BlockBody(Collections.emptyList(), Collections.emptyList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public void setup() throws IOException {
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(anyLong())).thenReturn(Optional.of(fakeHeader));
Expand Down Expand Up @@ -284,7 +283,6 @@ private BlockHeader createBlock(final long number, final Optional<String> messag
null,
null,
null,
null,
new MainnetBlockHeaderFunctions());
testHash = fakeHeader.getHash();
when(blockchain.getBlockHeader(number)).thenReturn(Optional.of(fakeHeader));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"method": "debug_traceCall",
"params": [
{
"to": "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e",
"to": "0x0F792be4B0c0cb4DAE440Ef133E90C0eCD48CCCC",
"data": "0x000000000000000000000000000000000000000000000000000000000001A00E"
},
"latest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.google.common.base.MoreObjects;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64;

public final class GenesisState {

Expand Down Expand Up @@ -217,12 +216,6 @@ private static BlockHeader buildHeader(
.parentBeaconBlockRoot(
(isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null))
.requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null)
.targetBlobsPerBlock(
isPragueAtGenesis(genesis)
// TODO SLD EIP-7742 Currently defaulting to null due to dependency on web3j
// BlockHeader in CodeDelegationTransactionAcceptanceTest
? genesis.getTargetBlobsPerBlock().map(UInt64::fromHexString).orElse(null)
: null)
.buildBlockHeader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.google.common.base.Suppliers;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64;

/** A mined Ethereum block header. */
public class BlockHeader extends SealableBlockHeader
Expand Down Expand Up @@ -66,7 +65,6 @@ public BlockHeader(
final BlobGas excessBlobGas,
final Bytes32 parentBeaconBlockRoot,
final Hash requestsHash,
final UInt64 targetBlobsPerBlock,
final BlockHeaderFunctions blockHeaderFunctions) {
super(
parentHash,
Expand All @@ -88,8 +86,7 @@ public BlockHeader(
blobGasUsed,
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobsPerBlock);
requestsHash);
this.nonce = nonce;
this.hash = Suppliers.memoize(() -> blockHeaderFunctions.hash(this));
this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this));
Expand Down Expand Up @@ -190,9 +187,6 @@ public void writeTo(final RLPOutput out) {

if (requestsHash == null) break;
out.writeBytes(requestsHash);

if (targetBlobsPerBlock == null) break;
out.writeUInt64Scalar(targetBlobsPerBlock);
} while (false);
out.endList();
}
Expand Down Expand Up @@ -225,8 +219,6 @@ public static BlockHeader readFrom(
!input.isEndOfCurrentList() ? BlobGas.of(input.readUInt64Scalar()) : null;
final Bytes32 parentBeaconBlockRoot = !input.isEndOfCurrentList() ? input.readBytes32() : null;
final Hash requestsHash = !input.isEndOfCurrentList() ? Hash.wrap(input.readBytes32()) : null;
final UInt64 targetBlobsPerBlock =
!input.isEndOfCurrentList() ? input.readUInt64Scalar() : null;
input.leaveList();
return new BlockHeader(
parentHash,
Expand All @@ -250,7 +242,6 @@ public static BlockHeader readFrom(
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobsPerBlock,
blockHeaderFunctions);
}

Expand Down Expand Up @@ -304,9 +295,6 @@ public String toString() {
if (requestsHash != null) {
sb.append("requestsHash=").append(requestsHash);
}
if (targetBlobsPerBlock != null) {
sb.append("targetBlobsPerBlock=").append(targetBlobsPerBlock);
}
return sb.append("}").toString();
}

Expand Down Expand Up @@ -341,7 +329,6 @@ public static org.hyperledger.besu.ethereum.core.BlockHeader convertPluginBlockH
.getRequestsHash()
.map(h -> Hash.fromHexString(h.toHexString()))
.orElse(null),
pluginBlockHeader.getTargetBlobsPerBlock().orElse(null),
blockHeaderFunctions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64;

/** A utility class for building block headers. */
public class BlockHeaderBuilder {
Expand Down Expand Up @@ -81,7 +80,6 @@ public class BlockHeaderBuilder {
private Long blobGasUsed = null;
private BlobGas excessBlobGas = null;
private Bytes32 parentBeaconBlockRoot = null;
private UInt64 targetBlobsPerBlock = null;

public static BlockHeaderBuilder create() {
return new BlockHeaderBuilder();
Expand Down Expand Up @@ -130,8 +128,7 @@ public static BlockHeaderBuilder fromHeader(final BlockHeader header) {
.blobGasUsed(header.getBlobGasUsed().orElse(null))
.excessBlobGas(header.getExcessBlobGas().orElse(null))
.parentBeaconBlockRoot(header.getParentBeaconBlockRoot().orElse(null))
.requestsHash(header.getRequestsHash().orElse(null))
.targetBlobsPerBlock(header.getTargetBlobsPerBlock().orElse(null));
.requestsHash(header.getRequestsHash().orElse(null));
}

public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilder) {
Expand All @@ -156,7 +153,6 @@ public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilde
.excessBlobGas(fromBuilder.excessBlobGas)
.parentBeaconBlockRoot(fromBuilder.parentBeaconBlockRoot)
.requestsHash(fromBuilder.requestsHash)
.targetBlobsPerBlock(fromBuilder.targetBlobsPerBlock)
.blockHeaderFunctions(fromBuilder.blockHeaderFunctions);
toBuilder.nonce = fromBuilder.nonce;
return toBuilder;
Expand Down Expand Up @@ -236,7 +232,6 @@ public BlockHeader buildBlockHeader() {
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobsPerBlock,
blockHeaderFunctions);
}

Expand All @@ -252,8 +247,7 @@ public ProcessableBlockHeader buildProcessableBlockHeader() {
timestamp,
baseFee,
mixHashOrPrevRandao,
parentBeaconBlockRoot,
targetBlobsPerBlock);
parentBeaconBlockRoot);
}

public SealableBlockHeader buildSealableBlockHeader() {
Expand All @@ -279,8 +273,7 @@ public SealableBlockHeader buildSealableBlockHeader() {
blobGasUsed,
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobsPerBlock);
requestsHash);
}

private void validateBlockHeader() {
Expand Down Expand Up @@ -320,7 +313,6 @@ public BlockHeaderBuilder populateFrom(final ProcessableBlockHeader processableB
baseFee(processableBlockHeader.getBaseFee().orElse(null));
processableBlockHeader.getPrevRandao().ifPresent(this::prevRandao);
processableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
processableBlockHeader.getTargetBlobsPerBlock().ifPresent(this::targetBlobsPerBlock);
return this;
}

Expand All @@ -346,7 +338,6 @@ public BlockHeaderBuilder populateFrom(final SealableBlockHeader sealableBlockHe
sealableBlockHeader.getExcessBlobGas().ifPresent(this::excessBlobGas);
sealableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
requestsHash(sealableBlockHeader.getRequestsHash().orElse(null));
sealableBlockHeader.getTargetBlobsPerBlock().ifPresent(this::targetBlobsPerBlock);
return this;
}

Expand Down Expand Up @@ -480,9 +471,4 @@ public BlockHeaderBuilder parentBeaconBlockRoot(final Bytes32 parentBeaconBlockR
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
return this;
}

public BlockHeaderBuilder targetBlobsPerBlock(final UInt64 targetBlobsPerBlock) {
this.targetBlobsPerBlock = targetBlobsPerBlock;
return this;
}
}
Loading

0 comments on commit 0d17286

Please sign in to comment.