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

feat: add associated types as tx hooks args #1225

Merged
merged 5 commits into from
Dec 18, 2023

Conversation

vlopes11
Copy link
Contributor

This commit introduces associated types to the TxHooks trait, enhancing its ability to define custom interactions between the trait and its implementing modules. The associated types allow for greater flexibility in the implementation of TxHooks, enabling diverse use cases beyond the current Accounts module.

The current Accounts implementation of TxHooks serves the purpose of extracting a public key from a transaction and mapping it to a rollup address, creating an execution context. This functionality is achieved through the pre_dispatch_tx_hook signature which returns a C::Address. However, this tight coupling with the accounts module restricts future expansions of TxHooks.

With this modification, hooks gain increased versatility and modules are free to implement them as per their requirements. Additionally, runtimes can consume these implementations, utilizing them as essential building blocks, while the banks module is empowered to enforce a gas cap on the pre-dispatch hook.

This commit introduces associated types to the `TxHooks` trait,
enhancing its ability to define custom interactions between the trait
and its implementing modules. The associated types allow for greater
flexibility in the implementation of `TxHooks`, enabling diverse use
cases beyond the current `Accounts` module.

The current `Accounts` implementation of `TxHooks` serves the purpose of
extracting a public key from a transaction and mapping it to a rollup
address, creating an execution context. This functionality is achieved
through the `pre_dispatch_tx_hook` signature which returns a
`C::Address`. However, this tight coupling with the `accounts` module
restricts future expansions of `TxHooks`.

With this modification, hooks gain increased versatility and modules are
free to implement them as per their requirements. Additionally, runtimes
can consume these implementations, utilizing them as essential building
blocks, while the banks module is empowered to enforce a gas cap on the
pre-dispatch hook.
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

Merging #1225 (cc46a64) into nightly (a23a76f) will increase coverage by 0.0%.
Report is 3 commits behind head on nightly.
The diff coverage is 93.3%.

Additional details and impacted files
Files Coverage Δ
full-node/sov-sequencer/src/batch_builder.rs 97.0% <100.0%> (+<0.1%) ⬆️
...tions/integration-tests/src/chain_state/helpers.rs 78.5% <100.0%> (+1.3%) ⬆️
...m/module-implementations/sov-accounts/src/hooks.rs 100.0% <100.0%> (+3.7%) ⬆️
...tem/module-implementations/sov-accounts/src/lib.rs 66.6% <ø> (ø)
...m/module-implementations/sov-accounts/src/tests.rs 99.4% <100.0%> (+<0.1%) ⬆️
...implementations/sov-prover-incentives/src/tests.rs 100.0% <100.0%> (ø)
...tem/sov-modules-api/src/containers/kernel_value.rs 44.8% <100.0%> (+0.8%) ⬆️
...em/sov-modules-rollup-blueprint/src/runtime_rpc.rs 100.0% <100.0%> (ø)
module-system/sov-modules-stf-blueprint/src/lib.rs 89.8% <ø> (ø)
...tem/sov-modules-stf-blueprint/src/stf_blueprint.rs 88.2% <100.0%> (+0.2%) ⬆️
... and 1 more

... and 3 files with indirect coverage changes

@vlopes11 vlopes11 requested a review from bkolad December 15, 2023 12:54
@vlopes11 vlopes11 requested a review from bkolad December 15, 2023 14:03
@vlopes11 vlopes11 added this pull request to the merge queue Dec 18, 2023
Merged via the queue into nightly with commit 6067bbd Dec 18, 2023
16 checks passed
@vlopes11 vlopes11 deleted the vlopes11/feature/tx-hooks-args branch December 18, 2023 10:40
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