-
Notifications
You must be signed in to change notification settings - Fork 221
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
Embed TxEnvelope into rpc-types-eth::Transaction
#1460
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, it's because
Signed
has an unskippedhash
field- the outer
Transaction
consumes the"hash"
in deserialization - there is no "hash" field left for
Signed
to deserialize
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.
so the problem becomes
- let
Signed
deserialize the hash - make
hash
available onTransaction
in a generic way
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just remove the hash
from Transaction?
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
yes. I'd like to merge #1485 and then see how much of this i can trim while still keeping functionality right. Might break this up into several prepatory PRs |
okay I split up a bunch of the non-central functionality into small PRs. should help trim scope some |
6e5065e
to
bac7800
Compare
02c50c7
to
7998bf5
Compare
closes #1165. Alternative smaller approach than #1169
This is a breaking change
cc @klkvr
Solution
changes:
T
inalloy_rpc_types_eth::Transaction
, default toTxEnvelope
TransactionTrait for Transaction<T>
rpc_types_eth::Signature
as in [wip] feat: embedTxEnvelope
intorpc_types::Transaction
#1169AnyTxEnvelope
,AnyTypedTransaction
andAnyReceiptEnvelope
abstractionsTransactionResponse: AsRef<Self::TxEnvelope>
bound to network assoc typedrive-by
cargo hack --target wasm32-unknown-unknown
is this correct?
gasPrice
field 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