-
Notifications
You must be signed in to change notification settings - Fork 25
RLP encoding for EVM transactions #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
25c58f6
to
1314541
Compare
updates dependencies to ethereum/ethereum-types needed for #786
1314541
to
ee4f519
Compare
I'm getting two test failures that are blocking me: fragment_serialization_bijection |
60a2428
to
f9a3035
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe u64
is more than needed here (I don't have a clue what rlp
is), but this seems to fix the test failure.
* update evm to v0.35 updates dependencies to ethereum/ethereum-types needed for #786
9a4541f
to
7de69cd
Compare
@saibatizoku , mostly looks good, but we need to ensure that this new serde implementation for the EvmTransaction converges to the original Ethereum implementation that is the original goal of implementing Rlp encoding. |
#[cfg(feature = "evm")] | ||
let ledger = ledger.set_evm_block0().set_evm_environment(); | ||
ledger | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not the previous implementation ?
It looked prettier IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy complained, so I removed the lint. I think it's not that bad looking, and explicitly handles the not(
feature, which can't hurt.
I agree, there are also some possible test values in the |
d873b27
to
18fd090
Compare
18fd090
to
1de70ac
Compare
} | ||
} | ||
|
||
impl Decodable for EthereumTransaction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in case that we do not want to propagate all these Ethereum traits as Decodable
and Encodable
, I would prefer to add just a from_bytes(&[u8]) -> Self
and to_bytes(self) -> &[u8]
methods for the EthereumTransaction
it seems to be more convenient for the further usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add these functions, although the Serialize
/Deserialize
traits end up providing the same, and make use of the Ethereum traits under the hood, so I think that it's equivalent.
} | ||
} | ||
|
||
impl Serialize for EthereumTransaction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am not sure that these trait implementation as Serialize
, Deserialize
will also be needed for us, maybe we can just remove it at this point ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we need these traits for Fragment-related ser/de, but I'm not sure.
chain-evm/src/transaction.rs
Outdated
|
||
/// Wrapper type for `ethereum::TransactionV2`, which includes the `EIP1559Transaction`, `EIP2930Transaction`, `LegacyTransaction` variants. | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct EthereumTransaction(TransactionV2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we should also add implementation of the TryFrom
/TryInto
for the conversion into the EvmTransaction
type
9bea94c
to
cafc247
Compare
update tests for evm transaction serialization bijection
updates tests and vm function signatures
remove DeserializeFromSlice, as we get a blanket impl now
Co-authored-by: Enzo Cioppettini <48031343+enzoc4@users.noreply.github.com>
Co-authored-by: Enzo Cioppettini <48031343+enzoc4@users.noreply.github.com>
Co-authored-by: Enzo Cioppettini <48031343+enzoc4@users.noreply.github.com>
Co-authored-by: Alex Pozhylenkov <leshiy12345678@gmail.com>
implements RLP encoding/decoding implements Serialize/Deserialize from chain_core
brings in secp256k1 crate dependency
also adds tests for the Secret type, which holds a SecretKey and offers helpful conversions
cafc247
to
f3bd658
Compare
chain-impl-mockchain/src/evm/mod.rs
Outdated
use EvmTransaction::*; | ||
impl EvmTransaction { | ||
/// Serialize the contract into a `ByteBuilder`. | ||
pub fn serialize_in(&self, _bb: ByteBuilder<Self>) -> ByteBuilder<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to implement Serialize
trait, it will allow to use serialization_bijection
function in tests and it will follow to the full serde interface. (as Deserialize
trait has been implemented)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restored the Serialize
trait, and kept the RLP encoding because it handles things like U256
values and list of items better than we were doing it. If anything, I would move the EvmTransaction type into chain-evm
to clean up dependencies a bit, but that would be in a future PR.
* added ledger status validation after transaction scenario * removed useless validation * added scenario for invalid transaction * added scenarios for correct fees when casting & tallying votes * partial PR correction * PR corrections * deleted comment * PR corrections
9f2cad9
to
cf41a3b
Compare
Replacing codec from chain-libs with RLP encoding from Ethereum for EVM Transactions