refactor(rpc/v10): rework AddTransaction, decouple EstimateMessageFee, tighten validation#3582
refactor(rpc/v10): rework AddTransaction, decouple EstimateMessageFee, tighten validation#3582thiagodeev wants to merge 41 commits into
Conversation
… pointers in ResourceBoundsMap
… required fields and remove JSON unmarshal method
…ssary nil checks and simplifying resource bounds handling
… handling with generics
…mize AddTransaction flow In our old code, we were unnecessarily compiling the casm class in the ' h.receivedTransactionFeed != nil' condition
…create a new payload type for it
2827ddb to
f00cd36
Compare
…dcastedTransactionToCore and CompileBroadcastedDeclareTxn
f00cd36 to
9920346
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3582 +/- ##
==========================================
- Coverage 75.15% 75.05% -0.11%
==========================================
Files 427 427
Lines 38456 38663 +207
==========================================
+ Hits 28902 29017 +115
- Misses 7548 7637 +89
- Partials 2006 2009 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…he EstimateMessageFee method
…n DeployAccount transaction handling
9217d61 to
214dfec
Compare
0a54650 to
c75c681
Compare
68ab5af to
95aaac4
Compare
|
Claude finished @thiagodeev's task in 5m 15s —— View job Claude Code ReviewI reviewed the v10
SummaryThe refactor is well-structured and the performance wins are real. I found one blocker (a typed-nil interface bug that panics the builder), plus a few minor notes. 🔴 Blocker
🟡 Minor / nits
✅ Looks good
|
…mpileBroadcastedTxToCore to avoid nil interface bugs
…l on estimateMessageFee
|
Claude finished @thiagodeev's task in 4m 54s —— View job Claude Code ReviewRe-reviewed after the latest pushes (typed-nil fix,
SummaryThe earlier blocker is fixed ✅ and I found no new blockers. Remaining items are minor/nits. ✅ Blocker resolved — typed-nil
|
| DeployTransaction: core.DeployTransaction{ | ||
| TransactionHash: txn.Hash, | ||
| ContractAddressSalt: txn.ContractAddressSalt, | ||
| // bug: TxnDeployAccount does not contain SenderAddress field, so this is nil |
| var l1DataGasResourceBounds ResourceBounds | ||
| if _, ok := rb[core.ResourceL1DataGas]; ok { | ||
| l1DataGasResourceBounds = &ResourceBounds{ | ||
| l1DataGasResourceBounds = ResourceBounds{ | ||
| MaxAmount: felt.NewFromUint64[felt.Felt](rb[core.ResourceL1DataGas].MaxAmount), | ||
| MaxPricePerUnit: rb[core.ResourceL1DataGas].MaxPricePerUnit, | ||
| } | ||
| } else { | ||
| l1DataGasResourceBounds = &ResourceBounds{ | ||
| l1DataGasResourceBounds = ResourceBounds{ | ||
| MaxAmount: &felt.Zero, | ||
| MaxPricePerUnit: &felt.Zero, | ||
| } | ||
| } |
There was a problem hiding this comment.
alternatively to avoid the if else block:
l1DataGasResourceBounds := ResourceBounds{
MaxAmount: &felt.Zero,
MaxPricePerUnit: &felt.Zero,
}
if _, ok := rb[core.ResourceL1DataGas]; ok {
l1DataGasResourceBounds = ResourceBounds{
MaxAmount: felt.NewFromUint64[felt.Felt](rb[core.ResourceL1DataGas].MaxAmount),
MaxPricePerUnit: rb[core.ResourceL1DataGas].MaxPricePerUnit,
}
}|
Claude finished @thiagodeev's task in 1m 38s —— View job Claude Code ReviewRe-reviewed after the latest push (
SummaryNo new blockers. The new commit is a clean, behavior-preserving refactor and the previously-fixed typed-nil ✅ New change is correct —
|
|
@claude you're wrong. The gateway branch only calls |
TODO: apply the changes for other rpc pkgs as well
Validation
validator.WithRequiredStructEnabled. Lets us drop pointer indirection onResourceBoundsMap/ResourceBounds(value types now) and rely onvalidatetags directly on the fields.EstimateMessageFeedecoupled fromEstimateFeeBroadcastedTransactionso it could reuse theEstimateFeeplumbing. That workaround is gone —EstimateMessageFeenow has its own direct path with noBroadcastedTransactionround-trip.AddTransactionrefactorAdaptBroadcastedTransactioninto smaller, single-purpose functions.ContractClasstype for thecontract_classfield instead ofjson.RawMessage. Two wins:BroadcastedTransaction → core.Transaction, removing the intermediate hop throughstarknet.Transaction.Bug fix (v9; v10 unaffected)
DECLAREtransactions,pushToFeederGatewaywas mutating the originaltx.ContractClass. By the time the tx reachedreceivedTransactionFeed, the mutated state caused the send to fail and the tx was never published.Benchmark result:
Config: count=5, benchtime=3s, Intel i5-11400H @ 2.70GHz, Go 1.26.
ContractClassToGatewayPayload(pooledgzip.Writer,gzip.BestSpeed, streamed json -> gzip -> base64 pipeline).ContractClasswork involved.Declare_RealCompiler_Gatewaygain is modest because FFI Sierra->CASM compile dominates wall-clock time.