-
Notifications
You must be signed in to change notification settings - Fork 166
fix(levm): reorder fee token validations to prevent storage rollback issue #6045
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: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -462,8 +462,11 @@ fn prepare_execution_fee_token(vm: &mut VM<'_>) -> Result<(), crate::errors::VME | |||||||||||||||||||||||
| // (2) INSUFFICIENT_MAX_FEE_PER_BLOB_GAS | ||||||||||||||||||||||||
| // NOT CHECKED: the blob price does not matter, fee token transactions do not support blobs | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // (3) INSUFFICIENT_ACCOUNT_FUNDS | ||||||||||||||||||||||||
| deduct_caller_fee_token(vm, gaslimit_price_product.saturating_mul(fee_token_ratio))?; | ||||||||||||||||||||||||
| // ═══════════════════════════════════════════════════════════════════════════ | ||||||||||||||||||||||||
| // IMPORTANT: All validations that can fail MUST happen BEFORE fee deduction. | ||||||||||||||||||||||||
| // Fee token storage changes via `transfer_fee_token` bypass the backup | ||||||||||||||||||||||||
| // mechanism, so they cannot be rolled back if validation fails later. | ||||||||||||||||||||||||
| // ═══════════════════════════════════════════════════════════════════════════ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // (4) INSUFFICIENT_MAX_FEE_PER_GAS | ||||||||||||||||||||||||
| default_hook::validate_sufficient_max_fee_per_gas(vm)?; | ||||||||||||||||||||||||
|
|
@@ -515,6 +518,11 @@ fn prepare_execution_fee_token(vm: &mut VM<'_>) -> Result<(), crate::errors::VME | |||||||||||||||||||||||
| // Transaction is type 4 if authorization_list is Some | ||||||||||||||||||||||||
| // NOT CHECKED: fee token transactions are not type 4 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // (3) INSUFFICIENT_ACCOUNT_FUNDS | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| // NOTE: Fee deduction is intentionally placed AFTER all validations above. | ||||||||||||||||||||||||
| // This ensures that if any validation fails, fee tokens are never locked. | ||||||||||||||||||||||||
| deduct_caller_fee_token(vm, gaslimit_price_product.saturating_mul(fee_token_ratio))?; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| default_hook::transfer_value(vm)?; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
| // NOTE: Fee deduction is intentionally placed AFTER all validations above. | |
| // This ensures that if any validation fails, fee tokens are never locked. | |
| deduct_caller_fee_token(vm, gaslimit_price_product.saturating_mul(fee_token_ratio))?; | |
| default_hook::transfer_value(vm)?; | |
| // NOTE: Fee deduction is intentionally placed AFTER all validations above | |
| // and AFTER value transfer. This ensures that if any validation or value | |
| // transfer fails, fee tokens are never locked. | |
| default_hook::transfer_value(vm)?; | |
| deduct_caller_fee_token(vm, gaslimit_price_product.saturating_mul(fee_token_ratio))?; |
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.
Now there's a gap in the numbering.