mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-08 23:08:15 -05:00
Merge branch 'main' into zkbesu
# Conflicts: # .github/pull_request_template.md # .github/workflows/sonarcloud.yml
This commit is contained in:
@@ -57,7 +57,7 @@ public class BytesTrieSet<E extends Bytes> extends AbstractSet<E> {
|
||||
if (leafObject == null) sb.append("null");
|
||||
else {
|
||||
sb.append('[');
|
||||
System.out.println(leafObject.toHexString());
|
||||
sb.append(leafObject.toHexString());
|
||||
sb.append(']');
|
||||
}
|
||||
sb.append(", children=");
|
||||
|
||||
@@ -62,7 +62,7 @@ public class CancunGasCalculator extends ShanghaiGasCalculator {
|
||||
|
||||
/**
|
||||
* The blob gas cost per blob. This is the gas cost for each blob of data that is added to the
|
||||
* block.
|
||||
* block. 1 << 17 = 131072 = 0x20000
|
||||
*/
|
||||
private static final long BLOB_GAS_PER_BLOB = 1 << 17;
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright contributors to Besu.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
package org.hyperledger.besu.evm.operation;
|
||||
|
||||
import org.hyperledger.besu.datatypes.Hash;
|
||||
import org.hyperledger.besu.evm.account.Account;
|
||||
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
|
||||
import org.hyperledger.besu.evm.worldstate.CodeDelegationHelper;
|
||||
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
/**
|
||||
* ExtCode* operations treat EOAs with delegated code differently than other operations. This
|
||||
* abstract class contains common methods for this behaviour.
|
||||
*/
|
||||
abstract class AbstractExtCodeOperation extends AbstractOperation {
|
||||
/**
|
||||
* Instantiates a new Abstract operation.
|
||||
*
|
||||
* @param opcode the opcode
|
||||
* @param name the name
|
||||
* @param stackItemsConsumed the stack items consumed
|
||||
* @param stackItemsProduced the stack items produced
|
||||
* @param gasCalculator the gas calculator
|
||||
*/
|
||||
protected AbstractExtCodeOperation(
|
||||
final int opcode,
|
||||
final String name,
|
||||
final int stackItemsConsumed,
|
||||
final int stackItemsProduced,
|
||||
final GasCalculator gasCalculator) {
|
||||
super(opcode, name, stackItemsConsumed, stackItemsProduced, gasCalculator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code for standard accounts or a special designator for EOAs with delegated code
|
||||
*
|
||||
* @param account The account
|
||||
* @return the code or the special 7702 designator
|
||||
*/
|
||||
protected Bytes getCode(final Account account) {
|
||||
if (account == null) {
|
||||
return Bytes.EMPTY;
|
||||
}
|
||||
|
||||
return account.hasDelegatedCode()
|
||||
? CodeDelegationHelper.getCodeDelegationForRead()
|
||||
: account.getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the code hash for standard accounts or a special designator for EOAs with delegated
|
||||
* code
|
||||
*
|
||||
* @param account The account
|
||||
* @return the code hash or the hash of the special 7702 designator
|
||||
*/
|
||||
protected Hash getCodeHash(final Account account) {
|
||||
if (account.hasDelegatedCode()) {
|
||||
return Hash.hash(CodeDelegationHelper.getCodeDelegationForRead());
|
||||
}
|
||||
|
||||
return account.getCodeHash();
|
||||
}
|
||||
}
|
||||
@@ -57,9 +57,9 @@ public class BlockHashOperation extends AbstractOperation {
|
||||
final long currentBlockNumber = blockValues.getNumber();
|
||||
final BlockHashLookup blockHashLookup = frame.getBlockHashLookup();
|
||||
|
||||
// If the current block is the genesis block or the sought block is
|
||||
// not within the lookback window, zero is returned.
|
||||
if (currentBlockNumber == 0
|
||||
// If the sought block is negative, a future block, the current block, or not in the
|
||||
// lookback window, zero is returned.
|
||||
if (soughtBlock < 0
|
||||
|| soughtBlock >= currentBlockNumber
|
||||
|| soughtBlock < (currentBlockNumber - blockHashLookup.getLookback())) {
|
||||
frame.pushStackItem(Bytes32.ZERO);
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.hyperledger.besu.evm.internal.Words;
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
/** The Ext code copy operation. */
|
||||
public class ExtCodeCopyOperation extends AbstractExtCodeOperation {
|
||||
public class ExtCodeCopyOperation extends AbstractOperation {
|
||||
|
||||
/** This is the "code" legacy contracts see when copying code from an EOF contract. */
|
||||
public static final Bytes EOF_REPLACEMENT_CODE = Bytes.fromHexString("0xef00");
|
||||
@@ -93,8 +93,7 @@ public class ExtCodeCopyOperation extends AbstractExtCodeOperation {
|
||||
}
|
||||
|
||||
final Account account = frame.getWorldUpdater().get(address);
|
||||
|
||||
final Bytes code = getCode(account);
|
||||
final Bytes code = account != null ? account.getCode() : Bytes.EMPTY;
|
||||
|
||||
if (enableEIP3540
|
||||
&& code.size() >= 2
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.hyperledger.besu.evm.internal.Words;
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
/** The Ext code hash operation. */
|
||||
public class ExtCodeHashOperation extends AbstractExtCodeOperation {
|
||||
public class ExtCodeHashOperation extends AbstractOperation {
|
||||
|
||||
// // 0x9dbf3648db8210552e9c4f75c6a1c3057c0ca432043bd648be15fe7be05646f5
|
||||
static final Hash EOF_REPLACEMENT_HASH = Hash.hash(ExtCodeCopyOperation.EOF_REPLACEMENT_CODE);
|
||||
@@ -85,14 +85,14 @@ public class ExtCodeHashOperation extends AbstractExtCodeOperation {
|
||||
if (account == null || account.isEmpty()) {
|
||||
frame.pushStackItem(Bytes.EMPTY);
|
||||
} else {
|
||||
final Bytes code = getCode(account);
|
||||
final Bytes code = account.getCode();
|
||||
if (enableEIP3540
|
||||
&& code.size() >= 2
|
||||
&& code.get(0) == EOFLayout.EOF_PREFIX_BYTE
|
||||
&& code.get(1) == 0) {
|
||||
frame.pushStackItem(EOF_REPLACEMENT_HASH);
|
||||
} else {
|
||||
frame.pushStackItem(getCodeHash(account));
|
||||
frame.pushStackItem(account.getCodeHash());
|
||||
}
|
||||
}
|
||||
return new OperationResult(cost, null);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.hyperledger.besu.evm.internal.Words;
|
||||
import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
/** The Ext code size operation. */
|
||||
public class ExtCodeSizeOperation extends AbstractExtCodeOperation {
|
||||
public class ExtCodeSizeOperation extends AbstractOperation {
|
||||
|
||||
static final Bytes EOF_SIZE = Bytes.of(2);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ExtCodeSizeOperation extends AbstractExtCodeOperation {
|
||||
if (account == null) {
|
||||
codeSize = Bytes.EMPTY;
|
||||
} else {
|
||||
final Bytes code = getCode(account);
|
||||
final Bytes code = account.getCode();
|
||||
if (enableEIP3540
|
||||
&& code.size() >= 2
|
||||
&& code.get(0) == EOFLayout.EOF_PREFIX_BYTE
|
||||
|
||||
@@ -20,11 +20,6 @@ import org.apache.tuweni.bytes.Bytes;
|
||||
|
||||
/** Helper class for 7702 delegated code interactions */
|
||||
public class CodeDelegationHelper {
|
||||
/**
|
||||
* The designator that is returned when a ExtCode* operation calls a contract with delegated code
|
||||
*/
|
||||
public static final Bytes DELEGATED_CODE_DESIGNATOR = Bytes.fromHexString("ef01");
|
||||
|
||||
/** The prefix that is used to identify delegated code */
|
||||
public static final Bytes CODE_DELEGATION_PREFIX = Bytes.fromHexString("ef0100");
|
||||
|
||||
@@ -47,13 +42,4 @@ public class CodeDelegationHelper {
|
||||
&& code.size() == DELEGATED_CODE_SIZE
|
||||
&& code.slice(0, CODE_DELEGATION_PREFIX.size()).equals(CODE_DELEGATION_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the delegated code designator
|
||||
*
|
||||
* @return the hardcoded designator for delegated code: ef01
|
||||
*/
|
||||
public static Bytes getCodeDelegationForRead() {
|
||||
return DELEGATED_CODE_DESIGNATOR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CodeDelegationService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the provided account has either no code set or has already delegated code.
|
||||
* Returns true if the provided account has either no code set or has already delegated code.
|
||||
*
|
||||
* @param account the account to check.
|
||||
* @return {@code true} if the account can set delegated code, {@code false} otherwise.
|
||||
|
||||
Reference in New Issue
Block a user