Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ci issues #8089

Draft
wants to merge 2 commits into
base: verkle
Choose a base branch
from
Draft
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 @@ -641,7 +641,7 @@ && isDescendantOf(newHead, blockchain.getChainHeadHeader())) {
return ForkchoiceResult.withResult(newFinalized, Optional.of(newHead));
}

public boolean setNewHead(final MutableBlockchain blockchain, final BlockHeader newHead) {
private boolean setNewHead(final MutableBlockchain blockchain, final BlockHeader newHead) {

if (newHead.getHash().equals(blockchain.getChainHeadHash())) {
LOG.atDebug()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ default Wei decrementBalance(final Wei value) {
*/
void setBalance(Wei value);

/**
* Gets the code size of this account.
*
* @return the code size of this account.
*/
Optional<Long> getCodeSize();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class BerlinGasCalculator extends IstanbulGasCalculator {
protected static final long ACCESS_LIST_STORAGE_COST = 1900L;

// redefinitions for EIP-2929
/** The constant SLOAD_GAS. */
protected static final long SLOAD_GAS = WARM_STORAGE_READ_COST;

/** The constant SSTORE_RESET_GAS. */
Expand All @@ -66,7 +67,7 @@ public class BerlinGasCalculator extends IstanbulGasCalculator {
private static final long NEGATIVE_SSTORE_CLEARS_SCHEDULE = -SSTORE_CLEARS_SCHEDULE;

// unchanged from Frontier
protected static final long COPY_WORD_GAS_COST = 3L;
private static final long COPY_WORD_GAS_COST = 3L;

private final int maxPrecompile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@

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

/**
* Gas Calculator as per EIP-4762
*
* <UL>
* <LI>Gas costs for EIP-4762 (Stateless trie)
* </UL>
*/
public class Eip4762GasCalculator extends PragueGasCalculator {
public static final Address HISTORY_STORAGE_ADDRESS =
private static final Address HISTORY_STORAGE_ADDRESS =
Address.fromHexString("0xfffffffffffffffffffffffffffffffffffffffe");
private static final long CREATE_OPERATION_GAS_COST = 1_000L;

/** Instantiates a new Prague Gas Calculator. */
/** Instantiates a new EIP-4762 Gas Calculator. */
public Eip4762GasCalculator() {
super(KZG_POINT_EVAL.toArrayUnsafe()[19]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ long callOperationGasCost(
*/
long gasAvailableForChildCall(MessageFrame frame, long stipend, boolean transfersValue);

/**
* The cost of creating a contract account to the trie.
*
* @param frame The current frame
* @return the gas cost
*/
long completedCreateContractGasCost(final MessageFrame frame);

/**
Expand Down Expand Up @@ -333,6 +339,13 @@ long callOperationGasCost(
*/
long initcodeCost(final int initCodeLength);

/**
* The cost of checking if a contract already exists in the trie.
*
* @param frame The current frame
* @param address The contract address
* @return the gas cost for the proof of absence check
*/
default long proofOfAbsenceCost(final MessageFrame frame, final Address address) {
return 0;
}
Expand Down Expand Up @@ -370,6 +383,15 @@ default long proofOfAbsenceCost(final MessageFrame frame, final Address address)
long codeCopyOperationGasCost(
MessageFrame frame, long memOffset, long codeOffset, long readSize, final long codeSize);

/**
* Returns the amount of gas consumed by a PUSH operation.
*
* @param frame The current frame
* @param codeOffset offset of the code in bytes where the EVM is currently executing
* @param readSize size, in bytes, of the code that is being read by the PUSH operation
* @param codeSize full size of the code
* @return the amount of gas consumed by a PUSH operation
*/
long pushOperationGasCost(MessageFrame frame, long codeOffset, long readSize, long codeSize);

/**
Expand Down Expand Up @@ -538,6 +560,9 @@ long selfDestructOperationGasCost(
/**
* Returns the cost for executing a {@link SLoadOperation}.
*
* @param frame The current frame
* @param key The slot key
* @param slotIsWarm The storage slot is warm
* @return the cost for executing the storage load operation
*/
long sloadOperationGasCost(MessageFrame frame, UInt256 key, final boolean slotIsWarm);
Expand Down Expand Up @@ -763,6 +788,11 @@ default long calculateDelegateCodeGasRefund(final long alreadyExistingAccountSiz
return 0L;
}

/**
* Creates a new access witness instance.
*
* @return an access witness instance that by default is an access witness that does nothing
*/
default AccessWitness newAccessWitness() {
return NoopAccessWitness.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
*/
package org.hyperledger.besu.evm.gascalculator.stateless;

/**
* Manages access events that are done to the AccessWitness. An access mode is passed to the witness
* representing the type of access being done on the verkle trie leaf node: read, write to an
* existing leaf (reset) or write to a non-existent leaf (set). The access mode is then evaluated
* against structures that tracks previous access events, to avoid double charging. What results is
* the **new** access event schedule that is then used for gas charging.
*/
public final class AccessEvents {

private static final long WITNESS_BRANCH_COST = 1900;
Expand All @@ -22,51 +29,177 @@ public final class AccessEvents {
private static final long CHUNK_EDIT_COST = 500;
private static final long CHUNK_FILL_COST = 6200;

public static final short NONE = 0;
public static final short BRANCH_READ = 1;
public static final short BRANCH_WRITE = 2;
public static final short LEAF_READ = 4;
public static final short LEAF_RESET = 8;
public static final short LEAF_SET = 16;
/** Bit mask for NONE */
public static final int NONE = 0;

/** Bit mask for BRANCH READ */
public static final int BRANCH_READ = 1;

/** Bit mask for BRANCH WRITE */
public static final int BRANCH_WRITE = 2;

/** Bit mask for LEAF READ */
public static final int LEAF_READ = 4;

/** Bit mask for LEAF RESET */
public static final int LEAF_RESET = 8;

/** Bit mask for LEAF SET */
public static final int LEAF_SET = 16;

private AccessEvents() {}

public static boolean isBranchRead(final short accessEvents) {
/**
* Checks if a branch read event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains a branch read event, false otherwise
*/
public static boolean isBranchRead(final int accessEvents) {
return (accessEvents & BRANCH_READ) != 0;
}

public static boolean isBranchWrite(final short accessEvents) {
/**
* Adds a branch read event to the bit mask of access events.
*
* @param accessEvents bit mask of all access events so far
* @return bit mask with all access events plus a branch read
*/
public static int branchRead(final int accessEvents) {
return accessEvents | BRANCH_READ;
}

/**
* Checks if a branch write event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains a branch write event, false otherwise
*/
public static boolean isBranchWrite(final int accessEvents) {
return (accessEvents & BRANCH_WRITE) != 0;
}

public static boolean isLeafRead(final short accessEvents) {
/**
* Adds a branch write event to the bit mask of access events.
*
* @param accessEvents bit mask of all access events so far
* @return bit mask with all access events plus a branch write
*/
public static int branchWrite(final int accessEvents) {
return accessEvents | BRANCH_WRITE;
}

/**
* Checks if a leaf read event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains a leaf read event, false otherwise
*/
public static boolean isLeafRead(final int accessEvents) {
return (accessEvents & LEAF_READ) != 0;
}

public static boolean isLeafReset(final short accessEvents) {
/**
* Adds a leaf read event to the bit mask of access events.
*
* @param accessEvents bit mask of all access events so far
* @return bit mask with all access events plus a leaf read
*/
public static int leafRead(final int accessEvents) {
return accessEvents | LEAF_READ;
}

/**
* Checks if a leaf reset event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains a leaf reset event, false otherwise
*/
public static boolean isLeafReset(final int accessEvents) {
return (accessEvents & LEAF_RESET) != 0;
}

public static boolean isLeafSet(final short accessEvents) {
/**
* Adds a leaf reset event to the bit mask of access events.
*
* @param accessEvents bit mask of all access events so far
* @return bit mask with all access events plus a leaf reset
*/
public static int leafReset(final int accessEvents) {
return accessEvents | LEAF_RESET;
}

/**
* Checks if a leaf set event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains a leaf set event, false otherwise
*/
public static boolean isLeafSet(final int accessEvents) {
return (accessEvents & LEAF_SET) != 0;
}

/**
* Adds a leaf set event to the bit mask of access events.
*
* @param accessEvents bit mask of all access events so far
* @return bit mask with all access events plus a leaf set
*/
public static int leafSet(final int accessEvents) {
return accessEvents | LEAF_SET;
}

/**
* Checks if a write event has occurred.
*
* @param accessEvents bit mask of all access events so far
* @return true if bit mask contains any of the write events, false otherwise
*/
public static boolean isWrite(final int accessEvents) {
return isBranchWrite(accessEvents) || isLeafSet(accessEvents) || isLeafReset(accessEvents);
}

/**
* The branch read event cost.
*
* @return cost of a branch read event.
*/
public static long getBranchReadCost() {
return WITNESS_BRANCH_COST;
}

/**
* The leaf read event cost.
*
* @return cost of a leaf read event.
*/
public static long getLeafReadCost() {
return WITNESS_CHUNK_COST;
}

/**
* The branch write event cost.
*
* @return cost of a branch write event.
*/
public static long getBranchWriteCost() {
return SUBTREE_EDIT_COST;
}

/**
* The leaf reset event cost.
*
* @return cost of a leaf reset event.
*/
public static long getLeafResetCost() {
return CHUNK_EDIT_COST;
}

/**
* The leaf set event cost.
*
* @return cost of a leaf set event.
*/
public static long getLeafSetCost() {
return CHUNK_FILL_COST;
}
Expand Down

This file was deleted.

Loading
Loading