mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 13:58:02 -05:00
Merge branch 'main' into zkbesu
# Conflicts: # gradle/verification-metadata.xml # plugin-api/build.gradle
This commit is contained in:
20
.github/ISSUE_TEMPLATE/release-checklist.md
vendored
20
.github/ISSUE_TEMPLATE/release-checklist.md
vendored
@@ -8,8 +8,8 @@ assignees: ''
|
|||||||
---
|
---
|
||||||
|
|
||||||
- [ ] Confirm anything outstanding for release with other maintainers on #besu-release in Discord
|
- [ ] Confirm anything outstanding for release with other maintainers on #besu-release in Discord
|
||||||
|
- [ ] Update changelog if necessary, and merge a PR for it to main
|
||||||
- [ ] Notify maintainers about updating changelog for in-flight PRs
|
- [ ] Notify maintainers about updating changelog for in-flight PRs
|
||||||
- [ ] Update changelog if necessary, and merge a PR for it to main
|
|
||||||
- [ ] Optional: for hotfixes, create a release branch and cherry-pick, e.g. `release-<version>-hotfix`
|
- [ ] Optional: for hotfixes, create a release branch and cherry-pick, e.g. `release-<version>-hotfix`
|
||||||
- [ ] Optional: create a PR into main from the hotfix branch to see the CI checks pass
|
- [ ] Optional: create a PR into main from the hotfix branch to see the CI checks pass
|
||||||
- [ ] On the appropriate branch/commit, create a calver tag for the release candidate, format example: `24.4.0-RC2`
|
- [ ] On the appropriate branch/commit, create a calver tag for the release candidate, format example: `24.4.0-RC2`
|
||||||
@@ -18,18 +18,14 @@ assignees: ''
|
|||||||
- [ ] Sign off burn-in; convey burn-in results in #besu-release in Discord
|
- [ ] Sign off burn-in; convey burn-in results in #besu-release in Discord
|
||||||
- [ ] Using the same git sha, create a calver tag for the FULL RELEASE, example format `24.4.0`
|
- [ ] Using the same git sha, create a calver tag for the FULL RELEASE, example format `24.4.0`
|
||||||
- [ ] Using the FULL RELEASE tag, create a release in github to trigger the workflows. Once published:
|
- [ ] Using the FULL RELEASE tag, create a release in github to trigger the workflows. Once published:
|
||||||
- makes the release "latest" in github
|
|
||||||
- this is now public and notifies subscribed users
|
- this is now public and notifies subscribed users
|
||||||
|
- makes the release "latest" in github
|
||||||
- publishes artefacts and version-specific docker tags
|
- publishes artefacts and version-specific docker tags
|
||||||
- publishes the docker `latest` tag variants
|
- publishes the docker `latest` tag variants
|
||||||
- [ ] Draft homebrew PR
|
- [ ] Check binary SHAs are correct on the release page
|
||||||
- [ ] Draft documentation release
|
- [ ] Check "Container Verify" GitHub workflow has run successfully
|
||||||
- [ ] Ensure binary SHAs are correct on the release page
|
- [ ] Create homebrew release - run https://github.com/hyperledger/homebrew-besu/actions/workflows/update-version.yml
|
||||||
- [ ] Docker release startup test:
|
- [ ] Create besu-docs release - https://github.com/hyperledger/besu-docs/releases/new
|
||||||
- `docker run hyperledger/besu:<version>`
|
- Copy release notes from besu
|
||||||
- `docker run hyperledger/besu:<version>-arm64`
|
- If publishing the release in github doesn't automatically trigger this workflow, then manually run https://github.com/hyperledger/besu-docs/actions/workflows/update-version.yml
|
||||||
- `docker run --platform linux/amd64 hyperledger/besu:<version>-amd64`
|
|
||||||
- `docker run --pull=always hyperledger/besu:latest` (check version is <version>)
|
|
||||||
- [ ] Merge homebrew PR
|
|
||||||
- [ ] Publish Docs Release
|
|
||||||
- [ ] Social announcements
|
- [ ] Social announcements
|
||||||
|
|||||||
16
CHANGELOG.md
16
CHANGELOG.md
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## Next release
|
## Next release
|
||||||
|
|
||||||
|
### Upcoming Breaking Changes
|
||||||
|
- Receipt compaction will be enabled by default in a future version of Besu. After this change it will not be possible to downgrade to the previous Besu version.
|
||||||
|
- --Xbonsai-limit-trie-logs-enabled is deprecated, use --bonsai-limit-trie-logs-enabled instead
|
||||||
|
- --Xbonsai-trie-logs-pruning-window-size is deprecated, use --bonsai-trie-logs-pruning-window-size instead
|
||||||
|
- `besu storage x-trie-log` subcommand is deprecated, use `besu storage trie-log` instead
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
- Remove deprecated sync modes (X_SNAP and X_CHECKPOINT). Use SNAP and CHECKPOINT instead [#7309](https://github.com/hyperledger/besu/pull/7309)
|
- Remove deprecated sync modes (X_SNAP and X_CHECKPOINT). Use SNAP and CHECKPOINT instead [#7309](https://github.com/hyperledger/besu/pull/7309)
|
||||||
- Remove PKI-backed QBFT (deprecated in 24.5.1) Other forms of QBFT remain unchanged. [#7293](https://github.com/hyperledger/besu/pull/7293)
|
- Remove PKI-backed QBFT (deprecated in 24.5.1) Other forms of QBFT remain unchanged. [#7293](https://github.com/hyperledger/besu/pull/7293)
|
||||||
@@ -10,8 +16,16 @@
|
|||||||
- `--Xsnapsync-bft-enabled` option enables experimental support for snap sync with IBFT/QBFT permissioned Bonsai-DB chains [#7140](https://github.com/hyperledger/besu/pull/7140)
|
- `--Xsnapsync-bft-enabled` option enables experimental support for snap sync with IBFT/QBFT permissioned Bonsai-DB chains [#7140](https://github.com/hyperledger/besu/pull/7140)
|
||||||
- Add support to load external profiles using `--profile` [#7265](https://github.com/hyperledger/besu/issues/7265)
|
- Add support to load external profiles using `--profile` [#7265](https://github.com/hyperledger/besu/issues/7265)
|
||||||
- `privacy-nonce-always-increments` option enables private transactions to always increment the nonce, even if the transaction is invalid [#6593](https://github.com/hyperledger/besu/pull/6593)
|
- `privacy-nonce-always-increments` option enables private transactions to always increment the nonce, even if the transaction is invalid [#6593](https://github.com/hyperledger/besu/pull/6593)
|
||||||
- Add `block-test` subcommand to the evmtool which runs blockchain reference tests [#7310](https://github.com/hyperledger/besu/pull/7310)
|
- Added `block-test` subcommand to the evmtool which runs blockchain reference tests [#7293](https://github.com/hyperledger/besu/pull/7293)
|
||||||
|
- removed PKI backed QBFT [#7310](https://github.com/hyperledger/besu/pull/7310)
|
||||||
- Implement gnark-crypto for eip-2537 [#7316](https://github.com/hyperledger/besu/pull/7316)
|
- Implement gnark-crypto for eip-2537 [#7316](https://github.com/hyperledger/besu/pull/7316)
|
||||||
|
- Improve blob size transaction selector [#7312](https://github.com/hyperledger/besu/pull/7312)
|
||||||
|
- Added EIP-7702 [#7237](https://github.com/hyperledger/besu/pull/7237)
|
||||||
|
- Implement gnark-crypto for eip-196 [#7262](https://github.com/hyperledger/besu/pull/7262)
|
||||||
|
- Add trie log pruner metrics [#7352](https://github.com/hyperledger/besu/pull/7352)
|
||||||
|
- `--Xbonsai-parallel-tx-processing-enabled` option enables executing transactions in parallel during block processing for Bonsai nodes
|
||||||
|
|
||||||
|
- Add option `--poa-discovery-retry-bootnodes` for PoA networks to always use bootnodes during peer refresh, not just on first start [#7314](https://github.com/hyperledger/besu/pull/7314)
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
- Fix `eth_call` deserialization to correctly ignore unknown fields in the transaction object. [#7323](https://github.com/hyperledger/besu/pull/7323)
|
- Fix `eth_call` deserialization to correctly ignore unknown fields in the transaction object. [#7323](https://github.com/hyperledger/besu/pull/7323)
|
||||||
|
|||||||
@@ -122,39 +122,11 @@ task acceptanceTest(type: Test) {
|
|||||||
|
|
||||||
doFirst { mkdir "${buildDir}/jvmErrorLogs" }
|
doFirst { mkdir "${buildDir}/jvmErrorLogs" }
|
||||||
}
|
}
|
||||||
task acceptanceTestMainnet(type: Test) {
|
|
||||||
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
|
|
||||||
exclude '**/bft/**'
|
|
||||||
exclude '**/clique/**'
|
|
||||||
exclude '**/permissioning/**'
|
|
||||||
exclude '**/privacy/**'
|
|
||||||
|
|
||||||
useJUnitPlatform {}
|
|
||||||
|
|
||||||
dependsOn(rootProject.installDist)
|
|
||||||
setSystemProperties(test.getSystemProperties())
|
|
||||||
systemProperty 'acctests.runBesuAsProcess', 'true'
|
|
||||||
systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security"
|
|
||||||
mustRunAfter rootProject.subprojects*.test
|
|
||||||
description = 'Runs MAINNET Besu acceptance tests (excluding permissioning, privacy and some other stable features).'
|
|
||||||
group = 'verification'
|
|
||||||
|
|
||||||
jvmArgs "-XX:ErrorFile=${buildDir}/jvmErrorLogs/java_err_pid%p.log"
|
|
||||||
|
|
||||||
testLogging {
|
|
||||||
exceptionFormat = 'full'
|
|
||||||
showStackTraces = true
|
|
||||||
showStandardStreams = Boolean.getBoolean('acctests.showStandardStreams')
|
|
||||||
showExceptions = true
|
|
||||||
showCauses = true
|
|
||||||
}
|
|
||||||
|
|
||||||
doFirst { mkdir "${buildDir}/jvmErrorLogs" }
|
|
||||||
}
|
|
||||||
|
|
||||||
task acceptanceTestNotPrivacy(type: Test) {
|
task acceptanceTestNotPrivacy(type: Test) {
|
||||||
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
|
inputs.property "integration.date", LocalTime.now() // so it runs at every invocation
|
||||||
exclude '**/privacy/**'
|
exclude '**/privacy/**'
|
||||||
|
exclude '**/permissioning/**'
|
||||||
exclude '**/bftsoak/**'
|
exclude '**/bftsoak/**'
|
||||||
|
|
||||||
useJUnitPlatform {}
|
useJUnitPlatform {}
|
||||||
@@ -164,7 +136,7 @@ task acceptanceTestNotPrivacy(type: Test) {
|
|||||||
systemProperty 'acctests.runBesuAsProcess', 'true'
|
systemProperty 'acctests.runBesuAsProcess', 'true'
|
||||||
systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security"
|
systemProperty 'java.security.properties', "${buildDir}/resources/test/acceptanceTesting.security"
|
||||||
mustRunAfter rootProject.subprojects*.test
|
mustRunAfter rootProject.subprojects*.test
|
||||||
description = 'Runs MAINNET Besu acceptance tests (excluding privacy since they run nightly, and are being refactored).'
|
description = 'Runs MAINNET Besu acceptance tests (excluding specific non-mainnet suites).'
|
||||||
group = 'verification'
|
group = 'verification'
|
||||||
|
|
||||||
jvmArgs "-XX:ErrorFile=${buildDir}/jvmErrorLogs/java_err_pid%p.log"
|
jvmArgs "-XX:ErrorFile=${buildDir}/jvmErrorLogs/java_err_pid%p.log"
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ public class LoggingTest extends AcceptanceTestBase {
|
|||||||
|
|
||||||
node.verify(net.awaitPeerCount(0));
|
node.verify(net.awaitPeerCount(0));
|
||||||
|
|
||||||
assertThat(cluster.getConsoleContents()).contains("| INFO |");
|
assertThat(cluster.getConsoleContents()).contains("INFO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,193 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.tests.acceptance.ethereum;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthTransactions;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.web3j.protocol.core.methods.response.EthBlock;
|
||||||
|
|
||||||
|
public class PragueAcceptanceTestHelper {
|
||||||
|
protected static final MediaType MEDIA_TYPE_JSON =
|
||||||
|
MediaType.parse("application/json; charset=utf-8");
|
||||||
|
|
||||||
|
private final OkHttpClient httpClient;
|
||||||
|
private final ObjectMapper mapper;
|
||||||
|
private final BesuNode besuNode;
|
||||||
|
private final EthTransactions ethTransactions;
|
||||||
|
|
||||||
|
private long blockTimeStamp = 0;
|
||||||
|
|
||||||
|
PragueAcceptanceTestHelper(final BesuNode besuNode, final EthTransactions ethTransactions) {
|
||||||
|
this.besuNode = besuNode;
|
||||||
|
this.ethTransactions = ethTransactions;
|
||||||
|
httpClient = new OkHttpClient();
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildNewBlock() throws IOException {
|
||||||
|
final EthBlock.Block block = besuNode.execute(ethTransactions.block());
|
||||||
|
|
||||||
|
blockTimeStamp += 1;
|
||||||
|
final Call buildBlockRequest =
|
||||||
|
createEngineCall(createForkChoiceRequest(block.getHash(), blockTimeStamp));
|
||||||
|
|
||||||
|
final String payloadId;
|
||||||
|
try (final Response buildBlockResponse = buildBlockRequest.execute()) {
|
||||||
|
payloadId =
|
||||||
|
mapper
|
||||||
|
.readTree(buildBlockResponse.body().string())
|
||||||
|
.get("result")
|
||||||
|
.get("payloadId")
|
||||||
|
.asText();
|
||||||
|
|
||||||
|
assertThat(payloadId).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
waitFor(500);
|
||||||
|
|
||||||
|
final Call getPayloadRequest = createEngineCall(createGetPayloadRequest(payloadId));
|
||||||
|
|
||||||
|
final ObjectNode executionPayload;
|
||||||
|
final String newBlockHash;
|
||||||
|
final String parentBeaconBlockRoot;
|
||||||
|
try (final Response getPayloadResponse = getPayloadRequest.execute()) {
|
||||||
|
assertThat(getPayloadResponse.code()).isEqualTo(200);
|
||||||
|
|
||||||
|
executionPayload =
|
||||||
|
(ObjectNode)
|
||||||
|
mapper
|
||||||
|
.readTree(getPayloadResponse.body().string())
|
||||||
|
.get("result")
|
||||||
|
.get("executionPayload");
|
||||||
|
|
||||||
|
newBlockHash = executionPayload.get("blockHash").asText();
|
||||||
|
parentBeaconBlockRoot = executionPayload.remove("parentBeaconBlockRoot").asText();
|
||||||
|
|
||||||
|
assertThat(newBlockHash).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Call newPayloadRequest =
|
||||||
|
createEngineCall(
|
||||||
|
createNewPayloadRequest(executionPayload.toString(), parentBeaconBlockRoot));
|
||||||
|
try (final Response newPayloadResponse = newPayloadRequest.execute()) {
|
||||||
|
assertThat(newPayloadResponse.code()).isEqualTo(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Call moveChainAheadRequest = createEngineCall(createForkChoiceRequest(newBlockHash));
|
||||||
|
|
||||||
|
try (final Response moveChainAheadResponse = moveChainAheadRequest.execute()) {
|
||||||
|
assertThat(moveChainAheadResponse.code()).isEqualTo(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Call createEngineCall(final String request) {
|
||||||
|
return httpClient.newCall(
|
||||||
|
new Request.Builder()
|
||||||
|
.url(besuNode.engineRpcUrl().get())
|
||||||
|
.post(RequestBody.create(request, MEDIA_TYPE_JSON))
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createForkChoiceRequest(final String blockHash) {
|
||||||
|
return createForkChoiceRequest(blockHash, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createForkChoiceRequest(final String parentBlockHash, final Long timeStamp) {
|
||||||
|
final Optional<Long> maybeTimeStamp = Optional.ofNullable(timeStamp);
|
||||||
|
|
||||||
|
String forkChoiceRequest =
|
||||||
|
"{"
|
||||||
|
+ " \"jsonrpc\": \"2.0\","
|
||||||
|
+ " \"method\": \"engine_forkchoiceUpdatedV3\","
|
||||||
|
+ " \"params\": ["
|
||||||
|
+ " {"
|
||||||
|
+ " \"headBlockHash\": \""
|
||||||
|
+ parentBlockHash
|
||||||
|
+ "\","
|
||||||
|
+ " \"safeBlockHash\": \""
|
||||||
|
+ parentBlockHash
|
||||||
|
+ "\","
|
||||||
|
+ " \"finalizedBlockHash\": \""
|
||||||
|
+ parentBlockHash
|
||||||
|
+ "\""
|
||||||
|
+ " }";
|
||||||
|
|
||||||
|
if (maybeTimeStamp.isPresent()) {
|
||||||
|
forkChoiceRequest +=
|
||||||
|
" ,{"
|
||||||
|
+ " \"timestamp\": \""
|
||||||
|
+ Long.toHexString(maybeTimeStamp.get())
|
||||||
|
+ "\","
|
||||||
|
+ " \"prevRandao\": \"0x0000000000000000000000000000000000000000000000000000000000000000\","
|
||||||
|
+ " \"suggestedFeeRecipient\": \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\","
|
||||||
|
+ " \"withdrawals\": [],"
|
||||||
|
+ " \"parentBeaconBlockRoot\": \"0x0000000000000000000000000000000000000000000000000000000000000000\""
|
||||||
|
+ " }";
|
||||||
|
}
|
||||||
|
|
||||||
|
forkChoiceRequest += " ]," + " \"id\": 67" + "}";
|
||||||
|
|
||||||
|
return forkChoiceRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createGetPayloadRequest(final String payloadId) {
|
||||||
|
return "{"
|
||||||
|
+ " \"jsonrpc\": \"2.0\","
|
||||||
|
+ " \"method\": \"engine_getPayloadV4\","
|
||||||
|
+ " \"params\": [\""
|
||||||
|
+ payloadId
|
||||||
|
+ "\"],"
|
||||||
|
+ " \"id\": 67"
|
||||||
|
+ "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createNewPayloadRequest(
|
||||||
|
final String executionPayload, final String parentBeaconBlockRoot) {
|
||||||
|
return "{"
|
||||||
|
+ " \"jsonrpc\": \"2.0\","
|
||||||
|
+ " \"method\": \"engine_newPayloadV4\","
|
||||||
|
+ " \"params\": ["
|
||||||
|
+ executionPayload
|
||||||
|
+ ",[],"
|
||||||
|
+ "\""
|
||||||
|
+ parentBeaconBlockRoot
|
||||||
|
+ "\""
|
||||||
|
+ "],"
|
||||||
|
+ " \"id\": 67"
|
||||||
|
+ "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void waitFor(final long durationMilliSeconds) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(durationMilliSeconds);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.tests.acceptance.ethereum;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.crypto.SECP256K1;
|
||||||
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
import org.hyperledger.besu.datatypes.TransactionType;
|
||||||
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
|
import org.hyperledger.besu.ethereum.core.SetCodeAuthorization;
|
||||||
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase;
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.account.Account;
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.blockchain.Amount;
|
||||||
|
import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
import org.apache.tuweni.bytes.Bytes32;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.web3j.protocol.core.methods.response.TransactionReceipt;
|
||||||
|
|
||||||
|
public class SetCodeTransactionAcceptanceTest extends AcceptanceTestBase {
|
||||||
|
private static final String GENESIS_FILE = "/dev/dev_prague.json";
|
||||||
|
private static final SECP256K1 secp256k1 = new SECP256K1();
|
||||||
|
|
||||||
|
public static final Address SEND_ALL_ETH_CONTRACT_ADDRESS =
|
||||||
|
Address.fromHexStringStrict("0000000000000000000000000000000000009999");
|
||||||
|
|
||||||
|
private final Account authorizer =
|
||||||
|
accounts.createAccount(
|
||||||
|
Address.fromHexStringStrict("8da48afC965480220a3dB9244771bd3afcB5d895"));
|
||||||
|
public static final Bytes AUTHORIZER_PRIVATE_KEY =
|
||||||
|
Bytes.fromHexString("11f2e7b6a734ab03fa682450e0d4681d18a944f8b83c99bf7b9b4de6c0f35ea1");
|
||||||
|
|
||||||
|
private final Account transactionSponsor =
|
||||||
|
accounts.createAccount(
|
||||||
|
Address.fromHexStringStrict("a05b21E5186Ce93d2a226722b85D6e550Ac7D6E3"));
|
||||||
|
public static final Bytes TRANSACTION_SPONSOR_PRIVATE_KEY =
|
||||||
|
Bytes.fromHexString("3a4ff6d22d7502ef2452368165422861c01a0f72f851793b372b87888dc3c453");
|
||||||
|
|
||||||
|
private BesuNode besuNode;
|
||||||
|
private PragueAcceptanceTestHelper testHelper;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() throws IOException {
|
||||||
|
besuNode = besu.createExecutionEngineGenesisNode("besuNode", GENESIS_FILE);
|
||||||
|
cluster.start(besuNode);
|
||||||
|
|
||||||
|
testHelper = new PragueAcceptanceTestHelper(besuNode, ethTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* At the beginning of the test both the authorizer and the transaction sponsor have a balance of
|
||||||
|
* 90000 ETH. The authorizer creates an authorization for a contract that send all its ETH to any
|
||||||
|
* given address. The transaction sponsor created a 7702 transaction with it and sends all the ETH
|
||||||
|
* from the authorizer to itself. The authorizer balance should be 0 and the transaction sponsor
|
||||||
|
* balance should be 180000 ETH minus the transaction costs.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldTransferAllEthOfAuthorizerToSponsor() throws IOException {
|
||||||
|
|
||||||
|
// 7702 transaction
|
||||||
|
final org.hyperledger.besu.datatypes.SetCodeAuthorization authorization =
|
||||||
|
SetCodeAuthorization.builder()
|
||||||
|
.chainId(BigInteger.valueOf(20211))
|
||||||
|
.address(SEND_ALL_ETH_CONTRACT_ADDRESS)
|
||||||
|
.signAndBuild(
|
||||||
|
secp256k1.createKeyPair(
|
||||||
|
secp256k1.createPrivateKey(AUTHORIZER_PRIVATE_KEY.toUnsignedBigInteger())));
|
||||||
|
|
||||||
|
final Transaction tx =
|
||||||
|
Transaction.builder()
|
||||||
|
.type(TransactionType.SET_CODE)
|
||||||
|
.chainId(BigInteger.valueOf(20211))
|
||||||
|
.nonce(0)
|
||||||
|
.maxPriorityFeePerGas(Wei.of(1000000000))
|
||||||
|
.maxFeePerGas(Wei.fromHexString("0x02540BE400"))
|
||||||
|
.gasLimit(1000000)
|
||||||
|
.to(Address.fromHexStringStrict(authorizer.getAddress()))
|
||||||
|
.value(Wei.ZERO)
|
||||||
|
.payload(Bytes32.leftPad(Bytes.fromHexString(transactionSponsor.getAddress())))
|
||||||
|
.accessList(List.of())
|
||||||
|
.setCodeTransactionPayloads(List.of(authorization))
|
||||||
|
.signAndBuild(
|
||||||
|
secp256k1.createKeyPair(
|
||||||
|
secp256k1.createPrivateKey(
|
||||||
|
TRANSACTION_SPONSOR_PRIVATE_KEY.toUnsignedBigInteger())));
|
||||||
|
|
||||||
|
final String txHash =
|
||||||
|
besuNode.execute(ethTransactions.sendRawTransaction(tx.encoded().toHexString()));
|
||||||
|
testHelper.buildNewBlock();
|
||||||
|
|
||||||
|
Optional<TransactionReceipt> maybeTransactionReceipt =
|
||||||
|
besuNode.execute(ethTransactions.getTransactionReceipt(txHash));
|
||||||
|
assertThat(maybeTransactionReceipt).isPresent();
|
||||||
|
|
||||||
|
cluster.verify(authorizer.balanceEquals(0));
|
||||||
|
|
||||||
|
final String gasPriceWithout0x =
|
||||||
|
maybeTransactionReceipt.get().getEffectiveGasPrice().substring(2);
|
||||||
|
final BigInteger txCost =
|
||||||
|
maybeTransactionReceipt.get().getGasUsed().multiply(new BigInteger(gasPriceWithout0x, 16));
|
||||||
|
BigInteger expectedSponsorBalance = new BigInteger("180000000000000000000000").subtract(txCost);
|
||||||
|
cluster.verify(transactionSponsor.balanceEquals(Amount.wei(expectedSponsorBalance)));
|
||||||
|
}
|
||||||
|
}
|
||||||
112
acceptance-tests/tests/src/test/resources/dev/dev_prague.json
Normal file
112
acceptance-tests/tests/src/test/resources/dev/dev_prague.json
Normal file
File diff suppressed because one or more lines are too long
@@ -259,7 +259,7 @@ public class Runner implements AutoCloseable {
|
|||||||
try {
|
try {
|
||||||
shutdown.await();
|
shutdown.await();
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
LOG.debug("Interrupted while waiting for service " + serviceName + " to stop", e);
|
LOG.debug("Interrupted while waiting for service {} to stop {}", serviceName, e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ public class RunnerBuilder {
|
|||||||
private boolean legacyForkIdEnabled;
|
private boolean legacyForkIdEnabled;
|
||||||
private Optional<EnodeDnsConfiguration> enodeDnsConfiguration;
|
private Optional<EnodeDnsConfiguration> enodeDnsConfiguration;
|
||||||
private List<SubnetInfo> allowedSubnets = new ArrayList<>();
|
private List<SubnetInfo> allowedSubnets = new ArrayList<>();
|
||||||
|
private boolean poaDiscoveryRetryBootnodes = true;
|
||||||
|
|
||||||
/** Instantiates a new Runner builder. */
|
/** Instantiates a new Runner builder. */
|
||||||
public RunnerBuilder() {}
|
public RunnerBuilder() {}
|
||||||
@@ -617,6 +618,17 @@ public class RunnerBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate if peer table refreshes should always query bootnodes
|
||||||
|
*
|
||||||
|
* @param poaDiscoveryRetryBootnodes whether to always query bootnodes
|
||||||
|
* @return the runner builder
|
||||||
|
*/
|
||||||
|
public RunnerBuilder poaDiscoveryRetryBootnodes(final boolean poaDiscoveryRetryBootnodes) {
|
||||||
|
this.poaDiscoveryRetryBootnodes = poaDiscoveryRetryBootnodes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Runner instance.
|
* Build Runner instance.
|
||||||
*
|
*
|
||||||
@@ -639,6 +651,8 @@ public class RunnerBuilder {
|
|||||||
bootstrap = ethNetworkConfig.bootNodes();
|
bootstrap = ethNetworkConfig.bootNodes();
|
||||||
}
|
}
|
||||||
discoveryConfiguration.setBootnodes(bootstrap);
|
discoveryConfiguration.setBootnodes(bootstrap);
|
||||||
|
discoveryConfiguration.setIncludeBootnodesOnPeerRefresh(
|
||||||
|
besuController.getGenesisConfigOptions().isPoa() && poaDiscoveryRetryBootnodes);
|
||||||
LOG.info("Resolved {} bootnodes.", bootstrap.size());
|
LOG.info("Resolved {} bootnodes.", bootstrap.size());
|
||||||
LOG.debug("Bootnodes = {}", bootstrap);
|
LOG.debug("Bootnodes = {}", bootstrap);
|
||||||
discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.dnsDiscoveryUrl());
|
discoveryConfiguration.setDnsDiscoveryURL(ethNetworkConfig.dnsDiscoveryUrl());
|
||||||
@@ -708,6 +722,7 @@ public class RunnerBuilder {
|
|||||||
final boolean fallbackEnabled = natMethod == NatMethod.AUTO || natMethodFallbackEnabled;
|
final boolean fallbackEnabled = natMethod == NatMethod.AUTO || natMethodFallbackEnabled;
|
||||||
final NatService natService = new NatService(buildNatManager(natMethod), fallbackEnabled);
|
final NatService natService = new NatService(buildNatManager(natMethod), fallbackEnabled);
|
||||||
final NetworkBuilder inactiveNetwork = caps -> new NoopP2PNetwork();
|
final NetworkBuilder inactiveNetwork = caps -> new NoopP2PNetwork();
|
||||||
|
|
||||||
final NetworkBuilder activeNetwork =
|
final NetworkBuilder activeNetwork =
|
||||||
caps -> {
|
caps -> {
|
||||||
return DefaultP2PNetwork.builder()
|
return DefaultP2PNetwork.builder()
|
||||||
|
|||||||
@@ -516,6 +516,19 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Boolean option to set that in a PoA network the bootnodes should always be queried during
|
||||||
|
// peer table refresh. If this flag is disabled bootnodes are only sent FINDN requests on first
|
||||||
|
// startup, meaning that an offline bootnode or network outage at the client can prevent it
|
||||||
|
// discovering any peers without a restart.
|
||||||
|
@Option(
|
||||||
|
names = {"--poa-discovery-retry-bootnodes"},
|
||||||
|
description =
|
||||||
|
"Always use of bootnodes for discovery in PoA networks. Disabling this reverts "
|
||||||
|
+ " to the same behaviour as non-PoA networks, where neighbours are only discovered from bootnodes on first startup."
|
||||||
|
+ "(default: ${DEFAULT-VALUE})",
|
||||||
|
arity = "1")
|
||||||
|
private final Boolean poaDiscoveryRetryBootnodes = true;
|
||||||
|
|
||||||
private Collection<Bytes> bannedNodeIds = new ArrayList<>();
|
private Collection<Bytes> bannedNodeIds = new ArrayList<>();
|
||||||
|
|
||||||
// Used to discover the default IP of the client.
|
// Used to discover the default IP of the client.
|
||||||
@@ -1916,6 +1929,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
.privacyParameters(privacyParameters())
|
.privacyParameters(privacyParameters())
|
||||||
.clock(Clock.systemUTC())
|
.clock(Clock.systemUTC())
|
||||||
.isRevertReasonEnabled(isRevertReasonEnabled)
|
.isRevertReasonEnabled(isRevertReasonEnabled)
|
||||||
|
.isParallelTxProcessingEnabled(
|
||||||
|
dataStorageConfiguration.getUnstable().isParallelTxProcessingEnabled())
|
||||||
.storageProvider(storageProvider)
|
.storageProvider(storageProvider)
|
||||||
.gasLimitCalculator(
|
.gasLimitCalculator(
|
||||||
miningParametersSupplier.get().getTargetGasLimit().isPresent()
|
miningParametersSupplier.get().getTargetGasLimit().isPresent()
|
||||||
@@ -2339,6 +2354,7 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
|
|||||||
.rpcEndpointService(rpcEndpointServiceImpl)
|
.rpcEndpointService(rpcEndpointServiceImpl)
|
||||||
.enodeDnsConfiguration(getEnodeDnsConfiguration())
|
.enodeDnsConfiguration(getEnodeDnsConfiguration())
|
||||||
.allowedSubnets(p2PDiscoveryOptionGroup.allowedSubnets)
|
.allowedSubnets(p2PDiscoveryOptionGroup.allowedSubnets)
|
||||||
|
.poaDiscoveryRetryBootnodes(p2PDiscoveryOptionGroup.poaDiscoveryRetryBootnodes)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
addShutdownHook(runner);
|
addShutdownHook(runner);
|
||||||
|
|||||||
@@ -122,6 +122,14 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
"Enables code storage using code hash instead of by account hash. (default: ${DEFAULT-VALUE})")
|
"Enables code storage using code hash instead of by account hash. (default: ${DEFAULT-VALUE})")
|
||||||
private boolean bonsaiCodeUsingCodeHashEnabled = DEFAULT_BONSAI_CODE_USING_CODE_HASH_ENABLED;
|
private boolean bonsaiCodeUsingCodeHashEnabled = DEFAULT_BONSAI_CODE_USING_CODE_HASH_ENABLED;
|
||||||
|
|
||||||
|
@CommandLine.Option(
|
||||||
|
hidden = true,
|
||||||
|
names = {"--Xbonsai-parallel-tx-processing-enabled"},
|
||||||
|
arity = "1",
|
||||||
|
description =
|
||||||
|
"Enables parallelization of transactions to optimize processing speed by concurrently loading and executing necessary data in advance. (default: ${DEFAULT-VALUE})")
|
||||||
|
private Boolean isParallelTxProcessingEnabled = false;
|
||||||
|
|
||||||
/** Default Constructor. */
|
/** Default Constructor. */
|
||||||
Unstable() {}
|
Unstable() {}
|
||||||
}
|
}
|
||||||
@@ -142,40 +150,48 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
* @param syncMode the sync mode
|
* @param syncMode the sync mode
|
||||||
*/
|
*/
|
||||||
public void validate(final CommandLine commandLine, final SyncMode syncMode) {
|
public void validate(final CommandLine commandLine, final SyncMode syncMode) {
|
||||||
if (DataStorageFormat.BONSAI == dataStorageFormat && bonsaiLimitTrieLogsEnabled) {
|
if (DataStorageFormat.BONSAI == dataStorageFormat) {
|
||||||
if (SyncMode.FULL == syncMode) {
|
if (bonsaiLimitTrieLogsEnabled) {
|
||||||
throw new CommandLine.ParameterException(
|
if (SyncMode.FULL == syncMode) {
|
||||||
commandLine,
|
throw new CommandLine.ParameterException(
|
||||||
String.format(
|
commandLine,
|
||||||
"Cannot enable %s with sync-mode %s. You must set %s or use a different sync-mode",
|
String.format(
|
||||||
BONSAI_LIMIT_TRIE_LOGS_ENABLED,
|
"Cannot enable %s with sync-mode %s. You must set %s or use a different sync-mode",
|
||||||
SyncMode.FULL,
|
BONSAI_LIMIT_TRIE_LOGS_ENABLED,
|
||||||
BONSAI_LIMIT_TRIE_LOGS_ENABLED + "=false"));
|
SyncMode.FULL,
|
||||||
|
BONSAI_LIMIT_TRIE_LOGS_ENABLED + "=false"));
|
||||||
|
}
|
||||||
|
if (bonsaiMaxLayersToLoad < MINIMUM_BONSAI_TRIE_LOG_RETENTION_LIMIT) {
|
||||||
|
throw new CommandLine.ParameterException(
|
||||||
|
commandLine,
|
||||||
|
String.format(
|
||||||
|
BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD + " minimum value is %d",
|
||||||
|
MINIMUM_BONSAI_TRIE_LOG_RETENTION_LIMIT));
|
||||||
|
}
|
||||||
|
if (bonsaiTrieLogPruningWindowSize <= 0) {
|
||||||
|
throw new CommandLine.ParameterException(
|
||||||
|
commandLine,
|
||||||
|
String.format(
|
||||||
|
BONSAI_TRIE_LOG_PRUNING_WINDOW_SIZE + "=%d must be greater than 0",
|
||||||
|
bonsaiTrieLogPruningWindowSize));
|
||||||
|
}
|
||||||
|
if (bonsaiTrieLogPruningWindowSize <= bonsaiMaxLayersToLoad) {
|
||||||
|
throw new CommandLine.ParameterException(
|
||||||
|
commandLine,
|
||||||
|
String.format(
|
||||||
|
BONSAI_TRIE_LOG_PRUNING_WINDOW_SIZE
|
||||||
|
+ "=%d must be greater than "
|
||||||
|
+ BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD
|
||||||
|
+ "=%d",
|
||||||
|
bonsaiTrieLogPruningWindowSize,
|
||||||
|
bonsaiMaxLayersToLoad));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bonsaiMaxLayersToLoad < MINIMUM_BONSAI_TRIE_LOG_RETENTION_LIMIT) {
|
} else {
|
||||||
|
if (unstableOptions.isParallelTxProcessingEnabled) {
|
||||||
throw new CommandLine.ParameterException(
|
throw new CommandLine.ParameterException(
|
||||||
commandLine,
|
commandLine,
|
||||||
String.format(
|
"Transaction parallelization is not supported unless operating in a 'diffbased' mode, such as Bonsai.");
|
||||||
BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD + " minimum value is %d",
|
|
||||||
MINIMUM_BONSAI_TRIE_LOG_RETENTION_LIMIT));
|
|
||||||
}
|
|
||||||
if (bonsaiTrieLogPruningWindowSize <= 0) {
|
|
||||||
throw new CommandLine.ParameterException(
|
|
||||||
commandLine,
|
|
||||||
String.format(
|
|
||||||
BONSAI_TRIE_LOG_PRUNING_WINDOW_SIZE + "=%d must be greater than 0",
|
|
||||||
bonsaiTrieLogPruningWindowSize));
|
|
||||||
}
|
|
||||||
if (bonsaiTrieLogPruningWindowSize <= bonsaiMaxLayersToLoad) {
|
|
||||||
throw new CommandLine.ParameterException(
|
|
||||||
commandLine,
|
|
||||||
String.format(
|
|
||||||
BONSAI_TRIE_LOG_PRUNING_WINDOW_SIZE
|
|
||||||
+ "=%d must be greater than "
|
|
||||||
+ BONSAI_STORAGE_FORMAT_MAX_LAYERS_TO_LOAD
|
|
||||||
+ "=%d",
|
|
||||||
bonsaiTrieLogPruningWindowSize,
|
|
||||||
bonsaiMaxLayersToLoad));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,6 +214,8 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
domainObject.getUnstable().getBonsaiFullFlatDbEnabled();
|
domainObject.getUnstable().getBonsaiFullFlatDbEnabled();
|
||||||
dataStorageOptions.unstableOptions.bonsaiCodeUsingCodeHashEnabled =
|
dataStorageOptions.unstableOptions.bonsaiCodeUsingCodeHashEnabled =
|
||||||
domainObject.getUnstable().getBonsaiCodeStoredByCodeHashEnabled();
|
domainObject.getUnstable().getBonsaiCodeStoredByCodeHashEnabled();
|
||||||
|
dataStorageOptions.unstableOptions.isParallelTxProcessingEnabled =
|
||||||
|
domainObject.getUnstable().isParallelTxProcessingEnabled();
|
||||||
|
|
||||||
return dataStorageOptions;
|
return dataStorageOptions;
|
||||||
}
|
}
|
||||||
@@ -214,6 +232,7 @@ public class DataStorageOptions implements CLIOptions<DataStorageConfiguration>
|
|||||||
ImmutableDataStorageConfiguration.Unstable.builder()
|
ImmutableDataStorageConfiguration.Unstable.builder()
|
||||||
.bonsaiFullFlatDbEnabled(unstableOptions.bonsaiFullFlatDbEnabled)
|
.bonsaiFullFlatDbEnabled(unstableOptions.bonsaiFullFlatDbEnabled)
|
||||||
.bonsaiCodeStoredByCodeHashEnabled(unstableOptions.bonsaiCodeUsingCodeHashEnabled)
|
.bonsaiCodeStoredByCodeHashEnabled(unstableOptions.bonsaiCodeUsingCodeHashEnabled)
|
||||||
|
.isParallelTxProcessingEnabled(unstableOptions.isParallelTxProcessingEnabled)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,6 +203,9 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
|
|
||||||
private int numberOfBlocksToCache = 0;
|
private int numberOfBlocksToCache = 0;
|
||||||
|
|
||||||
|
/** whether parallel transaction processing is enabled or not */
|
||||||
|
protected boolean isParallelTxProcessingEnabled;
|
||||||
|
|
||||||
/** Instantiates a new Besu controller builder. */
|
/** Instantiates a new Besu controller builder. */
|
||||||
protected BesuControllerBuilder() {}
|
protected BesuControllerBuilder() {}
|
||||||
|
|
||||||
@@ -512,6 +515,20 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether parallel transaction processing is enabled. When parallel transaction processing
|
||||||
|
* is enabled, transactions within a block can be processed in parallel and potentially improving
|
||||||
|
* performance
|
||||||
|
*
|
||||||
|
* @param isParallelTxProcessingEnabled true to enable parallel transaction
|
||||||
|
* @return the besu controller
|
||||||
|
*/
|
||||||
|
public BesuControllerBuilder isParallelTxProcessingEnabled(
|
||||||
|
final boolean isParallelTxProcessingEnabled) {
|
||||||
|
this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build besu controller.
|
* Build besu controller.
|
||||||
*
|
*
|
||||||
@@ -793,7 +810,8 @@ public abstract class BesuControllerBuilder implements MiningParameterOverrides
|
|||||||
scheduler::executeServiceTask,
|
scheduler::executeServiceTask,
|
||||||
dataStorageConfiguration.getBonsaiMaxLayersToLoad(),
|
dataStorageConfiguration.getBonsaiMaxLayersToLoad(),
|
||||||
dataStorageConfiguration.getBonsaiTrieLogPruningWindowSize(),
|
dataStorageConfiguration.getBonsaiTrieLogPruningWindowSize(),
|
||||||
isProofOfStake);
|
isProofOfStake,
|
||||||
|
metricsSystem);
|
||||||
trieLogPruner.initialize();
|
trieLogPruner.initialize();
|
||||||
|
|
||||||
return trieLogPruner;
|
return trieLogPruner;
|
||||||
|
|||||||
@@ -136,7 +136,9 @@ public class CliqueBesuControllerBuilder extends BesuControllerBuilder {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -358,6 +358,15 @@ public class ConsensusScheduleBesuControllerBuilder extends BesuControllerBuilde
|
|||||||
return super.isRevertReasonEnabled(isRevertReasonEnabled);
|
return super.isRevertReasonEnabled(isRevertReasonEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BesuControllerBuilder isParallelTxProcessingEnabled(
|
||||||
|
final boolean isParallelTxProcessingEnabled) {
|
||||||
|
besuControllerBuilderSchedule
|
||||||
|
.values()
|
||||||
|
.forEach(b -> b.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled));
|
||||||
|
return super.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
|
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
|
||||||
besuControllerBuilderSchedule.values().forEach(b -> b.gasLimitCalculator(gasLimitCalculator));
|
besuControllerBuilderSchedule.values().forEach(b -> b.gasLimitCalculator(gasLimitCalculator));
|
||||||
|
|||||||
@@ -291,7 +291,9 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
|
|||||||
bftExtraDataCodec().get(),
|
bftExtraDataCodec().get(),
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -99,7 +99,9 @@ public class MainnetBesuControllerBuilder extends BesuControllerBuilder {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -177,7 +177,9 @@ public class MergeBesuControllerBuilder extends BesuControllerBuilder {
|
|||||||
privacyParameters,
|
privacyParameters,
|
||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState;
|
|||||||
import org.hyperledger.besu.consensus.common.bft.statemachine.FutureMessageBuffer;
|
import org.hyperledger.besu.consensus.common.bft.statemachine.FutureMessageBuffer;
|
||||||
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
|
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
|
||||||
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
|
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
|
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftGossip;
|
import org.hyperledger.besu.consensus.qbft.QbftGossip;
|
||||||
@@ -330,7 +329,9 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
|
|||||||
bftExtraDataCodec().get(),
|
bftExtraDataCodec().get(),
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -388,7 +389,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
|
|||||||
new ForkingValidatorProvider(
|
new ForkingValidatorProvider(
|
||||||
blockchain, qbftForksSchedule, blockValidatorProvider, transactionValidatorProvider);
|
blockchain, qbftForksSchedule, blockValidatorProvider, transactionValidatorProvider);
|
||||||
|
|
||||||
return new QbftContext(validatorProvider, epochManager, bftBlockInterface().get());
|
return new BftContext(validatorProvider, epochManager, bftBlockInterface().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BftValidatorOverrides convertBftForks(final List<QbftFork> bftForks) {
|
private BftValidatorOverrides convertBftForks(final List<QbftFork> bftForks) {
|
||||||
|
|||||||
@@ -374,6 +374,13 @@ public class TransitionBesuControllerBuilder extends BesuControllerBuilder {
|
|||||||
return propagateConfig(z -> z.isRevertReasonEnabled(isRevertReasonEnabled));
|
return propagateConfig(z -> z.isRevertReasonEnabled(isRevertReasonEnabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BesuControllerBuilder isParallelTxProcessingEnabled(
|
||||||
|
final boolean isParallelTxProcessingEnabled) {
|
||||||
|
super.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled);
|
||||||
|
return propagateConfig(z -> z.isParallelTxProcessingEnabled(isParallelTxProcessingEnabled));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
|
public BesuControllerBuilder gasLimitCalculator(final GasLimitCalculator gasLimitCalculator) {
|
||||||
super.gasLimitCalculator(gasLimitCalculator);
|
super.gasLimitCalculator(gasLimitCalculator);
|
||||||
|
|||||||
@@ -379,22 +379,20 @@ public class BesuPluginContextImpl implements BesuContext, PluginVersionsProvide
|
|||||||
plugin ->
|
plugin ->
|
||||||
summary.add(
|
summary.add(
|
||||||
String.format(
|
String.format(
|
||||||
" - %s (Version: %s)",
|
" - %s (%s)", plugin.getClass().getSimpleName(), plugin.getVersion())));
|
||||||
plugin.getClass().getSimpleName(), plugin.getVersion())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify and log detected but not registered (skipped) plugins
|
// Identify and log detected but not registered (skipped) plugins
|
||||||
List<String> skippedPlugins =
|
List<BesuPlugin> skippedPlugins =
|
||||||
detectedPlugins.stream()
|
detectedPlugins.stream().filter(plugin -> !registeredPlugins.contains(plugin)).toList();
|
||||||
.filter(plugin -> !registeredPlugins.contains(plugin))
|
|
||||||
.map(plugin -> plugin.getClass().getSimpleName())
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (!skippedPlugins.isEmpty()) {
|
if (!skippedPlugins.isEmpty()) {
|
||||||
summary.add("Skipped Plugins:");
|
summary.add("Detected but not registered:");
|
||||||
skippedPlugins.forEach(
|
skippedPlugins.forEach(
|
||||||
pluginName ->
|
plugin ->
|
||||||
summary.add(String.format(" - %s (Detected but not registered)", pluginName)));
|
summary.add(
|
||||||
|
String.format(
|
||||||
|
" - %s (%s)", plugin.getClass().getSimpleName(), plugin.getVersion())));
|
||||||
}
|
}
|
||||||
summary.add(
|
summary.add(
|
||||||
String.format(
|
String.format(
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.hyperledger.besu.ethereum.forkid.ForkId;
|
|||||||
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
|
import org.hyperledger.besu.ethereum.forkid.ForkIdManager;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.DefaultProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -177,12 +178,21 @@ public class ForkIdsNetworkConfigTest {
|
|||||||
new MilestoneStreamingProtocolSchedule(
|
new MilestoneStreamingProtocolSchedule(
|
||||||
(DefaultProtocolSchedule)
|
(DefaultProtocolSchedule)
|
||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
configOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()));
|
configOptions,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()));
|
||||||
MilestoneStreamingProtocolSchedule postMergeProtocolSchedule =
|
MilestoneStreamingProtocolSchedule postMergeProtocolSchedule =
|
||||||
new MilestoneStreamingProtocolSchedule(
|
new MilestoneStreamingProtocolSchedule(
|
||||||
(DefaultProtocolSchedule)
|
(DefaultProtocolSchedule)
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
configOptions, false, MiningParameters.MINING_DISABLED, new BadBlockManager()));
|
configOptions,
|
||||||
|
false,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()));
|
||||||
final MilestoneStreamingTransitionProtocolSchedule schedule =
|
final MilestoneStreamingTransitionProtocolSchedule schedule =
|
||||||
new MilestoneStreamingTransitionProtocolSchedule(
|
new MilestoneStreamingTransitionProtocolSchedule(
|
||||||
preMergeProtocolSchedule, postMergeProtocolSchedule);
|
preMergeProtocolSchedule, postMergeProtocolSchedule);
|
||||||
|
|||||||
@@ -804,6 +804,28 @@ public class BesuCommandTest extends CommandTestAbstract {
|
|||||||
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void poaDiscoveryRetryBootnodesValueTrueMustBeUsed() {
|
||||||
|
parseCommand("--poa-discovery-retry-bootnodes", "true");
|
||||||
|
|
||||||
|
verify(mockRunnerBuilder).poaDiscoveryRetryBootnodes(eq(true));
|
||||||
|
verify(mockRunnerBuilder).build();
|
||||||
|
|
||||||
|
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
||||||
|
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void poaDiscoveryRetryBootnodesValueFalseMustBeUsed() {
|
||||||
|
parseCommand("--poa-discovery-retry-bootnodes", "false");
|
||||||
|
|
||||||
|
verify(mockRunnerBuilder).poaDiscoveryRetryBootnodes(eq(false));
|
||||||
|
verify(mockRunnerBuilder).build();
|
||||||
|
|
||||||
|
assertThat(commandOutput.toString(UTF_8)).isEmpty();
|
||||||
|
assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void callingWithBootnodesOptionButNoValueMustPassEmptyBootnodeList() {
|
public void callingWithBootnodesOptionButNoValueMustPassEmptyBootnodeList() {
|
||||||
parseCommand("--bootnodes");
|
parseCommand("--bootnodes");
|
||||||
|
|||||||
@@ -277,6 +277,8 @@ public abstract class CommandTestAbstract {
|
|||||||
when(mockControllerBuilder.privacyParameters(any())).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.privacyParameters(any())).thenReturn(mockControllerBuilder);
|
||||||
when(mockControllerBuilder.clock(any())).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.clock(any())).thenReturn(mockControllerBuilder);
|
||||||
when(mockControllerBuilder.isRevertReasonEnabled(false)).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.isRevertReasonEnabled(false)).thenReturn(mockControllerBuilder);
|
||||||
|
when(mockControllerBuilder.isParallelTxProcessingEnabled(false))
|
||||||
|
.thenReturn(mockControllerBuilder);
|
||||||
when(mockControllerBuilder.storageProvider(any())).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.storageProvider(any())).thenReturn(mockControllerBuilder);
|
||||||
when(mockControllerBuilder.gasLimitCalculator(any())).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.gasLimitCalculator(any())).thenReturn(mockControllerBuilder);
|
||||||
when(mockControllerBuilder.requiredBlocks(any())).thenReturn(mockControllerBuilder);
|
when(mockControllerBuilder.requiredBlocks(any())).thenReturn(mockControllerBuilder);
|
||||||
@@ -350,6 +352,7 @@ public abstract class CommandTestAbstract {
|
|||||||
when(mockRunnerBuilder.apiConfiguration(any())).thenReturn(mockRunnerBuilder);
|
when(mockRunnerBuilder.apiConfiguration(any())).thenReturn(mockRunnerBuilder);
|
||||||
when(mockRunnerBuilder.enodeDnsConfiguration(any())).thenReturn(mockRunnerBuilder);
|
when(mockRunnerBuilder.enodeDnsConfiguration(any())).thenReturn(mockRunnerBuilder);
|
||||||
when(mockRunnerBuilder.allowedSubnets(any())).thenReturn(mockRunnerBuilder);
|
when(mockRunnerBuilder.allowedSubnets(any())).thenReturn(mockRunnerBuilder);
|
||||||
|
when(mockRunnerBuilder.poaDiscoveryRetryBootnodes(anyBoolean())).thenReturn(mockRunnerBuilder);
|
||||||
when(mockRunnerBuilder.build()).thenReturn(mockRunner);
|
when(mockRunnerBuilder.build()).thenReturn(mockRunner);
|
||||||
|
|
||||||
final SignatureAlgorithm signatureAlgorithm = SignatureAlgorithmFactory.getInstance();
|
final SignatureAlgorithm signatureAlgorithm = SignatureAlgorithmFactory.getInstance();
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ public class TransactionPoolOptionsTest
|
|||||||
@Test
|
@Test
|
||||||
public void maxPrioritizedTxsPerTypeWrongTxType() {
|
public void maxPrioritizedTxsPerTypeWrongTxType() {
|
||||||
internalTestFailure(
|
internalTestFailure(
|
||||||
"Invalid value for option '--tx-pool-max-prioritized-by-type' (MAP<TYPE,INTEGER>): expected one of [FRONTIER, ACCESS_LIST, EIP1559, BLOB] (case-insensitive) but was 'WRONG_TYPE'",
|
"Invalid value for option '--tx-pool-max-prioritized-by-type' (MAP<TYPE,INTEGER>): expected one of [FRONTIER, ACCESS_LIST, EIP1559, BLOB, SET_CODE] (case-insensitive) but was 'WRONG_TYPE'",
|
||||||
"--tx-pool-max-prioritized-by-type",
|
"--tx-pool-max-prioritized-by-type",
|
||||||
"WRONG_TYPE=1");
|
"WRONG_TYPE=1");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ data-path="/opt/besu" # Path
|
|||||||
|
|
||||||
# network
|
# network
|
||||||
discovery-enabled=false
|
discovery-enabled=false
|
||||||
|
poa-discovery-retry-bootnodes=true
|
||||||
bootnodes=[
|
bootnodes=[
|
||||||
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
||||||
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ nat-method="NONE"
|
|||||||
Xnat-kube-service-name="besu"
|
Xnat-kube-service-name="besu"
|
||||||
Xnat-method-fallback-enabled=true
|
Xnat-method-fallback-enabled=true
|
||||||
discovery-enabled=false
|
discovery-enabled=false
|
||||||
|
poa-discovery-retry-bootnodes=true
|
||||||
bootnodes=[
|
bootnodes=[
|
||||||
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
||||||
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
"enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@192.168.0.1:4567",
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -64,6 +65,9 @@ public class CliqueProtocolSchedule {
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule create(
|
public static ProtocolSchedule create(
|
||||||
@@ -74,7 +78,9 @@ public class CliqueProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
|
final CliqueConfigOptions cliqueConfig = config.getCliqueConfigOptions();
|
||||||
|
|
||||||
@@ -110,7 +116,9 @@ public class CliqueProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager)
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +132,9 @@ public class CliqueProtocolSchedule {
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -134,7 +145,9 @@ public class CliqueProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
forksSchedule,
|
forksSchedule,
|
||||||
@@ -143,7 +156,9 @@ public class CliqueProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ProtocolSpecBuilder applyCliqueSpecificModifications(
|
private static ProtocolSpecBuilder applyCliqueSpecificModifications(
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -68,7 +69,9 @@ public class CliqueProtocolScheduleTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
|
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
|
||||||
final ProtocolSpec tangerineWhistleSpec = protocolSchedule.getByBlockHeader(blockHeader(2));
|
final ProtocolSpec tangerineWhistleSpec = protocolSchedule.getByBlockHeader(blockHeader(2));
|
||||||
@@ -92,7 +95,9 @@ public class CliqueProtocolScheduleTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.getByBlockHeader(blockHeader(0));
|
.getByBlockHeader(blockHeader(0));
|
||||||
|
|
||||||
assertThat(homestead.getName()).isEqualTo("Frontier");
|
assertThat(homestead.getName()).isEqualTo("Frontier");
|
||||||
@@ -116,7 +121,9 @@ public class CliqueProtocolScheduleTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()))
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("Epoch length in config must be greater than zero");
|
.hasMessage("Epoch length in config must be greater than zero");
|
||||||
}
|
}
|
||||||
@@ -136,7 +143,9 @@ public class CliqueProtocolScheduleTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()))
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("Epoch length in config must be greater than zero");
|
.hasMessage("Epoch length in config must be greater than zero");
|
||||||
}
|
}
|
||||||
@@ -160,7 +169,9 @@ public class CliqueProtocolScheduleTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
BlockHeader emptyFrontierParent =
|
BlockHeader emptyFrontierParent =
|
||||||
headerBuilder
|
headerBuilder
|
||||||
|
|||||||
@@ -106,7 +106,9 @@ public class CliqueBlockCreatorTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
|
final Address otherAddress = Util.publicKeyToAddress(otherKeyPair.getPublicKey());
|
||||||
validatorList.add(otherAddress);
|
validatorList.add(otherAddress);
|
||||||
|
|||||||
@@ -105,7 +105,9 @@ public class CliqueMinerExecutorTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS);
|
cliqueEthContext = mock(EthContext.class, RETURNS_DEEP_STUBS);
|
||||||
blockHeaderBuilder = new BlockHeaderTestFixture();
|
blockHeaderBuilder = new BlockHeaderTestFixture();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator;
|
import org.hyperledger.besu.ethereum.mainnet.WithdrawalsValidator;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -58,6 +59,9 @@ public abstract class BaseBftProtocolScheduleBuilder {
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
|
* @param metricsSystem metricsSystem A metricSystem instance to be able to expose metrics in the
|
||||||
|
* underlying calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public BftProtocolSchedule createProtocolSchedule(
|
public BftProtocolSchedule createProtocolSchedule(
|
||||||
@@ -68,7 +72,9 @@ public abstract class BaseBftProtocolScheduleBuilder {
|
|||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
|
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
|
||||||
|
|
||||||
forksSchedule
|
forksSchedule
|
||||||
@@ -90,7 +96,9 @@ public abstract class BaseBftProtocolScheduleBuilder {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager)
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule);
|
return new BftProtocolSchedule((DefaultProtocolSchedule) protocolSchedule);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -177,7 +178,9 @@ public class CombinedProtocolScheduleFactoryTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
return new BftProtocolSchedule(
|
return new BftProtocolSchedule(
|
||||||
(DefaultProtocolSchedule) protocolScheduleBuilder.createProtocolSchedule());
|
(DefaultProtocolSchedule) protocolScheduleBuilder.createProtocolSchedule());
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -245,7 +246,9 @@ public class BaseBftProtocolScheduleBuilderTest {
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BftConfigOptions createBftConfig(final BigInteger blockReward) {
|
private BftConfigOptions createBftConfig(final BigInteger blockReward) {
|
||||||
|
|||||||
@@ -333,7 +333,9 @@ public class TestContextBuilder {
|
|||||||
IBFT_EXTRA_DATA_ENCODER,
|
IBFT_EXTRA_DATA_ENCODER,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// From here down is BASICALLY taken from IbftBesuController
|
// From here down is BASICALLY taken from IbftBesuController
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -46,6 +47,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static BftProtocolSchedule create(
|
public static BftProtocolSchedule create(
|
||||||
@@ -56,7 +60,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return new IbftProtocolScheduleBuilder()
|
return new IbftProtocolScheduleBuilder()
|
||||||
.createProtocolSchedule(
|
.createProtocolSchedule(
|
||||||
config,
|
config,
|
||||||
@@ -66,7 +72,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -78,6 +86,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static BftProtocolSchedule create(
|
public static BftProtocolSchedule create(
|
||||||
@@ -86,7 +97,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
forksSchedule,
|
forksSchedule,
|
||||||
@@ -95,7 +108,9 @@ public class IbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
|
|||||||
import org.hyperledger.besu.ethereum.core.Util;
|
import org.hyperledger.besu.ethereum.core.Util;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -103,7 +104,9 @@ public class IbftProtocolScheduleTest {
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateHeader(
|
private boolean validateHeader(
|
||||||
|
|||||||
@@ -121,7 +121,9 @@ public class BftBlockCreatorTest {
|
|||||||
bftExtraDataEncoder,
|
bftExtraDataEncoder,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
final ProtocolContext protContext =
|
final ProtocolContext protContext =
|
||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
blockchain,
|
blockchain,
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
import org.hyperledger.besu.util.Subscribers;
|
import org.hyperledger.besu.util.Subscribers;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -184,7 +185,9 @@ public class IbftBlockHeightManagerTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
ProtocolSchedule protocolSchedule =
|
ProtocolSchedule protocolSchedule =
|
||||||
new BftProtocolSchedule(
|
new BftProtocolSchedule(
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.MainnetEVMs;
|
import org.hyperledger.besu.evm.MainnetEVMs;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -49,19 +50,24 @@ public class MergeProtocolSchedule {
|
|||||||
* @param isRevertReasonEnabled the is revert reason enabled
|
* @param isRevertReasonEnabled the is revert reason enabled
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule create(
|
public static ProtocolSchedule create(
|
||||||
final GenesisConfigOptions config,
|
final GenesisConfigOptions config,
|
||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +78,7 @@ public class MergeProtocolSchedule {
|
|||||||
* @param isRevertReasonEnabled the is revert reason enabled
|
* @param isRevertReasonEnabled the is revert reason enabled
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule create(
|
public static ProtocolSchedule create(
|
||||||
@@ -79,7 +86,9 @@ public class MergeProtocolSchedule {
|
|||||||
final PrivacyParameters privacyParameters,
|
final PrivacyParameters privacyParameters,
|
||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications =
|
Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> postMergeModifications =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
@@ -98,7 +107,9 @@ public class MergeProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager)
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;
|
import org.hyperledger.besu.ethereum.mainnet.ScheduledProtocolSpec;
|
||||||
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -65,17 +66,30 @@ public class TransitionProtocolSchedule implements ProtocolSchedule {
|
|||||||
* milestone starting points
|
* milestone starting points
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return an initialised TransitionProtocolSchedule using post-merge defaults
|
* @return an initialised TransitionProtocolSchedule using post-merge defaults
|
||||||
*/
|
*/
|
||||||
public static TransitionProtocolSchedule fromConfig(
|
public static TransitionProtocolSchedule fromConfig(
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
ProtocolSchedule preMergeProtocolSchedule =
|
ProtocolSchedule preMergeProtocolSchedule =
|
||||||
MainnetProtocolSchedule.fromConfig(genesisConfigOptions, miningParameters, badBlockManager);
|
MainnetProtocolSchedule.fromConfig(
|
||||||
|
genesisConfigOptions,
|
||||||
|
miningParameters,
|
||||||
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
ProtocolSchedule postMergeProtocolSchedule =
|
ProtocolSchedule postMergeProtocolSchedule =
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
genesisConfigOptions, false, miningParameters, badBlockManager);
|
genesisConfigOptions,
|
||||||
|
false,
|
||||||
|
miningParameters,
|
||||||
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
return new TransitionProtocolSchedule(
|
return new TransitionProtocolSchedule(
|
||||||
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
|
preMergeProtocolSchedule, postMergeProtocolSchedule, PostMergeContext.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpec;
|
|||||||
import org.hyperledger.besu.evm.operation.InvalidOperation;
|
import org.hyperledger.besu.evm.operation.InvalidOperation;
|
||||||
import org.hyperledger.besu.evm.operation.PrevRanDaoOperation;
|
import org.hyperledger.besu.evm.operation.PrevRanDaoOperation;
|
||||||
import org.hyperledger.besu.evm.operation.Push0Operation;
|
import org.hyperledger.besu.evm.operation.Push0Operation;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
@@ -48,7 +49,12 @@ public class MergeProtocolScheduleTest {
|
|||||||
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
|
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
|
||||||
final ProtocolSchedule protocolSchedule =
|
final ProtocolSchedule protocolSchedule =
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
|
config,
|
||||||
|
false,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
|
final ProtocolSpec homesteadSpec = protocolSchedule.getByBlockHeader(blockHeader(1));
|
||||||
final ProtocolSpec londonSpec = protocolSchedule.getByBlockHeader(blockHeader(1559));
|
final ProtocolSpec londonSpec = protocolSchedule.getByBlockHeader(blockHeader(1559));
|
||||||
@@ -64,7 +70,12 @@ public class MergeProtocolScheduleTest {
|
|||||||
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
|
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
|
||||||
final ProtocolSchedule protocolSchedule =
|
final ProtocolSchedule protocolSchedule =
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
|
config,
|
||||||
|
false,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final long lastParisBlockNumber = 17034869L;
|
final long lastParisBlockNumber = 17034869L;
|
||||||
final ProtocolSpec parisSpec =
|
final ProtocolSpec parisSpec =
|
||||||
@@ -100,7 +111,12 @@ public class MergeProtocolScheduleTest {
|
|||||||
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
|
final GenesisConfigOptions config = GenesisConfigFile.fromConfig(jsonInput).getConfigOptions();
|
||||||
final ProtocolSchedule protocolSchedule =
|
final ProtocolSchedule protocolSchedule =
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
|
config,
|
||||||
|
false,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final ProtocolSpec parisSpec =
|
final ProtocolSpec parisSpec =
|
||||||
protocolSchedule.getByBlockHeader(
|
protocolSchedule.getByBlockHeader(
|
||||||
@@ -128,7 +144,12 @@ public class MergeProtocolScheduleTest {
|
|||||||
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
|
final GenesisConfigOptions config = GenesisConfigFile.mainnet().getConfigOptions();
|
||||||
final ProtocolSchedule protocolSchedule =
|
final ProtocolSchedule protocolSchedule =
|
||||||
MergeProtocolSchedule.create(
|
MergeProtocolSchedule.create(
|
||||||
config, false, MiningParameters.MINING_DISABLED, new BadBlockManager());
|
config,
|
||||||
|
false,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final long lastParisBlockNumber = 17034869L;
|
final long lastParisBlockNumber = 17034869L;
|
||||||
final ProtocolSpec parisSpec =
|
final ProtocolSpec parisSpec =
|
||||||
@@ -160,7 +181,9 @@ public class MergeProtocolScheduleTest {
|
|||||||
GenesisConfigFile.DEFAULT.getConfigOptions(),
|
GenesisConfigFile.DEFAULT.getConfigOptions(),
|
||||||
false,
|
false,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.getByBlockHeader(blockHeader(0));
|
.getByBlockHeader(blockHeader(0));
|
||||||
|
|
||||||
assertThat(london.getName()).isEqualTo("Paris");
|
assertThat(london.getName()).isEqualTo("Paris");
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.hyperledger.besu.datatypes.Address;
|
|||||||
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
||||||
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -56,6 +57,8 @@ public interface MergeGenesisConfigHelper {
|
|||||||
getPosGenesisConfigFile().getConfigOptions(),
|
getPosGenesisConfigFile().getConfigOptions(),
|
||||||
false,
|
false,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ import org.hyperledger.besu.consensus.common.bft.statemachine.FutureMessageBuffe
|
|||||||
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
|
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
|
||||||
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
|
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
|
||||||
import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions;
|
import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
|
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftGossip;
|
import org.hyperledger.besu.consensus.qbft.QbftGossip;
|
||||||
@@ -438,7 +437,9 @@ public class TestContextBuilder {
|
|||||||
BFT_EXTRA_DATA_ENCODER,
|
BFT_EXTRA_DATA_ENCODER,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks);
|
final BftValidatorOverrides validatorOverrides = convertBftForks(qbftForks);
|
||||||
final TransactionSimulator transactionSimulator =
|
final TransactionSimulator transactionSimulator =
|
||||||
@@ -458,7 +459,7 @@ public class TestContextBuilder {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
new QbftContext(validatorProvider, epochManager, blockInterface),
|
new BftContext(validatorProvider, epochManager, blockInterface),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
|
|
||||||
final TransactionPoolConfiguration poolConf =
|
final TransactionPoolConfiguration poolConf =
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
@@ -30,7 +31,6 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
|||||||
import org.hyperledger.besu.consensus.common.bft.RoundTimer;
|
import org.hyperledger.besu.consensus.common.bft.RoundTimer;
|
||||||
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
|
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
|
||||||
import org.hyperledger.besu.consensus.common.bft.inttest.StubValidatorMulticaster;
|
import org.hyperledger.besu.consensus.common.bft.inttest.StubValidatorMulticaster;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter;
|
import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter;
|
||||||
import org.hyperledger.besu.consensus.qbft.payload.MessageFactory;
|
import org.hyperledger.besu.consensus.qbft.payload.MessageFactory;
|
||||||
@@ -129,7 +129,7 @@ public class QbftRoundIntegrationTest {
|
|||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(
|
||||||
QbftContext.class, emptyList(), qbftExtraDataEncoder),
|
BftContext.class, emptyList(), qbftExtraDataEncoder),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright ConsenSys AG.
|
|
||||||
*
|
|
||||||
* 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.consensus.qbft;
|
|
||||||
|
|
||||||
import org.hyperledger.besu.consensus.common.EpochManager;
|
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftBlockInterface;
|
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
|
||||||
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
|
|
||||||
|
|
||||||
/** The Qbft context. */
|
|
||||||
public class QbftContext extends BftContext {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Qbft context.
|
|
||||||
*
|
|
||||||
* @param validatorProvider the validator provider
|
|
||||||
* @param epochManager the epoch manager
|
|
||||||
* @param blockInterface the block interface
|
|
||||||
*/
|
|
||||||
public QbftContext(
|
|
||||||
final ValidatorProvider validatorProvider,
|
|
||||||
final EpochManager epochManager,
|
|
||||||
final BftBlockInterface blockInterface) {
|
|
||||||
super(validatorProvider, epochManager, blockInterface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -31,6 +31,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -50,6 +51,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters The mining parameters
|
* @param miningParameters The mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static BftProtocolSchedule create(
|
public static BftProtocolSchedule create(
|
||||||
@@ -60,7 +64,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return new QbftProtocolScheduleBuilder()
|
return new QbftProtocolScheduleBuilder()
|
||||||
.createProtocolSchedule(
|
.createProtocolSchedule(
|
||||||
config,
|
config,
|
||||||
@@ -70,7 +76,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +90,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
* @param evmConfiguration the evm configuration
|
* @param evmConfiguration the evm configuration
|
||||||
* @param miningParameters The mining parameters
|
* @param miningParameters The mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static BftProtocolSchedule create(
|
public static BftProtocolSchedule create(
|
||||||
@@ -90,7 +101,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
qbftForksSchedule,
|
qbftForksSchedule,
|
||||||
@@ -99,7 +112,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,6 +126,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
* @param bftExtraDataCodec the bft extra data codec
|
* @param bftExtraDataCodec the bft extra data codec
|
||||||
* @param miningParameters The mining parameters
|
* @param miningParameters The mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
|
* @param metricsSystem A metricSystem instance to be able to expose metrics in the underlying
|
||||||
|
* calls
|
||||||
* @return the protocol schedule
|
* @return the protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule create(
|
public static ProtocolSchedule create(
|
||||||
@@ -119,7 +137,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final BftExtraDataCodec bftExtraDataCodec,
|
final BftExtraDataCodec bftExtraDataCodec,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
qbftForksSchedule,
|
qbftForksSchedule,
|
||||||
@@ -128,7 +148,9 @@ public class QbftProtocolScheduleBuilder extends BaseBftProtocolScheduleBuilder
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import static java.util.Collections.singletonList;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder;
|
import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.cryptoservices.NodeKey;
|
import org.hyperledger.besu.cryptoservices.NodeKey;
|
||||||
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
|
import org.hyperledger.besu.cryptoservices.NodeKeyUtils;
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
@@ -45,8 +46,7 @@ public class QbftBlockHeaderValidationRulesetFactoryTest {
|
|||||||
return new ProtocolContext(
|
return new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(BftContext.class, validators, new QbftExtraDataCodec()),
|
||||||
QbftContext.class, validators, new QbftExtraDataCodec()),
|
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.hyperledger.besu.config.JsonUtil;
|
|||||||
import org.hyperledger.besu.config.QbftConfigOptions;
|
import org.hyperledger.besu.config.QbftConfigOptions;
|
||||||
import org.hyperledger.besu.consensus.common.ForkSpec;
|
import org.hyperledger.besu.consensus.common.ForkSpec;
|
||||||
import org.hyperledger.besu.consensus.common.ForksSchedule;
|
import org.hyperledger.besu.consensus.common.ForksSchedule;
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
import org.hyperledger.besu.cryptoservices.NodeKey;
|
import org.hyperledger.besu.cryptoservices.NodeKey;
|
||||||
@@ -40,6 +41,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
|
|||||||
import org.hyperledger.besu.ethereum.core.Util;
|
import org.hyperledger.besu.ethereum.core.Util;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
import org.hyperledger.besu.ethereum.mainnet.HeaderValidationMode;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -58,8 +60,7 @@ public class QbftProtocolScheduleTest {
|
|||||||
return new ProtocolContext(
|
return new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(BftContext.class, validators, new QbftExtraDataCodec()),
|
||||||
QbftContext.class, validators, new QbftExtraDataCodec()),
|
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +139,9 @@ public class QbftProtocolScheduleTest {
|
|||||||
bftExtraDataCodec,
|
bftExtraDataCodec,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateHeader(
|
private boolean validateHeader(
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupC
|
|||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
||||||
import org.hyperledger.besu.consensus.common.bft.Vote;
|
import org.hyperledger.besu.consensus.common.bft.Vote;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.datatypes.Address;
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
import org.hyperledger.besu.ethereum.ProtocolContext;
|
import org.hyperledger.besu.ethereum.ProtocolContext;
|
||||||
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
import org.hyperledger.besu.ethereum.chain.BadBlockManager;
|
||||||
@@ -47,7 +47,7 @@ public class QbftValidatorsValidationRuleTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraData(QbftContext.class, Collections.emptyList(), bftExtraData),
|
setupContextWithBftExtraData(BftContext.class, Collections.emptyList(), bftExtraData),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
when(bftExtraData.getValidators()).thenReturn(Collections.emptyList());
|
when(bftExtraData.getValidators()).thenReturn(Collections.emptyList());
|
||||||
when(bftExtraData.getVote()).thenReturn(Optional.empty());
|
when(bftExtraData.getVote()).thenReturn(Optional.empty());
|
||||||
@@ -66,7 +66,7 @@ public class QbftValidatorsValidationRuleTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraData(QbftContext.class, validators, bftExtraData),
|
setupContextWithBftExtraData(BftContext.class, validators, bftExtraData),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
when(bftExtraData.getValidators()).thenReturn(validators);
|
when(bftExtraData.getValidators()).thenReturn(validators);
|
||||||
assertThat(qbftValidatorsValidationRule.validate(blockHeader, null, context)).isTrue();
|
assertThat(qbftValidatorsValidationRule.validate(blockHeader, null, context)).isTrue();
|
||||||
@@ -84,7 +84,7 @@ public class QbftValidatorsValidationRuleTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraData(QbftContext.class, validators, bftExtraData),
|
setupContextWithBftExtraData(BftContext.class, validators, bftExtraData),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
when(bftExtraData.getValidators()).thenReturn(validators);
|
when(bftExtraData.getValidators()).thenReturn(validators);
|
||||||
assertThat(qbftValidatorsValidationRule.validate(blockHeader, null, context)).isFalse();
|
assertThat(qbftValidatorsValidationRule.validate(blockHeader, null, context)).isFalse();
|
||||||
@@ -98,7 +98,7 @@ public class QbftValidatorsValidationRuleTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraData(QbftContext.class, Collections.emptyList(), bftExtraData),
|
setupContextWithBftExtraData(BftContext.class, Collections.emptyList(), bftExtraData),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
when(bftExtraData.getValidators()).thenReturn(Collections.emptyList());
|
when(bftExtraData.getValidators()).thenReturn(Collections.emptyList());
|
||||||
when(bftExtraData.getVote()).thenReturn(Optional.of(mock(Vote.class)));
|
when(bftExtraData.getVote()).thenReturn(Optional.of(mock(Vote.class)));
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import org.hyperledger.besu.config.StubGenesisConfigOptions;
|
import org.hyperledger.besu.config.StubGenesisConfigOptions;
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
@@ -42,7 +43,6 @@ import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
|
|||||||
import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry;
|
import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry;
|
||||||
import org.hyperledger.besu.consensus.common.bft.network.ValidatorMulticaster;
|
import org.hyperledger.besu.consensus.common.bft.network.ValidatorMulticaster;
|
||||||
import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState;
|
import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData;
|
import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit;
|
||||||
@@ -78,6 +78,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
import org.hyperledger.besu.util.Subscribers;
|
import org.hyperledger.besu.util.Subscribers;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -172,7 +173,7 @@ public class QbftBlockHeightManagerTest {
|
|||||||
blockchain,
|
blockchain,
|
||||||
null,
|
null,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(
|
||||||
QbftContext.class, validators, new QbftExtraDataCodec()),
|
BftContext.class, validators, new QbftExtraDataCodec()),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
|
|
||||||
final ProtocolScheduleBuilder protocolScheduleBuilder =
|
final ProtocolScheduleBuilder protocolScheduleBuilder =
|
||||||
@@ -184,7 +185,9 @@ public class QbftBlockHeightManagerTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
|
|
||||||
ProtocolSchedule protocolSchedule =
|
ProtocolSchedule protocolSchedule =
|
||||||
new BftProtocolSchedule(
|
new BftProtocolSchedule(
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftBlockHashing;
|
import org.hyperledger.besu.consensus.common.bft.BftBlockHashing;
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
@@ -37,7 +38,6 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
|||||||
import org.hyperledger.besu.consensus.common.bft.RoundTimer;
|
import org.hyperledger.besu.consensus.common.bft.RoundTimer;
|
||||||
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
|
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
|
||||||
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange;
|
||||||
import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter;
|
import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter;
|
||||||
@@ -123,7 +123,7 @@ public class QbftRoundTest {
|
|||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(
|
||||||
QbftContext.class, emptyList(), new QbftExtraDataCodec()),
|
BftContext.class, emptyList(), new QbftExtraDataCodec()),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
|
|
||||||
when(messageValidator.validateProposal(any())).thenReturn(true);
|
when(messageValidator.validateProposal(any())).thenReturn(true);
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal;
|
||||||
import org.hyperledger.besu.consensus.qbft.payload.MessageFactory;
|
import org.hyperledger.besu.consensus.qbft.payload.MessageFactory;
|
||||||
@@ -74,7 +74,7 @@ public class ProposalPayloadValidatorTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
setupContextWithBftExtraDataEncoder(QbftContext.class, emptyList(), bftExtraDataCodec),
|
setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataCodec),
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ import static org.mockito.ArgumentMatchers.eq;
|
|||||||
import static org.mockito.Mockito.reset;
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
|
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal;
|
||||||
@@ -102,8 +102,7 @@ public class ProposalValidatorTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataEncoder),
|
||||||
QbftContext.class, emptyList(), bftExtraDataEncoder),
|
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
|
|
||||||
// typically tests require the blockValidation to be successful
|
// typically tests require the blockValidation to be successful
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ import static org.mockito.Mockito.any;
|
|||||||
import static org.mockito.Mockito.lenient;
|
import static org.mockito.Mockito.lenient;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.consensus.common.bft.BftContext;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
|
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier;
|
||||||
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers;
|
||||||
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
import org.hyperledger.besu.consensus.common.bft.payload.SignedData;
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftContext;
|
|
||||||
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
|
||||||
import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange;
|
import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange;
|
||||||
import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata;
|
import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata;
|
||||||
@@ -84,8 +84,7 @@ public class RoundChangeMessageValidatorTest {
|
|||||||
new ProtocolContext(
|
new ProtocolContext(
|
||||||
blockChain,
|
blockChain,
|
||||||
worldStateArchive,
|
worldStateArchive,
|
||||||
setupContextWithBftExtraDataEncoder(
|
setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataEncoder),
|
||||||
QbftContext.class, emptyList(), bftExtraDataEncoder),
|
|
||||||
new BadBlockManager());
|
new BadBlockManager());
|
||||||
|
|
||||||
lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec);
|
lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec);
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
super(new Blake2bfDigest());
|
super(new Blake2bfDigest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Blake2bfMessageDigest clone() throws CloneNotSupportedException {
|
||||||
|
Blake2bfMessageDigest cloned = (Blake2bfMessageDigest) super.clone();
|
||||||
|
cloned.digest = ((Blake2bfDigest) this.digest).clone();
|
||||||
|
return cloned;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the `F` compression function of the Blake2b cryptographic hash function.
|
* Implementation of the `F` compression function of the Blake2b cryptographic hash function.
|
||||||
*
|
*
|
||||||
@@ -43,7 +50,7 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
*
|
*
|
||||||
* <p>Optimized for 64-bit platforms
|
* <p>Optimized for 64-bit platforms
|
||||||
*/
|
*/
|
||||||
public static class Blake2bfDigest implements Digest {
|
public static class Blake2bfDigest implements Digest, Cloneable {
|
||||||
/** The constant MESSAGE_LENGTH_BYTES. */
|
/** The constant MESSAGE_LENGTH_BYTES. */
|
||||||
public static final int MESSAGE_LENGTH_BYTES = 213;
|
public static final int MESSAGE_LENGTH_BYTES = 213;
|
||||||
|
|
||||||
@@ -71,18 +78,18 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
// buffer which holds serialized input for this compression function
|
// buffer which holds serialized input for this compression function
|
||||||
// [ 4 bytes for rounds ][ 64 bytes for h ][ 128 bytes for m ]
|
// [ 4 bytes for rounds ][ 64 bytes for h ][ 128 bytes for m ]
|
||||||
// [ 8 bytes for t_0 ][ 8 bytes for t_1 ][ 1 byte for f ]
|
// [ 8 bytes for t_0 ][ 8 bytes for t_1 ][ 1 byte for f ]
|
||||||
private final byte[] buffer;
|
private byte[] buffer;
|
||||||
|
|
||||||
private int bufferPos;
|
private int bufferPos;
|
||||||
|
|
||||||
// deserialized inputs for f compression
|
// deserialized inputs for f compression
|
||||||
private final long[] h;
|
private long[] h;
|
||||||
private final long[] m;
|
private long[] m;
|
||||||
private final long[] t;
|
private long[] t;
|
||||||
private boolean f;
|
private boolean f;
|
||||||
private long rounds; // unsigned integer represented as long
|
private long rounds; // unsigned integer represented as long
|
||||||
|
|
||||||
private final long[] v;
|
private long[] v;
|
||||||
private static boolean useNative;
|
private static boolean useNative;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -112,6 +119,17 @@ public class Blake2bfMessageDigest extends BCMessageDigest implements Cloneable
|
|||||||
v = new long[16];
|
v = new long[16];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Blake2bfDigest clone() throws CloneNotSupportedException {
|
||||||
|
Blake2bfDigest cloned = (Blake2bfDigest) super.clone();
|
||||||
|
cloned.buffer = this.buffer.clone();
|
||||||
|
cloned.h = this.h.clone();
|
||||||
|
cloned.m = this.m.clone();
|
||||||
|
cloned.t = this.t.clone();
|
||||||
|
cloned.v = this.v.clone();
|
||||||
|
return cloned;
|
||||||
|
}
|
||||||
|
|
||||||
/** Disable native. */
|
/** Disable native. */
|
||||||
public static void disableNative() {
|
public static void disableNative() {
|
||||||
useNative = false;
|
useNative = false;
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ package org.hyperledger.besu.crypto;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.bouncycastle.util.Pack;
|
import org.bouncycastle.util.Pack;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -29,6 +36,16 @@ import org.junit.jupiter.params.provider.CsvFileSource;
|
|||||||
*/
|
*/
|
||||||
public class Blake2bfMessageDigestTest {
|
public class Blake2bfMessageDigestTest {
|
||||||
|
|
||||||
|
private static final SecureRandom SECURE_RANDOM;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
SECURE_RANDOM = SecureRandom.getInstanceStrong();
|
||||||
|
} catch (NoSuchAlgorithmException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Blake2bfMessageDigest messageDigest;
|
private Blake2bfMessageDigest messageDigest;
|
||||||
|
|
||||||
// output when input is all 0
|
// output when input is all 0
|
||||||
@@ -124,6 +141,39 @@ public class Blake2bfMessageDigestTest {
|
|||||||
.isInstanceOf(IllegalArgumentException.class);
|
.isInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Test
|
||||||
|
public void testDigestThreadSafety() throws ExecutionException, InterruptedException {
|
||||||
|
final byte[] input = new byte[213];
|
||||||
|
;
|
||||||
|
SECURE_RANDOM.nextBytes(input);
|
||||||
|
int numberOfHashes = 10;
|
||||||
|
|
||||||
|
CompletableFuture<byte[]>[] futures =
|
||||||
|
IntStream.range(0, numberOfHashes)
|
||||||
|
.mapToObj(
|
||||||
|
i ->
|
||||||
|
CompletableFuture.supplyAsync(
|
||||||
|
() -> {
|
||||||
|
try {
|
||||||
|
MessageDigest clonedDigest = messageDigest.clone();
|
||||||
|
clonedDigest.update(input);
|
||||||
|
byte[] digest = clonedDigest.digest();
|
||||||
|
return digest;
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.toArray(CompletableFuture[]::new);
|
||||||
|
|
||||||
|
CompletableFuture.allOf(futures).get();
|
||||||
|
|
||||||
|
byte[] expectedHash = futures[0].get();
|
||||||
|
for (CompletableFuture<byte[]> future : futures) {
|
||||||
|
assertThat(expectedHash).isEqualTo(future.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@CsvFileSource(resources = "eip152TestCases.csv", numLinesToSkip = 1)
|
@CsvFileSource(resources = "eip152TestCases.csv", numLinesToSkip = 1)
|
||||||
public void eip152TestCases(final String hexIn, final String hexExpected) {
|
public void eip152TestCases(final String hexIn, final String hexExpected) {
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.datatypes;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SetCodeAuthorization is a data structure that represents the authorization to set code on a EOA
|
||||||
|
* account.
|
||||||
|
*/
|
||||||
|
public interface SetCodeAuthorization {
|
||||||
|
/**
|
||||||
|
* Return the chain id.
|
||||||
|
*
|
||||||
|
* @return chain id
|
||||||
|
*/
|
||||||
|
BigInteger chainId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the address of the account which code will be used.
|
||||||
|
*
|
||||||
|
* @return address
|
||||||
|
*/
|
||||||
|
Address address();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the signature.
|
||||||
|
*
|
||||||
|
* @return signature
|
||||||
|
*/
|
||||||
|
SECPSignature signature();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the authorizer address.
|
||||||
|
*
|
||||||
|
* @return authorizer address of the EOA which will load the code into its account
|
||||||
|
*/
|
||||||
|
Optional<Address> authorizer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a valid nonce or empty otherwise. A nonce is valid if the size of the list is exactly 1
|
||||||
|
*
|
||||||
|
* @return all the optional nonce
|
||||||
|
*/
|
||||||
|
Optional<Long> nonce();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the recovery id.
|
||||||
|
*
|
||||||
|
* @return byte
|
||||||
|
*/
|
||||||
|
byte v();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the r value of the signature.
|
||||||
|
*
|
||||||
|
* @return r value
|
||||||
|
*/
|
||||||
|
BigInteger r();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the s value of the signature.
|
||||||
|
*
|
||||||
|
* @return s value
|
||||||
|
*/
|
||||||
|
BigInteger s();
|
||||||
|
}
|
||||||
@@ -94,7 +94,7 @@ public class StorageSlotKey implements Comparable<StorageSlotKey> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(slotHash.hashCode());
|
return slotHash.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -234,4 +234,18 @@ public interface Transaction {
|
|||||||
* @return the size in bytes of the encoded transaction.
|
* @return the size in bytes of the encoded transaction.
|
||||||
*/
|
*/
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the set code transaction payload if this transaction is a 7702 transaction.
|
||||||
|
*
|
||||||
|
* @return the set code transaction payloads
|
||||||
|
*/
|
||||||
|
Optional<List<SetCodeAuthorization>> getAuthorizationList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of the authorization list.
|
||||||
|
*
|
||||||
|
* @return the size of the authorization list
|
||||||
|
*/
|
||||||
|
int authorizationListSize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ public enum TransactionType {
|
|||||||
/** Eip1559 transaction type. */
|
/** Eip1559 transaction type. */
|
||||||
EIP1559(0x02),
|
EIP1559(0x02),
|
||||||
/** Blob transaction type. */
|
/** Blob transaction type. */
|
||||||
BLOB(0x03);
|
BLOB(0x03),
|
||||||
|
/** Eip7702 transaction type. */
|
||||||
|
SET_CODE(0x04);
|
||||||
|
|
||||||
private static final Set<TransactionType> ACCESS_LIST_SUPPORTED_TRANSACTION_TYPES =
|
private static final Set<TransactionType> ACCESS_LIST_SUPPORTED_TRANSACTION_TYPES =
|
||||||
Set.of(ACCESS_LIST, EIP1559, BLOB);
|
Set.of(ACCESS_LIST, EIP1559, BLOB, SET_CODE);
|
||||||
|
|
||||||
private static final EnumSet<TransactionType> LEGACY_FEE_MARKET_TRANSACTION_TYPES =
|
private static final EnumSet<TransactionType> LEGACY_FEE_MARKET_TRANSACTION_TYPES =
|
||||||
EnumSet.of(TransactionType.FRONTIER, TransactionType.ACCESS_LIST);
|
EnumSet.of(TransactionType.FRONTIER, TransactionType.ACCESS_LIST);
|
||||||
@@ -83,7 +85,8 @@ public enum TransactionType {
|
|||||||
TransactionType.FRONTIER,
|
TransactionType.FRONTIER,
|
||||||
TransactionType.ACCESS_LIST,
|
TransactionType.ACCESS_LIST,
|
||||||
TransactionType.EIP1559,
|
TransactionType.EIP1559,
|
||||||
TransactionType.BLOB
|
TransactionType.BLOB,
|
||||||
|
TransactionType.SET_CODE
|
||||||
})
|
})
|
||||||
.filter(transactionType -> transactionType.typeValue == serializedTypeValue)
|
.filter(transactionType -> transactionType.typeValue == serializedTypeValue)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
@@ -128,4 +131,13 @@ public enum TransactionType {
|
|||||||
public boolean supportsBlob() {
|
public boolean supportsBlob() {
|
||||||
return this.equals(BLOB);
|
return this.equals(BLOB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does transaction type require code.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean requiresSetCode() {
|
||||||
|
return this.equals(SET_CODE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.hyperledger.besu.ethereum.mainnet.MainnetProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
|
import org.hyperledger.besu.ethereum.mainnet.ScheduleBasedBlockHeaderFunctions;
|
||||||
import org.hyperledger.besu.ethereum.util.RawBlockIterator;
|
import org.hyperledger.besu.ethereum.util.RawBlockIterator;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -46,7 +47,9 @@ public class BlockchainImporter {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(),
|
GenesisConfigFile.fromConfig(genesisJson).getConfigOptions(),
|
||||||
MiningParameters.newDefault(),
|
MiningParameters.newDefault(),
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
final BlockHeaderFunctions blockHeaderFunctions =
|
final BlockHeaderFunctions blockHeaderFunctions =
|
||||||
ScheduleBasedBlockHeaderFunctions.create(protocolSchedule);
|
ScheduleBasedBlockHeaderFunctions.create(protocolSchedule);
|
||||||
blocks = new ArrayList<>();
|
blocks = new ArrayList<>();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
|
public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
|
||||||
|
|
||||||
private final Optional<ScheduledProtocolSpec.Hardfork> cancun;
|
private final Optional<ScheduledProtocolSpec.Hardfork> supportedHardFork;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(EngineForkchoiceUpdatedV3.class);
|
private static final Logger LOG = LoggerFactory.getLogger(EngineForkchoiceUpdatedV3.class);
|
||||||
|
|
||||||
public EngineForkchoiceUpdatedV3(
|
public EngineForkchoiceUpdatedV3(
|
||||||
@@ -43,7 +43,11 @@ public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
|
|||||||
final MergeMiningCoordinator mergeCoordinator,
|
final MergeMiningCoordinator mergeCoordinator,
|
||||||
final EngineCallListener engineCallListener) {
|
final EngineCallListener engineCallListener) {
|
||||||
super(vertx, protocolSchedule, protocolContext, mergeCoordinator, engineCallListener);
|
super(vertx, protocolSchedule, protocolContext, mergeCoordinator, engineCallListener);
|
||||||
this.cancun = protocolSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("Cancun"));
|
this.supportedHardFork =
|
||||||
|
protocolSchedule.hardforkFor(
|
||||||
|
s ->
|
||||||
|
s.fork().name().equalsIgnoreCase("Cancun")
|
||||||
|
|| s.fork().name().equalsIgnoreCase("Prague"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,12 +81,12 @@ public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
|
|||||||
@Override
|
@Override
|
||||||
protected ValidationResult<RpcErrorType> validateForkSupported(final long blockTimestamp) {
|
protected ValidationResult<RpcErrorType> validateForkSupported(final long blockTimestamp) {
|
||||||
if (protocolSchedule.isPresent()) {
|
if (protocolSchedule.isPresent()) {
|
||||||
if (cancun.isPresent() && blockTimestamp >= cancun.get().milestone()) {
|
if (supportedHardFork.isPresent() && blockTimestamp >= supportedHardFork.get().milestone()) {
|
||||||
return ValidationResult.valid();
|
return ValidationResult.valid();
|
||||||
} else {
|
} else {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
RpcErrorType.UNSUPPORTED_FORK,
|
RpcErrorType.UNSUPPORTED_FORK,
|
||||||
"Cancun configured to start at timestamp: " + cancun.get().milestone());
|
"Cancun configured to start at timestamp: " + supportedHardFork.get().milestone());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
@@ -99,7 +103,7 @@ public class EngineForkchoiceUpdatedV3 extends AbstractEngineForkchoiceUpdated {
|
|||||||
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
|
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
|
||||||
} else if (payloadAttributes.getTimestamp().longValue() == 0) {
|
} else if (payloadAttributes.getTimestamp().longValue() == 0) {
|
||||||
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
|
return Optional.of(new JsonRpcErrorResponse(requestId, getInvalidPayloadAttributesError()));
|
||||||
} else if (payloadAttributes.getTimestamp() < cancun.get().milestone()) {
|
} else if (payloadAttributes.getTimestamp() < supportedHardFork.get().milestone()) {
|
||||||
return Optional.of(new JsonRpcErrorResponse(requestId, RpcErrorType.UNSUPPORTED_FORK));
|
return Optional.of(new JsonRpcErrorResponse(requestId, RpcErrorType.UNSUPPORTED_FORK));
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngin
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonGetter;
|
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
|
||||||
@JsonPropertyOrder({"status", "latestValidHash", "validationError"})
|
@JsonPropertyOrder({"status", "latestValidHash", "validationError"})
|
||||||
@@ -28,10 +30,11 @@ public class EnginePayloadStatusResult {
|
|||||||
Optional<Hash> latestValidHash;
|
Optional<Hash> latestValidHash;
|
||||||
Optional<String> validationError;
|
Optional<String> validationError;
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
public EnginePayloadStatusResult(
|
public EnginePayloadStatusResult(
|
||||||
final EngineStatus status,
|
@JsonProperty("status") final EngineStatus status,
|
||||||
final Hash latestValidHash,
|
@JsonProperty("latestValidHash") final Hash latestValidHash,
|
||||||
final Optional<String> validationError) {
|
@JsonProperty("errorMessage") final Optional<String> validationError) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.latestValidHash = Optional.ofNullable(latestValidHash);
|
this.latestValidHash = Optional.ofNullable(latestValidHash);
|
||||||
this.validationError = validationError;
|
this.validationError = validationError;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
|
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
|
||||||
|
|
||||||
import org.hyperledger.besu.datatypes.AccessListEntry;
|
import org.hyperledger.besu.datatypes.AccessListEntry;
|
||||||
|
import org.hyperledger.besu.datatypes.SetCodeAuthorization;
|
||||||
import org.hyperledger.besu.datatypes.TransactionType;
|
import org.hyperledger.besu.datatypes.TransactionType;
|
||||||
import org.hyperledger.besu.datatypes.VersionedHash;
|
import org.hyperledger.besu.datatypes.VersionedHash;
|
||||||
import org.hyperledger.besu.datatypes.Wei;
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
@@ -30,6 +31,7 @@ import org.apache.tuweni.bytes.Bytes;
|
|||||||
|
|
||||||
@JsonPropertyOrder({
|
@JsonPropertyOrder({
|
||||||
"accessList",
|
"accessList",
|
||||||
|
"authorizationList",
|
||||||
"blockHash",
|
"blockHash",
|
||||||
"blockNumber",
|
"blockNumber",
|
||||||
"chainId",
|
"chainId",
|
||||||
@@ -91,6 +93,9 @@ public class TransactionCompleteResult implements TransactionResult {
|
|||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
private final List<VersionedHash> versionedHashes;
|
private final List<VersionedHash> versionedHashes;
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
private final List<SetCodeAuthorization> authorizationList;
|
||||||
|
|
||||||
public TransactionCompleteResult(final TransactionWithMetadata tx) {
|
public TransactionCompleteResult(final TransactionWithMetadata tx) {
|
||||||
final Transaction transaction = tx.getTransaction();
|
final Transaction transaction = tx.getTransaction();
|
||||||
final TransactionType transactionType = transaction.getType();
|
final TransactionType transactionType = transaction.getType();
|
||||||
@@ -125,7 +130,8 @@ public class TransactionCompleteResult implements TransactionResult {
|
|||||||
this.yParity = Quantity.create(transaction.getYParity());
|
this.yParity = Quantity.create(transaction.getYParity());
|
||||||
this.v =
|
this.v =
|
||||||
(transactionType == TransactionType.ACCESS_LIST
|
(transactionType == TransactionType.ACCESS_LIST
|
||||||
|| transactionType == TransactionType.EIP1559)
|
|| transactionType == TransactionType.EIP1559)
|
||||||
|
|| transactionType == TransactionType.SET_CODE
|
||||||
? Quantity.create(transaction.getYParity())
|
? Quantity.create(transaction.getYParity())
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
@@ -133,6 +139,7 @@ public class TransactionCompleteResult implements TransactionResult {
|
|||||||
this.r = Quantity.create(transaction.getR());
|
this.r = Quantity.create(transaction.getR());
|
||||||
this.s = Quantity.create(transaction.getS());
|
this.s = Quantity.create(transaction.getS());
|
||||||
this.versionedHashes = transaction.getVersionedHashes().orElse(null);
|
this.versionedHashes = transaction.getVersionedHashes().orElse(null);
|
||||||
|
this.authorizationList = transaction.getAuthorizationList().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonGetter(value = "accessList")
|
@JsonGetter(value = "accessList")
|
||||||
@@ -246,4 +253,9 @@ public class TransactionCompleteResult implements TransactionResult {
|
|||||||
public List<VersionedHash> getVersionedHashes() {
|
public List<VersionedHash> getVersionedHashes() {
|
||||||
return versionedHashes;
|
return versionedHashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonGetter(value = "authorizationList")
|
||||||
|
public List<SetCodeAuthorization> getAuthorizationList() {
|
||||||
|
return authorizationList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,9 @@ public class JsonRpcHttpServiceHostAllowlistTest {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -138,7 +138,11 @@ public class JsonRpcHttpServiceLoginTest {
|
|||||||
blockchainQueries,
|
blockchainQueries,
|
||||||
synchronizer,
|
synchronizer,
|
||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
genesisConfigOptions, MiningParameters.MINING_DISABLED, new BadBlockManager()),
|
genesisConfigOptions,
|
||||||
|
MiningParameters.MINING_DISABLED,
|
||||||
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -118,7 +118,9 @@ public class JsonRpcHttpServiceTestBase {
|
|||||||
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -123,7 +123,9 @@ public class JsonRpcHttpServiceTlsClientAuthTest {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ class JsonRpcHttpServiceTlsMisconfigurationTest {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ public class JsonRpcHttpServiceTlsTest {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
new StubGenesisConfigOptions().constantinopleBlock(0).chainId(CHAIN_ID),
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -176,7 +176,9 @@ public class WebSocketServiceLoginTest {
|
|||||||
MainnetProtocolSchedule.fromConfig(
|
MainnetProtocolSchedule.fromConfig(
|
||||||
genesisConfigOptions,
|
genesisConfigOptions,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager()),
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem()),
|
||||||
mock(ProtocolContext.class),
|
mock(ProtocolContext.class),
|
||||||
mock(FilterManager.class),
|
mock(FilterManager.class),
|
||||||
mock(TransactionPool.class),
|
mock(TransactionPool.class),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.hyperledger.besu.datatypes.Wei;
|
|||||||
import org.hyperledger.besu.ethereum.GasLimitCalculator;
|
import org.hyperledger.besu.ethereum.GasLimitCalculator;
|
||||||
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector;
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.AbstractTransactionSelector;
|
||||||
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.BlobPriceTransactionSelector;
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.BlobPriceTransactionSelector;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.BlobSizeTransactionSelector;
|
||||||
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.BlockSizeTransactionSelector;
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.BlockSizeTransactionSelector;
|
||||||
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector;
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.MinPriorityFeePerGasTransactionSelector;
|
||||||
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.PriceTransactionSelector;
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.selectors.PriceTransactionSelector;
|
||||||
@@ -146,6 +147,7 @@ public class BlockTransactionSelector {
|
|||||||
final BlockSelectionContext context) {
|
final BlockSelectionContext context) {
|
||||||
return List.of(
|
return List.of(
|
||||||
new BlockSizeTransactionSelector(context),
|
new BlockSizeTransactionSelector(context),
|
||||||
|
new BlobSizeTransactionSelector(context),
|
||||||
new PriceTransactionSelector(context),
|
new PriceTransactionSelector(context),
|
||||||
new BlobPriceTransactionSelector(context),
|
new BlobPriceTransactionSelector(context),
|
||||||
new MinPriorityFeePerGasTransactionSelector(context),
|
new MinPriorityFeePerGasTransactionSelector(context),
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.blockcreation.txselection.selectors;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
|
||||||
|
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
|
||||||
|
import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class extends AbstractTransactionSelector and provides a specific implementation for
|
||||||
|
* evaluating transactions based on blobs size. It checks if a transaction supports blobs, and if
|
||||||
|
* so, checks that there is enough remaining blob gas in the block to fit the blobs of the tx.
|
||||||
|
*/
|
||||||
|
public class BlobSizeTransactionSelector extends AbstractTransactionSelector {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(BlobSizeTransactionSelector.class);
|
||||||
|
|
||||||
|
public BlobSizeTransactionSelector(final BlockSelectionContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates a transaction considering other transactions in the same block. If the tx does not
|
||||||
|
* support blobs, no check is performed, and SELECTED is returned, otherwise SELECTED is returned
|
||||||
|
* only if there is enough remaining blob gas to fit the blobs of the tx, otherwise a specific not
|
||||||
|
* selected result is returned, depending on the fact that the block already contains the max
|
||||||
|
* number of blobs or not.
|
||||||
|
*
|
||||||
|
* @param evaluationContext The current selection session data.
|
||||||
|
* @param transactionSelectionResults The results of other transaction evaluations in the same
|
||||||
|
* block.
|
||||||
|
* @return The result of the transaction selection.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TransactionSelectionResult evaluateTransactionPreProcessing(
|
||||||
|
final TransactionEvaluationContext evaluationContext,
|
||||||
|
final TransactionSelectionResults transactionSelectionResults) {
|
||||||
|
|
||||||
|
final var tx = evaluationContext.getTransaction();
|
||||||
|
if (tx.getType().supportsBlob()) {
|
||||||
|
|
||||||
|
final var remainingBlobGas =
|
||||||
|
context.gasLimitCalculator().currentBlobGasLimit()
|
||||||
|
- transactionSelectionResults.getCumulativeBlobGasUsed();
|
||||||
|
|
||||||
|
if (remainingBlobGas == 0) {
|
||||||
|
LOG.atTrace()
|
||||||
|
.setMessage("The block already contains the max number of allowed blobs")
|
||||||
|
.addArgument(evaluationContext.getPendingTransaction()::toTraceLog)
|
||||||
|
.log();
|
||||||
|
return TransactionSelectionResult.BLOBS_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
final long requestedBlobGas = context.gasCalculator().blobGasCost(tx.getBlobCount());
|
||||||
|
|
||||||
|
if (requestedBlobGas > remainingBlobGas) {
|
||||||
|
LOG.atTrace()
|
||||||
|
.setMessage(
|
||||||
|
"There is not enough blob gas available to fit the blobs of the transaction {} in the block."
|
||||||
|
+ " Available {} / Requested {}")
|
||||||
|
.addArgument(evaluationContext.getPendingTransaction()::toTraceLog)
|
||||||
|
.addArgument(remainingBlobGas)
|
||||||
|
.addArgument(requestedBlobGas)
|
||||||
|
.log();
|
||||||
|
return TransactionSelectionResult.TX_TOO_LARGE_FOR_REMAINING_BLOB_GAS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TransactionSelectionResult.SELECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TransactionSelectionResult evaluateTransactionPostProcessing(
|
||||||
|
final TransactionEvaluationContext evaluationContext,
|
||||||
|
final TransactionSelectionResults blockTransactionResults,
|
||||||
|
final TransactionProcessingResult processingResult) {
|
||||||
|
// All necessary checks were done in the pre-processing method, so nothing to do here.
|
||||||
|
return TransactionSelectionResult.SELECTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,15 +89,8 @@ public class BlockSizeTransactionSelector extends AbstractTransactionSelector {
|
|||||||
private boolean transactionTooLargeForBlock(
|
private boolean transactionTooLargeForBlock(
|
||||||
final Transaction transaction,
|
final Transaction transaction,
|
||||||
final TransactionSelectionResults transactionSelectionResults) {
|
final TransactionSelectionResults transactionSelectionResults) {
|
||||||
final long blobGasUsed = context.gasCalculator().blobGasCost(transaction.getBlobCount());
|
|
||||||
|
|
||||||
if (blobGasUsed
|
return transaction.getGasLimit()
|
||||||
> context.gasLimitCalculator().currentBlobGasLimit()
|
|
||||||
- transactionSelectionResults.getCumulativeBlobGasUsed()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return transaction.getGasLimit() + blobGasUsed
|
|
||||||
> context.processableBlockHeader().getGasLimit()
|
> context.processableBlockHeader().getGasLimit()
|
||||||
- transactionSelectionResults.getCumulativeGasUsed();
|
- transactionSelectionResults.getCumulativeGasUsed();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,9 @@ abstract class AbstractBlockCreatorTest {
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule())
|
.createProtocolSchedule())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
@@ -223,7 +223,9 @@ public abstract class AbstractBlockTransactionSelectorTest {
|
|||||||
GenesisConfigFile.fromResource("/dev.json").getConfigOptions(),
|
GenesisConfigFile.fromResource("/dev.json").getConfigOptions(),
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager());
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem());
|
||||||
final MainnetTransactionProcessor mainnetTransactionProcessor =
|
final MainnetTransactionProcessor mainnetTransactionProcessor =
|
||||||
protocolSchedule.getByBlockHeader(blockHeader(0)).getTransactionProcessor();
|
protocolSchedule.getByBlockHeader(blockHeader(0)).getTransactionProcessor();
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
import org.hyperledger.besu.testutil.TestClock;
|
import org.hyperledger.besu.testutil.TestClock;
|
||||||
import org.hyperledger.besu.util.number.Fraction;
|
import org.hyperledger.besu.util.number.Fraction;
|
||||||
|
|
||||||
@@ -60,7 +61,9 @@ public class LegacyFeeMarketBlockTransactionSelectorTest
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.metrics.noop.NoOpMetricsSystem;
|
||||||
import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
|
import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
|
||||||
import org.hyperledger.besu.testutil.TestClock;
|
import org.hyperledger.besu.testutil.TestClock;
|
||||||
import org.hyperledger.besu.util.number.Fraction;
|
import org.hyperledger.besu.util.number.Fraction;
|
||||||
@@ -71,7 +72,9 @@ public class LondonFeeMarketBlockTransactionSelectorTest
|
|||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
MiningParameters.MINING_DISABLED,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
|
|||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule())
|
.createProtocolSchedule())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -158,8 +160,10 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
|
|||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule())
|
.createProtocolSchedule())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -209,8 +213,10 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
|
|||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
final ExecutionContextTestFixture executionContextTestFixture =
|
final ExecutionContextTestFixture executionContextTestFixture =
|
||||||
ExecutionContextTestFixture.builder(genesisConfigFile)
|
ExecutionContextTestFixture.builder(genesisConfigFile)
|
||||||
@@ -285,8 +291,10 @@ class PoWBlockCreatorTest extends AbstractBlockCreatorTest {
|
|||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
MiningParameters.MINING_DISABLED,
|
||||||
new BadBlockManager())
|
new BadBlockManager(),
|
||||||
|
false,
|
||||||
|
new NoOpMetricsSystem())
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
final ExecutionContextTestFixture executionContextTestFixture =
|
final ExecutionContextTestFixture executionContextTestFixture =
|
||||||
ExecutionContextTestFixture.builder(genesisConfigFile)
|
ExecutionContextTestFixture.builder(genesisConfigFile)
|
||||||
|
|||||||
@@ -0,0 +1,188 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.blockcreation.txselection.selectors;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.fail;
|
||||||
|
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.crypto.KeyPair;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
|
||||||
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
import org.hyperledger.besu.datatypes.Blob;
|
||||||
|
import org.hyperledger.besu.datatypes.BlobsWithCommitments;
|
||||||
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
import org.hyperledger.besu.datatypes.KZGCommitment;
|
||||||
|
import org.hyperledger.besu.datatypes.KZGProof;
|
||||||
|
import org.hyperledger.besu.datatypes.TransactionType;
|
||||||
|
import org.hyperledger.besu.datatypes.VersionedHash;
|
||||||
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.BlockSelectionContext;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionEvaluationContext;
|
||||||
|
import org.hyperledger.besu.ethereum.blockcreation.txselection.TransactionSelectionResults;
|
||||||
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
|
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
|
||||||
|
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
|
||||||
|
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
|
||||||
|
import org.hyperledger.besu.plugin.data.TransactionSelectionResult;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
import org.apache.tuweni.bytes.Bytes48;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class BlobSizeTransactionSelectorTest {
|
||||||
|
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
|
||||||
|
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
|
||||||
|
private static final KeyPair KEYS = SIGNATURE_ALGORITHM.get().generateKeyPair();
|
||||||
|
|
||||||
|
private static final long BLOB_GAS_PER_BLOB = CancunGasCalculator.BLOB_GAS_PER_BLOB;
|
||||||
|
private static final int MAX_BLOBS = 6;
|
||||||
|
private static final long MAX_BLOB_GAS = BLOB_GAS_PER_BLOB * MAX_BLOBS;
|
||||||
|
|
||||||
|
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||||
|
BlockSelectionContext blockSelectionContext;
|
||||||
|
|
||||||
|
@Mock TransactionSelectionResults selectionResults;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void notBlobTransactionsAreSelectedWithoutAnyCheck() {
|
||||||
|
final var selector = new BlobSizeTransactionSelector(blockSelectionContext);
|
||||||
|
|
||||||
|
final var nonBlobTx = createEIP1559PendingTransaction();
|
||||||
|
|
||||||
|
final var txEvaluationContext = new TransactionEvaluationContext(nonBlobTx, null, null, null);
|
||||||
|
|
||||||
|
final var result =
|
||||||
|
selector.evaluateTransactionPreProcessing(txEvaluationContext, selectionResults);
|
||||||
|
assertThat(result).isEqualTo(TransactionSelectionResult.SELECTED);
|
||||||
|
verifyNoInteractions(selectionResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void firstBlobTransactionIsSelected() {
|
||||||
|
when(blockSelectionContext.gasLimitCalculator().currentBlobGasLimit()).thenReturn(MAX_BLOB_GAS);
|
||||||
|
when(blockSelectionContext.gasCalculator().blobGasCost(anyInt()))
|
||||||
|
.thenAnswer(iom -> BLOB_GAS_PER_BLOB * iom.getArgument(0, Integer.class));
|
||||||
|
|
||||||
|
final var selector = new BlobSizeTransactionSelector(blockSelectionContext);
|
||||||
|
|
||||||
|
final var firstBlobTx = createBlobPendingTransaction(MAX_BLOBS);
|
||||||
|
|
||||||
|
final var txEvaluationContext = new TransactionEvaluationContext(firstBlobTx, null, null, null);
|
||||||
|
|
||||||
|
when(selectionResults.getCumulativeBlobGasUsed()).thenReturn(0L);
|
||||||
|
|
||||||
|
final var result =
|
||||||
|
selector.evaluateTransactionPreProcessing(txEvaluationContext, selectionResults);
|
||||||
|
assertThat(result).isEqualTo(TransactionSelectionResult.SELECTED);
|
||||||
|
verify(selectionResults).getCumulativeBlobGasUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void returnsBlobsFullWhenMaxNumberOfBlobsAlreadyPresent() {
|
||||||
|
when(blockSelectionContext.gasLimitCalculator().currentBlobGasLimit()).thenReturn(MAX_BLOB_GAS);
|
||||||
|
|
||||||
|
final var selector = new BlobSizeTransactionSelector(blockSelectionContext);
|
||||||
|
|
||||||
|
final var firstBlobTx = createBlobPendingTransaction(1);
|
||||||
|
|
||||||
|
final var txEvaluationContext = new TransactionEvaluationContext(firstBlobTx, null, null, null);
|
||||||
|
|
||||||
|
when(selectionResults.getCumulativeBlobGasUsed()).thenReturn(MAX_BLOB_GAS);
|
||||||
|
|
||||||
|
final var result =
|
||||||
|
selector.evaluateTransactionPreProcessing(txEvaluationContext, selectionResults);
|
||||||
|
assertThat(result).isEqualTo(TransactionSelectionResult.BLOBS_FULL);
|
||||||
|
verify(selectionResults).getCumulativeBlobGasUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void returnsTooLargeForRemainingBlobGas() {
|
||||||
|
when(blockSelectionContext.gasLimitCalculator().currentBlobGasLimit()).thenReturn(MAX_BLOB_GAS);
|
||||||
|
when(blockSelectionContext.gasCalculator().blobGasCost(anyInt()))
|
||||||
|
.thenAnswer(iom -> BLOB_GAS_PER_BLOB * iom.getArgument(0, Integer.class));
|
||||||
|
|
||||||
|
final var selector = new BlobSizeTransactionSelector(blockSelectionContext);
|
||||||
|
|
||||||
|
final var firstBlobTx = createBlobPendingTransaction(MAX_BLOBS);
|
||||||
|
|
||||||
|
final var txEvaluationContext = new TransactionEvaluationContext(firstBlobTx, null, null, null);
|
||||||
|
|
||||||
|
when(selectionResults.getCumulativeBlobGasUsed()).thenReturn(MAX_BLOB_GAS - 1);
|
||||||
|
|
||||||
|
final var result =
|
||||||
|
selector.evaluateTransactionPreProcessing(txEvaluationContext, selectionResults);
|
||||||
|
assertThat(result).isEqualTo(TransactionSelectionResult.TX_TOO_LARGE_FOR_REMAINING_BLOB_GAS);
|
||||||
|
verify(selectionResults).getCumulativeBlobGasUsed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private PendingTransaction createEIP1559PendingTransaction() {
|
||||||
|
return PendingTransaction.newPendingTransaction(
|
||||||
|
createTransaction(TransactionType.EIP1559, 0), false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PendingTransaction createBlobPendingTransaction(final int blobCount) {
|
||||||
|
return PendingTransaction.newPendingTransaction(
|
||||||
|
createTransaction(TransactionType.BLOB, blobCount), false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Transaction createTransaction(final TransactionType type, final int blobCount) {
|
||||||
|
|
||||||
|
var tx =
|
||||||
|
new TransactionTestFixture()
|
||||||
|
.to(Optional.of(Address.fromHexString("0x634316eA0EE79c701c6F67C53A4C54cBAfd2316d")))
|
||||||
|
.nonce(0)
|
||||||
|
.type(type);
|
||||||
|
tx.maxFeePerGas(Optional.of(Wei.of(1000))).maxPriorityFeePerGas(Optional.of(Wei.of(100)));
|
||||||
|
if (type.supportsBlob()) {
|
||||||
|
if (blobCount > 0) {
|
||||||
|
tx.maxFeePerBlobGas(Optional.of(Wei.of(10)));
|
||||||
|
final var versionHashes =
|
||||||
|
IntStream.range(0, blobCount)
|
||||||
|
.mapToObj(i -> new VersionedHash((byte) 1, Hash.ZERO))
|
||||||
|
.toList();
|
||||||
|
final var kgzCommitments =
|
||||||
|
IntStream.range(0, blobCount)
|
||||||
|
.mapToObj(i -> new KZGCommitment(Bytes48.random()))
|
||||||
|
.toList();
|
||||||
|
final var kzgProofs =
|
||||||
|
IntStream.range(0, blobCount).mapToObj(i -> new KZGProof(Bytes48.random())).toList();
|
||||||
|
final var blobs =
|
||||||
|
IntStream.range(0, blobCount).mapToObj(i -> new Blob(Bytes.random(32 * 4096))).toList();
|
||||||
|
tx.versionedHashes(Optional.of(versionHashes));
|
||||||
|
final var blobsWithCommitments =
|
||||||
|
new BlobsWithCommitments(kgzCommitments, blobs, kzgProofs, versionHashes);
|
||||||
|
tx.blobsWithCommitments(Optional.of(blobsWithCommitments));
|
||||||
|
} else {
|
||||||
|
fail("At least 1 blob is required for blob tx type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tx.createTransaction(KEYS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,7 +76,7 @@ public class ChainDataPruner implements BlockAddedObserver {
|
|||||||
if (event.isNewCanonicalHead() && blocksToBePruned >= pruningFrequency) {
|
if (event.isNewCanonicalHead() && blocksToBePruned >= pruningFrequency) {
|
||||||
long currentRetainedBlock = blockNumber - currentPruningMark + 1;
|
long currentRetainedBlock = blockNumber - currentPruningMark + 1;
|
||||||
while (currentRetainedBlock > blocksToRetain) {
|
while (currentRetainedBlock > blocksToRetain) {
|
||||||
LOG.debug("Pruning chain data with block height of " + currentPruningMark);
|
LOG.debug("Pruning chain data with block height of {}", currentPruningMark);
|
||||||
pruneChainDataAtBlock(pruningTransaction, currentPruningMark);
|
pruneChainDataAtBlock(pruningTransaction, currentPruningMark);
|
||||||
currentPruningMark++;
|
currentPruningMark++;
|
||||||
currentRetainedBlock = blockNumber - currentPruningMark;
|
currentRetainedBlock = blockNumber - currentPruningMark;
|
||||||
|
|||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.core;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.crypto.KeyPair;
|
||||||
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
|
||||||
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
|
import org.hyperledger.besu.ethereum.core.encoding.SetCodeTransactionEncoder;
|
||||||
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class SetCodeAuthorization implements org.hyperledger.besu.datatypes.SetCodeAuthorization {
|
||||||
|
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
|
||||||
|
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
|
||||||
|
|
||||||
|
public static final Bytes MAGIC = Bytes.fromHexString("05");
|
||||||
|
|
||||||
|
private final BigInteger chainId;
|
||||||
|
private final Address address;
|
||||||
|
private final Optional<Long> nonce;
|
||||||
|
private final SECPSignature signature;
|
||||||
|
private Optional<Address> authorizer = Optional.empty();
|
||||||
|
private boolean isAuthorityComputed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An access list entry as defined in EIP-7702
|
||||||
|
*
|
||||||
|
* @param chainId can be either the current chain id or zero
|
||||||
|
* @param address the address from which the code will be set into the EOA account
|
||||||
|
* @param nonce an optional nonce after which this auth expires
|
||||||
|
* @param signature the signature of the EOA account which will be used to set the code
|
||||||
|
*/
|
||||||
|
public SetCodeAuthorization(
|
||||||
|
final BigInteger chainId,
|
||||||
|
final Address address,
|
||||||
|
final Optional<Long> nonce,
|
||||||
|
final SECPSignature signature) {
|
||||||
|
this.chainId = chainId;
|
||||||
|
this.address = address;
|
||||||
|
this.nonce = nonce;
|
||||||
|
this.signature = signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create access list entry.
|
||||||
|
*
|
||||||
|
* @param chainId can be either the current chain id or zero
|
||||||
|
* @param address the address from which the code will be set into the EOA account
|
||||||
|
* @param nonces the list of nonces
|
||||||
|
* @param v the recovery id
|
||||||
|
* @param r the r value of the signature
|
||||||
|
* @param s the s value of the signature
|
||||||
|
* @return SetCodeTransactionEntry
|
||||||
|
*/
|
||||||
|
@JsonCreator
|
||||||
|
public static org.hyperledger.besu.datatypes.SetCodeAuthorization createSetCodeAuthorizationEntry(
|
||||||
|
@JsonProperty("chainId") final BigInteger chainId,
|
||||||
|
@JsonProperty("address") final Address address,
|
||||||
|
@JsonProperty("nonce") final List<Long> nonces,
|
||||||
|
@JsonProperty("v") final byte v,
|
||||||
|
@JsonProperty("r") final BigInteger r,
|
||||||
|
@JsonProperty("s") final BigInteger s) {
|
||||||
|
return new SetCodeAuthorization(
|
||||||
|
chainId,
|
||||||
|
address,
|
||||||
|
Optional.ofNullable(nonces.get(0)),
|
||||||
|
SIGNATURE_ALGORITHM.get().createSignature(r, s, v));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("chainId")
|
||||||
|
@Override
|
||||||
|
public BigInteger chainId() {
|
||||||
|
return chainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("address")
|
||||||
|
@Override
|
||||||
|
public Address address() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("signature")
|
||||||
|
@Override
|
||||||
|
public SECPSignature signature() {
|
||||||
|
return signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Address> authorizer() {
|
||||||
|
if (!isAuthorityComputed) {
|
||||||
|
authorizer = computeAuthority();
|
||||||
|
isAuthorityComputed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return authorizer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Long> nonce() {
|
||||||
|
return nonce;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("v")
|
||||||
|
@Override
|
||||||
|
public byte v() {
|
||||||
|
return signature.getRecId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("r")
|
||||||
|
@Override
|
||||||
|
public BigInteger r() {
|
||||||
|
return signature.getR();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("s")
|
||||||
|
@Override
|
||||||
|
public BigInteger s() {
|
||||||
|
return signature.getS();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<Address> computeAuthority() {
|
||||||
|
BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput();
|
||||||
|
SetCodeTransactionEncoder.encodeSingleSetCodeWithoutSignature(this, rlpOutput);
|
||||||
|
|
||||||
|
final Hash hash = Hash.hash(Bytes.concatenate(MAGIC, rlpOutput.encoded()));
|
||||||
|
|
||||||
|
return SIGNATURE_ALGORITHM
|
||||||
|
.get()
|
||||||
|
.recoverPublicKeyFromSignature(hash, signature)
|
||||||
|
.map(Address::extract);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create set code authorization with a builder.
|
||||||
|
*
|
||||||
|
* @return SetCodeAuthorization.Builder
|
||||||
|
*/
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Builder for SetCodeAuthorization. */
|
||||||
|
public static class Builder {
|
||||||
|
private BigInteger chainId = BigInteger.ZERO;
|
||||||
|
private Address address;
|
||||||
|
private Optional<Long> nonce = Optional.empty();
|
||||||
|
private SECPSignature signature;
|
||||||
|
|
||||||
|
/** Create a new builder. */
|
||||||
|
protected Builder() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the optional chain id.
|
||||||
|
*
|
||||||
|
* @param chainId the chain id
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder chainId(final BigInteger chainId) {
|
||||||
|
this.chainId = chainId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the address of the authorized smart contract.
|
||||||
|
*
|
||||||
|
* @param address the address
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder address(final Address address) {
|
||||||
|
this.address = address;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the optional nonce.
|
||||||
|
*
|
||||||
|
* @param nonce the optional nonce.
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder nonces(final Optional<Long> nonce) {
|
||||||
|
this.nonce = nonce;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the signature of the authorizer account.
|
||||||
|
*
|
||||||
|
* @param signature the signature
|
||||||
|
* @return this builder
|
||||||
|
*/
|
||||||
|
public Builder signature(final SECPSignature signature) {
|
||||||
|
this.signature = signature;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sign the authorization with the given key pair and return the authorization.
|
||||||
|
*
|
||||||
|
* @param keyPair the key pair
|
||||||
|
* @return SetCodeAuthorization
|
||||||
|
*/
|
||||||
|
public org.hyperledger.besu.datatypes.SetCodeAuthorization signAndBuild(final KeyPair keyPair) {
|
||||||
|
final BytesValueRLPOutput output = new BytesValueRLPOutput();
|
||||||
|
output.startList();
|
||||||
|
output.writeBigIntegerScalar(chainId);
|
||||||
|
output.writeBytes(address);
|
||||||
|
output.startList();
|
||||||
|
nonce.ifPresent(output::writeLongScalar);
|
||||||
|
output.endList();
|
||||||
|
output.endList();
|
||||||
|
|
||||||
|
signature(
|
||||||
|
SIGNATURE_ALGORITHM
|
||||||
|
.get()
|
||||||
|
.sign(Hash.hash(Bytes.concatenate(MAGIC, output.encoded())), keyPair));
|
||||||
|
return build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the authorization.
|
||||||
|
*
|
||||||
|
* @return SetCodeAuthorization
|
||||||
|
*/
|
||||||
|
public org.hyperledger.besu.datatypes.SetCodeAuthorization build() {
|
||||||
|
if (address == null) {
|
||||||
|
throw new IllegalStateException("Address must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signature == null) {
|
||||||
|
throw new IllegalStateException("Signature must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SetCodeAuthorization(chainId, address, nonce, signature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ import org.hyperledger.besu.datatypes.BlobsWithCommitments;
|
|||||||
import org.hyperledger.besu.datatypes.Hash;
|
import org.hyperledger.besu.datatypes.Hash;
|
||||||
import org.hyperledger.besu.datatypes.KZGCommitment;
|
import org.hyperledger.besu.datatypes.KZGCommitment;
|
||||||
import org.hyperledger.besu.datatypes.KZGProof;
|
import org.hyperledger.besu.datatypes.KZGProof;
|
||||||
|
import org.hyperledger.besu.datatypes.SetCodeAuthorization;
|
||||||
import org.hyperledger.besu.datatypes.Sha256Hash;
|
import org.hyperledger.besu.datatypes.Sha256Hash;
|
||||||
import org.hyperledger.besu.datatypes.TransactionType;
|
import org.hyperledger.besu.datatypes.TransactionType;
|
||||||
import org.hyperledger.besu.datatypes.VersionedHash;
|
import org.hyperledger.besu.datatypes.VersionedHash;
|
||||||
@@ -38,6 +39,7 @@ import org.hyperledger.besu.datatypes.Wei;
|
|||||||
import org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder;
|
import org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder;
|
||||||
import org.hyperledger.besu.ethereum.core.encoding.BlobTransactionEncoder;
|
import org.hyperledger.besu.ethereum.core.encoding.BlobTransactionEncoder;
|
||||||
import org.hyperledger.besu.ethereum.core.encoding.EncodingContext;
|
import org.hyperledger.besu.ethereum.core.encoding.EncodingContext;
|
||||||
|
import org.hyperledger.besu.ethereum.core.encoding.SetCodeTransactionEncoder;
|
||||||
import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder;
|
import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder;
|
||||||
import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder;
|
import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder;
|
||||||
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
|
||||||
@@ -122,6 +124,7 @@ public class Transaction
|
|||||||
private final Optional<List<VersionedHash>> versionedHashes;
|
private final Optional<List<VersionedHash>> versionedHashes;
|
||||||
|
|
||||||
private final Optional<BlobsWithCommitments> blobsWithCommitments;
|
private final Optional<BlobsWithCommitments> blobsWithCommitments;
|
||||||
|
private final Optional<List<SetCodeAuthorization>> maybeAuthorizationList;
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
@@ -177,7 +180,8 @@ public class Transaction
|
|||||||
final Address sender,
|
final Address sender,
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final Optional<List<VersionedHash>> versionedHashes,
|
final Optional<List<VersionedHash>> versionedHashes,
|
||||||
final Optional<BlobsWithCommitments> blobsWithCommitments) {
|
final Optional<BlobsWithCommitments> blobsWithCommitments,
|
||||||
|
final Optional<List<SetCodeAuthorization>> maybeAuthorizationList) {
|
||||||
|
|
||||||
if (!forCopy) {
|
if (!forCopy) {
|
||||||
if (transactionType.requiresChainId()) {
|
if (transactionType.requiresChainId()) {
|
||||||
@@ -213,6 +217,12 @@ public class Transaction
|
|||||||
checkArgument(
|
checkArgument(
|
||||||
maxFeePerBlobGas.isPresent(), "Must specify max fee per blob gas for blob transaction");
|
maxFeePerBlobGas.isPresent(), "Must specify max fee per blob gas for blob transaction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (transactionType.requiresSetCode()) {
|
||||||
|
checkArgument(
|
||||||
|
maybeAuthorizationList.isPresent(),
|
||||||
|
"Must specify set code transaction payload for set code transaction");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactionType = transactionType;
|
this.transactionType = transactionType;
|
||||||
@@ -231,6 +241,7 @@ public class Transaction
|
|||||||
this.chainId = chainId;
|
this.chainId = chainId;
|
||||||
this.versionedHashes = versionedHashes;
|
this.versionedHashes = versionedHashes;
|
||||||
this.blobsWithCommitments = blobsWithCommitments;
|
this.blobsWithCommitments = blobsWithCommitments;
|
||||||
|
this.maybeAuthorizationList = maybeAuthorizationList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -462,6 +473,7 @@ public class Transaction
|
|||||||
payload,
|
payload,
|
||||||
maybeAccessList,
|
maybeAccessList,
|
||||||
versionedHashes.orElse(null),
|
versionedHashes.orElse(null),
|
||||||
|
maybeAuthorizationList,
|
||||||
chainId);
|
chainId);
|
||||||
}
|
}
|
||||||
return hashNoSignature;
|
return hashNoSignature;
|
||||||
@@ -668,6 +680,16 @@ public class Transaction
|
|||||||
return blobsWithCommitments;
|
return blobsWithCommitments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<SetCodeAuthorization>> getAuthorizationList() {
|
||||||
|
return maybeAuthorizationList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int authorizationListSize() {
|
||||||
|
return maybeAuthorizationList.map(List::size).orElse(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of transaction hashes extracted from the collection of Transaction passed as
|
* Return the list of transaction hashes extracted from the collection of Transaction passed as
|
||||||
* argument
|
* argument
|
||||||
@@ -692,6 +714,7 @@ public class Transaction
|
|||||||
final Bytes payload,
|
final Bytes payload,
|
||||||
final Optional<List<AccessListEntry>> accessList,
|
final Optional<List<AccessListEntry>> accessList,
|
||||||
final List<VersionedHash> versionedHashes,
|
final List<VersionedHash> versionedHashes,
|
||||||
|
final Optional<List<SetCodeAuthorization>> authorizationList,
|
||||||
final Optional<BigInteger> chainId) {
|
final Optional<BigInteger> chainId) {
|
||||||
if (transactionType.requiresChainId()) {
|
if (transactionType.requiresChainId()) {
|
||||||
checkArgument(chainId.isPresent(), "Transaction type %s requires chainId", transactionType);
|
checkArgument(chainId.isPresent(), "Transaction type %s requires chainId", transactionType);
|
||||||
@@ -736,6 +759,21 @@ public class Transaction
|
|||||||
new IllegalStateException(
|
new IllegalStateException(
|
||||||
"Developer error: the transaction should be guaranteed to have an access list here")),
|
"Developer error: the transaction should be guaranteed to have an access list here")),
|
||||||
chainId);
|
chainId);
|
||||||
|
case SET_CODE ->
|
||||||
|
setCodePreimage(
|
||||||
|
nonce,
|
||||||
|
maxPriorityFeePerGas,
|
||||||
|
maxFeePerGas,
|
||||||
|
gasLimit,
|
||||||
|
to,
|
||||||
|
value,
|
||||||
|
payload,
|
||||||
|
chainId,
|
||||||
|
accessList,
|
||||||
|
authorizationList.orElseThrow(
|
||||||
|
() ->
|
||||||
|
new IllegalStateException(
|
||||||
|
"Developer error: the transaction should be guaranteed to have a set code payload here")));
|
||||||
};
|
};
|
||||||
return keccak256(preimage);
|
return keccak256(preimage);
|
||||||
}
|
}
|
||||||
@@ -873,6 +911,38 @@ public class Transaction
|
|||||||
return Bytes.concatenate(Bytes.of(TransactionType.ACCESS_LIST.getSerializedType()), encode);
|
return Bytes.concatenate(Bytes.of(TransactionType.ACCESS_LIST.getSerializedType()), encode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Bytes setCodePreimage(
|
||||||
|
final long nonce,
|
||||||
|
final Wei maxPriorityFeePerGas,
|
||||||
|
final Wei maxFeePerGas,
|
||||||
|
final long gasLimit,
|
||||||
|
final Optional<Address> to,
|
||||||
|
final Wei value,
|
||||||
|
final Bytes payload,
|
||||||
|
final Optional<BigInteger> chainId,
|
||||||
|
final Optional<List<AccessListEntry>> accessList,
|
||||||
|
final List<SetCodeAuthorization> authorizationList) {
|
||||||
|
final Bytes encoded =
|
||||||
|
RLP.encode(
|
||||||
|
rlpOutput -> {
|
||||||
|
rlpOutput.startList();
|
||||||
|
eip1559PreimageFields(
|
||||||
|
nonce,
|
||||||
|
maxPriorityFeePerGas,
|
||||||
|
maxFeePerGas,
|
||||||
|
gasLimit,
|
||||||
|
to,
|
||||||
|
value,
|
||||||
|
payload,
|
||||||
|
chainId,
|
||||||
|
accessList,
|
||||||
|
rlpOutput);
|
||||||
|
SetCodeTransactionEncoder.encodeSetCodeInner(authorizationList, rlpOutput);
|
||||||
|
rlpOutput.endList();
|
||||||
|
});
|
||||||
|
return Bytes.concatenate(Bytes.of(TransactionType.SET_CODE.getSerializedType()), encoded);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object other) {
|
public boolean equals(final Object other) {
|
||||||
if (!(other instanceof Transaction that)) {
|
if (!(other instanceof Transaction that)) {
|
||||||
@@ -1040,7 +1110,8 @@ public class Transaction
|
|||||||
sender,
|
sender,
|
||||||
chainId,
|
chainId,
|
||||||
detachedVersionedHashes,
|
detachedVersionedHashes,
|
||||||
detachedBlobsWithCommitments);
|
detachedBlobsWithCommitments,
|
||||||
|
maybeAuthorizationList);
|
||||||
|
|
||||||
// copy also the computed fields, to avoid to recompute them
|
// copy also the computed fields, to avoid to recompute them
|
||||||
copiedTx.sender = this.sender;
|
copiedTx.sender = this.sender;
|
||||||
@@ -1108,6 +1179,7 @@ public class Transaction
|
|||||||
protected Optional<BigInteger> v = Optional.empty();
|
protected Optional<BigInteger> v = Optional.empty();
|
||||||
protected List<VersionedHash> versionedHashes = null;
|
protected List<VersionedHash> versionedHashes = null;
|
||||||
private BlobsWithCommitments blobsWithCommitments;
|
private BlobsWithCommitments blobsWithCommitments;
|
||||||
|
protected Optional<List<SetCodeAuthorization>> setCodeTransactionPayloads = Optional.empty();
|
||||||
|
|
||||||
public Builder copiedFrom(final Transaction toCopy) {
|
public Builder copiedFrom(final Transaction toCopy) {
|
||||||
this.transactionType = toCopy.transactionType;
|
this.transactionType = toCopy.transactionType;
|
||||||
@@ -1126,6 +1198,7 @@ public class Transaction
|
|||||||
this.chainId = toCopy.chainId;
|
this.chainId = toCopy.chainId;
|
||||||
this.versionedHashes = toCopy.versionedHashes.orElse(null);
|
this.versionedHashes = toCopy.versionedHashes.orElse(null);
|
||||||
this.blobsWithCommitments = toCopy.blobsWithCommitments.orElse(null);
|
this.blobsWithCommitments = toCopy.blobsWithCommitments.orElse(null);
|
||||||
|
this.setCodeTransactionPayloads = toCopy.maybeAuthorizationList;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,6 +1292,8 @@ public class Transaction
|
|||||||
transactionType = TransactionType.EIP1559;
|
transactionType = TransactionType.EIP1559;
|
||||||
} else if (accessList.isPresent()) {
|
} else if (accessList.isPresent()) {
|
||||||
transactionType = TransactionType.ACCESS_LIST;
|
transactionType = TransactionType.ACCESS_LIST;
|
||||||
|
} else if (setCodeTransactionPayloads.isPresent()) {
|
||||||
|
transactionType = TransactionType.SET_CODE;
|
||||||
} else {
|
} else {
|
||||||
transactionType = TransactionType.FRONTIER;
|
transactionType = TransactionType.FRONTIER;
|
||||||
}
|
}
|
||||||
@@ -1248,7 +1323,8 @@ public class Transaction
|
|||||||
sender,
|
sender,
|
||||||
chainId,
|
chainId,
|
||||||
Optional.ofNullable(versionedHashes),
|
Optional.ofNullable(versionedHashes),
|
||||||
Optional.ofNullable(blobsWithCommitments));
|
Optional.ofNullable(blobsWithCommitments),
|
||||||
|
setCodeTransactionPayloads);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Transaction signAndBuild(final KeyPair keys) {
|
public Transaction signAndBuild(final KeyPair keys) {
|
||||||
@@ -1275,6 +1351,7 @@ public class Transaction
|
|||||||
payload,
|
payload,
|
||||||
accessList,
|
accessList,
|
||||||
versionedHashes,
|
versionedHashes,
|
||||||
|
setCodeTransactionPayloads,
|
||||||
chainId),
|
chainId),
|
||||||
keys);
|
keys);
|
||||||
}
|
}
|
||||||
@@ -1298,5 +1375,11 @@ public class Transaction
|
|||||||
this.blobsWithCommitments = blobsWithCommitments;
|
this.blobsWithCommitments = blobsWithCommitments;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setCodeTransactionPayloads(
|
||||||
|
final List<SetCodeAuthorization> setCodeTransactionEntries) {
|
||||||
|
this.setCodeTransactionPayloads = Optional.ofNullable(setCodeTransactionEntries);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.core.encoding;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.crypto.SECPSignature;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithm;
|
||||||
|
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
|
||||||
|
import org.hyperledger.besu.datatypes.AccessListEntry;
|
||||||
|
import org.hyperledger.besu.datatypes.Address;
|
||||||
|
import org.hyperledger.besu.datatypes.TransactionType;
|
||||||
|
import org.hyperledger.besu.datatypes.Wei;
|
||||||
|
import org.hyperledger.besu.ethereum.core.SetCodeAuthorization;
|
||||||
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
|
import org.hyperledger.besu.ethereum.rlp.RLPInput;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
|
||||||
|
public class SetCodeTransactionDecoder {
|
||||||
|
private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
|
||||||
|
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
|
||||||
|
|
||||||
|
private SetCodeTransactionDecoder() {
|
||||||
|
// private constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Transaction decode(final RLPInput input) {
|
||||||
|
input.enterList();
|
||||||
|
final BigInteger chainId = input.readBigIntegerScalar();
|
||||||
|
final Transaction.Builder builder =
|
||||||
|
Transaction.builder()
|
||||||
|
.type(TransactionType.SET_CODE)
|
||||||
|
.chainId(chainId)
|
||||||
|
.nonce(input.readLongScalar())
|
||||||
|
.maxPriorityFeePerGas(Wei.of(input.readUInt256Scalar()))
|
||||||
|
.maxFeePerGas(Wei.of(input.readUInt256Scalar()))
|
||||||
|
.gasLimit(input.readLongScalar())
|
||||||
|
.to(input.readBytes(v -> v.isEmpty() ? null : Address.wrap(v)))
|
||||||
|
.value(Wei.of(input.readUInt256Scalar()))
|
||||||
|
.payload(input.readBytes())
|
||||||
|
.accessList(
|
||||||
|
input.readList(
|
||||||
|
accessListEntryRLPInput -> {
|
||||||
|
accessListEntryRLPInput.enterList();
|
||||||
|
final AccessListEntry accessListEntry =
|
||||||
|
new AccessListEntry(
|
||||||
|
Address.wrap(accessListEntryRLPInput.readBytes()),
|
||||||
|
accessListEntryRLPInput.readList(RLPInput::readBytes32));
|
||||||
|
accessListEntryRLPInput.leaveList();
|
||||||
|
return accessListEntry;
|
||||||
|
}))
|
||||||
|
.setCodeTransactionPayloads(
|
||||||
|
input.readList(
|
||||||
|
setCodeTransactionPayloadsRLPInput ->
|
||||||
|
decodeInnerPayload(setCodeTransactionPayloadsRLPInput)));
|
||||||
|
|
||||||
|
final byte recId = (byte) input.readUnsignedByteScalar();
|
||||||
|
final BigInteger r = input.readUInt256Scalar().toUnsignedBigInteger();
|
||||||
|
final BigInteger s = input.readUInt256Scalar().toUnsignedBigInteger();
|
||||||
|
|
||||||
|
input.leaveList();
|
||||||
|
|
||||||
|
final Transaction transaction =
|
||||||
|
builder.signature(SIGNATURE_ALGORITHM.get().createSignature(r, s, recId)).build();
|
||||||
|
|
||||||
|
return transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static org.hyperledger.besu.datatypes.SetCodeAuthorization decodeInnerPayload(
|
||||||
|
final RLPInput input) {
|
||||||
|
input.enterList();
|
||||||
|
final BigInteger chainId = input.readBigIntegerScalar();
|
||||||
|
final Address address = Address.wrap(input.readBytes());
|
||||||
|
|
||||||
|
Optional<Long> nonce = Optional.empty();
|
||||||
|
|
||||||
|
if (!input.nextIsList()) {
|
||||||
|
throw new IllegalArgumentException("Optional nonce must be an list, but isn't");
|
||||||
|
}
|
||||||
|
|
||||||
|
final long noncesSize = input.nextSize();
|
||||||
|
|
||||||
|
input.enterList();
|
||||||
|
if (noncesSize == 1) {
|
||||||
|
nonce = Optional.ofNullable(input.readLongScalar());
|
||||||
|
} else if (noncesSize > 1) {
|
||||||
|
throw new IllegalArgumentException("Nonce list may only have 1 member, if any");
|
||||||
|
}
|
||||||
|
input.leaveList();
|
||||||
|
|
||||||
|
final byte yParity = (byte) input.readUnsignedByteScalar();
|
||||||
|
final BigInteger r = input.readUInt256Scalar().toUnsignedBigInteger();
|
||||||
|
final BigInteger s = input.readUInt256Scalar().toUnsignedBigInteger();
|
||||||
|
|
||||||
|
input.leaveList();
|
||||||
|
|
||||||
|
final SECPSignature signature = SIGNATURE_ALGORITHM.get().createSignature(r, s, yParity);
|
||||||
|
|
||||||
|
return new SetCodeAuthorization(chainId, address, nonce, signature);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.core.encoding;
|
||||||
|
|
||||||
|
import static org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder.writeAccessList;
|
||||||
|
import static org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder.writeSignatureAndRecoveryId;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.datatypes.SetCodeAuthorization;
|
||||||
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
|
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
|
||||||
|
public class SetCodeTransactionEncoder {
|
||||||
|
|
||||||
|
private SetCodeTransactionEncoder() {
|
||||||
|
// private constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encodeSetCodeInner(
|
||||||
|
final List<SetCodeAuthorization> payloads, final RLPOutput rlpOutput) {
|
||||||
|
rlpOutput.startList();
|
||||||
|
payloads.forEach(payload -> encodeSingleSetCode(payload, rlpOutput));
|
||||||
|
rlpOutput.endList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encodeSingleSetCodeWithoutSignature(
|
||||||
|
final SetCodeAuthorization payload, final RLPOutput rlpOutput) {
|
||||||
|
rlpOutput.startList();
|
||||||
|
encodeAuthorizationDetails(payload, rlpOutput);
|
||||||
|
rlpOutput.endList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encodeSingleSetCode(
|
||||||
|
final SetCodeAuthorization payload, final RLPOutput rlpOutput) {
|
||||||
|
rlpOutput.startList();
|
||||||
|
encodeAuthorizationDetails(payload, rlpOutput);
|
||||||
|
rlpOutput.writeIntScalar(payload.signature().getRecId());
|
||||||
|
rlpOutput.writeBigIntegerScalar(payload.signature().getR());
|
||||||
|
rlpOutput.writeBigIntegerScalar(payload.signature().getS());
|
||||||
|
rlpOutput.endList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void encodeAuthorizationDetails(
|
||||||
|
final SetCodeAuthorization payload, final RLPOutput rlpOutput) {
|
||||||
|
rlpOutput.writeBigIntegerScalar(payload.chainId());
|
||||||
|
rlpOutput.writeBytes(payload.address().copy());
|
||||||
|
rlpOutput.startList();
|
||||||
|
payload.nonce().ifPresent(rlpOutput::writeLongScalar);
|
||||||
|
rlpOutput.endList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(final Transaction transaction, final RLPOutput out) {
|
||||||
|
out.startList();
|
||||||
|
out.writeBigIntegerScalar(transaction.getChainId().orElseThrow());
|
||||||
|
out.writeLongScalar(transaction.getNonce());
|
||||||
|
out.writeUInt256Scalar(transaction.getMaxPriorityFeePerGas().orElseThrow());
|
||||||
|
out.writeUInt256Scalar(transaction.getMaxFeePerGas().orElseThrow());
|
||||||
|
out.writeLongScalar(transaction.getGasLimit());
|
||||||
|
out.writeBytes(transaction.getTo().map(Bytes::copy).orElse(Bytes.EMPTY));
|
||||||
|
out.writeUInt256Scalar(transaction.getValue());
|
||||||
|
out.writeBytes(transaction.getPayload());
|
||||||
|
writeAccessList(out, transaction.getAccessList());
|
||||||
|
encodeSetCodeInner(
|
||||||
|
transaction
|
||||||
|
.getAuthorizationList()
|
||||||
|
.orElseThrow(
|
||||||
|
() ->
|
||||||
|
new IllegalStateException(
|
||||||
|
"Developer error: the transaction should be guaranteed to have a set code payload here")),
|
||||||
|
out);
|
||||||
|
writeSignatureAndRecoveryId(transaction, out);
|
||||||
|
out.endList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,7 +40,9 @@ public class TransactionDecoder {
|
|||||||
TransactionType.EIP1559,
|
TransactionType.EIP1559,
|
||||||
EIP1559TransactionDecoder::decode,
|
EIP1559TransactionDecoder::decode,
|
||||||
TransactionType.BLOB,
|
TransactionType.BLOB,
|
||||||
BlobTransactionDecoder::decode);
|
BlobTransactionDecoder::decode,
|
||||||
|
TransactionType.SET_CODE,
|
||||||
|
SetCodeTransactionDecoder::decode);
|
||||||
|
|
||||||
private static final ImmutableMap<TransactionType, Decoder> POOLED_TRANSACTION_DECODERS =
|
private static final ImmutableMap<TransactionType, Decoder> POOLED_TRANSACTION_DECODERS =
|
||||||
ImmutableMap.of(TransactionType.BLOB, BlobPooledTransactionDecoder::decode);
|
ImmutableMap.of(TransactionType.BLOB, BlobPooledTransactionDecoder::decode);
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ public class TransactionEncoder {
|
|||||||
TransactionType.EIP1559,
|
TransactionType.EIP1559,
|
||||||
EIP1559TransactionEncoder::encode,
|
EIP1559TransactionEncoder::encode,
|
||||||
TransactionType.BLOB,
|
TransactionType.BLOB,
|
||||||
BlobTransactionEncoder::encode);
|
BlobTransactionEncoder::encode,
|
||||||
|
TransactionType.SET_CODE,
|
||||||
|
SetCodeTransactionEncoder::encode);
|
||||||
|
|
||||||
private static final ImmutableMap<TransactionType, Encoder> POOLED_TRANSACTION_ENCODERS =
|
private static final ImmutableMap<TransactionType, Encoder> POOLED_TRANSACTION_ENCODERS =
|
||||||
ImmutableMap.of(TransactionType.BLOB, BlobPooledTransactionEncoder::encode);
|
ImmutableMap.of(TransactionType.BLOB, BlobPooledTransactionEncoder::encode);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolScheduleBuilder;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
/** A ProtocolSchedule which behaves similarly to MainNet, but with a much reduced difficulty. */
|
/** A ProtocolSchedule which behaves similarly to MainNet, but with a much reduced difficulty. */
|
||||||
public class FixedDifficultyProtocolSchedule {
|
public class FixedDifficultyProtocolSchedule {
|
||||||
@@ -32,7 +33,9 @@ public class FixedDifficultyProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return new ProtocolScheduleBuilder(
|
return new ProtocolScheduleBuilder(
|
||||||
config,
|
config,
|
||||||
ProtocolSpecAdapters.create(
|
ProtocolSpecAdapters.create(
|
||||||
@@ -43,7 +46,9 @@ public class FixedDifficultyProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager)
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,27 +57,35 @@ public class FixedDifficultyProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSchedule create(
|
public static ProtocolSchedule create(
|
||||||
final GenesisConfigOptions config,
|
final GenesisConfigOptions config,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return create(
|
return create(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ public class ForkIdManager {
|
|||||||
.sorted()
|
.sorted()
|
||||||
.collect(Collectors.toUnmodifiableList());
|
.collect(Collectors.toUnmodifiableList());
|
||||||
final List<Long> allForkNumbers =
|
final List<Long> allForkNumbers =
|
||||||
Stream.concat(blockNumberForks.stream(), timestampForks.stream())
|
Stream.concat(blockNumberForks.stream(), timestampForks.stream()).toList();
|
||||||
.collect(Collectors.toList());
|
|
||||||
this.forkNext = createForkIds();
|
this.forkNext = createForkIds();
|
||||||
this.allForkIds =
|
this.allForkIds =
|
||||||
Stream.concat(blockNumbersForkIds.stream(), timestampsForkIds.stream())
|
Stream.concat(blockNumbersForkIds.stream(), timestampsForkIds.stream())
|
||||||
@@ -93,7 +92,7 @@ public class ForkIdManager {
|
|||||||
public ForkId getForkIdForChainHead() {
|
public ForkId getForkIdForChainHead() {
|
||||||
if (legacyEth64) {
|
if (legacyEth64) {
|
||||||
return blockNumbersForkIds.isEmpty()
|
return blockNumbersForkIds.isEmpty()
|
||||||
? null
|
? new ForkId(genesisHashCrc, 0)
|
||||||
: blockNumbersForkIds.get(blockNumbersForkIds.size() - 1);
|
: blockNumbersForkIds.get(blockNumbersForkIds.size() - 1);
|
||||||
}
|
}
|
||||||
final BlockHeader header = chainHeadSupplier.get();
|
final BlockHeader header = chainHeadSupplier.get();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorld
|
|||||||
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
|
import org.hyperledger.besu.ethereum.trie.diffbased.bonsai.worldview.BonsaiWorldStateUpdateAccumulator;
|
||||||
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
|
import org.hyperledger.besu.ethereum.vm.CachingBlockHashLookup;
|
||||||
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
|
import org.hyperledger.besu.evm.gascalculator.CancunGasCalculator;
|
||||||
|
import org.hyperledger.besu.evm.operation.BlockHashOperation;
|
||||||
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
@@ -110,57 +111,67 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
|
|||||||
protocolSpec.getBlockHashProcessor().processBlockHashes(blockchain, worldState, blockHeader);
|
protocolSpec.getBlockHashProcessor().processBlockHashes(blockchain, worldState, blockHeader);
|
||||||
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(blockHeader, blockchain);
|
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(blockHeader, blockchain);
|
||||||
|
|
||||||
for (final Transaction transaction : transactions) {
|
final Address miningBeneficiary = miningBeneficiaryCalculator.calculateBeneficiary(blockHeader);
|
||||||
|
|
||||||
|
Optional<BlockHeader> maybeParentHeader =
|
||||||
|
blockchain.getBlockHeader(blockHeader.getParentHash());
|
||||||
|
|
||||||
|
Wei blobGasPrice =
|
||||||
|
maybeParentHeader
|
||||||
|
.map(
|
||||||
|
parentHeader ->
|
||||||
|
protocolSpec
|
||||||
|
.getFeeMarket()
|
||||||
|
.blobGasPricePerGas(
|
||||||
|
calculateExcessBlobGasForParent(protocolSpec, parentHeader)))
|
||||||
|
.orElse(Wei.ZERO);
|
||||||
|
|
||||||
|
final Optional<PreprocessingContext> preProcessingContext =
|
||||||
|
runBlockPreProcessing(
|
||||||
|
worldState,
|
||||||
|
privateMetadataUpdater,
|
||||||
|
blockHeader,
|
||||||
|
transactions,
|
||||||
|
miningBeneficiary,
|
||||||
|
blockHashLookup,
|
||||||
|
blobGasPrice);
|
||||||
|
|
||||||
|
for (int i = 0; i < transactions.size(); i++) {
|
||||||
|
final Transaction transaction = transactions.get(i);
|
||||||
if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) {
|
if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) {
|
||||||
return new BlockProcessingResult(Optional.empty(), "provided gas insufficient");
|
return new BlockProcessingResult(Optional.empty(), "provided gas insufficient");
|
||||||
}
|
}
|
||||||
|
final WorldUpdater blockUpdater = worldState.updater();
|
||||||
|
|
||||||
final WorldUpdater worldStateUpdater = worldState.updater();
|
TransactionProcessingResult transactionProcessingResult =
|
||||||
|
getTransactionProcessingResult(
|
||||||
final Address miningBeneficiary =
|
preProcessingContext,
|
||||||
miningBeneficiaryCalculator.calculateBeneficiary(blockHeader);
|
worldState,
|
||||||
|
blockUpdater,
|
||||||
Optional<BlockHeader> maybeParentHeader =
|
|
||||||
blockchain.getBlockHeader(blockHeader.getParentHash());
|
|
||||||
|
|
||||||
Wei blobGasPrice =
|
|
||||||
maybeParentHeader
|
|
||||||
.map(
|
|
||||||
parentHeader ->
|
|
||||||
protocolSpec
|
|
||||||
.getFeeMarket()
|
|
||||||
.blobGasPricePerGas(
|
|
||||||
calculateExcessBlobGasForParent(protocolSpec, parentHeader)))
|
|
||||||
.orElse(Wei.ZERO);
|
|
||||||
|
|
||||||
final TransactionProcessingResult result =
|
|
||||||
transactionProcessor.processTransaction(
|
|
||||||
worldStateUpdater,
|
|
||||||
blockHeader,
|
|
||||||
transaction,
|
|
||||||
miningBeneficiary,
|
|
||||||
OperationTracer.NO_TRACING,
|
|
||||||
blockHashLookup,
|
|
||||||
true,
|
|
||||||
TransactionValidationParams.processingBlock(),
|
|
||||||
privateMetadataUpdater,
|
privateMetadataUpdater,
|
||||||
blobGasPrice);
|
blockHeader,
|
||||||
if (result.isInvalid()) {
|
blobGasPrice,
|
||||||
|
miningBeneficiary,
|
||||||
|
transaction,
|
||||||
|
i,
|
||||||
|
blockHashLookup);
|
||||||
|
if (transactionProcessingResult.isInvalid()) {
|
||||||
String errorMessage =
|
String errorMessage =
|
||||||
MessageFormat.format(
|
MessageFormat.format(
|
||||||
"Block processing error: transaction invalid {0}. Block {1} Transaction {2}",
|
"Block processing error: transaction invalid {0}. Block {1} Transaction {2}",
|
||||||
result.getValidationResult().getErrorMessage(),
|
transactionProcessingResult.getValidationResult().getErrorMessage(),
|
||||||
blockHeader.getHash().toHexString(),
|
blockHeader.getHash().toHexString(),
|
||||||
transaction.getHash().toHexString());
|
transaction.getHash().toHexString());
|
||||||
LOG.info(errorMessage);
|
LOG.info(errorMessage);
|
||||||
if (worldState instanceof BonsaiWorldState) {
|
if (worldState instanceof BonsaiWorldState) {
|
||||||
((BonsaiWorldStateUpdateAccumulator) worldStateUpdater).reset();
|
((BonsaiWorldStateUpdateAccumulator) blockUpdater).reset();
|
||||||
}
|
}
|
||||||
return new BlockProcessingResult(Optional.empty(), errorMessage);
|
return new BlockProcessingResult(Optional.empty(), errorMessage);
|
||||||
}
|
}
|
||||||
worldStateUpdater.commit();
|
|
||||||
|
|
||||||
currentGasUsed += transaction.getGasLimit() - result.getGasRemaining();
|
blockUpdater.commit();
|
||||||
|
|
||||||
|
currentGasUsed += transaction.getGasLimit() - transactionProcessingResult.getGasRemaining();
|
||||||
if (transaction.getVersionedHashes().isPresent()) {
|
if (transaction.getVersionedHashes().isPresent()) {
|
||||||
currentBlobGasUsed +=
|
currentBlobGasUsed +=
|
||||||
(transaction.getVersionedHashes().get().size() * CancunGasCalculator.BLOB_GAS_PER_BLOB);
|
(transaction.getVersionedHashes().get().size() * CancunGasCalculator.BLOB_GAS_PER_BLOB);
|
||||||
@@ -168,7 +179,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
|
|||||||
|
|
||||||
final TransactionReceipt transactionReceipt =
|
final TransactionReceipt transactionReceipt =
|
||||||
transactionReceiptFactory.create(
|
transactionReceiptFactory.create(
|
||||||
transaction.getType(), result, worldState, currentGasUsed);
|
transaction.getType(), transactionProcessingResult, worldState, currentGasUsed);
|
||||||
receipts.add(transactionReceipt);
|
receipts.add(transactionReceipt);
|
||||||
}
|
}
|
||||||
if (blockHeader.getBlobGasUsed().isPresent()
|
if (blockHeader.getBlobGasUsed().isPresent()
|
||||||
@@ -235,6 +246,41 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
|
|||||||
Optional.of(new BlockProcessingOutputs(worldState, receipts, maybeRequests)));
|
Optional.of(new BlockProcessingOutputs(worldState, receipts, maybeRequests)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Optional<PreprocessingContext> runBlockPreProcessing(
|
||||||
|
final MutableWorldState worldState,
|
||||||
|
final PrivateMetadataUpdater privateMetadataUpdater,
|
||||||
|
final BlockHeader blockHeader,
|
||||||
|
final List<Transaction> transactions,
|
||||||
|
final Address miningBeneficiary,
|
||||||
|
final BlockHashOperation.BlockHashLookup blockHashLookup,
|
||||||
|
final Wei blobGasPrice) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected TransactionProcessingResult getTransactionProcessingResult(
|
||||||
|
final Optional<PreprocessingContext> preProcessingContext,
|
||||||
|
final MutableWorldState worldState,
|
||||||
|
final WorldUpdater blockUpdater,
|
||||||
|
final PrivateMetadataUpdater privateMetadataUpdater,
|
||||||
|
final BlockHeader blockHeader,
|
||||||
|
final Wei blobGasPrice,
|
||||||
|
final Address miningBeneficiary,
|
||||||
|
final Transaction transaction,
|
||||||
|
final int location,
|
||||||
|
final BlockHashLookup blockHashLookup) {
|
||||||
|
return transactionProcessor.processTransaction(
|
||||||
|
blockUpdater,
|
||||||
|
blockHeader,
|
||||||
|
transaction,
|
||||||
|
miningBeneficiary,
|
||||||
|
OperationTracer.NO_TRACING,
|
||||||
|
blockHashLookup,
|
||||||
|
true,
|
||||||
|
TransactionValidationParams.processingBlock(),
|
||||||
|
privateMetadataUpdater,
|
||||||
|
blobGasPrice);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean hasAvailableBlockBudget(
|
protected boolean hasAvailableBlockBudget(
|
||||||
final BlockHeader blockHeader, final Transaction transaction, final long currentGasUsed) {
|
final BlockHeader blockHeader, final Transaction transaction, final long currentGasUsed) {
|
||||||
final long remainingGasBudget = blockHeader.getGasLimit() - currentGasUsed;
|
final long remainingGasBudget = blockHeader.getGasLimit() - currentGasUsed;
|
||||||
@@ -261,4 +307,7 @@ public abstract class AbstractBlockProcessor implements BlockProcessor {
|
|||||||
final BlockHeader header,
|
final BlockHeader header,
|
||||||
final List<BlockHeader> ommers,
|
final List<BlockHeader> ommers,
|
||||||
final boolean skipZeroBlockRewards);
|
final boolean skipZeroBlockRewards);
|
||||||
|
|
||||||
|
public interface PreprocessingContext {}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* Copyright contributors to Hyperledger 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.ethereum.mainnet;
|
||||||
|
|
||||||
|
import org.hyperledger.besu.ethereum.core.Transaction;
|
||||||
|
import org.hyperledger.besu.evm.account.Account;
|
||||||
|
import org.hyperledger.besu.evm.account.AccountState;
|
||||||
|
import org.hyperledger.besu.evm.account.MutableAccount;
|
||||||
|
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
|
||||||
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.tuweni.bytes.Bytes;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class AuthorityProcessor {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(AuthorityProcessor.class);
|
||||||
|
|
||||||
|
private final Optional<BigInteger> maybeChainId;
|
||||||
|
|
||||||
|
public AuthorityProcessor(final Optional<BigInteger> maybeChainId) {
|
||||||
|
this.maybeChainId = maybeChainId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addContractToAuthority(
|
||||||
|
final WorldUpdater worldUpdater,
|
||||||
|
final AuthorizedCodeService authorizedCodeService,
|
||||||
|
final Transaction transaction) {
|
||||||
|
|
||||||
|
transaction
|
||||||
|
.getAuthorizationList()
|
||||||
|
.get()
|
||||||
|
.forEach(
|
||||||
|
payload ->
|
||||||
|
payload
|
||||||
|
.authorizer()
|
||||||
|
.ifPresent(
|
||||||
|
authorityAddress -> {
|
||||||
|
LOG.trace("Set code authority: {}", authorityAddress);
|
||||||
|
|
||||||
|
if (maybeChainId.isPresent()
|
||||||
|
&& !payload.chainId().equals(BigInteger.ZERO)
|
||||||
|
&& !maybeChainId.get().equals(payload.chainId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Optional<MutableAccount> maybeAccount =
|
||||||
|
Optional.ofNullable(worldUpdater.getAccount(authorityAddress));
|
||||||
|
final long accountNonce =
|
||||||
|
maybeAccount.map(AccountState::getNonce).orElse(0L);
|
||||||
|
|
||||||
|
if (payload.nonce().isPresent()
|
||||||
|
&& !payload.nonce().get().equals(accountNonce)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (authorizedCodeService.hasAuthorizedCode(authorityAddress)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<Account> codeAccount =
|
||||||
|
Optional.ofNullable(worldUpdater.get(payload.address()));
|
||||||
|
final Bytes code;
|
||||||
|
if (codeAccount.isPresent()) {
|
||||||
|
code = codeAccount.get().getCode();
|
||||||
|
} else {
|
||||||
|
code = Bytes.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
authorizedCodeService.addAuthorizedCode(authorityAddress, code);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,7 @@ import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
|||||||
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
|
import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
|
||||||
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
|
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -54,16 +55,23 @@ public class ClassicProtocolSpecs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder classicRecoveryInitDefinition(
|
public static ProtocolSpecBuilder classicRecoveryInitDefinition(
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return MainnetProtocolSpecs.homesteadDefinition(evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return MainnetProtocolSpecs.homesteadDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.blockHeaderValidatorBuilder(
|
.blockHeaderValidatorBuilder(
|
||||||
feeMarket -> MainnetBlockHeaderValidator.createClassicValidator())
|
feeMarket -> MainnetBlockHeaderValidator.createClassicValidator())
|
||||||
.name("ClassicRecoveryInit");
|
.name("ClassicRecoveryInit");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder tangerineWhistleDefinition(
|
public static ProtocolSpecBuilder tangerineWhistleDefinition(
|
||||||
final Optional<BigInteger> chainId, final EvmConfiguration evmConfiguration) {
|
final Optional<BigInteger> chainId,
|
||||||
return MainnetProtocolSpecs.homesteadDefinition(evmConfiguration)
|
final EvmConfiguration evmConfiguration,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return MainnetProtocolSpecs.homesteadDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.isReplayProtectionSupported(true)
|
.isReplayProtectionSupported(true)
|
||||||
.gasCalculator(TangerineWhistleGasCalculator::new)
|
.gasCalculator(TangerineWhistleGasCalculator::new)
|
||||||
.transactionValidatorFactoryBuilder(
|
.transactionValidatorFactoryBuilder(
|
||||||
@@ -74,8 +82,12 @@ public class ClassicProtocolSpecs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder dieHardDefinition(
|
public static ProtocolSpecBuilder dieHardDefinition(
|
||||||
final Optional<BigInteger> chainId, final EvmConfiguration evmConfiguration) {
|
final Optional<BigInteger> chainId,
|
||||||
return tangerineWhistleDefinition(chainId, evmConfiguration)
|
final EvmConfiguration evmConfiguration,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return tangerineWhistleDefinition(
|
||||||
|
chainId, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.gasCalculator(DieHardGasCalculator::new)
|
.gasCalculator(DieHardGasCalculator::new)
|
||||||
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_PAUSED)
|
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_PAUSED)
|
||||||
.name("DieHard");
|
.name("DieHard");
|
||||||
@@ -84,8 +96,11 @@ public class ClassicProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder gothamDefinition(
|
public static ProtocolSpecBuilder gothamDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return dieHardDefinition(chainId, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return dieHardDefinition(
|
||||||
|
chainId, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.blockReward(MAX_BLOCK_REWARD)
|
.blockReward(MAX_BLOCK_REWARD)
|
||||||
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_DELAYED)
|
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_DELAYED)
|
||||||
.blockProcessorBuilder(
|
.blockProcessorBuilder(
|
||||||
@@ -109,8 +124,15 @@ public class ClassicProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder defuseDifficultyBombDefinition(
|
public static ProtocolSpecBuilder defuseDifficultyBombDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return gothamDefinition(chainId, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return gothamDefinition(
|
||||||
|
chainId,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_REMOVED)
|
.difficultyCalculator(ClassicDifficultyCalculators.DIFFICULTY_BOMB_REMOVED)
|
||||||
.transactionValidatorFactoryBuilder(
|
.transactionValidatorFactoryBuilder(
|
||||||
(evm, gasLimitCalculator, feeMarket) ->
|
(evm, gasLimitCalculator, feeMarket) ->
|
||||||
@@ -123,8 +145,15 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return gothamDefinition(chainId, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return gothamDefinition(
|
||||||
|
chainId,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.evmBuilder(MainnetEVMs::byzantium)
|
.evmBuilder(MainnetEVMs::byzantium)
|
||||||
.evmConfiguration(evmConfiguration)
|
.evmConfiguration(evmConfiguration)
|
||||||
.gasCalculator(SpuriousDragonGasCalculator::new)
|
.gasCalculator(SpuriousDragonGasCalculator::new)
|
||||||
@@ -163,8 +192,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return atlantisDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return atlantisDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.evmBuilder(MainnetEVMs::constantinople)
|
.evmBuilder(MainnetEVMs::constantinople)
|
||||||
.gasCalculator(PetersburgGasCalculator::new)
|
.gasCalculator(PetersburgGasCalculator::new)
|
||||||
.evmBuilder(MainnetEVMs::constantinople)
|
.evmBuilder(MainnetEVMs::constantinople)
|
||||||
@@ -176,8 +213,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return aghartaDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return aghartaDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(IstanbulGasCalculator::new)
|
.gasCalculator(IstanbulGasCalculator::new)
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, evmConfig) ->
|
(gasCalculator, evmConfig) ->
|
||||||
@@ -191,8 +236,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return phoenixDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return phoenixDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.blockHeaderValidatorBuilder(
|
.blockHeaderValidatorBuilder(
|
||||||
feeMarket ->
|
feeMarket ->
|
||||||
MainnetBlockHeaderValidator.createPgaBlockHeaderValidator(
|
MainnetBlockHeaderValidator.createPgaBlockHeaderValidator(
|
||||||
@@ -228,8 +281,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return thanosDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return thanosDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(BerlinGasCalculator::new)
|
.gasCalculator(BerlinGasCalculator::new)
|
||||||
.transactionValidatorFactoryBuilder(
|
.transactionValidatorFactoryBuilder(
|
||||||
(evm, gasLimitCalculator, feeMarket) ->
|
(evm, gasLimitCalculator, feeMarket) ->
|
||||||
@@ -250,8 +311,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return magnetoDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return magnetoDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(LondonGasCalculator::new)
|
.gasCalculator(LondonGasCalculator::new)
|
||||||
.contractCreationProcessorBuilder(
|
.contractCreationProcessorBuilder(
|
||||||
evm ->
|
evm ->
|
||||||
@@ -264,8 +333,16 @@ public class ClassicProtocolSpecs {
|
|||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return mystiqueDefinition(chainId, enableRevertReason, ecip1017EraRounds, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return mystiqueDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
// EIP-3860
|
// EIP-3860
|
||||||
.gasCalculator(ShanghaiGasCalculator::new)
|
.gasCalculator(ShanghaiGasCalculator::new)
|
||||||
// EIP-3855
|
// EIP-3855
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
|
|||||||
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
||||||
import org.hyperledger.besu.evm.MainnetEVMs;
|
import org.hyperledger.besu.evm.MainnetEVMs;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -30,10 +31,18 @@ public class LineaProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
return MainnetProtocolSpecs.londonDefinition(
|
return MainnetProtocolSpecs.londonDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
// some Linea evm opcodes behave differently.
|
// some Linea evm opcodes behave differently.
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, jdCacheConfig) ->
|
(gasCalculator, jdCacheConfig) ->
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.hyperledger.besu.ethereum.core.PrivacyParameters;
|
|||||||
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators;
|
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyCalculators;
|
||||||
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
|
import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -40,6 +41,8 @@ public class MainnetProtocolSchedule {
|
|||||||
* @param evmConfiguration how to configure the EVMs jumpdest cache
|
* @param evmConfiguration how to configure the EVMs jumpdest cache
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled
|
||||||
|
* @param metricsSystem A metricSystem instance to expose metrics in the underlying calls
|
||||||
* @return A configured mainnet protocol schedule
|
* @return A configured mainnet protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule fromConfig(
|
public static ProtocolSchedule fromConfig(
|
||||||
@@ -48,7 +51,9 @@ public class MainnetProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
|
if (FixedDifficultyCalculators.isFixedDifficultyInConfig(config)) {
|
||||||
return FixedDifficultyProtocolSchedule.create(
|
return FixedDifficultyProtocolSchedule.create(
|
||||||
config,
|
config,
|
||||||
@@ -56,7 +61,9 @@ public class MainnetProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
return new ProtocolScheduleBuilder(
|
return new ProtocolScheduleBuilder(
|
||||||
config,
|
config,
|
||||||
@@ -66,7 +73,9 @@ public class MainnetProtocolSchedule {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager)
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.createProtocolSchedule();
|
.createProtocolSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +88,7 @@ public class MainnetProtocolSchedule {
|
|||||||
* @param evmConfiguration how to configure the EVMs jumpdest cache
|
* @param evmConfiguration how to configure the EVMs jumpdest cache
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return A configured mainnet protocol schedule
|
* @return A configured mainnet protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule fromConfig(
|
public static ProtocolSchedule fromConfig(
|
||||||
@@ -86,14 +96,18 @@ public class MainnetProtocolSchedule {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return fromConfig(
|
return fromConfig(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,20 +118,25 @@ public class MainnetProtocolSchedule {
|
|||||||
* @param evmConfiguration size of
|
* @param evmConfiguration size of
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return A configured mainnet protocol schedule
|
* @return A configured mainnet protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule fromConfig(
|
public static ProtocolSchedule fromConfig(
|
||||||
final GenesisConfigOptions config,
|
final GenesisConfigOptions config,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return fromConfig(
|
return fromConfig(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,18 +146,23 @@ public class MainnetProtocolSchedule {
|
|||||||
* starting points
|
* starting points
|
||||||
* @param miningParameters the mining parameters
|
* @param miningParameters the mining parameters
|
||||||
* @param badBlockManager the cache to use to keep invalid blocks
|
* @param badBlockManager the cache to use to keep invalid blocks
|
||||||
|
* @param isParallelTxProcessingEnabled indicates whether parallel transaction is enabled.
|
||||||
* @return A configured mainnet protocol schedule
|
* @return A configured mainnet protocol schedule
|
||||||
*/
|
*/
|
||||||
public static ProtocolSchedule fromConfig(
|
public static ProtocolSchedule fromConfig(
|
||||||
final GenesisConfigOptions config,
|
final GenesisConfigOptions config,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return fromConfig(
|
return fromConfig(
|
||||||
config,
|
config,
|
||||||
PrivacyParameters.DEFAULT,
|
PrivacyParameters.DEFAULT,
|
||||||
false,
|
false,
|
||||||
EvmConfiguration.DEFAULT,
|
EvmConfiguration.DEFAULT,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.mainnet;
|
|||||||
import org.hyperledger.besu.config.GenesisConfigOptions;
|
import org.hyperledger.besu.config.GenesisConfigOptions;
|
||||||
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
import org.hyperledger.besu.ethereum.core.MiningParameters;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -29,118 +30,209 @@ public class MainnetProtocolSpecFactory {
|
|||||||
private final OptionalLong ecip1017EraRounds;
|
private final OptionalLong ecip1017EraRounds;
|
||||||
private final EvmConfiguration evmConfiguration;
|
private final EvmConfiguration evmConfiguration;
|
||||||
private final MiningParameters miningParameters;
|
private final MiningParameters miningParameters;
|
||||||
|
private final boolean isParallelTxProcessingEnabled;
|
||||||
|
private final MetricsSystem metricsSystem;
|
||||||
|
|
||||||
public MainnetProtocolSpecFactory(
|
public MainnetProtocolSpecFactory(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final OptionalLong ecip1017EraRounds,
|
final OptionalLong ecip1017EraRounds,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
this.chainId = chainId;
|
this.chainId = chainId;
|
||||||
this.isRevertReasonEnabled = isRevertReasonEnabled;
|
this.isRevertReasonEnabled = isRevertReasonEnabled;
|
||||||
this.ecip1017EraRounds = ecip1017EraRounds;
|
this.ecip1017EraRounds = ecip1017EraRounds;
|
||||||
this.evmConfiguration = evmConfiguration;
|
this.evmConfiguration = evmConfiguration;
|
||||||
this.miningParameters = miningParameters;
|
this.miningParameters = miningParameters;
|
||||||
|
this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled;
|
||||||
|
this.metricsSystem = metricsSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder frontierDefinition() {
|
public ProtocolSpecBuilder frontierDefinition() {
|
||||||
return MainnetProtocolSpecs.frontierDefinition(evmConfiguration);
|
return MainnetProtocolSpecs.frontierDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder homesteadDefinition() {
|
public ProtocolSpecBuilder homesteadDefinition() {
|
||||||
return MainnetProtocolSpecs.homesteadDefinition(evmConfiguration);
|
return MainnetProtocolSpecs.homesteadDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder daoRecoveryInitDefinition() {
|
public ProtocolSpecBuilder daoRecoveryInitDefinition() {
|
||||||
return MainnetProtocolSpecs.daoRecoveryInitDefinition(evmConfiguration);
|
return MainnetProtocolSpecs.daoRecoveryInitDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder daoRecoveryTransitionDefinition() {
|
public ProtocolSpecBuilder daoRecoveryTransitionDefinition() {
|
||||||
return MainnetProtocolSpecs.daoRecoveryTransitionDefinition(evmConfiguration);
|
return MainnetProtocolSpecs.daoRecoveryTransitionDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder tangerineWhistleDefinition() {
|
public ProtocolSpecBuilder tangerineWhistleDefinition() {
|
||||||
return MainnetProtocolSpecs.tangerineWhistleDefinition(evmConfiguration);
|
return MainnetProtocolSpecs.tangerineWhistleDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder spuriousDragonDefinition() {
|
public ProtocolSpecBuilder spuriousDragonDefinition() {
|
||||||
return MainnetProtocolSpecs.spuriousDragonDefinition(chainId, evmConfiguration);
|
return MainnetProtocolSpecs.spuriousDragonDefinition(
|
||||||
|
chainId, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder byzantiumDefinition() {
|
public ProtocolSpecBuilder byzantiumDefinition() {
|
||||||
return MainnetProtocolSpecs.byzantiumDefinition(
|
return MainnetProtocolSpecs.byzantiumDefinition(
|
||||||
chainId, isRevertReasonEnabled, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder constantinopleDefinition() {
|
public ProtocolSpecBuilder constantinopleDefinition() {
|
||||||
return MainnetProtocolSpecs.constantinopleDefinition(
|
return MainnetProtocolSpecs.constantinopleDefinition(
|
||||||
chainId, isRevertReasonEnabled, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder petersburgDefinition() {
|
public ProtocolSpecBuilder petersburgDefinition() {
|
||||||
return MainnetProtocolSpecs.petersburgDefinition(
|
return MainnetProtocolSpecs.petersburgDefinition(
|
||||||
chainId, isRevertReasonEnabled, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder istanbulDefinition() {
|
public ProtocolSpecBuilder istanbulDefinition() {
|
||||||
return MainnetProtocolSpecs.istanbulDefinition(
|
return MainnetProtocolSpecs.istanbulDefinition(
|
||||||
chainId, isRevertReasonEnabled, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder muirGlacierDefinition() {
|
public ProtocolSpecBuilder muirGlacierDefinition() {
|
||||||
return MainnetProtocolSpecs.muirGlacierDefinition(
|
return MainnetProtocolSpecs.muirGlacierDefinition(
|
||||||
chainId, isRevertReasonEnabled, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder berlinDefinition() {
|
public ProtocolSpecBuilder berlinDefinition() {
|
||||||
return MainnetProtocolSpecs.berlinDefinition(chainId, isRevertReasonEnabled, evmConfiguration);
|
return MainnetProtocolSpecs.berlinDefinition(
|
||||||
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder londonDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder londonDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.londonDefinition(
|
return MainnetProtocolSpecs.londonDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder arrowGlacierDefinition(
|
public ProtocolSpecBuilder arrowGlacierDefinition(
|
||||||
final GenesisConfigOptions genesisConfigOptions) {
|
final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.arrowGlacierDefinition(
|
return MainnetProtocolSpecs.arrowGlacierDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder grayGlacierDefinition(
|
public ProtocolSpecBuilder grayGlacierDefinition(
|
||||||
final GenesisConfigOptions genesisConfigOptions) {
|
final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.grayGlacierDefinition(
|
return MainnetProtocolSpecs.grayGlacierDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder parisDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.parisDefinition(
|
return MainnetProtocolSpecs.parisDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder shanghaiDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.shanghaiDefinition(
|
return MainnetProtocolSpecs.shanghaiDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder cancunDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.cancunDefinition(
|
return MainnetProtocolSpecs.cancunDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder cancunEOFDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder cancunEOFDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.cancunEOFDefinition(
|
return MainnetProtocolSpecs.cancunEOFDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder pragueDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.pragueDefinition(
|
return MainnetProtocolSpecs.pragueDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder pragueEOFDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder pragueEOFDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.pragueEOFDefinition(
|
return MainnetProtocolSpecs.pragueEOFDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,7 +248,13 @@ public class MainnetProtocolSpecFactory {
|
|||||||
*/
|
*/
|
||||||
public ProtocolSpecBuilder futureEipsDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
public ProtocolSpecBuilder futureEipsDefinition(final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.futureEipsDefinition(
|
return MainnetProtocolSpecs.futureEipsDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,58 +270,101 @@ public class MainnetProtocolSpecFactory {
|
|||||||
public ProtocolSpecBuilder experimentalEipsDefinition(
|
public ProtocolSpecBuilder experimentalEipsDefinition(
|
||||||
final GenesisConfigOptions genesisConfigOptions) {
|
final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return MainnetProtocolSpecs.experimentalEipsDefinition(
|
return MainnetProtocolSpecs.experimentalEipsDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Classic Protocol Specs
|
// Classic Protocol Specs
|
||||||
public ProtocolSpecBuilder dieHardDefinition() {
|
public ProtocolSpecBuilder dieHardDefinition() {
|
||||||
return ClassicProtocolSpecs.dieHardDefinition(chainId, evmConfiguration);
|
return ClassicProtocolSpecs.dieHardDefinition(
|
||||||
|
chainId, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder gothamDefinition() {
|
public ProtocolSpecBuilder gothamDefinition() {
|
||||||
return ClassicProtocolSpecs.gothamDefinition(chainId, ecip1017EraRounds, evmConfiguration);
|
return ClassicProtocolSpecs.gothamDefinition(
|
||||||
|
chainId, ecip1017EraRounds, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder defuseDifficultyBombDefinition() {
|
public ProtocolSpecBuilder defuseDifficultyBombDefinition() {
|
||||||
return ClassicProtocolSpecs.defuseDifficultyBombDefinition(
|
return ClassicProtocolSpecs.defuseDifficultyBombDefinition(
|
||||||
chainId, ecip1017EraRounds, evmConfiguration);
|
chainId, ecip1017EraRounds, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder atlantisDefinition() {
|
public ProtocolSpecBuilder atlantisDefinition() {
|
||||||
return ClassicProtocolSpecs.atlantisDefinition(
|
return ClassicProtocolSpecs.atlantisDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder aghartaDefinition() {
|
public ProtocolSpecBuilder aghartaDefinition() {
|
||||||
return ClassicProtocolSpecs.aghartaDefinition(
|
return ClassicProtocolSpecs.aghartaDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder phoenixDefinition() {
|
public ProtocolSpecBuilder phoenixDefinition() {
|
||||||
return ClassicProtocolSpecs.phoenixDefinition(
|
return ClassicProtocolSpecs.phoenixDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder thanosDefinition() {
|
public ProtocolSpecBuilder thanosDefinition() {
|
||||||
return ClassicProtocolSpecs.thanosDefinition(
|
return ClassicProtocolSpecs.thanosDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder magnetoDefinition() {
|
public ProtocolSpecBuilder magnetoDefinition() {
|
||||||
return ClassicProtocolSpecs.magnetoDefinition(
|
return ClassicProtocolSpecs.magnetoDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder mystiqueDefinition() {
|
public ProtocolSpecBuilder mystiqueDefinition() {
|
||||||
return ClassicProtocolSpecs.mystiqueDefinition(
|
return ClassicProtocolSpecs.mystiqueDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSpecBuilder spiralDefinition() {
|
public ProtocolSpecBuilder spiralDefinition() {
|
||||||
return ClassicProtocolSpecs.spiralDefinition(
|
return ClassicProtocolSpecs.spiralDefinition(
|
||||||
chainId, isRevertReasonEnabled, ecip1017EraRounds, evmConfiguration);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
ecip1017EraRounds,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -233,6 +374,12 @@ public class MainnetProtocolSpecFactory {
|
|||||||
public ProtocolSpecBuilder lineaOpCodesDefinition(
|
public ProtocolSpecBuilder lineaOpCodesDefinition(
|
||||||
final GenesisConfigOptions genesisConfigOptions) {
|
final GenesisConfigOptions genesisConfigOptions) {
|
||||||
return LineaProtocolSpecs.lineaOpCodesDefinition(
|
return LineaProtocolSpecs.lineaOpCodesDefinition(
|
||||||
chainId, isRevertReasonEnabled, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
isRevertReasonEnabled,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.hyperledger.besu.ethereum.mainnet.blockhash.FrontierBlockHashProcesso
|
|||||||
import org.hyperledger.besu.ethereum.mainnet.blockhash.PragueBlockHashProcessor;
|
import org.hyperledger.besu.ethereum.mainnet.blockhash.PragueBlockHashProcessor;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.BaseFeeMarket;
|
||||||
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
|
||||||
|
import org.hyperledger.besu.ethereum.mainnet.parallelization.MainnetParallelBlockProcessor;
|
||||||
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
|
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionProcessor;
|
||||||
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
|
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
|
||||||
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
import org.hyperledger.besu.ethereum.privacy.storage.PrivateMetadataUpdater;
|
||||||
@@ -67,6 +68,7 @@ import org.hyperledger.besu.evm.processor.ContractCreationProcessor;
|
|||||||
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
|
import org.hyperledger.besu.evm.processor.MessageCallProcessor;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldState;
|
import org.hyperledger.besu.evm.worldstate.WorldState;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -101,7 +103,10 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
|
|
||||||
private MainnetProtocolSpecs() {}
|
private MainnetProtocolSpecs() {}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder frontierDefinition(final EvmConfiguration evmConfiguration) {
|
public static ProtocolSpecBuilder frontierDefinition(
|
||||||
|
final EvmConfiguration evmConfiguration,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return new ProtocolSpecBuilder()
|
return new ProtocolSpecBuilder()
|
||||||
.gasCalculator(FrontierGasCalculator::new)
|
.gasCalculator(FrontierGasCalculator::new)
|
||||||
.gasLimitCalculatorBuilder(feeMarket -> new FrontierTargetingGasLimitCalculator())
|
.gasLimitCalculatorBuilder(feeMarket -> new FrontierTargetingGasLimitCalculator())
|
||||||
@@ -152,7 +157,10 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
.transactionReceiptFactory(MainnetProtocolSpecs::frontierTransactionReceiptFactory)
|
.transactionReceiptFactory(MainnetProtocolSpecs::frontierTransactionReceiptFactory)
|
||||||
.blockReward(FRONTIER_BLOCK_REWARD)
|
.blockReward(FRONTIER_BLOCK_REWARD)
|
||||||
.skipZeroBlockRewards(false)
|
.skipZeroBlockRewards(false)
|
||||||
.blockProcessorBuilder(MainnetBlockProcessor::new)
|
.blockProcessorBuilder(
|
||||||
|
isParallelTxProcessingEnabled
|
||||||
|
? new MainnetParallelBlockProcessor.ParallelBlockProcessorBuilder(metricsSystem)
|
||||||
|
: MainnetBlockProcessor::new)
|
||||||
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder())
|
.blockValidatorBuilder(MainnetProtocolSpecs.blockValidatorBuilder())
|
||||||
.blockImporterBuilder(MainnetBlockImporter::new)
|
.blockImporterBuilder(MainnetBlockImporter::new)
|
||||||
.blockHeaderFunctions(new MainnetBlockHeaderFunctions())
|
.blockHeaderFunctions(new MainnetBlockHeaderFunctions())
|
||||||
@@ -173,8 +181,11 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
return MainnetBlockValidator::new;
|
return MainnetBlockValidator::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder homesteadDefinition(final EvmConfiguration evmConfiguration) {
|
public static ProtocolSpecBuilder homesteadDefinition(
|
||||||
return frontierDefinition(evmConfiguration)
|
final EvmConfiguration evmConfiguration,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return frontierDefinition(evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.gasCalculator(HomesteadGasCalculator::new)
|
.gasCalculator(HomesteadGasCalculator::new)
|
||||||
.evmBuilder(MainnetEVMs::homestead)
|
.evmBuilder(MainnetEVMs::homestead)
|
||||||
.contractCreationProcessorBuilder(
|
.contractCreationProcessorBuilder(
|
||||||
@@ -190,8 +201,10 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder daoRecoveryInitDefinition(
|
public static ProtocolSpecBuilder daoRecoveryInitDefinition(
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return homesteadDefinition(evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return homesteadDefinition(evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createDaoValidator())
|
.blockHeaderValidatorBuilder(feeMarket -> MainnetBlockHeaderValidator.createDaoValidator())
|
||||||
.blockProcessorBuilder(
|
.blockProcessorBuilder(
|
||||||
(transactionProcessor,
|
(transactionProcessor,
|
||||||
@@ -201,33 +214,53 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
skipZeroBlockRewards,
|
skipZeroBlockRewards,
|
||||||
protocolSchedule) ->
|
protocolSchedule) ->
|
||||||
new DaoBlockProcessor(
|
new DaoBlockProcessor(
|
||||||
new MainnetBlockProcessor(
|
isParallelTxProcessingEnabled
|
||||||
transactionProcessor,
|
? new MainnetParallelBlockProcessor(
|
||||||
transactionReceiptFactory,
|
transactionProcessor,
|
||||||
blockReward,
|
transactionReceiptFactory,
|
||||||
miningBeneficiaryCalculator,
|
blockReward,
|
||||||
skipZeroBlockRewards,
|
miningBeneficiaryCalculator,
|
||||||
protocolSchedule)))
|
skipZeroBlockRewards,
|
||||||
|
protocolSchedule,
|
||||||
|
metricsSystem)
|
||||||
|
: new MainnetBlockProcessor(
|
||||||
|
transactionProcessor,
|
||||||
|
transactionReceiptFactory,
|
||||||
|
blockReward,
|
||||||
|
miningBeneficiaryCalculator,
|
||||||
|
skipZeroBlockRewards,
|
||||||
|
protocolSchedule)))
|
||||||
.name("DaoRecoveryInit");
|
.name("DaoRecoveryInit");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder daoRecoveryTransitionDefinition(
|
public static ProtocolSpecBuilder daoRecoveryTransitionDefinition(
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return daoRecoveryInitDefinition(evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
.blockProcessorBuilder(MainnetBlockProcessor::new)
|
final MetricsSystem metricsSystem) {
|
||||||
|
return daoRecoveryInitDefinition(evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
|
.blockProcessorBuilder(
|
||||||
|
isParallelTxProcessingEnabled
|
||||||
|
? new MainnetParallelBlockProcessor.ParallelBlockProcessorBuilder(metricsSystem)
|
||||||
|
: MainnetBlockProcessor::new)
|
||||||
.name("DaoRecoveryTransition");
|
.name("DaoRecoveryTransition");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder tangerineWhistleDefinition(
|
public static ProtocolSpecBuilder tangerineWhistleDefinition(
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return homesteadDefinition(evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return homesteadDefinition(evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.gasCalculator(TangerineWhistleGasCalculator::new)
|
.gasCalculator(TangerineWhistleGasCalculator::new)
|
||||||
.name("TangerineWhistle");
|
.name("TangerineWhistle");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtocolSpecBuilder spuriousDragonDefinition(
|
public static ProtocolSpecBuilder spuriousDragonDefinition(
|
||||||
final Optional<BigInteger> chainId, final EvmConfiguration evmConfiguration) {
|
final Optional<BigInteger> chainId,
|
||||||
return tangerineWhistleDefinition(evmConfiguration)
|
final EvmConfiguration evmConfiguration,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return tangerineWhistleDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.isReplayProtectionSupported(true)
|
.isReplayProtectionSupported(true)
|
||||||
.gasCalculator(SpuriousDragonGasCalculator::new)
|
.gasCalculator(SpuriousDragonGasCalculator::new)
|
||||||
.skipZeroBlockRewards(true)
|
.skipZeroBlockRewards(true)
|
||||||
@@ -271,8 +304,11 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder byzantiumDefinition(
|
public static ProtocolSpecBuilder byzantiumDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return spuriousDragonDefinition(chainId, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return spuriousDragonDefinition(
|
||||||
|
chainId, evmConfiguration, isParallelTxProcessingEnabled, metricsSystem)
|
||||||
.gasCalculator(ByzantiumGasCalculator::new)
|
.gasCalculator(ByzantiumGasCalculator::new)
|
||||||
.evmBuilder(MainnetEVMs::byzantium)
|
.evmBuilder(MainnetEVMs::byzantium)
|
||||||
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium)
|
.precompileContractRegistryBuilder(MainnetPrecompiledContractRegistries::byzantium)
|
||||||
@@ -301,8 +337,15 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder constantinopleDefinition(
|
public static ProtocolSpecBuilder constantinopleDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return byzantiumDefinition(chainId, enableRevertReason, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return byzantiumDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.difficultyCalculator(MainnetDifficultyCalculators.CONSTANTINOPLE)
|
.difficultyCalculator(MainnetDifficultyCalculators.CONSTANTINOPLE)
|
||||||
.gasCalculator(ConstantinopleGasCalculator::new)
|
.gasCalculator(ConstantinopleGasCalculator::new)
|
||||||
.evmBuilder(MainnetEVMs::constantinople)
|
.evmBuilder(MainnetEVMs::constantinople)
|
||||||
@@ -313,8 +356,15 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder petersburgDefinition(
|
public static ProtocolSpecBuilder petersburgDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return constantinopleDefinition(chainId, enableRevertReason, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return constantinopleDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(PetersburgGasCalculator::new)
|
.gasCalculator(PetersburgGasCalculator::new)
|
||||||
.name("Petersburg");
|
.name("Petersburg");
|
||||||
}
|
}
|
||||||
@@ -322,8 +372,15 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
public static ProtocolSpecBuilder istanbulDefinition(
|
public static ProtocolSpecBuilder istanbulDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return petersburgDefinition(chainId, enableRevertReason, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return petersburgDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(IstanbulGasCalculator::new)
|
.gasCalculator(IstanbulGasCalculator::new)
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, jdCacheConfig) ->
|
(gasCalculator, jdCacheConfig) ->
|
||||||
@@ -344,8 +401,15 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
static ProtocolSpecBuilder muirGlacierDefinition(
|
static ProtocolSpecBuilder muirGlacierDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return istanbulDefinition(chainId, enableRevertReason, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return istanbulDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.difficultyCalculator(MainnetDifficultyCalculators.MUIR_GLACIER)
|
.difficultyCalculator(MainnetDifficultyCalculators.MUIR_GLACIER)
|
||||||
.name("MuirGlacier");
|
.name("MuirGlacier");
|
||||||
}
|
}
|
||||||
@@ -353,8 +417,15 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
static ProtocolSpecBuilder berlinDefinition(
|
static ProtocolSpecBuilder berlinDefinition(
|
||||||
final Optional<BigInteger> chainId,
|
final Optional<BigInteger> chainId,
|
||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final EvmConfiguration evmConfiguration) {
|
final EvmConfiguration evmConfiguration,
|
||||||
return muirGlacierDefinition(chainId, enableRevertReason, evmConfiguration)
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
return muirGlacierDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.gasCalculator(BerlinGasCalculator::new)
|
.gasCalculator(BerlinGasCalculator::new)
|
||||||
.transactionValidatorFactoryBuilder(
|
.transactionValidatorFactoryBuilder(
|
||||||
(evm, gasLimitCalculator, feeMarket) ->
|
(evm, gasLimitCalculator, feeMarket) ->
|
||||||
@@ -376,7 +447,9 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
final long londonForkBlockNumber =
|
final long londonForkBlockNumber =
|
||||||
genesisConfigOptions.getLondonBlockNumber().orElse(Long.MAX_VALUE);
|
genesisConfigOptions.getLondonBlockNumber().orElse(Long.MAX_VALUE);
|
||||||
final BaseFeeMarket londonFeeMarket;
|
final BaseFeeMarket londonFeeMarket;
|
||||||
@@ -390,7 +463,12 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
londonFeeMarket =
|
londonFeeMarket =
|
||||||
FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
|
FeeMarket.london(londonForkBlockNumber, genesisConfigOptions.getBaseFeePerGas());
|
||||||
}
|
}
|
||||||
return berlinDefinition(chainId, enableRevertReason, evmConfiguration)
|
return berlinDefinition(
|
||||||
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
evmConfiguration,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.feeMarket(londonFeeMarket)
|
.feeMarket(londonFeeMarket)
|
||||||
.gasCalculator(LondonGasCalculator::new)
|
.gasCalculator(LondonGasCalculator::new)
|
||||||
.gasLimitCalculatorBuilder(
|
.gasLimitCalculatorBuilder(
|
||||||
@@ -455,9 +533,17 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return londonDefinition(
|
return londonDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER)
|
.difficultyCalculator(MainnetDifficultyCalculators.ARROW_GLACIER)
|
||||||
.name("ArrowGlacier");
|
.name("ArrowGlacier");
|
||||||
}
|
}
|
||||||
@@ -467,9 +553,17 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return arrowGlacierDefinition(
|
return arrowGlacierDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER)
|
.difficultyCalculator(MainnetDifficultyCalculators.GRAY_GLACIER)
|
||||||
.name("GrayGlacier");
|
.name("GrayGlacier");
|
||||||
}
|
}
|
||||||
@@ -479,10 +573,18 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
return grayGlacierDefinition(
|
return grayGlacierDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, jdCacheConfig) ->
|
(gasCalculator, jdCacheConfig) ->
|
||||||
MainnetEVMs.paris(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
|
MainnetEVMs.paris(gasCalculator, chainId.orElse(BigInteger.ZERO), evmConfiguration))
|
||||||
@@ -499,9 +601,17 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return parisDefinition(
|
return parisDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
// gas calculator has new code to support EIP-3860 limit and meter initcode
|
// gas calculator has new code to support EIP-3860 limit and meter initcode
|
||||||
.gasCalculator(ShanghaiGasCalculator::new)
|
.gasCalculator(ShanghaiGasCalculator::new)
|
||||||
// EVM has a new operation for EIP-3855 PUSH0 instruction
|
// EVM has a new operation for EIP-3855 PUSH0 instruction
|
||||||
@@ -550,7 +660,9 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L);
|
final long londonForkBlockNumber = genesisConfigOptions.getLondonBlockNumber().orElse(0L);
|
||||||
final BaseFeeMarket cancunFeeMarket;
|
final BaseFeeMarket cancunFeeMarket;
|
||||||
if (genesisConfigOptions.isZeroBaseFee()) {
|
if (genesisConfigOptions.isZeroBaseFee()) {
|
||||||
@@ -565,7 +677,13 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return shanghaiDefinition(
|
return shanghaiDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.feeMarket(cancunFeeMarket)
|
.feeMarket(cancunFeeMarket)
|
||||||
// gas calculator for EIP-4844 blob gas
|
// gas calculator for EIP-4844 blob gas
|
||||||
.gasCalculator(CancunGasCalculator::new)
|
.gasCalculator(CancunGasCalculator::new)
|
||||||
@@ -595,7 +713,8 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
true,
|
true,
|
||||||
evmConfiguration.evmStackSize(),
|
evmConfiguration.evmStackSize(),
|
||||||
feeMarket,
|
feeMarket,
|
||||||
CoinbaseFeePriceCalculator.eip1559()))
|
CoinbaseFeePriceCalculator.eip1559(),
|
||||||
|
new AuthorityProcessor(chainId)))
|
||||||
// change to check for max blob gas per block for EIP-4844
|
// change to check for max blob gas per block for EIP-4844
|
||||||
.transactionValidatorFactoryBuilder(
|
.transactionValidatorFactoryBuilder(
|
||||||
(evm, gasLimitCalculator, feeMarket) ->
|
(evm, gasLimitCalculator, feeMarket) ->
|
||||||
@@ -622,11 +741,19 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
ProtocolSpecBuilder protocolSpecBuilder =
|
ProtocolSpecBuilder protocolSpecBuilder =
|
||||||
cancunDefinition(
|
cancunDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("CancunEOF");
|
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("CancunEOF");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,14 +762,22 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
final Address depositContractAddress =
|
final Address depositContractAddress =
|
||||||
genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);
|
genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);
|
||||||
|
|
||||||
return cancunDefinition(
|
return cancunDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
// EIP-3074 AUTH and AUTHCALL gas
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
|
// EIP-3074 AUTH and AUTCALL gas
|
||||||
.gasCalculator(PragueGasCalculator::new)
|
.gasCalculator(PragueGasCalculator::new)
|
||||||
// EIP-3074 AUTH and AUTHCALL
|
// EIP-3074 AUTH and AUTHCALL
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
@@ -658,6 +793,23 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
// EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests
|
// EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests
|
||||||
.requestProcessorCoordinator(pragueRequestsProcessors(depositContractAddress))
|
.requestProcessorCoordinator(pragueRequestsProcessors(depositContractAddress))
|
||||||
|
|
||||||
|
// change to accept EIP-7702 transactions
|
||||||
|
.transactionValidatorFactoryBuilder(
|
||||||
|
(evm, gasLimitCalculator, feeMarket) ->
|
||||||
|
new TransactionValidatorFactory(
|
||||||
|
evm.getGasCalculator(),
|
||||||
|
gasLimitCalculator,
|
||||||
|
feeMarket,
|
||||||
|
true,
|
||||||
|
chainId,
|
||||||
|
Set.of(
|
||||||
|
TransactionType.FRONTIER,
|
||||||
|
TransactionType.ACCESS_LIST,
|
||||||
|
TransactionType.EIP1559,
|
||||||
|
TransactionType.BLOB,
|
||||||
|
TransactionType.SET_CODE),
|
||||||
|
evm.getEvmVersion().getMaxInitcodeSize()))
|
||||||
|
|
||||||
// EIP-2935 Blockhash processor
|
// EIP-2935 Blockhash processor
|
||||||
.blockHashProcessor(new PragueBlockHashProcessor())
|
.blockHashProcessor(new PragueBlockHashProcessor())
|
||||||
.name("Prague");
|
.name("Prague");
|
||||||
@@ -668,11 +820,19 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
ProtocolSpecBuilder protocolSpecBuilder =
|
ProtocolSpecBuilder protocolSpecBuilder =
|
||||||
pragueDefinition(
|
pragueDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters);
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("PragueEOF");
|
return addEOF(chainId, evmConfiguration, protocolSpecBuilder).name("PragueEOF");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,9 +864,17 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
return pragueEOFDefinition(
|
return pragueEOFDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
// Use Future EIP configured EVM
|
// Use Future EIP configured EVM
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, jdCacheConfig) ->
|
(gasCalculator, jdCacheConfig) ->
|
||||||
@@ -731,10 +899,18 @@ public abstract class MainnetProtocolSpecs {
|
|||||||
final boolean enableRevertReason,
|
final boolean enableRevertReason,
|
||||||
final GenesisConfigOptions genesisConfigOptions,
|
final GenesisConfigOptions genesisConfigOptions,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters) {
|
final MiningParameters miningParameters,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
|
|
||||||
return futureEipsDefinition(
|
return futureEipsDefinition(
|
||||||
chainId, enableRevertReason, genesisConfigOptions, evmConfiguration, miningParameters)
|
chainId,
|
||||||
|
enableRevertReason,
|
||||||
|
genesisConfigOptions,
|
||||||
|
evmConfiguration,
|
||||||
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem)
|
||||||
.evmBuilder(
|
.evmBuilder(
|
||||||
(gasCalculator, jdCacheConfig) ->
|
(gasCalculator, jdCacheConfig) ->
|
||||||
MainnetEVMs.experimentalEips(
|
MainnetEVMs.experimentalEips(
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import org.hyperledger.besu.evm.frame.MessageFrame;
|
|||||||
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
|
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
|
||||||
import org.hyperledger.besu.evm.processor.AbstractMessageProcessor;
|
import org.hyperledger.besu.evm.processor.AbstractMessageProcessor;
|
||||||
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
import org.hyperledger.besu.evm.tracing.OperationTracer;
|
||||||
|
import org.hyperledger.besu.evm.worldstate.AuthorizedCodeService;
|
||||||
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
import org.hyperledger.besu.evm.worldstate.WorldUpdater;
|
||||||
|
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
@@ -80,6 +81,8 @@ public class MainnetTransactionProcessor {
|
|||||||
protected final FeeMarket feeMarket;
|
protected final FeeMarket feeMarket;
|
||||||
private final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator;
|
private final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator;
|
||||||
|
|
||||||
|
private final Optional<AuthorityProcessor> maybeAuthorityProcessor;
|
||||||
|
|
||||||
public MainnetTransactionProcessor(
|
public MainnetTransactionProcessor(
|
||||||
final GasCalculator gasCalculator,
|
final GasCalculator gasCalculator,
|
||||||
final TransactionValidatorFactory transactionValidatorFactory,
|
final TransactionValidatorFactory transactionValidatorFactory,
|
||||||
@@ -90,6 +93,30 @@ public class MainnetTransactionProcessor {
|
|||||||
final int maxStackSize,
|
final int maxStackSize,
|
||||||
final FeeMarket feeMarket,
|
final FeeMarket feeMarket,
|
||||||
final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator) {
|
final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator) {
|
||||||
|
this(
|
||||||
|
gasCalculator,
|
||||||
|
transactionValidatorFactory,
|
||||||
|
contractCreationProcessor,
|
||||||
|
messageCallProcessor,
|
||||||
|
clearEmptyAccounts,
|
||||||
|
warmCoinbase,
|
||||||
|
maxStackSize,
|
||||||
|
feeMarket,
|
||||||
|
coinbaseFeePriceCalculator,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainnetTransactionProcessor(
|
||||||
|
final GasCalculator gasCalculator,
|
||||||
|
final TransactionValidatorFactory transactionValidatorFactory,
|
||||||
|
final AbstractMessageProcessor contractCreationProcessor,
|
||||||
|
final AbstractMessageProcessor messageCallProcessor,
|
||||||
|
final boolean clearEmptyAccounts,
|
||||||
|
final boolean warmCoinbase,
|
||||||
|
final int maxStackSize,
|
||||||
|
final FeeMarket feeMarket,
|
||||||
|
final CoinbaseFeePriceCalculator coinbaseFeePriceCalculator,
|
||||||
|
final AuthorityProcessor maybeAuthorityProcessor) {
|
||||||
this.gasCalculator = gasCalculator;
|
this.gasCalculator = gasCalculator;
|
||||||
this.transactionValidatorFactory = transactionValidatorFactory;
|
this.transactionValidatorFactory = transactionValidatorFactory;
|
||||||
this.contractCreationProcessor = contractCreationProcessor;
|
this.contractCreationProcessor = contractCreationProcessor;
|
||||||
@@ -99,6 +126,7 @@ public class MainnetTransactionProcessor {
|
|||||||
this.maxStackSize = maxStackSize;
|
this.maxStackSize = maxStackSize;
|
||||||
this.feeMarket = feeMarket;
|
this.feeMarket = feeMarket;
|
||||||
this.coinbaseFeePriceCalculator = coinbaseFeePriceCalculator;
|
this.coinbaseFeePriceCalculator = coinbaseFeePriceCalculator;
|
||||||
|
this.maybeAuthorityProcessor = Optional.ofNullable(maybeAuthorityProcessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -259,6 +287,8 @@ public class MainnetTransactionProcessor {
|
|||||||
final PrivateMetadataUpdater privateMetadataUpdater,
|
final PrivateMetadataUpdater privateMetadataUpdater,
|
||||||
final Wei blobGasPrice) {
|
final Wei blobGasPrice) {
|
||||||
try {
|
try {
|
||||||
|
final AuthorizedCodeService authorizedCodeService = new AuthorizedCodeService();
|
||||||
|
worldState.setAuthorizedCodeService(authorizedCodeService);
|
||||||
final var transactionValidator = transactionValidatorFactory.get();
|
final var transactionValidator = transactionValidatorFactory.get();
|
||||||
LOG.trace("Starting execution of {}", transaction);
|
LOG.trace("Starting execution of {}", transaction);
|
||||||
ValidationResult<TransactionInvalidReason> validationResult =
|
ValidationResult<TransactionInvalidReason> validationResult =
|
||||||
@@ -332,15 +362,19 @@ public class MainnetTransactionProcessor {
|
|||||||
transaction.getPayload(), transaction.isContractCreation());
|
transaction.getPayload(), transaction.isContractCreation());
|
||||||
final long accessListGas =
|
final long accessListGas =
|
||||||
gasCalculator.accessListGasCost(accessListEntries.size(), accessListStorageCount);
|
gasCalculator.accessListGasCost(accessListEntries.size(), accessListStorageCount);
|
||||||
final long gasAvailable = transaction.getGasLimit() - intrinsicGas - accessListGas;
|
final long setCodeGas = gasCalculator.setCodeListGasCost(transaction.authorizationListSize());
|
||||||
|
final long gasAvailable =
|
||||||
|
transaction.getGasLimit() - intrinsicGas - accessListGas - setCodeGas;
|
||||||
LOG.trace(
|
LOG.trace(
|
||||||
"Gas available for execution {} = {} - {} - {} (limit - intrinsic - accessList)",
|
"Gas available for execution {} = {} - {} - {} - {} (limit - intrinsic - accessList - setCode)",
|
||||||
gasAvailable,
|
gasAvailable,
|
||||||
transaction.getGasLimit(),
|
transaction.getGasLimit(),
|
||||||
intrinsicGas,
|
intrinsicGas,
|
||||||
accessListGas);
|
accessListGas,
|
||||||
|
setCodeGas);
|
||||||
|
|
||||||
final WorldUpdater worldUpdater = worldState.updater();
|
final WorldUpdater worldUpdater = worldState.updater();
|
||||||
|
worldUpdater.setAuthorizedCodeService(authorizedCodeService);
|
||||||
final ImmutableMap.Builder<String, Object> contextVariablesBuilder =
|
final ImmutableMap.Builder<String, Object> contextVariablesBuilder =
|
||||||
ImmutableMap.<String, Object>builder()
|
ImmutableMap.<String, Object>builder()
|
||||||
.put(KEY_IS_PERSISTING_PRIVATE_STATE, isPersistingPrivateState)
|
.put(KEY_IS_PERSISTING_PRIVATE_STATE, isPersistingPrivateState)
|
||||||
@@ -374,6 +408,15 @@ public class MainnetTransactionProcessor {
|
|||||||
if (transaction.getVersionedHashes().isPresent()) {
|
if (transaction.getVersionedHashes().isPresent()) {
|
||||||
commonMessageFrameBuilder.versionedHashes(
|
commonMessageFrameBuilder.versionedHashes(
|
||||||
Optional.of(transaction.getVersionedHashes().get().stream().toList()));
|
Optional.of(transaction.getVersionedHashes().get().stream().toList()));
|
||||||
|
} else if (transaction.getAuthorizationList().isPresent()) {
|
||||||
|
if (maybeAuthorityProcessor.isEmpty()) {
|
||||||
|
throw new RuntimeException("Authority processor is required for 7702 transactions");
|
||||||
|
}
|
||||||
|
|
||||||
|
maybeAuthorityProcessor
|
||||||
|
.get()
|
||||||
|
.addContractToAuthority(worldUpdater, authorizedCodeService, transaction);
|
||||||
|
addressList.addAll(authorizedCodeService.getAuthorities());
|
||||||
} else {
|
} else {
|
||||||
commonMessageFrameBuilder.versionedHashes(Optional.empty());
|
commonMessageFrameBuilder.versionedHashes(Optional.empty());
|
||||||
}
|
}
|
||||||
@@ -392,6 +435,7 @@ public class MainnetTransactionProcessor {
|
|||||||
.contract(contractAddress)
|
.contract(contractAddress)
|
||||||
.inputData(initCodeBytes.slice(code.getSize()))
|
.inputData(initCodeBytes.slice(code.getSize()))
|
||||||
.code(code)
|
.code(code)
|
||||||
|
.authorizedCodeService(authorizedCodeService)
|
||||||
.build();
|
.build();
|
||||||
} else {
|
} else {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent") // isContractCall tests isPresent
|
@SuppressWarnings("OptionalGetWithoutIsPresent") // isContractCall tests isPresent
|
||||||
@@ -407,6 +451,7 @@ public class MainnetTransactionProcessor {
|
|||||||
maybeContract
|
maybeContract
|
||||||
.map(c -> messageCallProcessor.getCodeFromEVM(c.getCodeHash(), c.getCode()))
|
.map(c -> messageCallProcessor.getCodeFromEVM(c.getCodeHash(), c.getCode()))
|
||||||
.orElse(CodeV0.EMPTY_CODE))
|
.orElse(CodeV0.EMPTY_CODE))
|
||||||
|
.authorizedCodeService(authorizedCodeService)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
Deque<MessageFrame> messageFrameStack = initialFrame.getMessageFrameStack();
|
Deque<MessageFrame> messageFrameStack = initialFrame.getMessageFrameStack();
|
||||||
@@ -462,7 +507,6 @@ public class MainnetTransactionProcessor {
|
|||||||
final long gasUsedByTransaction = transaction.getGasLimit() - initialFrame.getRemainingGas();
|
final long gasUsedByTransaction = transaction.getGasLimit() - initialFrame.getRemainingGas();
|
||||||
|
|
||||||
// update the coinbase
|
// update the coinbase
|
||||||
final var coinbase = worldState.getOrCreate(miningBeneficiary);
|
|
||||||
final long usedGas = transaction.getGasLimit() - refundedGas;
|
final long usedGas = transaction.getGasLimit() - refundedGas;
|
||||||
final CoinbaseFeePriceCalculator coinbaseCalculator;
|
final CoinbaseFeePriceCalculator coinbaseCalculator;
|
||||||
if (blockHeader.getBaseFee().isPresent()) {
|
if (blockHeader.getBaseFee().isPresent()) {
|
||||||
@@ -484,7 +528,11 @@ public class MainnetTransactionProcessor {
|
|||||||
final Wei coinbaseWeiDelta =
|
final Wei coinbaseWeiDelta =
|
||||||
coinbaseCalculator.price(usedGas, transactionGasPrice, blockHeader.getBaseFee());
|
coinbaseCalculator.price(usedGas, transactionGasPrice, blockHeader.getBaseFee());
|
||||||
|
|
||||||
|
operationTracer.traceBeforeRewardTransaction(worldUpdater, transaction, coinbaseWeiDelta);
|
||||||
|
|
||||||
|
final var coinbase = worldState.getOrCreate(miningBeneficiary);
|
||||||
coinbase.incrementBalance(coinbaseWeiDelta);
|
coinbase.incrementBalance(coinbaseWeiDelta);
|
||||||
|
authorizedCodeService.resetAuthorities();
|
||||||
|
|
||||||
operationTracer.traceEndTransaction(
|
operationTracer.traceEndTransaction(
|
||||||
worldUpdater,
|
worldUpdater,
|
||||||
|
|||||||
@@ -189,7 +189,8 @@ public class MainnetTransactionValidator implements TransactionValidator {
|
|||||||
final long intrinsicGasCost =
|
final long intrinsicGasCost =
|
||||||
gasCalculator.transactionIntrinsicGasCost(
|
gasCalculator.transactionIntrinsicGasCost(
|
||||||
transaction.getPayload(), transaction.isContractCreation())
|
transaction.getPayload(), transaction.isContractCreation())
|
||||||
+ (transaction.getAccessList().map(gasCalculator::accessListGasCost).orElse(0L));
|
+ (transaction.getAccessList().map(gasCalculator::accessListGasCost).orElse(0L))
|
||||||
|
+ gasCalculator.setCodeListGasCost(transaction.authorizationListSize());
|
||||||
if (Long.compareUnsigned(intrinsicGasCost, transaction.getGasLimit()) > 0) {
|
if (Long.compareUnsigned(intrinsicGasCost, transaction.getGasLimit()) > 0) {
|
||||||
return ValidationResult.invalid(
|
return ValidationResult.invalid(
|
||||||
TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
|
TransactionInvalidReason.INTRINSIC_GAS_EXCEEDS_GAS_LIMIT,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.core.MiningParameters;
|
|||||||
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
|
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
|
||||||
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
|
import org.hyperledger.besu.ethereum.privacy.PrivateTransactionValidator;
|
||||||
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
import org.hyperledger.besu.evm.internal.EvmConfiguration;
|
||||||
|
import org.hyperledger.besu.plugin.services.MetricsSystem;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
@@ -45,6 +46,8 @@ public class ProtocolScheduleBuilder {
|
|||||||
private final EvmConfiguration evmConfiguration;
|
private final EvmConfiguration evmConfiguration;
|
||||||
private final MiningParameters miningParameters;
|
private final MiningParameters miningParameters;
|
||||||
private final BadBlockManager badBlockManager;
|
private final BadBlockManager badBlockManager;
|
||||||
|
private final boolean isParallelTxProcessingEnabled;
|
||||||
|
private final MetricsSystem metricsSystem;
|
||||||
|
|
||||||
public ProtocolScheduleBuilder(
|
public ProtocolScheduleBuilder(
|
||||||
final GenesisConfigOptions config,
|
final GenesisConfigOptions config,
|
||||||
@@ -54,7 +57,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
this(
|
this(
|
||||||
config,
|
config,
|
||||||
Optional.of(defaultChainId),
|
Optional.of(defaultChainId),
|
||||||
@@ -63,7 +68,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolScheduleBuilder(
|
public ProtocolScheduleBuilder(
|
||||||
@@ -73,7 +80,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
this(
|
this(
|
||||||
config,
|
config,
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
@@ -82,7 +91,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
isRevertReasonEnabled,
|
isRevertReasonEnabled,
|
||||||
evmConfiguration,
|
evmConfiguration,
|
||||||
miningParameters,
|
miningParameters,
|
||||||
badBlockManager);
|
badBlockManager,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProtocolScheduleBuilder(
|
private ProtocolScheduleBuilder(
|
||||||
@@ -93,7 +104,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
final boolean isRevertReasonEnabled,
|
final boolean isRevertReasonEnabled,
|
||||||
final EvmConfiguration evmConfiguration,
|
final EvmConfiguration evmConfiguration,
|
||||||
final MiningParameters miningParameters,
|
final MiningParameters miningParameters,
|
||||||
final BadBlockManager badBlockManager) {
|
final BadBlockManager badBlockManager,
|
||||||
|
final boolean isParallelTxProcessingEnabled,
|
||||||
|
final MetricsSystem metricsSystem) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.protocolSpecAdapters = protocolSpecAdapters;
|
this.protocolSpecAdapters = protocolSpecAdapters;
|
||||||
this.privacyParameters = privacyParameters;
|
this.privacyParameters = privacyParameters;
|
||||||
@@ -102,6 +115,8 @@ public class ProtocolScheduleBuilder {
|
|||||||
this.defaultChainId = defaultChainId;
|
this.defaultChainId = defaultChainId;
|
||||||
this.miningParameters = miningParameters;
|
this.miningParameters = miningParameters;
|
||||||
this.badBlockManager = badBlockManager;
|
this.badBlockManager = badBlockManager;
|
||||||
|
this.isParallelTxProcessingEnabled = isParallelTxProcessingEnabled;
|
||||||
|
this.metricsSystem = metricsSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolSchedule createProtocolSchedule() {
|
public ProtocolSchedule createProtocolSchedule() {
|
||||||
@@ -121,7 +136,9 @@ public class ProtocolScheduleBuilder {
|
|||||||
config.getEcip1017EraRounds(),
|
config.getEcip1017EraRounds(),
|
||||||
evmConfiguration.overrides(
|
evmConfiguration.overrides(
|
||||||
config.getContractSizeLimit(), OptionalInt.empty(), config.getEvmStackSize()),
|
config.getContractSizeLimit(), OptionalInt.empty(), config.getEvmStackSize()),
|
||||||
miningParameters);
|
miningParameters,
|
||||||
|
isParallelTxProcessingEnabled,
|
||||||
|
metricsSystem);
|
||||||
|
|
||||||
validateForkOrdering();
|
validateForkOrdering();
|
||||||
|
|
||||||
@@ -203,7 +220,8 @@ public class ProtocolScheduleBuilder {
|
|||||||
protocolSchedule,
|
protocolSchedule,
|
||||||
BuilderMapEntry.MilestoneType.BLOCK_NUMBER,
|
BuilderMapEntry.MilestoneType.BLOCK_NUMBER,
|
||||||
classicBlockNumber,
|
classicBlockNumber,
|
||||||
ClassicProtocolSpecs.classicRecoveryInitDefinition(evmConfiguration),
|
ClassicProtocolSpecs.classicRecoveryInitDefinition(
|
||||||
|
evmConfiguration, isParallelTxProcessingEnabled, metricsSystem),
|
||||||
Function.identity());
|
Function.identity());
|
||||||
protocolSchedule.putBlockNumberMilestone(
|
protocolSchedule.putBlockNumberMilestone(
|
||||||
classicBlockNumber + 1, originalProtocolSpec);
|
classicBlockNumber + 1, originalProtocolSpec);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class ProtocolSpecBuilder {
|
|||||||
private Function<FeeMarket, GasLimitCalculator> gasLimitCalculatorBuilder;
|
private Function<FeeMarket, GasLimitCalculator> gasLimitCalculatorBuilder;
|
||||||
private Wei blockReward;
|
private Wei blockReward;
|
||||||
private boolean skipZeroBlockRewards;
|
private boolean skipZeroBlockRewards;
|
||||||
|
|
||||||
private BlockHeaderFunctions blockHeaderFunctions;
|
private BlockHeaderFunctions blockHeaderFunctions;
|
||||||
private AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory;
|
private AbstractBlockProcessor.TransactionReceiptFactory transactionReceiptFactory;
|
||||||
private DifficultyCalculator difficultyCalculator;
|
private DifficultyCalculator difficultyCalculator;
|
||||||
@@ -66,9 +67,11 @@ public class ProtocolSpecBuilder {
|
|||||||
private BiFunction<EVM, PrecompileContractRegistry, AbstractMessageProcessor>
|
private BiFunction<EVM, PrecompileContractRegistry, AbstractMessageProcessor>
|
||||||
messageCallProcessorBuilder;
|
messageCallProcessorBuilder;
|
||||||
private TransactionProcessorBuilder transactionProcessorBuilder;
|
private TransactionProcessorBuilder transactionProcessorBuilder;
|
||||||
|
|
||||||
private BlockProcessorBuilder blockProcessorBuilder;
|
private BlockProcessorBuilder blockProcessorBuilder;
|
||||||
private BlockValidatorBuilder blockValidatorBuilder;
|
private BlockValidatorBuilder blockValidatorBuilder;
|
||||||
private BlockImporterBuilder blockImporterBuilder;
|
private BlockImporterBuilder blockImporterBuilder;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private MiningBeneficiaryCalculator miningBeneficiaryCalculator;
|
private MiningBeneficiaryCalculator miningBeneficiaryCalculator;
|
||||||
private PrivacyParameters privacyParameters;
|
private PrivacyParameters privacyParameters;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user