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

Remove transmutation of persistent executor #5253

Open
mversic opened this issue Nov 26, 2024 · 1 comment
Open

Remove transmutation of persistent executor #5253

mversic opened this issue Nov 26, 2024 · 1 comment

Comments

@mversic
Copy link
Contributor

mversic commented Nov 26, 2024

Currently WasmCache stores &'world mut StateTransaction<'block, 'state> inside. We create WasmCache before obtaining any StateTransaction, so the first problem is that there is no 'world lifetime when we create WasmCache.

I tried to eliminate 'world lifetime by storing Arc<RefCell<StateTransaction<'block, 'state>>> inside WasmCache. In this case problem will be in categorize_transactions function. Basically:

fn categorize_transactions<'block, 'state>(
    transactions: Vec<AcceptedTransaction>,
    state_block: &'block mut StateBlock<'state>,
) -> Vec<CommittedTransaction> {
    let wasm_cache: WasmCache<'block, 'state> = WasmCache::new();
    validate(tx1, state_block, &mut wasm_cache);
    validate(tx2, state_block, &mut wasm_cache);  // here borrow check error
    ...
}

fn validate(
    tx: AcceptedTransaction,
    state_block: &'block mut StateBlock<'state>,
    wasm_cache: &mut WasmCache<'block, 'state>,
) {
    ...
}

&mut WasmCache<'block, 'state> is invariant over 'block thus calling validate multiple times will fail borrow check

Originally posted by @dima74 in #5082 (comment)

@s8sato s8sato self-assigned this Nov 28, 2024
@s8sato
Copy link
Contributor

s8sato commented Dec 2, 2024

I concluded that the current approach is the best:
since Store<T> instantiates and owns Instance, the only way to handle numerous T (corresponds to a transaction) while keeping a single Instance would be to have a comprehensive T (i.e. Option<CommonState<WithMut<'txn, 'block, 'base>, Validate<SignedTransaction>>>) and replace it transmuting about lifetimes (i.e. 'txn)

@s8sato s8sato removed their assignment Dec 2, 2024
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

No branches or pull requests

2 participants