@@ -194,13 +194,41 @@ Task<bool> RemoteChainStorage::read_rlp_transactions(BlockNum block_num, const e
194194 }
195195 rlp_txs.reserve (block.transactions .size ());
196196 for (const auto & transaction : block.transactions ) {
197- rlp::encode (rlp_txs.emplace_back (), transaction);
197+ rlp::encode (rlp_txs.emplace_back (), transaction, /* wrap_eip2718_into_string= */ false );
198198 }
199199 co_return true ;
200200}
201201
202- Task<bool > RemoteChainStorage::read_rlp_transaction (const evmc::bytes32& /* txn_hash*/ , Bytes& /* rlp_tx*/ ) const {
203- throw std::logic_error{" RemoteChainStorage::read_rlp_transaction not implemented" };
202+ Task<bool > RemoteChainStorage::read_rlp_transaction (const evmc::bytes32& txn_hash, Bytes& rlp_tx) const {
203+ auto block_num = co_await providers_.block_num_from_txn_hash (txn_hash.bytes );
204+ if (!block_num) {
205+ co_return false ;
206+ }
207+
208+ const auto block_hash = co_await providers_.canonical_block_hash_from_number (*block_num);
209+ if (!block_hash) {
210+ co_return false ;
211+ }
212+
213+ std::vector<Bytes> rlp_txs;
214+ if (!co_await read_rlp_transactions (*block_num, *block_hash, rlp_txs)) {
215+ co_return false ;
216+ }
217+
218+ Block block;
219+ const bool success = co_await providers_.block (*block_num, block_hash->bytes , /* .read_senders=*/ false , block);
220+ if (!success) {
221+ co_return false ;
222+ }
223+ for (const auto & transaction : block.transactions ) {
224+ Bytes rlp;
225+ if (transaction.hash () == txn_hash) {
226+ rlp::encode (rlp, transaction, /* wrap_eip2718_into_string=*/ false );
227+ rlp_tx = rlp;
228+ co_return true ;
229+ }
230+ }
231+ co_return false ;
204232}
205233
206234Task<std::optional<intx::uint256>> RemoteChainStorage::read_total_difficulty (const Hash& hash, BlockNum block_num) const {
0 commit comments