Rename targetBlobCount to targetBlobsPerBlock (#7981)

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
This commit is contained in:
Simon Dudley
2024-12-04 16:18:47 +10:00
committed by GitHub
parent 74929eb215
commit 1671306749
17 changed files with 59 additions and 58 deletions

View File

@@ -266,14 +266,14 @@ public class GenesisConfigFile {
}
/**
* Gets target blob count.
* Gets target blobs per block.
*
* @return the target blob count
* @return the target blobs per block
*/
public Optional<String> getTargetBlobCount() {
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, "targetblobcount");
return JsonUtil.getValueAsString(genesisRoot, "targetblobsperblock");
}
/**

View File

@@ -39,5 +39,5 @@ public enum JsonRpcResponseKey {
BASEFEE,
WITHDRAWALS_ROOT,
REQUESTS_HASH,
TARGET_BLOB_COUNT
TARGET_BLOBS_PER_BLOCK
}

View File

@@ -107,9 +107,9 @@ public class JsonRpcResponseUtils {
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 targetBlobCount =
values.containsKey(JsonRpcResponseKey.TARGET_BLOB_COUNT)
? UInt64.fromHexString(values.get(JsonRpcResponseKey.TARGET_BLOB_COUNT))
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<>();
@@ -136,7 +136,7 @@ public class JsonRpcResponseUtils {
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,
targetBlobCount,
targetBlobsPerBlock,
blockHeaderFunctions);
return new JsonRpcSuccessResponse(

View File

@@ -88,7 +88,7 @@ public class BlockResult implements JsonRpcResult {
private final String blobGasUsed;
private final String excessBlobGas;
private final String parentBeaconBlockRoot;
private final String targetBlobCount;
private final String targetBlobsPerBlock;
public BlockResult(
final BlockHeader header,
@@ -139,7 +139,7 @@ public class BlockResult implements JsonRpcResult {
this.excessBlobGas = header.getExcessBlobGas().map(Quantity::create).orElse(null);
this.parentBeaconBlockRoot =
header.getParentBeaconBlockRoot().map(Bytes32::toHexString).orElse(null);
this.targetBlobCount = header.getTargetBlobCount().map(Quantity::create).orElse(null);
this.targetBlobsPerBlock = header.getTargetBlobsPerBlock().map(Quantity::create).orElse(null);
}
@JsonGetter(value = "number")
@@ -278,8 +278,8 @@ public class BlockResult implements JsonRpcResult {
return parentBeaconBlockRoot;
}
@JsonGetter(value = "targetBlobCount")
public String getTargetBlobCount() {
return targetBlobCount;
@JsonGetter(value = "targetBlobsPerBlock")
public String getTargetBlobsPerBlock() {
return targetBlobsPerBlock;
}
}

View File

@@ -219,11 +219,11 @@ public final class GenesisState {
.parentBeaconBlockRoot(
(isCancunAtGenesis(genesis) ? parseParentBeaconBlockRoot(genesis) : null))
.requestsHash(isPragueAtGenesis(genesis) ? Hash.EMPTY_REQUESTS_HASH : null)
.targetBlobCount(
.targetBlobsPerBlock(
isPragueAtGenesis(genesis)
// TODO SLD EIP-7742 Currently defaulting to null due to dependency on web3j
// BlockHeader in CodeDelegationTransactionAcceptanceTest
? genesis.getTargetBlobCount().map(UInt64::fromHexString).orElse(null)
? genesis.getTargetBlobsPerBlock().map(UInt64::fromHexString).orElse(null)
: null)
.buildBlockHeader();
}

View File

@@ -66,7 +66,7 @@ public class BlockHeader extends SealableBlockHeader
final BlobGas excessBlobGas,
final Bytes32 parentBeaconBlockRoot,
final Hash requestsHash,
final UInt64 targetBlobCount,
final UInt64 targetBlobsPerBlock,
final BlockHeaderFunctions blockHeaderFunctions) {
super(
parentHash,
@@ -89,7 +89,7 @@ public class BlockHeader extends SealableBlockHeader
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobCount);
targetBlobsPerBlock);
this.nonce = nonce;
this.hash = Suppliers.memoize(() -> blockHeaderFunctions.hash(this));
this.parsedExtraData = Suppliers.memoize(() -> blockHeaderFunctions.parseExtraData(this));
@@ -191,8 +191,8 @@ public class BlockHeader extends SealableBlockHeader
if (requestsHash == null) break;
out.writeBytes(requestsHash);
if (targetBlobCount == null) break;
out.writeUInt64Scalar(targetBlobCount);
if (targetBlobsPerBlock == null) break;
out.writeUInt64Scalar(targetBlobsPerBlock);
} while (false);
out.endList();
}
@@ -225,7 +225,8 @@ public class BlockHeader extends SealableBlockHeader
!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 targetBlobCount = !input.isEndOfCurrentList() ? input.readUInt64Scalar() : null;
final UInt64 targetBlobsPerBlock =
!input.isEndOfCurrentList() ? input.readUInt64Scalar() : null;
input.leaveList();
return new BlockHeader(
parentHash,
@@ -249,7 +250,7 @@ public class BlockHeader extends SealableBlockHeader
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobCount,
targetBlobsPerBlock,
blockHeaderFunctions);
}
@@ -303,8 +304,8 @@ public class BlockHeader extends SealableBlockHeader
if (requestsHash != null) {
sb.append("requestsHash=").append(requestsHash);
}
if (targetBlobCount != null) {
sb.append("targetBlobCount=").append(targetBlobCount);
if (targetBlobsPerBlock != null) {
sb.append("targetBlobsPerBlock=").append(targetBlobsPerBlock);
}
return sb.append("}").toString();
}
@@ -340,7 +341,7 @@ public class BlockHeader extends SealableBlockHeader
.getRequestsHash()
.map(h -> Hash.fromHexString(h.toHexString()))
.orElse(null),
pluginBlockHeader.getTargetBlobCount().orElse(null),
pluginBlockHeader.getTargetBlobsPerBlock().orElse(null),
blockHeaderFunctions);
}

View File

@@ -77,7 +77,7 @@ public class BlockHeaderBuilder {
private Long blobGasUsed = null;
private BlobGas excessBlobGas = null;
private Bytes32 parentBeaconBlockRoot = null;
private UInt64 targetBlobCount = null;
private UInt64 targetBlobsPerBlock = null;
public static BlockHeaderBuilder create() {
return new BlockHeaderBuilder();
@@ -127,7 +127,7 @@ public class BlockHeaderBuilder {
.excessBlobGas(header.getExcessBlobGas().orElse(null))
.parentBeaconBlockRoot(header.getParentBeaconBlockRoot().orElse(null))
.requestsHash(header.getRequestsHash().orElse(null))
.targetBlobCount(header.getTargetBlobCount().orElse(null));
.targetBlobsPerBlock(header.getTargetBlobsPerBlock().orElse(null));
}
public static BlockHeaderBuilder fromBuilder(final BlockHeaderBuilder fromBuilder) {
@@ -152,7 +152,7 @@ public class BlockHeaderBuilder {
.excessBlobGas(fromBuilder.excessBlobGas)
.parentBeaconBlockRoot(fromBuilder.parentBeaconBlockRoot)
.requestsHash(fromBuilder.requestsHash)
.targetBlobCount(fromBuilder.targetBlobCount)
.targetBlobsPerBlock(fromBuilder.targetBlobsPerBlock)
.blockHeaderFunctions(fromBuilder.blockHeaderFunctions);
toBuilder.nonce = fromBuilder.nonce;
return toBuilder;
@@ -183,7 +183,7 @@ public class BlockHeaderBuilder {
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobCount,
targetBlobsPerBlock,
blockHeaderFunctions);
}
@@ -200,7 +200,7 @@ public class BlockHeaderBuilder {
baseFee,
mixHashOrPrevRandao,
parentBeaconBlockRoot,
targetBlobCount);
targetBlobsPerBlock);
}
public SealableBlockHeader buildSealableBlockHeader() {
@@ -227,7 +227,7 @@ public class BlockHeaderBuilder {
excessBlobGas,
parentBeaconBlockRoot,
requestsHash,
targetBlobCount);
targetBlobsPerBlock);
}
private void validateBlockHeader() {
@@ -267,7 +267,7 @@ public class BlockHeaderBuilder {
baseFee(processableBlockHeader.getBaseFee().orElse(null));
processableBlockHeader.getPrevRandao().ifPresent(this::prevRandao);
processableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
processableBlockHeader.getTargetBlobCount().ifPresent(this::targetBlobCount);
processableBlockHeader.getTargetBlobsPerBlock().ifPresent(this::targetBlobsPerBlock);
return this;
}
@@ -293,7 +293,7 @@ public class BlockHeaderBuilder {
sealableBlockHeader.getExcessBlobGas().ifPresent(this::excessBlobGas);
sealableBlockHeader.getParentBeaconBlockRoot().ifPresent(this::parentBeaconBlockRoot);
requestsHash(sealableBlockHeader.getRequestsHash().orElse(null));
sealableBlockHeader.getTargetBlobCount().ifPresent(this::targetBlobCount);
sealableBlockHeader.getTargetBlobsPerBlock().ifPresent(this::targetBlobsPerBlock);
return this;
}
@@ -428,8 +428,8 @@ public class BlockHeaderBuilder {
return this;
}
public BlockHeaderBuilder targetBlobCount(final UInt64 targetBlobCount) {
this.targetBlobCount = targetBlobCount;
public BlockHeaderBuilder targetBlobsPerBlock(final UInt64 targetBlobsPerBlock) {
this.targetBlobsPerBlock = targetBlobsPerBlock;
return this;
}
}

View File

@@ -48,7 +48,7 @@ public class ProcessableBlockHeader
// parentBeaconBlockRoot is included for Cancun
protected final Bytes32 parentBeaconBlockRoot;
// TODO SLD Quantity or UInt64Value<UInt64> instead?
protected final UInt64 targetBlobCount;
protected final UInt64 targetBlobsPerBlock;
protected ProcessableBlockHeader(
final Hash parentHash,
@@ -60,7 +60,7 @@ public class ProcessableBlockHeader
final Wei baseFee,
final Bytes32 mixHashOrPrevRandao,
final Bytes32 parentBeaconBlockRoot,
final UInt64 targetBlobCount) {
final UInt64 targetBlobsPerBlock) {
this.parentHash = parentHash;
this.coinbase = coinbase;
this.difficulty = difficulty;
@@ -70,7 +70,7 @@ public class ProcessableBlockHeader
this.baseFee = baseFee;
this.mixHashOrPrevRandao = mixHashOrPrevRandao;
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
this.targetBlobCount = targetBlobCount;
this.targetBlobsPerBlock = targetBlobsPerBlock;
}
/**
@@ -184,13 +184,13 @@ public class ProcessableBlockHeader
}
/**
* Returns the target blob count if available.
* Returns the target blobs per block if available.
*
* @return the target blob count if available.
* @return the target blobs per block if available.
*/
@Override
public Optional<UInt64> getTargetBlobCount() {
return Optional.ofNullable(targetBlobCount);
public Optional<UInt64> getTargetBlobsPerBlock() {
return Optional.ofNullable(targetBlobsPerBlock);
}
public String toLogString() {

View File

@@ -71,7 +71,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader {
final BlobGas excessBlobGas,
final Bytes32 parentBeaconBlockRoot,
final Hash requestsHash,
final UInt64 targetBlobCount) {
final UInt64 targetBlobsPerBlock) {
super(
parentHash,
coinbase,
@@ -82,7 +82,7 @@ public class SealableBlockHeader extends ProcessableBlockHeader {
baseFee,
mixHashOrPrevRandao,
parentBeaconBlockRoot,
targetBlobCount);
targetBlobsPerBlock);
this.ommersHash = ommersHash;
this.stateRoot = stateRoot;
this.transactionsRoot = transactionsRoot;

View File

@@ -56,7 +56,7 @@ public class BlockHeaderTestFixture {
private Optional<BlobGas> excessBlobGas = Optional.empty();
private Optional<Long> blobGasUsed = Optional.empty();
private Optional<Bytes32> parentBeaconBlockRoot = Optional.empty();
private Optional<UInt64> targetBlobCount = Optional.empty();
private Optional<UInt64> targetBlobsPerBlock = Optional.empty();
public BlockHeader buildHeader() {
final BlockHeaderBuilder builder = BlockHeaderBuilder.create();
@@ -82,7 +82,7 @@ public class BlockHeaderTestFixture {
blobGasUsed.ifPresent(builder::blobGasUsed);
requestsHash.ifPresent(builder::requestsHash);
parentBeaconBlockRoot.ifPresent(builder::parentBeaconBlockRoot);
targetBlobCount.ifPresent(builder::targetBlobCount);
targetBlobsPerBlock.ifPresent(builder::targetBlobsPerBlock);
builder.blockHeaderFunctions(blockHeaderFunctions);
return builder.buildBlockHeader();
@@ -205,8 +205,8 @@ public class BlockHeaderTestFixture {
return this;
}
public BlockHeaderTestFixture targetBlobCount(final UInt64 targetBlobCount) {
this.targetBlobCount = Optional.of(targetBlobCount);
public BlockHeaderTestFixture targetBlobsPerBlock(final UInt64 targetBlobsPerBlock) {
this.targetBlobsPerBlock = Optional.of(targetBlobsPerBlock);
return this;
}
}

View File

@@ -328,8 +328,8 @@ final class GenesisStateTest {
.isEqualTo(
Hash.fromHexString(
"0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f"));
assertThat(header.getTargetBlobCount().isPresent()).isTrue();
assertThat(header.getTargetBlobCount().get()).isEqualTo(UInt64.ONE);
assertThat(header.getTargetBlobsPerBlock().isPresent()).isTrue();
assertThat(header.getTargetBlobsPerBlock().get()).isEqualTo(UInt64.ONE);
assertThat(header.getHash())
.isEqualTo(

View File

@@ -4074,5 +4074,5 @@
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x3b9aca00",
"targetBlobCount": "0x1"
"targetBlobsPerBlock": "0x1"
}

View File

@@ -90,7 +90,7 @@ public class ChainForTestCreator {
blockHeader.getExcessBlobGas().orElse(null),
blockHeader.getParentBeaconBlockRoot().orElse(null),
blockHeader.getRequestsHash().orElse(null),
blockHeader.getTargetBlobCount().orElse(null),
blockHeader.getTargetBlobsPerBlock().orElse(null),
new MainnetBlockHeaderFunctions());
}

View File

@@ -200,7 +200,7 @@ public class BlockchainReferenceTestCaseSpec {
excessBlobGas != null ? BlobGas.fromHexString(excessBlobGas) : null,
parentBeaconBlockRoot != null ? Bytes32.fromHexString(parentBeaconBlockRoot) : null,
requestsHash != null ? Hash.fromHexString(requestsHash) : null,
null, // TODO SLD EIP-7742 use targetBlobCount when reference tests are updated
null, // TODO SLD EIP-7742 use targetBlobsPerBlock when reference tests are updated
new BlockHeaderFunctions() {
@Override
public Hash hash(final BlockHeader header) {

View File

@@ -146,7 +146,7 @@ public class ReferenceTestEnv extends BlockHeader {
currentExcessBlobGas == null ? null : BlobGas.of(Long.decode(currentExcessBlobGas)),
beaconRoot == null ? null : Bytes32.fromHexString(beaconRoot),
null, // requestsHash
null, // TODO SLD EIP-7742 use targetBlobCount when reference tests are updated
null, // TODO SLD EIP-7742 use targetBlobsPerBlock when reference tests are updated
new MainnetBlockHeaderFunctions());
this.parentDifficulty = parentDifficulty;
this.parentBaseFee = parentBaseFee;

View File

@@ -71,7 +71,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files
knownHash = 'dkhT5PziIX6nhIRA4EghMEGKkEB7NTAyqRaKDcAidKc='
knownHash = 'dsbVupAvtmZlEeEeVDtk+VrzGFvyKxHgQntaMtOq5TY='
}
check.dependsOn('checkAPIChanges')

View File

@@ -108,13 +108,13 @@ public interface ProcessableBlockHeader {
Optional<? extends Bytes32> getParentBeaconBlockRoot();
/**
* The target_blob_count of this header.
* The target_blobs_per_block of this header.
*
* @return The target blob count of this header.
* @return The target blobs per block of this header.
*/
@Unstable
// TODO SLD should be Quantity or new subclass of Quantity?
default Optional<UInt64> getTargetBlobCount() {
default Optional<UInt64> getTargetBlobsPerBlock() {
return Optional.empty();
}
}