Skip to content

Commit

Permalink
Add DA costs to Receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Feb 26, 2024
1 parent 6e8c601 commit f881689
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func AdaptExecutionResources(response *starknet.ExecutionResources) *core.Execut
BuiltinInstanceCounter: core.BuiltinInstanceCounter(response.BuiltinInstanceCounter),
MemoryHoles: response.MemoryHoles,
Steps: response.Steps,
DataAvailability: (*core.DataAvailability)(response.DataAvailability),
}
}

Expand Down
4 changes: 4 additions & 0 deletions adapters/sn2core/sn2core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func TestAdaptBlock(t *testing.T) {
for i, feederReceipt := range response.Receipts {
assert.Equal(t, feederReceipt.ExecutionStatus == starknet.Reverted, block.Receipts[i].Reverted)
assert.Equal(t, feederReceipt.RevertError, block.Receipts[i].RevertReason)
if feederReceipt.ExecutionResources != nil {
assert.Equal(t, (*core.DataAvailability)(feederReceipt.ExecutionResources.DataAvailability),
block.Receipts[i].ExecutionResources.DataAvailability)
}
}
}
assert.Equal(t, expectedEventCount, block.EventCount)
Expand Down
2 changes: 2 additions & 0 deletions clients/feeder/feeder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ func TestBlockHeaderV0131Unmarshal(t *testing.T) {
require.Equal(t, utils.HexToFelt(t, "0x3c0c00c87"), block.L1DataGasPrice.PriceInFri)
require.Equal(t, starknet.Blob, block.L1DAMode)
require.Equal(t, "0.13.1", block.Version)
require.Equal(t, uint64(0), block.Receipts[0].ExecutionResources.DataAvailability.L1Gas)
require.Equal(t, uint64(128), block.Receipts[0].ExecutionResources.DataAvailability.L1DataGas)
}

func TestClassV0Unmarshal(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions core/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ type ExecutionResources struct {
BuiltinInstanceCounter BuiltinInstanceCounter
MemoryHoles uint64
Steps uint64
DataAvailability *DataAvailability
}

type DataAvailability struct {
L1Gas uint64
L1DataGas uint64
}

type BuiltinInstanceCounter struct {
Expand Down
6 changes: 6 additions & 0 deletions starknet/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ type ExecutionResources struct {
Steps uint64 `json:"n_steps"`
BuiltinInstanceCounter BuiltinInstanceCounter `json:"builtin_instance_counter"`
MemoryHoles uint64 `json:"n_memory_holes"`
DataAvailability *DataAvailability `json:"data_availability"`
}

type DataAvailability struct {
L1Gas uint64 `json:"l1_gas"`
L1DataGas uint64 `json:"l1_data_gas"`
}

type BuiltinInstanceCounter struct {
Expand Down

0 comments on commit f881689

Please sign in to comment.