-
Notifications
You must be signed in to change notification settings - Fork 26
feat: drop PolicyProvider
#701
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
base: rus/l1-aware-db
Are you sure you want to change the base?
Changes from all commits
e9cd5c4
22087ed
327d1a3
956e66a
9f06478
95366b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,8 +7,6 @@ pub struct L1BlockDeposits { | |||||||||||||||||||||||||||||||||
| pub header: SealedHeader<TempoHeader>, | ||||||||||||||||||||||||||||||||||
| /// Portal events extracted from this block. | ||||||||||||||||||||||||||||||||||
| pub events: L1PortalEvents, | ||||||||||||||||||||||||||||||||||
| /// TIP-403 policy events extracted from this block's receipts. | ||||||||||||||||||||||||||||||||||
| pub policy_events: Vec<PolicyEvent>, | ||||||||||||||||||||||||||||||||||
| /// Deposit queue hash chain value before this block's deposits. | ||||||||||||||||||||||||||||||||||
| pub queue_hash_before: B256, | ||||||||||||||||||||||||||||||||||
| /// Deposit queue hash chain value after this block's deposits. | ||||||||||||||||||||||||||||||||||
|
|
@@ -18,15 +16,13 @@ pub struct L1BlockDeposits { | |||||||||||||||||||||||||||||||||
| impl L1BlockDeposits { | ||||||||||||||||||||||||||||||||||
| /// Prepare all deposits for the payload builder. | ||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||
| /// Decrypts encrypted deposits, checks TIP-403 policy authorization, | ||||||||||||||||||||||||||||||||||
| /// and ABI-encodes everything into the types the `advanceTempo` call expects. | ||||||||||||||||||||||||||||||||||
| /// The resulting [`PreparedL1Block`] is ready to be passed through payload | ||||||||||||||||||||||||||||||||||
| /// attributes to the builder. | ||||||||||||||||||||||||||||||||||
| /// Decrypts encrypted deposits and ABI-encodes into the types the `advanceTempo` call expects. | ||||||||||||||||||||||||||||||||||
| /// Mint-recipient policy is enforced by upstream TIP-20 after the L1 state is anchored. | ||||||||||||||||||||||||||||||||||
| /// The resulting [`PreparedL1Block`] is ready to be passed via payload attributes to the builder. | ||||||||||||||||||||||||||||||||||
| pub async fn prepare( | ||||||||||||||||||||||||||||||||||
| self, | ||||||||||||||||||||||||||||||||||
| sequencer_key: &k256::SecretKey, | ||||||||||||||||||||||||||||||||||
| portal_address: Address, | ||||||||||||||||||||||||||||||||||
| policy_provider: &crate::state::PolicyProvider, | ||||||||||||||||||||||||||||||||||
| ) -> eyre::Result<PreparedL1Block> { | ||||||||||||||||||||||||||||||||||
| use crate::precompiles::ecies; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -54,7 +50,7 @@ impl L1BlockDeposits { | |||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| L1Deposit::Encrypted(d) => { | ||||||||||||||||||||||||||||||||||
| let mut queued = abi::QueuedDeposit { | ||||||||||||||||||||||||||||||||||
| let queued = abi::QueuedDeposit { | ||||||||||||||||||||||||||||||||||
| depositType: abi::DepositType::Encrypted, | ||||||||||||||||||||||||||||||||||
| depositData: Bytes::from( | ||||||||||||||||||||||||||||||||||
| abi::EncryptedDeposit { | ||||||||||||||||||||||||||||||||||
|
|
@@ -96,42 +92,9 @@ impl L1BlockDeposits { | |||||||||||||||||||||||||||||||||
| recipient = %dec.to, | ||||||||||||||||||||||||||||||||||
| token = %d.token, | ||||||||||||||||||||||||||||||||||
| amount = %d.amount, | ||||||||||||||||||||||||||||||||||
| "Decrypted encrypted deposit, checking policy" | ||||||||||||||||||||||||||||||||||
| "Decrypted encrypted deposit" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Check TIP-403 policy via the provider (cache-first, RPC fallback). | ||||||||||||||||||||||||||||||||||
| // Errors are propagated so the engine retries rather than allowing | ||||||||||||||||||||||||||||||||||
| // unauthorized deposits through. | ||||||||||||||||||||||||||||||||||
| let authorized = policy_provider | ||||||||||||||||||||||||||||||||||
| .is_authorized_async( | ||||||||||||||||||||||||||||||||||
| d.token, | ||||||||||||||||||||||||||||||||||
| dec.to, | ||||||||||||||||||||||||||||||||||
| l1_block_number, | ||||||||||||||||||||||||||||||||||
| crate::state::AuthRole::MintRecipient, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
| .await?; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if authorized { | ||||||||||||||||||||||||||||||||||
| debug!( | ||||||||||||||||||||||||||||||||||
| target: "zone::engine", | ||||||||||||||||||||||||||||||||||
| recipient = %dec.to, | ||||||||||||||||||||||||||||||||||
| token = %d.token, | ||||||||||||||||||||||||||||||||||
| "Policy authorized encrypted deposit recipient" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| warn!( | ||||||||||||||||||||||||||||||||||
| target: "zone::engine", | ||||||||||||||||||||||||||||||||||
| sender = %d.sender, | ||||||||||||||||||||||||||||||||||
| recipient = %dec.to, | ||||||||||||||||||||||||||||||||||
| token = %d.token, | ||||||||||||||||||||||||||||||||||
| amount = %d.amount, | ||||||||||||||||||||||||||||||||||
| "Encrypted deposit recipient unauthorized; queuing deposit bounce-back" | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| queued.rejected = true; | ||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we now never reject deposits? is it safe to just remove this logic?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they are rejected at execution when the 403 logic runs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically it would be this code which calls
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes since this is rejected at execution time, should be safe to remove here. |
||||||||||||||||||||||||||||||||||
| queued_deposits.push(queued); | ||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| let decryption = abi::DecryptionData { | ||||||||||||||||||||||||||||||||||
| sharedSecret: dec.proof.shared_secret, | ||||||||||||||||||||||||||||||||||
| sharedSecretYParity: dec.proof.shared_secret_y_parity, | ||||||||||||||||||||||||||||||||||
|
|
@@ -221,17 +184,16 @@ impl L1BlockDeposits { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /// An L1 block with deposits fully prepared for the payload builder. | ||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||
| /// All ECIES decryption, TIP-403 policy checks, and ABI encoding have been | ||||||||||||||||||||||||||||||||||
| /// performed. The builder only needs to RLP-encode the header and assemble | ||||||||||||||||||||||||||||||||||
| /// the `advanceTempo` calldata. | ||||||||||||||||||||||||||||||||||
| /// All ECIES decryption and ABI encoding have been performed. | ||||||||||||||||||||||||||||||||||
| /// The builder only needs to RLP-encode the header and assemble the `advanceTempo` calldata. | ||||||||||||||||||||||||||||||||||
| #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||||||||||||||||||||||||||||||||||
| pub struct PreparedL1Block { | ||||||||||||||||||||||||||||||||||
| /// The sealed L1 block header. | ||||||||||||||||||||||||||||||||||
| pub header: SealedHeader<TempoHeader>, | ||||||||||||||||||||||||||||||||||
| /// ABI-encoded queued deposits (regular + encrypted). | ||||||||||||||||||||||||||||||||||
| #[serde(skip)] | ||||||||||||||||||||||||||||||||||
| pub queued_deposits: Vec<abi::QueuedDeposit>, | ||||||||||||||||||||||||||||||||||
| /// Decryption data for non-rejected encrypted deposits, in order. | ||||||||||||||||||||||||||||||||||
| /// Decryption data for encrypted deposits accepted for on-chain verification, in order. | ||||||||||||||||||||||||||||||||||
| #[serde(skip)] | ||||||||||||||||||||||||||||||||||
| pub decryptions: Vec<abi::DecryptionData>, | ||||||||||||||||||||||||||||||||||
| /// Tokens newly enabled for bridging in this block. | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagging that this now depends on the raw-cache invalidation issue from #698. Once this precheck is removed, encrypted deposits rely on that cache for authorization, so a stale hit can mint where a cold node would bounce.