diff --git a/eosevm/consensus_parameters.cpp b/eosevm/consensus_parameters.cpp index cb0bb7b4..8948238d 100644 --- a/eosevm/consensus_parameters.cpp +++ b/eosevm/consensus_parameters.cpp @@ -62,12 +62,12 @@ std::optional ConsensusParameters::decode(silkworm::ByteVie // Parse according to version. For now, only 0. switch (version) { case 0: { - constexpr size_t size_before_fee_param = sizeof(uint64_t); - SILKWORM_ASSERT(encoded.length() > size_before_fee_param); - config.gas_fee_parameters = GasFeeParameters::decode(silkworm::ByteView{&encoded[size_before_fee_param], encoded.length() - size_before_fee_param}); + config.gas_fee_parameters = GasFeeParameters::decode(silkworm::ByteView{&encoded[sizeof(uint64_t)], encoded.length() - sizeof(uint64_t)}); break; - } - default: SILKWORM_ASSERT(version <= 0); + } + default: { + SILKWORM_ASSERT(false); + } } return config; diff --git a/silkworm/node/db/access_layer_test.cpp b/silkworm/node/db/access_layer_test.cpp index dd0b903e..97dcd71d 100644 --- a/silkworm/node/db/access_layer_test.cpp +++ b/silkworm/node/db/access_layer_test.cpp @@ -949,6 +949,14 @@ TEST_CASE("ConsensusParameters") { } }; + auto tmp = value1.encode(); + REQUIRE_THROWS(eosevm::ConsensusParameters::decode({})); + + ByteView bv{tmp}; + REQUIRE_NOTHROW(eosevm::ConsensusParameters::decode(bv)); + + REQUIRE_THROWS(eosevm::ConsensusParameters::decode(ByteView{bv.data(), bv.size()-1})); + constexpr eosevm::ConsensusParameters value2{ .gas_fee_parameters = eosevm::GasFeeParameters{ .gas_txnewaccount = 2,