Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

EIP-2935 #6991

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9f88959
extract into main
Gabriel-Trintinalia Apr 17, 2024
991b44a
Merge main into 'eip-2935'
Gabriel-Trintinalia Apr 23, 2024
1f17958
Add ClearEmptyAccountStrategy
Gabriel-Trintinalia Apr 23, 2024
11f6122
Add ClearEmptyAccountStrategy
Gabriel-Trintinalia Apr 23, 2024
5cfbfbd
Fix javadoc
Gabriel-Trintinalia Apr 23, 2024
d866d67
Fix acceptance test
Gabriel-Trintinalia Apr 23, 2024
c846e4b
Fix spotless
Gabriel-Trintinalia Apr 23, 2024
087817e
Merge branch 'main' into eip-2935
Gabriel-Trintinalia Apr 23, 2024
b34047a
Fix missing instance
Gabriel-Trintinalia Apr 23, 2024
48751d0
Merge branch 'eip-2935' of https://github.com/Gabriel-Trintinalia/bes…
Gabriel-Trintinalia Apr 23, 2024
eed222a
Fix integration test
Gabriel-Trintinalia Apr 23, 2024
7c10b05
Fix wrong strategy
Gabriel-Trintinalia Apr 24, 2024
9f9a8cf
Fix wrong parameter
Gabriel-Trintinalia Apr 24, 2024
ce1e7b9
Fix prague acceptance tests
Gabriel-Trintinalia Apr 24, 2024
a762f79
Refactoring plus testing
Gabriel-Trintinalia Apr 25, 2024
3b90f1f
Fix spotless
Gabriel-Trintinalia Apr 25, 2024
1baba67
Merge branch 'main' into eip-2935
Gabriel-Trintinalia Apr 25, 2024
223552c
Add unit tests and fix historicalWindow - 1
Gabriel-Trintinalia Apr 26, 2024
1284c6f
merge main
Gabriel-Trintinalia Apr 26, 2024
67d34af
Fix header
Gabriel-Trintinalia Apr 26, 2024
56c7a7f
Update address and rename to match spec
Gabriel-Trintinalia May 7, 2024
f843e3f
Rename constant
Gabriel-Trintinalia May 7, 2024
4ce46e1
Merge main into eip-2935
Gabriel-Trintinalia May 7, 2024
4150b18
Merge main into eip-2935
Gabriel-Trintinalia May 7, 2024
5068275
Fix acceptance tests
Gabriel-Trintinalia May 7, 2024
c4c0c90
PR recommendations
Gabriel-Trintinalia May 7, 2024
fd24617
Fix wrong window
Gabriel-Trintinalia May 7, 2024
b409d7f
Merge branch 'main' into eip-2935
jflo May 7, 2024
d1e27c1
Merge branch 'main' into eip-2935
jflo May 8, 2024
540221c
adopts pr suggestions, allows for current block number in serve window
jflo May 8, 2024
0292b24
needs to duplicate and expose to avoid circular dependency
jflo May 8, 2024
1a460c1
nope, handling of current block is correctly zero
jflo May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,7 +14,7 @@
"executionPayload": {
"parentHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0x9d7467981e875b5b81ec6b9ab44300fa390d253b5d83da24fe58700f66a3925e",
"stateRoot": "0xc809e88f0456bc45340fa03cedd1c1d658c1b947a7f23e6a17ed108af60d3afc",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
Expand All @@ -35,7 +35,7 @@
}
],
"blockNumber": "0x2",
"blockHash": "0xb4be7cd1193f86d725c93275f9f9fe902c5fc34e1758b9ebcac371de370a1bdd",
"blockHash": "0x41d9ad8707752c4e6c46eecc956e79fc1fafc44fc0cc5fd7a5b981b02e216932",
"blobGasUsed": "0x0",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
Expand Down
Expand Up @@ -6,7 +6,7 @@
{
"parentHash": "0x2b0ef8ec0a5f8b3bd5e64cde3f1ed7f61c472b79bea9e44598921c3c37890a6a",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986",
"stateRoot": "0xb25de115723e262bb1d5da7e3576dea47c3fe7e8ca52c430e6f9def712de830d",
"logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
Expand Down Expand Up @@ -36,7 +36,7 @@
}
],
"blockNumber": "0x2",
"blockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"blockHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"receiptsRoot": "0x79ee3424eb720a3ad4b1c5a372bb8160580cbe4d893778660f34213c685627a9",
"blobGasUsed": "0x0"
},
Expand All @@ -50,7 +50,7 @@
"id": 67,
"result": {
"status": "VALID",
"latestValidHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"latestValidHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"validationError": null
}
},
Expand Down
Expand Up @@ -4,9 +4,9 @@
"method": "engine_forkchoiceUpdatedV3",
"params": [
{
"headBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"safeBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"finalizedBlockHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c"
"headBlockHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"safeBlockHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"finalizedBlockHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e"
},
{
"timestamp": "0x30",
Expand All @@ -24,11 +24,11 @@
"result": {
"payloadStatus": {
"status": "VALID",
"latestValidHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"latestValidHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"validationError": null
},
"payloadId": "0x282643832633dccf"
"payloadId": "0x28264390264496cf"
}
},
"statusCode" : 200
"statusCode": 200
}
Expand Up @@ -3,7 +3,7 @@
"jsonrpc": "2.0",
"method": "engine_getPayloadV4",
"params": [
"0x282643832633dccf"
"0x28264390264496cf"
],
"id": 67
},
Expand All @@ -12,9 +12,9 @@
"id": 67,
"result": {
"executionPayload": {
"parentHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"parentHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986",
"stateRoot": "0xf786274a52a498c61961f6faa82c8f2df6c65bf6f0cbdd53216821bc981494a4",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
Expand All @@ -29,7 +29,7 @@
"depositReceipts": [],
"withdrawalRequests": [],
"blockNumber": "0x3",
"blockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"blockHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"blobGasUsed": "0x0"
},
Expand Down
Expand Up @@ -4,9 +4,9 @@
"method": "engine_newPayloadV3",
"params": [
{
"parentHash": "0x57291a8c6fd912648046cae66dcae8b3f3d00b49e679c69566cd11286490458c",
"parentHash": "0xcf161dd8d9811f119f7377aa7cccd933955d1a6deb538200785191fb938fec5e",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0xdcd8284a4904f95448a522e4c47d9c2f1b4541c5f6f711b42692fb26e1e0d986",
"stateRoot": "0xf786274a52a498c61961f6faa82c8f2df6c65bf6f0cbdd53216821bc981494a4",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
Expand All @@ -19,7 +19,7 @@
"depositReceipts": [],
"withdrawalRequests": [],
"blockNumber": "0x3",
"blockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"blockHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"excessBlobGas": "0x0",
"blobGasUsed": "0x0"
Expand All @@ -34,7 +34,7 @@
"id": 67,
"result": {
"status": "VALID",
"latestValidHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"latestValidHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"validationError": null
}
},
Expand Down
Expand Up @@ -4,9 +4,9 @@
"method": "engine_forkchoiceUpdatedV3",
"params": [
{
"headBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"safeBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"finalizedBlockHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b"
"headBlockHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"safeBlockHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"finalizedBlockHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98"
},
{
"timestamp": "0x40",
Expand All @@ -24,10 +24,10 @@
"result": {
"payloadStatus": {
"status": "VALID",
"latestValidHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"latestValidHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"validationError": null
},
"payloadId": "0x282643f22efc45bf"
"payloadId": "0x282643d998c41241"
}
},
"statusCode" : 200
Expand Down
Expand Up @@ -3,7 +3,7 @@
"jsonrpc": "2.0",
"method": "engine_getPayloadV4",
"params": [
"0x282643f22efc45bf"
"0x282643d998c41241"
],
"id": 67
},
Expand All @@ -12,9 +12,9 @@
"id": 67,
"result": {
"executionPayload": {
"parentHash": "0xbac2080fec3fecfb46b4fa1ce20767021f0e53e85b017d5b6a5f4ec43bdbf18b",
"parentHash": "0xf1626764177578f1bf1f0fcce3f5ecab4bf7e4c8c7754d1d30e7c0b98334ad98",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0x4a387af05417b5767993052457ca85b2a5a172b3f809eb5cbcf17f070f398c3f",
"stateRoot": "0x4021e9832c7d9945cb681d670c238c6178bd2184e957a474a7989d06f7171349",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
Expand All @@ -36,10 +36,10 @@
"validatorPubKey": "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"
}
],
"receiptsRoot": "0x765bd9d63cc10fa47117d6cc0958f15e55a3bde540d4ed15d220f573fbb82cba",
"blockNumber": "0x4",
"blobGasUsed": "0x0",
"blockHash": "0xe589c7673025f6844ffbaeddcf38d77d652669c60412e8506a2ae62ac80e9de4",
"blockNumber": "0x4"
"receiptsRoot": "0x765bd9d63cc10fa47117d6cc0958f15e55a3bde540d4ed15d220f573fbb82cba",
"blockHash": "0xc5c15f6a88d3576927b16de1c635cabf46bb9419a3bbb3be156ddbe229de5e64"
},
"blockValue": "0x12855dcd153473b",
"blobsBundle": {
Expand Down
Expand Up @@ -147,6 +147,7 @@ public class EthGetTransactionReceiptTest {
Optional.empty(),
null,
null,
Optional.empty(),
true,
true);
private final ProtocolSpec statusTransactionTypeSpec =
Expand Down Expand Up @@ -177,6 +178,7 @@ public class EthGetTransactionReceiptTest {
Optional.empty(),
null,
null,
Optional.empty(),
true,
true);

Expand Down
Expand Up @@ -213,6 +213,16 @@ protected BlockCreationResult createBlock(
ParentBeaconBlockRootHelper.storeParentBeaconBlockRoot(
disposableWorldState.updater(), timestamp, bytes32));

newProtocolSpec
.getHistoricalBlockHashProcessor()
.ifPresent(
historicalBlockHashProcessor -> {
final WorldUpdater updater = disposableWorldState.updater();
historicalBlockHashProcessor.storeHistoricalBlockHashes(
protocolContext.getBlockchain(), updater, processableBlockHeader);
updater.commit();
});

throwIfStopped();

final PluginTransactionSelector pluginTransactionSelector =
Expand Down
Expand Up @@ -112,6 +112,16 @@ public BlockProcessingResult processBlock(
updater, blockHeader.getTimestamp(), blockHeader.getParentBeaconBlockRoot().get());
}

protocolSpec
.getHistoricalBlockHashProcessor()
.ifPresent(
historicalBlockHashProcessor -> {
final WorldUpdater updater = worldState.updater();
historicalBlockHashProcessor.storeHistoricalBlockHashes(
blockchain, updater, blockHeader);
updater.commit();
});

for (final Transaction transaction : transactions) {
if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) {
return new BlockProcessingResult(Optional.empty(), "provided gas insufficient");
Expand Down
Expand Up @@ -21,6 +21,7 @@
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.feemarket.CoinbaseFeePriceCalculator;
import org.hyperledger.besu.ethereum.mainnet.ClearEmptyAccountStrategy.ClearEmptyAccount;
import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.evm.ClassicEVMs;
import org.hyperledger.besu.evm.MainnetEVMs;
Expand Down Expand Up @@ -181,7 +182,7 @@ public static ProtocolSpecBuilder atlantisDefinition(
transactionValidatorFactory,
contractCreationProcessor,
messageCallProcessor,
true,
new ClearEmptyAccount(),
false,
stackSizeLimit,
feeMarket,
Expand Down Expand Up @@ -370,7 +371,7 @@ public static ProtocolSpecBuilder spiralDefinition(
transactionValidatorFactory,
contractCreationProcessor,
messageCallProcessor,
true,
new ClearEmptyAccount(),
true,
stackSizeLimit,
feeMarket,
Expand Down
@@ -0,0 +1,63 @@
/*
* 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.datatypes.Address;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.ArrayList;
import java.util.List;

/** A helper class to store the historical block hash. */
public interface ClearEmptyAccountStrategy {

void process(final WorldUpdater worldUpdater);

class NotClearEmptyAccount implements ClearEmptyAccountStrategy {
@Override
public void process(final WorldUpdater worldUpdater) {
// nothing to do
}
}

class ClearEmptyAccount implements ClearEmptyAccountStrategy {
@Override
public void process(final WorldUpdater worldUpdater) {
new ArrayList<>(worldUpdater.getTouchedAccounts())
.stream()
.filter(Account::isEmpty)
.forEach(a -> worldUpdater.deleteAccount(a.getAddress()));
}
}

class ClearEmptyAccountWithException implements ClearEmptyAccountStrategy {

List<Address> exceptionList;

public ClearEmptyAccountWithException(final List<Address> exceptionList) {
this.exceptionList = exceptionList;
}

@Override
public void process(final WorldUpdater worldUpdater) {
new ArrayList<>(worldUpdater.getTouchedAccounts())
.stream()
.filter(account -> !exceptionList.contains(account.getAddress()))
jframe marked this conversation as resolved.
Show resolved Hide resolved
.filter(Account::isEmpty)
.forEach(a -> worldUpdater.deleteAccount(a.getAddress()));
}
}
}