Skip to content

Commit

Permalink
Merge branch 'master' into ci/machine24
Browse files Browse the repository at this point in the history
  • Loading branch information
yperbasis committed Jul 4, 2024
2 parents 751142b + 8d9c5c4 commit b7fc4a7
Show file tree
Hide file tree
Showing 42 changed files with 453 additions and 2,551 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rpc-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Checkout RPC Tests Repository & Install Requirements
run: |
rm -rf ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v0.28.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
git -c advice.detachedHead=false clone --depth 1 --branch v0.29.0 https://github.com/erigontech/rpc-tests ${{runner.workspace}}/rpc-tests
cd ${{runner.workspace}}/rpc-tests
pip3 install -r requirements.txt
Expand Down
20 changes: 0 additions & 20 deletions silkworm/core/chain/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ nlohmann::json ChainConfig::to_json() const noexcept {
Overloaded{
[&](const protocol::NoPreMergeConfig&) {},
[&](const protocol::EthashConfig& x) { ret.emplace("ethash", x.to_json()); },
[&](const protocol::CliqueConfig&) { ret.emplace("clique", empty_object); },
[&](const protocol::bor::Config& x) { ret.emplace("bor", x.to_json()); },
},
rule_set_config);
Expand Down Expand Up @@ -116,8 +115,6 @@ std::optional<ChainConfig> ChainConfig::from_json(const nlohmann::json& json) no
return std::nullopt;
}
config.rule_set_config = *ethash_config;
} else if (json.contains("clique")) {
config.rule_set_config = protocol::CliqueConfig{};
} else if (json.contains("bor")) {
std::optional<protocol::bor::Config> bor_config{protocol::bor::Config::from_json(json["bor"])};
if (!bor_config) {
Expand Down Expand Up @@ -281,23 +278,6 @@ SILKWORM_CONSTINIT const ChainConfig kMainnetConfig{
.rule_set_config = protocol::EthashConfig{},
};

SILKWORM_CONSTINIT const ChainConfig kGoerliConfig{
.chain_id = 5,
.homestead_block = 0,
.tangerine_whistle_block = 0,
.spurious_dragon_block = 0,
.byzantium_block = 0,
.constantinople_block = 0,
.petersburg_block = 0,
.istanbul_block = 1'561'651,
.berlin_block = 4'460'644,
.london_block = 5'062'605,
.terminal_total_difficulty = 10790000,
.shanghai_time = 1678832736,
.cancun_time = 1705473120,
.rule_set_config = protocol::CliqueConfig{},
};

SILKWORM_CONSTINIT const ChainConfig kHoleskyConfig{
.chain_id = 17000,
.homestead_block = 0,
Expand Down
14 changes: 2 additions & 12 deletions silkworm/core/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ namespace protocol {
bool operator==(const NoPreMergeConfig&) const = default;
};

//! \see CliqueRuleSet
struct CliqueConfig {
bool operator==(const CliqueConfig&) const = default;
};

//! \see RuleSet
using PreMergeRuleSetConfig = std::variant<NoPreMergeConfig, EthashConfig, CliqueConfig, bor::Config>;
//! \see IRuleSet
using PreMergeRuleSetConfig = std::variant<NoPreMergeConfig, EthashConfig, bor::Config>;

} // namespace protocol

Expand Down Expand Up @@ -142,9 +137,6 @@ using namespace evmc::literals;
inline constexpr evmc::bytes32 kMainnetGenesisHash{0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_bytes32};
SILKWORM_CONSTINIT extern const ChainConfig kMainnetConfig;

inline constexpr evmc::bytes32 kGoerliGenesisHash{0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a_bytes32};
SILKWORM_CONSTINIT extern const ChainConfig kGoerliConfig;

inline constexpr evmc::bytes32 kHoleskyGenesisHash{0xb5f7f912443c940f21fd611f12828d75b534364ed9e95ca4e307729a4661bde4_bytes32};
SILKWORM_CONSTINIT extern const ChainConfig kHoleskyConfig;

Expand All @@ -160,7 +152,6 @@ SILKWORM_CONSTINIT extern const ChainConfig kMumbaiConfig;
//! \brief Known chain names mapped to their respective chain IDs
inline constexpr SmallMap<std::string_view, ChainId> kKnownChainNameToId{
{"bor-mainnet"sv, 137},
{"goerli"sv, 5},
{"holesky"sv, 17000},
{"mainnet"sv, 1},
{"mumbai"sv, 80001},
Expand All @@ -170,7 +161,6 @@ inline constexpr SmallMap<std::string_view, ChainId> kKnownChainNameToId{
//! \brief Known chain IDs mapped to their respective chain configs
inline constexpr SmallMap<ChainId, const ChainConfig*> kKnownChainConfigs{
{*kKnownChainNameToId.find("mainnet"sv), &kMainnetConfig},
{*kKnownChainNameToId.find("goerli"sv), &kGoerliConfig},
{*kKnownChainNameToId.find("holesky"sv), &kHoleskyConfig},
{*kKnownChainNameToId.find("sepolia"sv), &kSepoliaConfig},
{*kKnownChainNameToId.find("bor-mainnet"sv), &kBorMainnetConfig},
Expand Down
47 changes: 4 additions & 43 deletions silkworm/core/chain/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,6 @@ TEST_CASE("distinct_fork_points") {
CHECK(kMainnetConfig.distinct_fork_numbers() == kExpectedMainnetForkNumbers);
CHECK(kMainnetConfig.distinct_fork_times() == kExpectedMainnetForkTimes);
CHECK(kMainnetConfig.distinct_fork_points() == kExpectedMainnetForkPoints);

const std::vector<BlockNum> kExpectedGoerliForkNumbers{
1'561'651,
4'460'644,
5'062'605,
};
const std::vector<BlockTime> kExpectedGoerliForkTimes{
1678832736,
1705473120,
};
std::vector<uint64_t> kExpectedGoerliForkPoints{kExpectedGoerliForkNumbers};
kExpectedGoerliForkPoints.insert(kExpectedGoerliForkPoints.end(),
kExpectedGoerliForkTimes.cbegin(), kExpectedGoerliForkTimes.cend());

CHECK(kGoerliConfig.distinct_fork_numbers() == kExpectedGoerliForkNumbers);
CHECK(kGoerliConfig.distinct_fork_times() == kExpectedGoerliForkTimes);
CHECK(kGoerliConfig.distinct_fork_points() == kExpectedGoerliForkPoints);
}

TEST_CASE("JSON serialization") {
Expand Down Expand Up @@ -210,28 +193,6 @@ TEST_CASE("terminalTotalDifficulty as JSON number (Erigon compatibility)") {
CHECK(config1->to_json() != mainnet_json_ttd_number); // "58750000000000000000000" vs 5.875e+22
CHECK(config1->terminal_total_difficulty == intx::from_string<intx::uint256>("58750000000000000000000"));

const auto goerli_json_ttd_number = nlohmann::json::parse(R"({
"chainId":5,
"homesteadBlock":0,
"eip150Block":0,
"eip155Block":0,
"byzantiumBlock":0,
"constantinopleBlock":0,
"petersburgBlock":0,
"istanbulBlock":1561651,
"berlinBlock":4460644,
"londonBlock":5062605,
"terminalTotalDifficulty":10790000,
"shanghaiTime":1678832736,
"clique":{}
})");

const std::optional<ChainConfig> config2{ChainConfig::from_json(goerli_json_ttd_number)};

REQUIRE(config2);
CHECK(config2->to_json() != goerli_json_ttd_number); // "10790000" vs 10790000
CHECK(config2->terminal_total_difficulty == intx::from_string<intx::uint256>("10790000"));

const auto sepolia_json_ttd_number = nlohmann::json::parse(R"({
"chainId":11155111,
"homesteadBlock":0,
Expand All @@ -250,11 +211,11 @@ TEST_CASE("terminalTotalDifficulty as JSON number (Erigon compatibility)") {
"ethash":{}
})");

const std::optional<ChainConfig> config3{ChainConfig::from_json(sepolia_json_ttd_number)};
const std::optional<ChainConfig> config2{ChainConfig::from_json(sepolia_json_ttd_number)};

REQUIRE(config3);
CHECK(config3->to_json() != sepolia_json_ttd_number); // "17000000000000000" vs 17000000000000000
CHECK(config3->terminal_total_difficulty == intx::from_string<intx::uint256>("17000000000000000"));
REQUIRE(config2);
CHECK(config2->to_json() != sepolia_json_ttd_number); // "17000000000000000" vs 17000000000000000
CHECK(config2->terminal_total_difficulty == intx::from_string<intx::uint256>("17000000000000000"));
}

} // namespace silkworm
3 changes: 0 additions & 3 deletions silkworm/core/chain/genesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <silkworm/core/chain/config.hpp>
#include <silkworm/core/chain/genesis_bor_mainnet.hpp>
#include <silkworm/core/chain/genesis_goerli.hpp>
#include <silkworm/core/chain/genesis_holesky.hpp>
#include <silkworm/core/chain/genesis_mainnet.hpp>
#include <silkworm/core/chain/genesis_mumbai.hpp>
Expand All @@ -38,8 +37,6 @@ std::string_view read_genesis_data(ChainId chain_id) {
switch (chain_id) {
case *kKnownChainNameToId.find("mainnet"sv):
return genesis_mainnet_json;
case *kKnownChainNameToId.find("goerli"sv):
return genesis_goerli_json;
case *kKnownChainNameToId.find("holesky"sv):
return genesis_holesky_json;
case *kKnownChainNameToId.find("sepolia"sv):
Expand Down
Loading

0 comments on commit b7fc4a7

Please sign in to comment.