Skip to content
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

Parallelize transaction validation in prepare_transactions #12735

Open
miloserdow opened this issue Jan 14, 2025 · 0 comments
Open

Parallelize transaction validation in prepare_transactions #12735

miloserdow opened this issue Jan 14, 2025 · 0 comments
Labels
A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) B-L3 Bootcamp: (“Task”) medium 10-50 line code change C-enhancement Category: An issue proposing an enhancement or a PR with one. T-contract-runtime Team: issues relevant to the contract runtime team

Comments

@miloserdow
Copy link
Member

Description

In the NightshadeRuntime implementation, the function prepare_transactions currently processes transactions sequentially. It would be great to parallelize at least validate_transaction calls here, potentially more.

// chain/chain/src/runtime/mod.rs
impl RuntimeAdapter for NightshadeRuntime {
// [...]
fn prepare_transactions(
        &self,
        storage_config: RuntimeStorageConfig,
        chunk: PrepareTransactionsChunkContext,
        prev_block: PrepareTransactionsBlockContext,
        transaction_groups: &mut dyn TransactionGroupIterator,
        chain_validate: &mut dyn FnMut(&SignedTransaction) -> bool,
        time_limit: Option<Duration>,
    ) -> Result<PreparedTransactions, Error> {
    // [...]
    // Take a single transaction from this transaction group
    while let Some(tx_peek) = transaction_group_iter.peek_next() {
        // [...]
        let res = validate_transaction(
                    runtime_config,
                    prev_block.next_gas_price,
                    &tx,
                    true,
                    protocol_version,
                );

See also: PR-12654

@miloserdow miloserdow added A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) B-L3 Bootcamp: (“Task”) medium 10-50 line code change C-enhancement Category: An issue proposing an enhancement or a PR with one. T-contract-runtime Team: issues relevant to the contract runtime team labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) B-L3 Bootcamp: (“Task”) medium 10-50 line code change C-enhancement Category: An issue proposing an enhancement or a PR with one. T-contract-runtime Team: issues relevant to the contract runtime team
Projects
None yet
Development

No branches or pull requests

1 participant