Skip to content

Commit

Permalink
Merge pull request #157 from eosnetworkfoundation/elmato/fix-consensu…
Browse files Browse the repository at this point in the history
…s-parameters-decode

[1.0] Fix ConsensusParameters::decode
  • Loading branch information
elmato authored Jun 17, 2024
2 parents 07f76fa + 97b2a41 commit 0f38246
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions eosevm/consensus_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ std::optional<ConsensusParameters> 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;
Expand Down
5 changes: 5 additions & 0 deletions silkworm/node/db/access_layer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,11 @@ TEST_CASE("ConsensusParameters") {
}
};

auto tmp = value1.encode();

ByteView bv{tmp};
REQUIRE_NOTHROW(eosevm::ConsensusParameters::decode(bv));

constexpr eosevm::ConsensusParameters value2{
.gas_fee_parameters = eosevm::GasFeeParameters{
.gas_txnewaccount = 2,
Expand Down

0 comments on commit 0f38246

Please sign in to comment.