-
Notifications
You must be signed in to change notification settings - Fork 784
vms/platformvm
: Remove MempoolTxVerifier
#2362
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
@@ -359,15 +348,6 @@ func TestStandardTxExecutorAddDelegator(t *testing.T) { | |||
} | |||
err = tx.Unsigned.Visit(&executor) | |||
require.ErrorIs(err, tt.expectedExecutionErr) | |||
|
|||
mempoolExecutor := MempoolTxVerifier{ |
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 run all the txs through the StandardTxExecutor
already which the MempoolTxVerifier
called internally anyway. This can be removed outside of this PR.
vms/platformvm
: Remove mempool tx verifier structvms/platformvm
: Remove mempool tx verifier struct
vms/platformvm
: Remove mempool tx verifier structvms/platformvm
: Remove mempool tx verifier struct
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 this is a step in the wrong direction:
- I am fine having small structs that do one clear thing, even if a small one. To me MempoolTxVerifier says clearly that mempool txs are validated not on chain tip state (as you may naively assume) but on a state version built on top of it. MempoolTxVerifier does call then the StandardTxExecutor, which tells us that, apart from the state, we reuse the very same code to validator blocks and mempool txs. This seems good engineering to me
- Block manager is already too big and it's doing many so many stuff that should be break up. The way I see it currently:
- Support blocks verification, acceptance and rejection
- Holds chain state at different heights (probably it's main function)
- Verify mempool txs, which does not make sense at all to me, but that I accepted as a temporary solution to move forward with the mempool cleanup.
I think if we want to keep refactoring code, we should focus on breaking block Manager into smaller chunks, rather than extending its scope.
abe32c5
to
d41fd0b
Compare
In-lining the struct can save us one alloc/op (and is marginally faster). Since this is run for each tx received from
Unfortunately we can't re-use the MempoolTxVerifier logic when we're verifying the mempool txs before putting them into a block so this logic is only used here (#2359) |
vms/platformvm
: Remove mempool tx verifier structvms/platformvm
: Remove MempoolTxVerifier
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.
just a question about naming. Other than that LGTM
ParentID: m.preferred, | ||
StateVersions: m, | ||
Tx: tx, | ||
stateDiff, err := state.NewDiff(m.preferred, m) |
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.
q: since we're dropping the mempool verifier, should we rename this VerifyTx
method as VerifyMempoolTx
?
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 we already use VerifyTx
exclusively for mempool verification (including in the network
pkg). Since we're not modifying the function usage, I think the same name is okay and keeps the diff minimal
65d8c92
to
4e0df0c
Compare
Why this should be merged
MempoolTxVerifier
is a thin wrapper onStandardTxVerifier
. It is only used in the P-Chain block executor managerVerifyTx
function. I found this pattern confusing when trying to figure out how mempool txs were being verified. This is an attempt at making this process easier to understand.How this works
In-lines
MempoolTxVerifier
logic to improve readabilityHow this was tested
CI