From f9d41a14f99b7637856e9e4578e368b2b1642ad6 Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Sat, 1 Jun 2024 02:29:43 -0300 Subject: [PATCH 1/2] Change db serialization format for non-legacy transactions --- silkworm/node/db/access_layer.cpp | 4 ++-- silkworm/silkrpc/core/rawdb/chain.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/silkworm/node/db/access_layer.cpp b/silkworm/node/db/access_layer.cpp index b31558bb..46965bc2 100644 --- a/silkworm/node/db/access_layer.cpp +++ b/silkworm/node/db/access_layer.cpp @@ -313,7 +313,7 @@ void write_transactions(RWTxn& txn, const std::vector& transactions auto key{db::block_key(base_id)}; for (const auto& transaction : transactions) { Bytes value{}; - rlp::encode(value, transaction); + rlp::encode(value, transaction, false); mdbx::slice value_slice{value.data(), value.length()}; cursor->put(to_slice(key), &value_slice, MDBX_APPEND); ++base_id; @@ -333,7 +333,7 @@ void read_transactions(ROCursor& txn_table, uint64_t base_id, uint64_t count, st for (auto data{txn_table.find(to_slice(key), false)}; data.done && i < count; data = txn_table.to_next(/*throw_notfound = */ false), ++i) { ByteView data_view{from_slice(data.value)}; - success_or_throw(rlp::decode(data_view, v.at(i))); + success_or_throw(rlp::decode_transaction(data_view, v.at(i), silkworm::rlp::Eip2718Wrapping::kNone)); } SILKWORM_ASSERT(i == count); } diff --git a/silkworm/silkrpc/core/rawdb/chain.cpp b/silkworm/silkrpc/core/rawdb/chain.cpp index c6c8d242..3659ad7e 100644 --- a/silkworm/silkrpc/core/rawdb/chain.cpp +++ b/silkworm/silkrpc/core/rawdb/chain.cpp @@ -355,7 +355,7 @@ boost::asio::awaitable read_canonical_transactions(const DatabaseR SILK_TRACE << "v: " << silkworm::to_hex(v); silkworm::ByteView value{v}; silkworm::Transaction tx{}; - const auto error = silkworm::rlp::decode(value, tx); + const auto error = silkworm::rlp::decode_transaction(value, tx, silkworm::rlp::Eip2718Wrapping::kNone); if (!error) { SILK_ERROR << "invalid RLP decoding for transaction index " << i; return false; From b693331c51afc0043ae385804975a9ddbd60aa5a Mon Sep 17 00:00:00 2001 From: Matias Romeo Date: Tue, 4 Jun 2024 02:44:46 -0300 Subject: [PATCH 2/2] Fix 'read rlp encoded transactions' test --- silkworm/node/db/access_layer_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/silkworm/node/db/access_layer_test.cpp b/silkworm/node/db/access_layer_test.cpp index fb6acc21..dd0b903e 100644 --- a/silkworm/node/db/access_layer_test.cpp +++ b/silkworm/node/db/access_layer_test.cpp @@ -881,7 +881,7 @@ TEST_CASE("read rlp encoded transactions") { for (size_t i = 0; i < rlp_transactions.size(); i++) { Bytes rlp_tx; - CHECK_NOTHROW(rlp::encode(rlp_tx, body.transactions[i])); + CHECK_NOTHROW(rlp::encode(rlp_tx, body.transactions[i], false)); CHECK(rlp_transactions[i] == rlp_tx); } }