Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static BlockAccessList decode(final RLPInput in) {
scIn.readList(
changeIn -> {
changeIn.enterList();
int txIndex = changeIn.readIntScalar();
long txIndex = changeIn.readUnsignedIntScalar();
UInt256 newVal = UInt256.fromBytes(changeIn.readBytes());
changeIn.leaveList();
return new StorageChange(txIndex, newVal);
Expand All @@ -72,7 +72,7 @@ public static BlockAccessList decode(final RLPInput in) {
acctIn.readList(
bcIn -> {
bcIn.enterList();
int txIndex = bcIn.readIntScalar();
long txIndex = bcIn.readUnsignedIntScalar();
Wei postBalance = Wei.of(UInt256.fromBytes(bcIn.readBytes()));
bcIn.leaveList();
return new BalanceChange(txIndex, postBalance);
Expand All @@ -82,7 +82,7 @@ public static BlockAccessList decode(final RLPInput in) {
acctIn.readList(
ncIn -> {
ncIn.enterList();
int txIndex = ncIn.readIntScalar();
long txIndex = ncIn.readUnsignedIntScalar();
long newNonce = ncIn.readLongScalar();
ncIn.leaveList();
return new NonceChange(txIndex, newNonce);
Expand All @@ -92,7 +92,7 @@ public static BlockAccessList decode(final RLPInput in) {
acctIn.readList(
ccIn -> {
ccIn.enterList();
int txIndex = ccIn.readIntScalar();
long txIndex = ccIn.readUnsignedIntScalar();
Bytes newCode = ccIn.readBytes();
ccIn.leaveList();
return new CodeChange(txIndex, newCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.hyperledger.besu.ethereum.rlp.RLPOutput;

import org.apache.tuweni.units.bigints.UInt256;
import org.apache.tuweni.units.bigints.UInt64;

public final class BlockAccessListEncoder {

Expand All @@ -40,7 +39,7 @@ public static void encode(final BlockAccessList bal, final RLPOutput out) {
sc.changes(),
(chg, chgOut) -> {
chgOut.startList();
chgOut.writeUInt64Scalar(UInt64.valueOf(chg.txIndex()));
chgOut.writeUnsignedInt(chg.txIndex());
Comment thread
matkt marked this conversation as resolved.
chgOut.writeUInt256Scalar(chg.newValue());
chgOut.endList();
});
Expand All @@ -55,7 +54,7 @@ public static void encode(final BlockAccessList bal, final RLPOutput out) {
acct.balanceChanges(),
(bc, bcOut) -> {
bcOut.startList();
bcOut.writeUInt64Scalar(UInt64.valueOf(bc.txIndex()));
bcOut.writeUnsignedInt(bc.txIndex());
Comment thread
matkt marked this conversation as resolved.
bcOut.writeUInt256Scalar(UInt256.fromBytes(bc.postBalance()));
bcOut.endList();
});
Expand All @@ -64,7 +63,7 @@ public static void encode(final BlockAccessList bal, final RLPOutput out) {
acct.nonceChanges(),
(nc, ncOut) -> {
ncOut.startList();
ncOut.writeUInt64Scalar(UInt64.valueOf(nc.txIndex()));
ncOut.writeUnsignedInt(nc.txIndex());
Comment thread
matkt marked this conversation as resolved.
ncOut.writeLongScalar(nc.newNonce());
ncOut.endList();
});
Expand All @@ -73,7 +72,7 @@ public static void encode(final BlockAccessList bal, final RLPOutput out) {
acct.codeChanges(),
(cc, ccOut) -> {
ccOut.startList();
ccOut.writeUInt64Scalar(UInt64.valueOf(cc.txIndex()));
ccOut.writeUnsignedInt(cc.txIndex());
Comment thread
matkt marked this conversation as resolved.
ccOut.writeBytes(cc.newCode());
ccOut.endList();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public boolean validate(
}
}

final int maxIndex = nbTransactions + 1;
final long maxIndex = (long) nbTransactions + 1L;
if (!validateConstraints(bal, blockHeader, maxIndex)) {
return false;
}
Expand All @@ -130,7 +130,7 @@ public boolean validate(
* overlap with storage_reads.
*/
private boolean validateConstraints(
final BlockAccessList bal, final BlockHeader blockHeader, final int maxIndex) {
final BlockAccessList bal, final BlockHeader blockHeader, final long maxIndex) {
Address prevAddress = null;

for (BlockAccessList.AccountChanges account : bal.accountChanges()) {
Expand All @@ -145,7 +145,7 @@ private boolean validateConstraints(

final Set<StorageSlotKey> changeSlots = new HashSet<>(account.storageChanges().size());
StorageSlotKey prevStorageSlot = null;
int prevStorageTxIndex = -1;
long prevStorageTxIndex = -1L;

for (BlockAccessList.SlotChanges slotChanges : account.storageChanges()) {
final StorageSlotKey slot = slotChanges.slot();
Expand All @@ -160,9 +160,9 @@ && compareSlotKeysByCanonicalOrder(prevStorageSlot, slot) >= 0) {
prevStorageSlot = slot;
changeSlots.add(slot);

prevStorageTxIndex = -1;
prevStorageTxIndex = -1L;
for (BlockAccessList.StorageChange ch : slotChanges.changes()) {
final int txIndex = ch.txIndex();
final long txIndex = ch.txIndex();
if (txIndex < 0) {
LOG.warn(
"Block access list has negative block_access_index for address {} block {}",
Expand Down Expand Up @@ -209,9 +209,9 @@ && compareSlotKeysByCanonicalOrder(prevStorageSlot, slot) >= 0) {
}
}

int prevTxIndex = -1;
long prevTxIndex = -1L;
for (BlockAccessList.BalanceChange ch : account.balanceChanges()) {
final int txIndex = ch.txIndex();
final long txIndex = ch.txIndex();
if (txIndex < 0) {
LOG.warn(
"Block access list has negative block_access_index in balance_changes for address {} block {}",
Expand All @@ -237,9 +237,9 @@ && compareSlotKeysByCanonicalOrder(prevStorageSlot, slot) >= 0) {
prevTxIndex = txIndex;
}

prevTxIndex = -1;
prevTxIndex = -1L;
for (BlockAccessList.NonceChange ch : account.nonceChanges()) {
final int txIndex = ch.txIndex();
final long txIndex = ch.txIndex();
if (txIndex < 0) {
LOG.warn(
"Block access list has negative block_access_index in nonce_changes for address {} block {}",
Expand All @@ -265,9 +265,9 @@ && compareSlotKeysByCanonicalOrder(prevStorageSlot, slot) >= 0) {
prevTxIndex = txIndex;
}

prevTxIndex = -1;
prevTxIndex = -1L;
for (BlockAccessList.CodeChange ch : account.codeChanges()) {
final int txIndex = ch.txIndex();
final long txIndex = ch.txIndex();
if (txIndex < 0) {
LOG.warn(
"Block access list has negative block_access_index in code_changes for address {} block {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@

public class AccessLocationTracker implements Eip7928AccessList {

private final int blockAccessIndex;
private final long blockAccessIndex;
private final Map<Address, AccountAccessList> touchedAccounts = new ConcurrentHashMap<>();

public AccessLocationTracker(final int blockAccessIndex) {
public AccessLocationTracker(final long blockAccessIndex) {
this.blockAccessIndex = blockAccessIndex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,28 @@ public String toString() {
return "BlockAccessList{" + "accountChanges=" + accountChanges + '}';
}

public record StorageChange(int txIndex, UInt256 newValue) {
public record StorageChange(long txIndex, UInt256 newValue) {
Comment thread
matkt marked this conversation as resolved.
@Override
public String toString() {
return "StorageChange{txIndex=" + txIndex + ", newValue=" + newValue + '}';
}
}

public record BalanceChange(int txIndex, Wei postBalance) {
public record BalanceChange(long txIndex, Wei postBalance) {
Comment thread
matkt marked this conversation as resolved.
@Override
public String toString() {
return "BalanceChange{txIndex=" + txIndex + ", postBalance=" + postBalance + '}';
}
}

public record NonceChange(int txIndex, long newNonce) {
public record NonceChange(long txIndex, long newNonce) {
Comment thread
matkt marked this conversation as resolved.
@Override
public String toString() {
return "NonceChange{txIndex=" + txIndex + ", newNonce=" + newNonce + '}';
}
}

public record CodeChange(int txIndex, Bytes newCode) {
public record CodeChange(long txIndex, Bytes newCode) {
Comment thread
matkt marked this conversation as resolved.
@Override
public String toString() {
return "CodeChange{txIndex=" + txIndex + ", newCode=" + newCode + '}';
Expand Down Expand Up @@ -157,12 +157,12 @@ public static AccessLocationTracker createPreExecutionAccessLocationTracker() {

public static AccessLocationTracker createPostExecutionAccessLocationTracker(
final int numberOfTransactions) {
return new AccessLocationTracker(numberOfTransactions + 1);
return new AccessLocationTracker((long) numberOfTransactions + 1L);
}

public static AccessLocationTracker createTransactionAccessLocationTracker(
final int transactionLocation) {
return new AccessLocationTracker(transactionLocation + 1);
return new AccessLocationTracker((long) transactionLocation + 1L);
}

public AccountBuilder getOrCreateAccountBuilder(final Address address) {
Expand Down Expand Up @@ -281,7 +281,7 @@ Optional<Bytes> getLastCode() {
}
}

void addStorageWrite(final StorageSlotKey slot, final int txIndex, final UInt256 value) {
void addStorageWrite(final StorageSlotKey slot, final long txIndex, final UInt256 value) {
final List<StorageChange> changes =
slotWrites.computeIfAbsent(slot, __ -> new ArrayList<>());
slotReads.remove(slot);
Expand All @@ -294,15 +294,15 @@ void addStorageRead(final StorageSlotKey slot) {
}
}

void addBalanceChange(final int txIndex, final Wei postBalance) {
void addBalanceChange(final long txIndex, final Wei postBalance) {
balances.add(new BalanceChange(txIndex, postBalance));
}

void addNonceChange(final int txIndex, final long newNonce) {
void addNonceChange(final long txIndex, final long newNonce) {
nonces.add(new NonceChange(txIndex, newNonce));
}

void addCodeChange(final int txIndex, final Bytes code) {
void addCodeChange(final long txIndex, final Bytes code) {
codes.add(new CodeChange(txIndex, code));
}

Expand All @@ -315,7 +315,7 @@ AccountChanges build() {
new SlotChanges(
e.getKey(),
e.getValue().stream()
.sorted(Comparator.comparingInt(StorageChange::txIndex))
.sorted(Comparator.comparingLong(StorageChange::txIndex))
.collect(Collectors.toList())))
.collect(Collectors.toList());

Expand All @@ -330,7 +330,7 @@ AccountChanges build() {
slotChanges,
reads,
balances.stream().sorted(Comparator.comparingLong(BalanceChange::txIndex)).toList(),
nonces.stream().sorted(Comparator.comparingDouble(NonceChange::txIndex)).toList(),
nonces.stream().sorted(Comparator.comparingLong(NonceChange::txIndex)).toList(),
codes.stream().sorted(Comparator.comparingLong(CodeChange::txIndex)).toList());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
*/
public final class PartialBlockAccessView {

private final int txIndex;
private final long txIndex;
private final List<AccountChanges> accountChanges;

public PartialBlockAccessView(final List<AccountChanges> accountChanges, final int txIndex) {
public PartialBlockAccessView(final List<AccountChanges> accountChanges, final long txIndex) {
this.accountChanges = accountChanges;
this.txIndex = txIndex;
}
Expand All @@ -66,7 +66,7 @@ public String toString() {
+ '}';
}

public int getTxIndex() {
public long getTxIndex() {
return txIndex;
}

Expand Down Expand Up @@ -166,10 +166,10 @@ public String toString() {

/** Builder for PartialBlockAccessView. */
public static class PartialBlockAccessViewBuilder {
private int txIndex;
private long txIndex;
private final Map<Address, AccountChangesBuilder> accountBuilders = new HashMap<>();

public PartialBlockAccessViewBuilder withTxIndex(final int txIndex) {
public PartialBlockAccessViewBuilder withTxIndex(final long txIndex) {
this.txIndex = txIndex;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ protected ParallelizedTransactionContext runTransaction(
final PathBasedWorldStateUpdateAccumulator<?> blockUpdater =
(PathBasedWorldStateUpdateAccumulator<?>) ws.updater();

applyWritesFromPriorTransactions(blockAccessList, transactionLocation + 1, blockUpdater);
applyWritesFromPriorTransactions(
blockAccessList, (long) transactionLocation + 1L, blockUpdater);
blockUpdater.commit();

final WorldUpdater txUpdater = blockUpdater.updater();
Expand Down Expand Up @@ -185,7 +186,7 @@ public Optional<TransactionProcessingResult> getProcessingResult(

private void applyWritesFromPriorTransactions(
final BlockAccessList blockAccessList,
final int balIndex,
final long balIndex,
final PathBasedWorldStateUpdateAccumulator<?> worldStateUpdater) {
for (var accountChanges : blockAccessList.accountChanges()) {
final Address address = accountChanges.address();
Expand Down Expand Up @@ -232,11 +233,11 @@ private void applyWritesFromPriorTransactions(
}

private BlockAccessList.BalanceChange findLatestBalanceChange(
final Collection<BlockAccessList.BalanceChange> changes, final int maxIndex) {
final Collection<BlockAccessList.BalanceChange> changes, final long maxIndex) {
BlockAccessList.BalanceChange latest = null;
int latestIndex = -1;
long latestIndex = -1L;
for (var change : changes) {
final int txIndex = change.txIndex();
final long txIndex = change.txIndex();
if (txIndex < maxIndex && txIndex > latestIndex) {
latest = change;
latestIndex = txIndex;
Expand All @@ -246,11 +247,11 @@ private BlockAccessList.BalanceChange findLatestBalanceChange(
}

private BlockAccessList.NonceChange findLatestNonceChange(
final Collection<BlockAccessList.NonceChange> changes, final int maxIndex) {
final Collection<BlockAccessList.NonceChange> changes, final long maxIndex) {
BlockAccessList.NonceChange latest = null;
int latestIndex = -1;
long latestIndex = -1L;
for (var change : changes) {
final int txIndex = change.txIndex();
final long txIndex = change.txIndex();
if (txIndex < maxIndex && txIndex > latestIndex) {
latest = change;
latestIndex = txIndex;
Expand All @@ -260,11 +261,11 @@ private BlockAccessList.NonceChange findLatestNonceChange(
}

private BlockAccessList.CodeChange findLatestCodeChange(
final Collection<BlockAccessList.CodeChange> changes, final int maxIndex) {
final Collection<BlockAccessList.CodeChange> changes, final long maxIndex) {
BlockAccessList.CodeChange latest = null;
int latestIndex = -1;
long latestIndex = -1L;
for (var change : changes) {
final int txIndex = change.txIndex();
final long txIndex = change.txIndex();
if (txIndex < maxIndex && txIndex > latestIndex) {
latest = change;
latestIndex = txIndex;
Expand All @@ -274,11 +275,11 @@ private BlockAccessList.CodeChange findLatestCodeChange(
}

private BlockAccessList.StorageChange findLatestStorageChange(
final Collection<BlockAccessList.StorageChange> changes, final int maxIndex) {
final Collection<BlockAccessList.StorageChange> changes, final long maxIndex) {
BlockAccessList.StorageChange latest = null;
int latestIndex = -1;
long latestIndex = -1L;
for (var change : changes) {
final int txIndex = change.txIndex();
final long txIndex = change.txIndex();
if (txIndex < maxIndex && txIndex > latestIndex) {
latest = change;
latestIndex = txIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ private BlockAccessList.SlotChanges slotChanges(final int txIndex) {
final List<BlockAccessList.StorageChange> changes = new ArrayList<>();

for (int i = 0; i < changeCount; i++) {
changes.add(new BlockAccessList.StorageChange(txIndex + i, uint256()));
changes.add(new BlockAccessList.StorageChange((long) txIndex + i, uint256()));
}

return new BlockAccessList.SlotChanges(slot, changes);
Expand Down
Loading
Loading