Skip to content

Comments

Refactor subspace transaction pool#1303

Merged
liuchengxu merged 10 commits intomainfrom
refactor-subspace-transaction-pool
Mar 29, 2023
Merged

Refactor subspace transaction pool#1303
liuchengxu merged 10 commits intomainfrom
refactor-subspace-transaction-pool

Conversation

@liuchengxu
Copy link
Contributor

@liuchengxu liuchengxu commented Mar 27, 2023

Some background: the sole purpose of subspace-transaction-pool is to perform some pre-validation before doing the normal extrinsic validation, primary chain/system domain/core domain all have their custom pre-validation logic.

Why this PR

Changes in this PR

  • Make subspace-transaction-pool generic over the TxPreValidator, now we have PrimaryChainTxPreValidator, SystemDomainTxPreValidator and CoreDomainTxPreValidator.
  • Remove subspace-fraud-proof dependency from subspace-transaction-pool.
  • Remove subspace-transaction-pool dependency from domain-executor.

Should be no logical changes in this PR, it's a pure refactoring.

Code contributor checklist:

…`BundleValidator` into `TxPreValidator`

This commits introduces a trait `PreValidateTransaction` which is
invoked before calling the normal `validate_transaction` function.

`FraudProofVerifierAndBundleValidator` is separated out temperoarily,
it's now used by both the primary chain and the system domain. However,
the system domain does not need the bundle validator at all, which will
be removed later, making it more explicit and easier to figure out the
ingredients of the custom tx-pre-validator for primary_chain/system_domain/core_domain.
…to service crates

This commit introduces `PrimaryChainTxPreValidator` and
`SystemDomainTxPreValidator`, moving the implementations of
`PreValidateTransaction` from `subspace-transaction-pool`
to the service crates where the transaction pool was constructed.

- PrimaryChainTxPreValidator: FraudProofVerifierAndBundleValidator
- SystemDomainTxPreValidator: only BundleValidator (xdm verifier will be integrated in later commits)
…saction-pool

`subspace-transaction-pool` is now pretty flexible, all kinds of
pre-validation requiremnts are actually handled by the `TxPreValidator`.
Replace `subspace_transaction_pool::new_full_with_verifier` with `subspace_transaction_pool::new_full`
using the core domain specific tx pre-validator.

The only requirement of pre-validation on the core domain is the xdm
verification.
Integrate the xdm verification in the system domain tx pre-validator and
also replace `subspace_transaction_pool::new_full_with_verifier` with
`subspace_transaction_pool::new_full`.
… remove `subspace-fraud-proof` dep from `subspace-transaction-pool`
Copy link
Contributor

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense overall but still not sure if tx_pre_validator needs to in service crate.

@liuchengxu
Copy link
Contributor Author

but still not sure if tx_pre_validator needs to in service crate.

Any suggestions?

@vedhavyas
Copy link
Contributor

So my PR brings the xdm verification already under domain_block_preprocessor. I think we can rename that to domain_block_validator and move these there.

@liuchengxu
Copy link
Contributor Author

These pre_tx_validators are not only for the domain block but also for the primary block, hence I don't think that's perfect.

vedhavyas
vedhavyas previously approved these changes Mar 28, 2023
@liuchengxu liuchengxu enabled auto-merge March 28, 2023 09:46
@liuchengxu liuchengxu merged commit 82b1b9d into main Mar 29, 2023
@liuchengxu liuchengxu deleted the refactor-subspace-transaction-pool branch March 29, 2023 08:41
i1i1 added a commit to autonomys/subspace-pulsar-sdk that referenced this pull request Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants