diff --git a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java index b1f59554af3..e8d58ac650c 100644 --- a/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java +++ b/besu/src/test/java/org/hyperledger/besu/controller/MergeBesuControllerBuilderTest.java @@ -99,7 +99,8 @@ public class MergeBesuControllerBuilderTest { BigInteger networkId = BigInteger.ONE; private final BlockHeaderTestFixture headerGenerator = new BlockHeaderTestFixture(); - private final BaseFeeMarket feeMarket = new LondonFeeMarket(0, Optional.of(Wei.of(42))); + private final BaseFeeMarket feeMarket = + new LondonFeeMarket(0, Optional.of(Wei.of(42)), Optional.empty()); private final TransactionPoolConfiguration poolConfiguration = TransactionPoolConfiguration.DEFAULT; private final ObservableMetricsSystem observableMetricsSystem = new NoOpMetricsSystem(); @@ -272,7 +273,9 @@ private BlockHeader finalizedBlockHeader() { .difficulty(Difficulty.MAX_VALUE) .parentHash(magicHash) .number(blockNumber) - .baseFeePerGas(feeMarket.computeBaseFee(blockNumber, Wei.of(0x3b9aca00), 0, 15000000l)) + .baseFeePerGas( + feeMarket.computeBaseFee( + blockNumber, Wei.of(0x3b9aca00), 0, 15000000l, OptionalLong.empty())) .gasLimit(30000000l) .stateRoot(magicHash) .buildHeader(); diff --git a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java index eb4d1d6b701..f28ccad35ef 100644 --- a/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java +++ b/consensus/merge/src/main/java/org/hyperledger/besu/consensus/merge/blockcreation/PayloadIdentifier.java @@ -47,7 +47,11 @@ public class PayloadIdentifier implements Quantity { */ @JsonCreator public PayloadIdentifier(final String payloadId) { - this.val = UInt64.fromHexString(payloadId); + if (payloadId.startsWith("0x")) { + this.val = UInt64.fromHexString(payloadId); + } else { + this.val = UInt64.valueOf(Math.abs(Long.parseLong(payloadId))); + } } /** @@ -56,7 +60,7 @@ public PayloadIdentifier(final String payloadId) { * @param payloadId the payload id */ public PayloadIdentifier(final Long payloadId) { - this.val = UInt64.valueOf(payloadId); + this.val = UInt64.valueOf(Math.abs(payloadId)); } /** diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java index 040ee371194..b672a514011 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/AbstractBlockProcessor.java @@ -117,10 +117,7 @@ public BlockProcessingResult processBlock( } Create2DeployerFunction.ensureCreate2Deployer( - genesisOptions, - blockHeader.getTimestamp(), - worldState.updater() - ); + genesisOptions, blockHeader.getTimestamp(), worldState.updater()); for (final Transaction transaction : transactions) { if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/Create2DeployerFunction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/Create2DeployerFunction.java index afd216f2a36..f220c933b3e 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/Create2DeployerFunction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/Create2DeployerFunction.java @@ -1,26 +1,42 @@ +/* + * Copyright optimism-java. + * + * 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.ethereum.mainnet; -import java.util.Optional; -import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.config.GenesisConfigOptions; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.evm.account.MutableAccount; import org.hyperledger.besu.evm.worldstate.WorldUpdater; -/** - * Create2DeployerFunction - */ +import java.util.Optional; + +import org.apache.tuweni.bytes.Bytes; + +/** Create2DeployerFunction */ public class Create2DeployerFunction { private static final String CREATE2_DEPLOYER_ADDR = "0x13b0d85ccb8bf860b6b79af3029fca081ae9bef2"; - private static final Bytes CREATE_2_DEPLOYER_CODE = Bytes.fromHexString( - "0x6080604052600436106100435760003560e01c8063076c37b21461004f578063481286e61461007157806356299481146100ba57806366cfa057146100da57600080fd5b3661004a57005b600080fd5b34801561005b57600080fd5b5061006f61006a366004610327565b6100fa565b005b34801561007d57600080fd5b5061009161008c366004610327565b61014a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100c657600080fd5b506100916100d5366004610349565b61015d565b3480156100e657600080fd5b5061006f6100f53660046103ca565b610172565b61014582826040518060200161010f9061031a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f90910116604052610183565b505050565b600061015683836102e7565b9392505050565b600061016a8484846102f0565b949350505050565b61017d838383610183565b50505050565b6000834710156101f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b815160000361025f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016101eb565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610156576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016101eb565b60006101568383305b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b61014e806104ad83390190565b6000806040838503121561033a57600080fd5b50508035926020909101359150565b60008060006060848603121561035e57600080fd5b8335925060208401359150604084013573ffffffffffffffffffffffffffffffffffffffff8116811461039057600080fd5b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156103df57600080fd5b8335925060208401359150604084013567ffffffffffffffff8082111561040557600080fd5b818601915086601f83011261041957600080fd5b81358181111561042b5761042b61039b565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156104715761047161039b565b8160405282815289602084870101111561048a57600080fd5b826020860160208301376000602084830101528095505050505050925092509256fe608060405234801561001057600080fd5b5061012e806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063249cb3fa14602d575b600080fd5b603c603836600460b1565b604e565b60405190815260200160405180910390f35b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915281205460ff16608857600060aa565b7fa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b45b9392505050565b6000806040838503121560c357600080fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811460ed57600080fd5b80915050925092905056fea26469706673582212205ffd4e6cede7d06a5daf93d48d0541fc68189eeb16608c1999a82063b666eb1164736f6c63430008130033a2646970667358221220fdc4a0fe96e3b21c108ca155438d37c9143fb01278a3c1d274948bad89c564ba64736f6c63430008130033"); + private static final Bytes CREATE_2_DEPLOYER_CODE = + Bytes.fromHexString( + "0x6080604052600436106100435760003560e01c8063076c37b21461004f578063481286e61461007157806356299481146100ba57806366cfa057146100da57600080fd5b3661004a57005b600080fd5b34801561005b57600080fd5b5061006f61006a366004610327565b6100fa565b005b34801561007d57600080fd5b5061009161008c366004610327565b61014a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b3480156100c657600080fd5b506100916100d5366004610349565b61015d565b3480156100e657600080fd5b5061006f6100f53660046103ca565b610172565b61014582826040518060200161010f9061031a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820381018352601f90910116604052610183565b505050565b600061015683836102e7565b9392505050565b600061016a8484846102f0565b949350505050565b61017d838383610183565b50505050565b6000834710156101f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f437265617465323a20696e73756666696369656e742062616c616e636500000060448201526064015b60405180910390fd5b815160000361025f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f437265617465323a2062797465636f6465206c656e677468206973207a65726f60448201526064016101eb565b8282516020840186f5905073ffffffffffffffffffffffffffffffffffffffff8116610156576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f437265617465323a204661696c6564206f6e206465706c6f790000000000000060448201526064016101eb565b60006101568383305b6000604051836040820152846020820152828152600b8101905060ff815360559020949350505050565b61014e806104ad83390190565b6000806040838503121561033a57600080fd5b50508035926020909101359150565b60008060006060848603121561035e57600080fd5b8335925060208401359150604084013573ffffffffffffffffffffffffffffffffffffffff8116811461039057600080fd5b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000806000606084860312156103df57600080fd5b8335925060208401359150604084013567ffffffffffffffff8082111561040557600080fd5b818601915086601f83011261041957600080fd5b81358181111561042b5761042b61039b565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156104715761047161039b565b8160405282815289602084870101111561048a57600080fd5b826020860160208301376000602084830101528095505050505050925092509256fe608060405234801561001057600080fd5b5061012e806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063249cb3fa14602d575b600080fd5b603c603836600460b1565b604e565b60405190815260200160405180910390f35b60008281526020818152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915281205460ff16608857600060aa565b7fa2ef4600d742022d532d4747cb3547474667d6f13804902513b2ec01c848f4b45b9392505050565b6000806040838503121560c357600080fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff8116811460ed57600080fd5b80915050925092905056fea26469706673582212205ffd4e6cede7d06a5daf93d48d0541fc68189eeb16608c1999a82063b666eb1164736f6c63430008130033a2646970667358221220fdc4a0fe96e3b21c108ca155438d37c9143fb01278a3c1d274948bad89c564ba64736f6c63430008130033"); /** * The Canyon hardfork issues an irregular state transition that force-deploys the create2 * deployer contract. This is done by directly setting the code of the create2 deployer account * prior to executing any transactions on the timestamp activation of the fork. + * * @param configOptions chain config options * @param timestamp the block header timestamp * @param updater world state updater @@ -37,6 +53,4 @@ public static void ensureCreate2Deployer( contract.setCode(CREATE_2_DEPLOYER_CODE); updater.commit(); } - - } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/L1CostCalculator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/L1CostCalculator.java index df33d0c5bf6..f20e65ff08c 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/L1CostCalculator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/L1CostCalculator.java @@ -65,8 +65,7 @@ public Wei l1Cost( final Transaction transaction, final WorldUpdater worldState) { long gas = 0; - boolean isRegolith = - options.isRegolith(blockHeader.getTimestamp()); + boolean isRegolith = options.isRegolith(blockHeader.getTimestamp()); gas += calculateRollupDataGasCost(transaction.getRollupGasData(), isRegolith); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java index e98f1bcc76d..5cd88b08ebf 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/feemarket/LondonFeeMarket.java @@ -72,7 +72,7 @@ protected LondonFeeMarket( @Override public long getBasefeeMaxChangeDenominator(final OptionalLong time) { - if (time.isPresent() && this.chainOptions.isPresent()) { + if (this.chainOptions.isPresent() && this.chainOptions.get().isOptimism() && time.isPresent()) { if (this.chainOptions.get().isCanyon(time.getAsLong())) { return chainOptions .get()