Skip to content
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

Update blockifier #2397

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion adapters/core2p2p/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func AdaptExecutionResources(er *core.ExecutionResources) *gen.Receipt_Execution
var l1Gas, l1DataGas, l2Gas, totalL1Gas, totalL1DataGas *felt.Felt
if da := er.DataAvailability; da != nil { // todo(kirill) check that it might be null
l1Gas = new(felt.Felt).SetUint64(da.L1Gas)
l2Gas = new(felt.Felt).SetUint64(da.L2Gas)
l1DataGas = new(felt.Felt).SetUint64(da.L1DataGas)
}
if tgs := er.TotalGasConsumed; tgs != nil {
Expand Down
1 change: 0 additions & 1 deletion adapters/p2p2core/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func adaptExecutionResources(er *gen.Receipt_ExecutionResources) *core.Execution
},
DataAvailability: &core.DataAvailability{
L1Gas: feltToUint64(er.L1Gas),
L2Gas: feltToUint64(er.L2Gas),
L1DataGas: feltToUint64(er.L1DataGas),
},
MemoryHoles: uint64(er.MemoryHoles),
Expand Down
1 change: 0 additions & 1 deletion core/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ type ExecutionResources struct {
type DataAvailability struct {
L1Gas uint64
L1DataGas uint64
L2Gas uint64
AnkushinDaniil marked this conversation as resolved.
Show resolved Hide resolved
}

type BuiltinInstanceCounter struct {
Expand Down
1 change: 0 additions & 1 deletion rpc/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func adaptExecutionResources(resources *core.ExecutionResources) *ExecutionResou
if da := resources.DataAvailability; da != nil {
res.DataAvailability = &DataAvailability{
L1Gas: da.L1Gas,
L2Gas: da.L2Gas,
L1DataGas: da.L1DataGas,
}
}
Expand Down
9 changes: 9 additions & 0 deletions rpc/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@

func adaptFeederExecutionResources(resources *starknet.ExecutionResources) *vm.ExecutionResources {
builtins := &resources.BuiltinInstanceCounter
var l1Gas, l1DataGas, l2Gas uint64
if tgs := resources.TotalGasConsumed; tgs != nil {
l1Gas = tgs.L1Gas
l1DataGas = tgs.L1DataGas
l2Gas = tgs.L2Gas
}

Check warning on line 117 in rpc/trace.go

View check run for this annotation

Codecov / codecov/patch

rpc/trace.go#L114-L117

Added lines #L114 - L117 were not covered by tests
return &vm.ExecutionResources{
L1Gas: l1Gas,
L1DataGas: l1DataGas,
L2Gas: l2Gas,
ComputationResources: vm.ComputationResources{
Steps: resources.Steps,
MemoryHoles: resources.MemoryHoles,
Expand Down
17 changes: 12 additions & 5 deletions rpc/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"encoding/json"
"errors"
"fmt"
"strings"

"github.com/NethermindEth/juno/adapters/sn2core"
"github.com/NethermindEth/juno/clients/gateway"
Expand Down Expand Up @@ -164,6 +165,7 @@
const (
ResourceL1Gas Resource = iota + 1
ResourceL2Gas
ResourceL1DataGas
)

func (r Resource) MarshalText() ([]byte, error) {
Expand All @@ -172,19 +174,25 @@
return []byte("l1_gas"), nil
case ResourceL2Gas:
return []byte("l2_gas"), nil
case ResourceL1DataGas:
return []byte("l1_data_gas"), nil

Check warning on line 178 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L177-L178

Added lines #L177 - L178 were not covered by tests
default:
return nil, fmt.Errorf("unknown Resource %v", r)
}
}

func (r *Resource) UnmarshalJSON(data []byte) error {
switch string(data) {
case `"l1_gas"`:
str := string(data)
lowerStr := strings.ToLower(strings.Trim(str, `"`))
switch lowerStr {
case "l1_gas":
*r = ResourceL1Gas
case `"l2_gas"`:
case "l2_gas":
*r = ResourceL2Gas
case "l1_data_gas":
*r = ResourceL1DataGas

Check warning on line 193 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L192-L193

Added lines #L192 - L193 were not covered by tests
default:
return fmt.Errorf("unknown Resource: %q", string(data))
return fmt.Errorf("unknown Resource: %q", str)

Check warning on line 195 in rpc/transaction.go

View check run for this annotation

Codecov / codecov/patch

rpc/transaction.go#L195

Added line #L195 was not covered by tests
}
return nil
}
Expand Down Expand Up @@ -262,7 +270,6 @@
type DataAvailability struct {
L1Gas uint64 `json:"l1_gas"`
L1DataGas uint64 `json:"l1_data_gas"`
L2Gas uint64 `json:"l2_gas"`
}

type ExecutionResources struct {
Expand Down
21 changes: 7 additions & 14 deletions rpc/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
},
"steps": 29
}
Expand Down Expand Up @@ -616,8 +615,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
},
"steps": 31
}
Expand Down Expand Up @@ -660,8 +658,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
},
"steps": 31
}
Expand Down Expand Up @@ -701,8 +698,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
},
"steps": 31
}
Expand Down Expand Up @@ -737,8 +733,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
},
"steps": 0
}
Expand Down Expand Up @@ -805,8 +800,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_data_gas": 0,
"l1_gas": 0,
"l2_gas": 0
"l1_gas": 0
}
},
"actual_fee": {
Expand Down Expand Up @@ -871,8 +865,7 @@ func TestTransactionReceiptByHash(t *testing.T) {
"l2_gas": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 192,
"l2_gas": 0
"l1_data_gas": 192
}
}
}`
Expand Down
1 change: 0 additions & 1 deletion starknet/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ type ExecutionResources struct {
type DataAvailability struct {
L1Gas uint64 `json:"l1_gas"`
L1DataGas uint64 `json:"l1_data_gas"`
L2Gas uint64 `json:"l2_gas"`
}

type BuiltinInstanceCounter struct {
Expand Down
11 changes: 8 additions & 3 deletions vm/class.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import (

func marshalClassInfo(class core.Class) (json.RawMessage, error) {
var classInfo struct {
Class any `json:"contract_class"`
AbiLength uint32 `json:"abi_length"`
SierraLength uint32 `json:"sierra_program_length"`
CairoVersion uint32 `json:"cairo_version"`
Class any `json:"contract_class"`
AbiLength uint32 `json:"abi_length"`
SierraLength uint32 `json:"sierra_program_length"`
SierraVersion string `json:"sierra_version"`
}

switch c := class.(type) {
case *core.Cairo0Class:
var err error
classInfo.CairoVersion = 0
classInfo.Class, err = core2sn.AdaptCairo0Class(c)
if err != nil {
return nil, err
Expand All @@ -30,9 +33,11 @@ func marshalClassInfo(class core.Class) (json.RawMessage, error) {
}

// we adapt the core type to the feeder type to avoid using JSON tags in core.Class.CompiledClass
classInfo.CairoVersion = 1
classInfo.Class = core2sn.AdaptCompiledClass(c.Compiled)
classInfo.AbiLength = uint32(len(c.Abi))
classInfo.SierraLength = uint32(len(c.Program))
classInfo.SierraVersion = c.SemanticVersion
default:
return nil, fmt.Errorf("unsupported class type %T", c)
}
Expand Down
9 changes: 5 additions & 4 deletions vm/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ edition = "2021"
[dependencies]
serde = "1.0.208"
serde_json = { version = "1.0.125", features = ["raw_value"] }
blockifier = "=0.8.0-rc.3"
cairo-lang-runner = { version = "=2.8.5" }
starknet_api = "0.13.0-rc.1"
blockifier = "=0.14.0-rc.0"
cairo-lang-starknet-classes = "=2.10.0-rc.1"
cairo-lang-runner = { version = "2.10.0-rc.0" }
starknet_api = "=0.14.0-rc.0"
cairo-vm = "=1.0.1"
starknet-types-core = { version = "0.1.5", features = ["hash", "prime-bigint"] }
starknet-types-core = { version = "0.1.6", features = ["hash", "prime-bigint"] }
indexmap = "2.1.0"
cached = "0.54.0"
once_cell = "1.19.0"
Expand Down
Loading