Embed TxEnvelope into rpc-types-eth::Transaction#1460
Conversation
|
this would break |
|
|
|
current CI error seems to indicate that anvil sometimes doesn't return a |
yes, we agree that this is a breaking change. however, it is not going to break the a more-complete fix might look like this: but that's somewhat outside the scope of #1165 |
yep, anvil does not return type flag for legacy transactions atm, I think we should fix this though I believe this should be handled during deserialization as well |
this won't work because of rlp bounds on envelope |
right now we are using |
|
it would be great if we'd figure out a way to have |
Envelope doesn't have RLP bounds, only 2718 bounds, which can be satisfied with a dummy implementation. It's impossible to correctly model unknown 2718 encodings so incorrect behavior here should be acceptable |
|
latest commit includes |
|
okay @klkvr this should be ready for re-review with above concerns addressed. I also put a summary of changes in the PR description
now handled by the new
handled by
handled by the dummy 2718 impls
I added this as |
|
also, agree the 2718 is pretty jank >.> i thought about making it panic instead |
something we could do is divide and second trait which would represent a normal network with infallible rpc<->consensus conversions which would have a blanket impl for all however doing all of this just for |
df5b08a to
b6aa8a4
Compare
I like the idea generally, but i think you're right that doing it just for |
|
updated the docs for |
2b0f30b to
1136ec6
Compare
| #[cfg_attr(feature = "serde", serde(default, skip_serializing_if = "Option::is_none"))] | ||
| pub authorization_list: Option<Vec<SignedAuthorization>>, | ||
| // /// Transaction hash | ||
| // pub hash: B256, |
There was a problem hiding this comment.
This is the last outstanding issue. For some reason, uncommenting this makes inner deserialization fail. Probably a subtle and annoying serde interaction 😮💨
There was a problem hiding this comment.
ah, it's because
Signedhas an unskippedhashfield- the outer
Transactionconsumes the"hash"in deserialization - there is no "hash" field left for
Signedto deserialize
There was a problem hiding this comment.
so the problem becomes
- let
Signeddeserialize the hash - make
hashavailable onTransactionin a generic way
There was a problem hiding this comment.
OR
- manually impl deserialize for Transaction to avoid consuming the hash
this seems easier and doesn't require introducing new bounds 👍
There was a problem hiding this comment.
should we just remove the hash from Transaction?
There was a problem hiding this comment.
I believe transaction hash is just keccak256(tx_envelope.encode_2718())? which should be possible to do for any envelope
will look into this today. at first blush, it looks like trie_hash is provided on the Encodable2718 trait, so we should be able to remove from Signed. We still strongly want memoization tho so need to figure out how to keep that without interfering with serialization 🤔
it also looks like d0794e5 lightly broke eip2718 abstraction by making type flag encoding tx-associated instead of envelope-associated. We would now behave badly for networks where the type flag is different (e.g. TxEip1559 is flag 17, or where both 4 and 5 are TxEip7702, so we should probably open a separate issue for that
There was a problem hiding this comment.
I believe transaction hash is just keccak256(tx_envelope.encode_2718())? which should be possible to do for any envelope
this is actually not the case for eip4844 with sidecar 😮💨 but it's straightforward to work around i think
There was a problem hiding this comment.
I'm wondering if we could solve this by adding a TxEnvelope trait which would have a tx_hash method? all normal variants already keep hash in Signed and we can just add a mandatory hash field to Other variant
I think #1485 is reasonable as well because sealable and signable are 2 valid distinct properties of transaction (eg deposit transaction is only sealable). but would like to keep scope here smaller if possible as PR is already pretty big
There was a problem hiding this comment.
I'm wondering if we could solve this by adding a TxEnvelope trait which would have a tx_hash method? all normal variants already keep hash in Signed and we can just add a mandatory hash field to Other variant
the trie_hash method already exists on Encodable2718, so we are covered there :)
There was a problem hiding this comment.
the trie_hash method already exists on Encodable2718, so we are covered there :)
yeah but our impl of Encodable2718 is not correct for Other variant?
81c92fd to
6e5065e
Compare
0ba1495 to
914ef71
Compare
Not that I know of This is rebased and ready for review |
|
side note, because the type aliases for |
| pub use alloy_consensus::{AnyHeader, AnyReceiptEnvelope}; | ||
|
|
||
| /// A catch-all header type for handling headers on multiple networks. | ||
| pub type AnyRpcHeader = alloy_rpc_types_eth::Header<alloy_consensus::AnyHeader>; | ||
|
|
||
| /// A catch-all block type for handling blocks on multiple networks. | ||
| pub type AnyRpcBlock = | ||
| WithOtherFields<Block<WithOtherFields<Transaction<AnyTxEnvelope>>, AnyRpcHeader>>; | ||
|
|
There was a problem hiding this comment.
we already have these here
alloy/crates/rpc-types-eth/src/lib.rs
Line 26 in 273d784
There was a problem hiding this comment.
Those can't be in the rpc-types-eth crate as they need to import AnyTxEnvelope now. In addition, it's somewhat unclean to put AnyRpc____ objects into rpc-types-eth. Do you thinkwe should add rpc-types-any as a crate?
There was a problem hiding this comment.
AnyRecipt and AnyHeader are already in alloy-consensus
can't AnyTxEnvelope be there too?
There was a problem hiding this comment.
i don't think it was a good idea to put them there in the first place. alloy-consensus has always been specifically eth consensus. It's also much more invasive to move a large type downwards instead of moving 2 aliases upwards
crates/network/src/any/mod.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl alloy_consensus::Transaction for AnyTxEnvelope { |
There was a problem hiding this comment.
do we need this to satisfy the the Network trait constraint
There was a problem hiding this comment.
we don't, but it seems sufficiently useful to users to have this
0b9fbc0 to
156d7d9
Compare
| /// A catch-all header type for handling headers on multiple networks. | ||
| pub type AnyRpcHeader = alloy_rpc_types_eth::Header<alloy_consensus::AnyHeader>; |
There was a problem hiding this comment.
moving these aliases here makes sense imo
klkvr
left a comment
There was a problem hiding this comment.
lgtm! will try to plug this into reth and see if anything breaks
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
closes #1165. Alternative smaller approach than #1169
This is a breaking change
cc @klkvr
Solution
changes:
Tinalloy_rpc_types_eth::Transaction, default toTxEnvelopeTransactionTrait for Transaction<T>rpc_types_eth::Signatureas in [wip] feat: embedTxEnvelopeintorpc_types::Transaction#1169AnyTxEnvelope,AnyTypedTransactionandAnyReceiptEnvelopeabstractionsTransactionResponse: AsRef<Self::TxEnvelope>bound to network assoc typedrive-by
cargo hack --target wasm32-unknown-unknownis this correct?
gasPricefield fromTxPoolContent. My belief is that this is now only produced for legacy transactions, so removing it is correct behavior and will not break deserializersPR Checklist