-
Notifications
You must be signed in to change notification settings - Fork 992
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
Tx
expiration
#1123
Tx
expiration
#1123
Conversation
pls update wasm |
ffde19d
to
9cfb5cf
Compare
9cfb5cf
to
7545109
Compare
@@ -129,6 +132,11 @@ pub enum ErrorCodes { | |||
InvalidOrder = 4, | |||
ExtraTxs = 5, | |||
Undecryptable = 6, | |||
ReplayTx = 7, |
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 unfortunately not documented in main, but the idea of these numbers is that past a certain threshold, we reject the block. In this branch, those are error codes >=4
. However, we can't reject an entire block if we get the InvalidDecryptedChainId
error since we have to include all decrypted txs in order. So its number should be lowered below the critical threshold
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 the same is also true of ExpiredDecryptedTx
status: if tx_results.iter().any(|res| res.code > 3) { | ||
ProposalStatus::Reject as i32 | ||
} else { | ||
status: if tx_results.iter().all(|res| { |
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 here. If the ordering of the errors is fixed, we just need to change the 3
to a 5
in the old code
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 I'm missing something, what do you mean when you say "in the old code"?
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.
status: if tx_results.iter().any(|res| res.code > 3) {
ProposalStatus::Reject as i32
} else {
```
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, I think I see what you mean. I've changed that code to use the enum variants because I was struggling to keep track of the error codes and thought that using the variants was more readable. Would you prefer to revert to using the codes instead?
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.
We rely on it heaving in eth-bridge-integration
, so I thinks it's easier for you to make this change than us.
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.
We also document it a lot better and add helper functions, so it's not such a secret design choice anymore.
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, in this PR I've also changed process_proposal
to reject the block in more cases: in particular to reject a block even in case of an InvalidTx
or InvalidSig
which we were not doing before. Does this look ok to you? In theory, the block proposer should be able to verify these at block construction time. So in essence the threshold could stay at 3 like before if I reorder the variants correctly in the enum
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.
Yep, sounds good
code: ErrorCodes::ExpiredDecryptedTx | ||
.into(), | ||
info: format!( | ||
"Dercrypted tx expired at {:#?}, block time: {:#?}", |
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.
Oh god. What did fmt do here??
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.
Also, Dercrypted
. 😆
135f68c
to
29d953d
Compare
29d953d
to
283868c
Compare
283868c
to
0e5e6f0
Compare
0e5e6f0
to
76ad54b
Compare
* grarco/tx-lifetime: changelog: add #1123 [ci] wasm checksums update Misc adjustments Refactors `prepare_proposal` tx validation Refactors block time retrieval Clippy + fmt Tx expiration check in `prepare_proposal`. Unit test Improves tx expiration checks. Adds unit tests Tx expiration validation Updates client for tx expiration Adds `expiration` field to `Tx` Wrapper `epoch` in replay protection specs
Closes #1009
Based on #1106
Adds an optional
expiration
field to structTx
to prevent transactions from being applied indefinitely.expiration
field to structTx
mempool_validate
check against last committed block timeprocess_proposal
check against the proposed block time or, if missing, the last committed block timeprepare_proposal
check against the proposed block time (if missing accept txs as assumed to have been checked bymempool_validate
)expiration
optional arg