Skip to content

Commit 6dcb2f5

Browse files
Add l2 gas
1 parent 6212ab5 commit 6dcb2f5

File tree

7 files changed

+13
-3
lines changed

7 files changed

+13
-3
lines changed

adapters/core2p2p/receipt.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ func AdaptExecutionResources(er *core.ExecutionResources) *gen.Receipt_Execution
103103
return nil
104104
}
105105

106-
var l1Gas, l1DataGas, totalL1Gas *felt.Felt
106+
var l1Gas, l2Gas, l1DataGas, totalL1Gas *felt.Felt
107107
if da := er.DataAvailability; da != nil { // todo(kirill) check that it might be null
108108
l1Gas = new(felt.Felt).SetUint64(da.L1Gas)
109+
l2Gas = new(felt.Felt).SetUint64(da.L2Gas)
109110
l1DataGas = new(felt.Felt).SetUint64(da.L1DataGas)
110111
}
111112
if tgs := er.TotalGasConsumed; tgs != nil {
@@ -129,6 +130,7 @@ func AdaptExecutionResources(er *core.ExecutionResources) *gen.Receipt_Execution
129130
Steps: uint32(er.Steps),
130131
MemoryHoles: uint32(er.MemoryHoles),
131132
L1Gas: AdaptFelt(l1Gas),
133+
L2Gas: AdaptFelt(l2Gas),
132134
L1DataGas: AdaptFelt(l1DataGas),
133135
TotalL1Gas: AdaptFelt(totalL1Gas),
134136
}

adapters/core2p2p/transaction.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ func adaptResourceLimits(bounds core.ResourceBounds) *gen.ResourceLimits {
161161

162162
func adaptResourceBounds(rb map[core.Resource]core.ResourceBounds) *gen.ResourceBounds {
163163
return &gen.ResourceBounds{
164-
L1Gas: adaptResourceLimits(rb[core.ResourceL1Gas]),
165-
L2Gas: adaptResourceLimits(rb[core.ResourceL2Gas]),
164+
L1Gas: adaptResourceLimits(rb[core.ResourceL1Gas]),
165+
L1DataGas: adaptResourceLimits(rb[core.ResourceL1DataGas]),
166+
L2Gas: adaptResourceLimits(rb[core.ResourceL2Gas]),
166167
}
167168
}
168169

adapters/p2p2core/receipt.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ func adaptExecutionResources(er *gen.Receipt_ExecutionResources) *core.Execution
5858
},
5959
DataAvailability: &core.DataAvailability{
6060
L1Gas: feltToUint64(er.L1Gas),
61+
L2Gas: feltToUint64(er.L2Gas),
6162
L1DataGas: feltToUint64(er.L1DataGas),
6263
},
6364
MemoryHoles: uint64(er.MemoryHoles),
6465
Steps: uint64(er.Steps), // todo SPEC 32 -> 64 bytes
6566
TotalGasConsumed: &core.GasConsumed{
6667
L1Gas: feltToUint64(er.TotalL1Gas),
68+
L2Gas: feltToUint64(er.L2Gas),
6769
// total_l1_data_gas = l1_data_gas, because there's only one place that can generate l1_data_gas costs
6870
L1DataGas: feltToUint64(er.L1DataGas),
6971
},

adapters/sn2core/sn2core.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func adaptGasConsumed(response *starknet.GasConsumed) *core.GasConsumed {
9090
return &core.GasConsumed{
9191
L1Gas: response.L1Gas,
9292
L1DataGas: response.L1DataGas,
93+
L2Gas: response.L2Gas,
9394
}
9495
}
9596

core/receipt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
type GasConsumed struct {
1313
L1Gas uint64
1414
L1DataGas uint64
15+
L2Gas uint64
1516
}
1617

1718
type TransactionReceipt struct {

core/transaction.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type ExecutionResources struct {
106106
type DataAvailability struct {
107107
L1Gas uint64
108108
L1DataGas uint64
109+
L2Gas uint64
109110
}
110111

111112
type BuiltinInstanceCounter struct {

starknet/transaction.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ type ExecutionResources struct {
220220
type DataAvailability struct {
221221
L1Gas uint64 `json:"l1_gas"`
222222
L1DataGas uint64 `json:"l1_data_gas"`
223+
L2Gas uint64 `json:"l2_gas"`
223224
}
224225

225226
type BuiltinInstanceCounter struct {
@@ -240,6 +241,7 @@ type BuiltinInstanceCounter struct {
240241
type GasConsumed struct {
241242
L1Gas uint64 `json:"l1_gas"`
242243
L1DataGas uint64 `json:"l1_data_gas"`
244+
L2Gas uint64 `json:"l2_gas"`
243245
}
244246

245247
type TransactionReceipt struct {

0 commit comments

Comments
 (0)