-
Notifications
You must be signed in to change notification settings - Fork 11
feat: support 'legacy' v3 transaction resource bounds #141
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
Conversation
|
Claude finished @kariy's task —— View job PR Review: Legacy V3 Transaction Resource Bounds
|
Binary size report 📊
|
|
Claude finished @kariy's task —— View job PR Review: Legacy V3 Transaction Resource Bounds
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #141 +/- ##
==========================================
- Coverage 73.44% 73.32% -0.12%
==========================================
Files 209 209
Lines 22944 23130 +186
==========================================
+ Hits 16852 16961 +109
- Misses 6092 6169 +77 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Claude finished @kariy's task —— View job PR Review: Legacy V3 Transaction Resource BoundsReview Tasks
OverviewThis PR implements support for "legacy" v3 transaction resource bounds, enabling backward compatibility for v3 transactions created before L1 data gas resource bounds were introduced. The implementation extends the
Code Quality & Best Practices✅ Strengths
|
|
Claude finished @kariy's task —— View job PR Review: Legacy V3 Transaction Resource BoundsReview Tasks
OverviewThis PR implements support for "legacy" v3 transaction resource bounds, enabling backward compatibility for v3 transactions created before L1 data gas resource bounds were introduced. The implementation extends the
Code Quality & Best Practices✅ Strengths
|
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>
## 'Legacy' Transaction V3 When V3 transaction was first introduced in RPC [v0.6.0], the `resource_bounds` field consists of only two fields; `l1_gas` and `l2_gas`. These values are included in the hash computation for the V3 transaction. But RPC [v0.8.0], a new field is added to the mapping, `l1_data_gas`. The addition of the new field means there are now two variations of the V3 transaction - with or without `l1_data_gas`. Depending on the presence of the field, the transaction hash is computed differently. Transaction V3 w/o `l1_data_gas` (legacy) hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` Transaction V3 w/ `l1_data_gas` hash: ``` h( "prefix", version, sender_address, h(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds), h(paymaster_data), chain_id, nonce, data_availability_modes, h(account_deployment_data), h(calldata) ) ``` V3 transaction without the `l1_data_gas` is referred to as 'legacy' V3. ## Previous Refactors When pull request [#141] was made, I didn't take into account the possibility that a transaction with 'legacy' resource bounds would have a nonzero `l2_gas`. Hence why in that pull request, the `ResourceBoundsMapping::L1Gas` wraps a `ResourceBounds` struct - intended only for the `l1_gas` field. Currently, when computing the hash for transaction that uses the legacy resource bounds mapping, Katana naively assumes that the `l2_gas` bounds is 0. While this is true for most part, because some Starknet client libraries (eg `starknet-rs`) hardcoded the `l2_gas` to 0, but this doesn't fully negate the possibility that a transaction could be submitted with non-zero `l2_gas`. Even though the `l2_gas` wasn't actually used for execution, it is still used to compute the hash for the transaction. Preserving all the bounds is important if we want to make sure the hashes of transactions stored in the Katana database are reproducible! Honestly, if we only consider the transaction version that Katana supports now - 0.14.0 compatible transaction where all 3 bounds must be present - then this change really doesn't do anything at all. Transactions using legacy resource bounds will be outright rejected by the RPC server, and we don't have to worry about ensuring their hashes reproducibility. This change only matters once we have Katana running as a full node, syncing from Starknet mainnet/sepolia where transactions with only `l1_gas` and `l2_gas` resource bounds exist. As such, it is important that all details of a transaction is preserved correctly. ## Database Compatibility This change isn't compatible with the current database format. As such a database version bump is required! [v0.6.0]: https://github.com/starkware-libs/starknet-specs/blob/49665932a97f8fdef7ac5869755d2858c5e3a687/api/starknet_api_openrpc.json#L3714 [v0.8.0]: https://github.com/starkware-libs/starknet-specs/blob/b4f81445c79b2a8b2b09ff5bb2b7eddca78a32de/api/starknet_api_openrpc.json#L3494-L3514 [#141]: #141 --------- Co-authored-by: Claude <noreply@anthropic.com>

In order to support database migration through re-execution of historical blocks, the transactions must be executed using the exact same parameters as when it was first executed. Currently, when the v6 versioned transaction (which uses 'legacy' v3 transactions resource bounds) is converted into
blockifier'sTransaction:katana/crates/executor/src/implementation/blockifier/utils.rs
Lines 156 to 405 in 39f66a5
the resource bounds is always mapped to
ValidResourceBounds::AllResources, this variant is for when all 3 bounds are specified by the transaction.katana/crates/executor/src/implementation/blockifier/utils.rs
Lines 565 to 582 in 39f66a5
The resource bounds variant used matters here as it will determine how the transaction is being priced. Previous versions of
katanawere mapping to theblockifier's counterpart like so:katana/crates/katana/executor/src/implementation/blockifier/utils.rs
Lines 490 to 504 in 783827e
which now is the equivalent of mapping to
ValidResourcesBounds::L1Gas:katana/crates/executor/src/implementation/blockifier/utils.rs
Lines 592 to 595 in 10b51e8
The information about the correct resource bounds must be preserved in order to re-execute it exactly as it was for the first time.