Skip to content

Commit 9783760

Browse files
authored
Merge pull request #6 from opentensor/polkadot-stable2506-2-otf-mev-block-builder
Shielded transactions support in block proposer
2 parents a584a57 + 09bcca6 commit 9783760

File tree

23 files changed

+1424
-61
lines changed

23 files changed

+1424
-61
lines changed

Cargo.lock

Lines changed: 74 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
594594
'cfg(ignore_flaky_test)',
595595
'cfg(substrate_runtime)',
596596
] }
597+
mismatched_lifetime_syntaxes = "allow"
597598

598599
[workspace.lints.clippy]
599600
all = { level = "allow", priority = 0 }
@@ -1468,6 +1469,11 @@ zombienet-orchestrator = { version = "0.3.0" }
14681469
zombienet-sdk = { version = "0.3.0" }
14691470
zstd = { version = "0.12.4", default-features = false }
14701471

1472+
stp-shield = { path = "substrate/primitives/shield", default-features = false }
1473+
stc-shield = { path = "substrate/client/shield", default-features = false }
1474+
ml-kem = { version = "0.2.2", default-features = false }
1475+
chacha20poly1305 = { version = "0.10", default-features = false }
1476+
14711477
[profile.release]
14721478
# Polkadot runtime requires unwinding.
14731479
opt-level = 3

substrate/client/basic-authorship/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ sp-inherents.default-features = true
4141
sp-inherents.workspace = true
4242
sp-runtime.default-features = true
4343
sp-runtime.workspace = true
44+
stp-shield = { workspace = true, default-features = true}
4445

4546
[dev-dependencies]
4647
parking_lot = { workspace = true, default-features = true }
4748
sc-client-api = { default-features = true, workspace = true }
4849
sc-transaction-pool = { default-features = true, workspace = true }
4950
substrate-test-runtime-client = { workspace = true }
51+
stc-shield = { workspace = true, default-features = true }

substrate/client/basic-authorship/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
Basic implementation of block-authoring logic.
22

3+
## MEV Shield integration
4+
5+
When a `ShieldKeystorePtr` is provided to `ProposerFactory`, the proposer will handle shielded transactions during block authoring:
6+
7+
1. Each pending transaction is inspected via the `ShieldApi` runtime API to detect whether it is a shielded wrapper.
8+
2. Shielded transactions are decrypted on the spot using the keystore registered as a runtime extension. Block size accounting is adjusted to reflect the inner plaintext size rather than the ciphertext size.
9+
3. If the wrapper extrinsic applies successfully, the decrypted inner transaction is immediately pushed into the block as a second extrinsic.
10+
11+
Decryption happens only at block authoring time, never earlier. Setting the environment variable `SUBSTRATE_SKIP_SHIELDED_TXS=1` causes the proposer to skip all shielded transactions (leaving them in the pool for other authors).
12+
13+
See [`stp-shield`](../../primitives/shield) and [`stc-shield`](../shield) for the underlying types and keystore implementation.
14+
315
# Example
416

517
```rust

0 commit comments

Comments
 (0)