-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from eosnetworkfoundation/elmato/fix-serializ…
…ation-consensus-params [1.0] Store block extra data in a separate table
- Loading branch information
Showing
23 changed files
with
242 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <silkworm/core/rlp/encode.hpp> | ||
#include <silkworm/core/rlp/decode.hpp> | ||
|
||
#include "block_extra_data.hpp" | ||
|
||
using namespace silkworm; | ||
|
||
namespace eosevm { | ||
bool operator==(const eosevm::block_extra_data& a, const eosevm::block_extra_data& b) { | ||
return a.consensus_parameter_index == b.consensus_parameter_index; | ||
} | ||
} | ||
|
||
namespace silkworm { namespace rlp { | ||
|
||
template <typename T> | ||
void encode(Bytes& to, const std::optional<T>& v) noexcept { | ||
auto has_value = v.has_value(); | ||
rlp::encode(to, has_value); | ||
if(has_value) { | ||
rlp::encode(to, v.value()); | ||
} | ||
} | ||
|
||
template <typename T> | ||
DecodingResult decode(ByteView& from, std::optional<T>& out) noexcept { | ||
bool has_value = false; | ||
if (DecodingResult res{decode(from, has_value, Leftover::kAllow)}; !res) { | ||
return res; | ||
} | ||
if(has_value) { | ||
out = T{}; | ||
if (DecodingResult res{decode(from, *out, Leftover::kAllow)}; !res) { | ||
return res; | ||
} | ||
} | ||
return {}; | ||
} | ||
|
||
silkworm::Bytes encode(const eosevm::block_extra_data& out) { | ||
silkworm::Bytes to; | ||
encode(to, out.consensus_parameter_index); | ||
return to; | ||
} | ||
|
||
DecodingResult decode(silkworm::ByteView& from, eosevm::block_extra_data& to) noexcept{ | ||
decode(from, to.consensus_parameter_index); | ||
return {}; | ||
} | ||
} } //namespace silkworm::rlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
|
||
namespace eosevm { | ||
|
||
struct block_extra_data { | ||
std::optional<evmc::bytes32> consensus_parameter_index; | ||
}; | ||
|
||
} // namespace eosevm | ||
|
||
namespace silkworm { namespace rlp { | ||
silkworm::Bytes encode(const eosevm::block_extra_data&); | ||
DecodingResult decode(silkworm::ByteView& from, eosevm::block_extra_data& to) noexcept; | ||
}} // namespace silkworm::rlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.