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(pop-api): add call filter #49

Merged
merged 8 commits into from
Mar 28, 2024
Merged

feat(pop-api): add call filter #49

merged 8 commits into from
Mar 28, 2024

Conversation

peterwht
Copy link
Collaborator

Adds an allowed list call filter to chain extension.

pallet-contracts's CallFilter is not being used because it will allowb contracts to directly use call_runtime. Once the pop api pallet is introduced, the call filter should be implemented there.

There is a new example contract for testing purposes that tests that the call filter works.

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

Allowed calls should be explicit rather than module-wide and the included test contract shouldnt be located within examples.

runtime/src/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/Cargo.toml Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/Cargo.toml Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/Cargo.toml Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/lib.rs Outdated Show resolved Hide resolved
pop-api/examples/filtered-call/lib.rs Outdated Show resolved Hide resolved
pop-api/src/lib.rs Outdated Show resolved Hide resolved
@peterwht peterwht requested a review from evilrobot-01 March 24, 2024 21:04
Copy link
Collaborator

@al3mart al3mart left a comment

Choose a reason for hiding this comment

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

It would be good to set the same filter for pallet-contracts in general ?

In case some contracts decide to not use pop-api to call the runtime.

@peterwht
Copy link
Collaborator Author

It would be good to set the same filter for pallet-contracts in general ?

In case some contracts decide to not use pop-api to call the runtime.

We do not want to expose call_runtime directly because then we may break contracts with runtime upgrades. If we were to utilize the CallFilter in pallet-contracts, we would have to ONLY allow calls going into the Pop API pallet. Then we can filter a second layer in to ensure the next call is allowed

Copy link
Collaborator

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

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

LGTM. Would ideally be good to address the clippy warnings in extensions.rs, perhaps when resolving conflicts after runtime split is merged.

@peterwht peterwht force-pushed the peter/feat-api-call-filter branch from 2581118 to b655413 Compare March 28, 2024 00:16
@peterwht peterwht merged commit 6f3a0a8 into main Mar 28, 2024
5 checks passed
@peterwht peterwht deleted the peter/feat-api-call-filter branch March 28, 2024 18:20
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.

4 participants