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 cairo-vm requirement from =1.0.0-rc5 to =1.0.0-rc6 in /vm/rust #1997

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/vm/rust"
schedule:
interval: "weekly"
5 changes: 5 additions & 0 deletions adapters/p2p2core/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ func adaptExecutionResources(er *spec.Receipt_ExecutionResources) *core.Executio
Keccak: uint64(er.GetBuiltins().GetKeccak()),
Poseidon: uint64(er.GetBuiltins().GetPoseidon()),
SegmentArena: 0, // todo(kirill) recheck
// todo(kirill) set fields after spec update
AddMod: 0,
MulMod: 0,
RangeCheck96: 0,
},
DataAvailability: nil, // todo(kirill) recheck
MemoryHoles: uint64(er.MemoryHoles),
Steps: uint64(er.Steps), // todo SPEC 32 -> 64 bytes
TotalGasConsumed: nil, // todo(kirill) fill after spec update
}
}

Expand Down
12 changes: 12 additions & 0 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ func AdaptTransactionReceipt(response *starknet.TransactionReceipt) *core.Transa
}
}

func adaptGasConsumed(response *starknet.GasConsumed) *core.GasConsumed {
if response == nil {
return nil
}

return &core.GasConsumed{
L1Gas: response.L1Gas,
L1DataGas: response.L1DataGas,
}
}

func AdaptEvent(response *starknet.Event) *core.Event {
if response == nil {
return nil
Expand All @@ -101,6 +112,7 @@ func AdaptExecutionResources(response *starknet.ExecutionResources) *core.Execut
MemoryHoles: response.MemoryHoles,
Steps: response.Steps,
DataAvailability: (*core.DataAvailability)(response.DataAvailability),
TotalGasConsumed: adaptGasConsumed(response.TotalGasConsumed),
}
}

Expand Down
4 changes: 4 additions & 0 deletions adapters/vm2core/vm2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ func AdaptExecutionResources(resources *vm.ExecutionResources) *core.ExecutionRe
Poseidon: resources.Poseidon,
SegmentArena: resources.SegmentArena,
Output: 0, // todo(kirill) recheck, add Output field to core?
AddMod: resources.AddMod,
MulMod: resources.MulMod,
RangeCheck96: resources.RangeCheck96,
},
MemoryHoles: resources.MemoryHoles,
Steps: resources.Steps,
DataAvailability: adaptDA(resources.DataAvailability),
TotalGasConsumed: nil, // todo: fill after 0.13.2
}
}

Expand Down
5 changes: 3 additions & 2 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type Reader interface {

var (
ErrParentDoesNotMatchHead = errors.New("block's parent hash does not match head block hash")
supportedStarknetVersion = semver.MustParse("0.13.1")
supportedStarknetVersion = semver.MustParse("0.13.2")
)

func checkBlockVersion(protocolVersion string) error {
Expand Down Expand Up @@ -340,6 +340,7 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit
if err := verifyBlock(txn, block); err != nil {
return err
}

if err := core.NewState(txn).Update(block.Number, stateUpdate, newClasses); err != nil {
return err
}
Expand Down Expand Up @@ -636,7 +637,7 @@ func (b *Blockchain) SanityCheckNewHeight(block *core.Block, stateUpdate *core.S
return nil, err
}

return core.VerifyBlockHash(block, b.network)
return core.VerifyBlockHash(block, b.network, stateUpdate.StateDiff)
}

type txAndReceiptDBKey struct {
Expand Down
25 changes: 25 additions & 0 deletions blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,31 @@ func TestStore(t *testing.T) {
})
}

func TestBlockCommitments(t *testing.T) {
chain := blockchain.New(pebble.NewMemTest(t), &utils.Mainnet)
client := feeder.NewTestClient(t, &utils.Mainnet)
gw := adaptfeeder.New(client)

b, err := gw.BlockByNumber(context.Background(), 0)
require.NoError(t, err)

su, err := gw.StateUpdate(context.Background(), 0)
require.NoError(t, err)

expectedCommitments := &core.BlockCommitments{
TransactionCommitment: new(felt.Felt).SetUint64(1),
EventCommitment: new(felt.Felt).SetUint64(2),
ReceiptCommitment: new(felt.Felt).SetUint64(3),
StateDiffCommitment: new(felt.Felt).SetUint64(4),
}

require.NoError(t, chain.Store(b, expectedCommitments, su, nil))

commitments, err := chain.BlockCommitmentsByNumber(0)
require.NoError(t, err)
require.Equal(t, expectedCommitments, commitments)
}

func TestTransactionAndReceipt(t *testing.T) {
chain := blockchain.New(pebble.NewMemTest(t), &utils.Mainnet)

Expand Down
16 changes: 16 additions & 0 deletions clients/feeder/feeder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ func TestBlockHeaderV0131Unmarshal(t *testing.T) {
require.Equal(t, uint64(128), block.Receipts[0].ExecutionResources.DataAvailability.L1DataGas)
}

func TestBlockHeaderv0132Unmarshal(t *testing.T) {
client := feeder.NewTestClient(t, &utils.SepoliaIntegration)
block, err := client.Block(context.Background(), "35748")
require.NoError(t, err)

// Only focus on checking the new fields
require.Equal(t, utils.HexToFelt(t, "0x1ea2a9cfa3df5297d58c0a04d09d276bc68d40fe64701305bbe2ed8f417e869"), block.Hash)
require.Equal(t, utils.HexToFelt(t, "0x77140bef51bbb4d1932f17cc5081825ff18465a1df4440ca0429a4fa80f1dc5"), block.ParentHash)
require.Equal(t, utils.HexToFelt(t, "0x6f12628d21a8df7f158b631d801fc0dd20034b9e22eca255bddc0c1c1bc283f"), block.ReceiptCommitment)
require.Equal(t, utils.HexToFelt(t, "0x23587c54d590b57b8e25acbf1e1a422eb4cd104e95ee4a681021a6bb7456afa"), block.StateDiffCommitment)
require.Equal(t, uint64(6), block.StateDiffLength)
require.Equal(t, "0.13.2", block.Version)
require.Equal(t, uint64(117620), block.Receipts[0].ExecutionResources.TotalGasConsumed.L1Gas)
require.Equal(t, uint64(192), block.Receipts[0].ExecutionResources.TotalGasConsumed.L1DataGas)
}

func TestClassV0Unmarshal(t *testing.T) {
client := feeder.NewTestClient(t, &utils.Mainnet)

Expand Down
134 changes: 134 additions & 0 deletions clients/feeder/testdata/sepolia-integration/block/35748.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"block_hash": "0x1ea2a9cfa3df5297d58c0a04d09d276bc68d40fe64701305bbe2ed8f417e869",
"parent_block_hash": "0x77140bef51bbb4d1932f17cc5081825ff18465a1df4440ca0429a4fa80f1dc5",
"block_number": 35748,
"state_root": "0x38e01cbe2d5721780b2e1a478fd131f2ffcc099528dd2e1289f26b027127790",
"transaction_commitment": "0x54f43cf29b80cc83aef36f3195b73cb165ad12553eae147b4cce62adbf0b180",
"event_commitment": "0x12dfbe9dbbaba9c34b5a4c0ba622dcd8e2bb0264481c77f073008b59825a758",
"receipt_commitment": "0x6f12628d21a8df7f158b631d801fc0dd20034b9e22eca255bddc0c1c1bc283f",
"state_diff_commitment": "0x23587c54d590b57b8e25acbf1e1a422eb4cd104e95ee4a681021a6bb7456afa",
"state_diff_length": 6,
"status": "ACCEPTED_ON_L1",
"l1_da_mode": "BLOB",
"l1_gas_price": {
"price_in_wei": "0x7427e87c4",
"price_in_fri": "0x9346cee0949c"
},
"l1_data_gas_price": {
"price_in_wei": "0x3b095dc6",
"price_in_fri": "0x4ada914d823"
},
"transactions": [
{
"transaction_hash": "0x5ac644bbd6ae98d3be2d988439854e33f0961e24f349a63b43e16d172bfe747",
"version": "0x2",
"max_fee": "0x4f6ac5195e92e4",
"signature": [
"0x43ad3c7c77f7b7762db41ee9d33958813ee25efed77bc7199e08f4f40b1a59",
"0xfedb8715405faf28de29a07a3f3f06f078bac3fcb67ac7f5ae392e15a75921"
],
"nonce": "0xd",
"class_hash": "0x2fd9e122406490dc0f299f3070eaaa8df854d97ff81b47e91da32b8cd9d757a",
"compiled_class_hash": "0x55d1e0ee31f8f937fc75b37045129fbe0e01747baacb44b89d2d3d2c649117e",
"sender_address": "0x472aa8128e01eb0df145810c9511a92852d62a68ba8198ce5fa414e6337a365",
"type": "DECLARE"
},
{
"transaction_hash": "0x21bc0afe54123b946855e1bf9389d943313df5c5c396fbf0630234a44f6f592",
"version": "0x2",
"max_fee": "0xe6e9346a5ae75a",
"signature": [
"0x12a928f7042a66c5419fc5182da6879c357f013335d8b61d0ad774009afbb40",
"0x63479f4343dc2f068bff99fbbf0027250a672999fb5675cee1f2d1a64d33844"
],
"nonce": "0xe",
"class_hash": "0x19de7881922dbc95846b1bb9464dba34046c46470cfb5e18b4cb2892fd4111f",
"compiled_class_hash": "0x6506976af042088c9ea49e6cc9c9a12838ee6920bb989dce02f5c6467667367",
"sender_address": "0x472aa8128e01eb0df145810c9511a92852d62a68ba8198ce5fa414e6337a365",
"type": "DECLARE"
}
],
"timestamp": 1720426817,
"sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"transaction_receipts": [
{
"execution_status": "SUCCEEDED",
"transaction_index": 0,
"transaction_hash": "0x5ac644bbd6ae98d3be2d988439854e33f0961e24f349a63b43e16d172bfe747",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x472aa8128e01eb0df145810c9511a92852d62a68ba8198ce5fa414e6337a365",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0xd07af45c84550",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 3950,
"builtin_instance_counter": {
"pedersen_builtin": 16,
"range_check_builtin": 157,
"ecdsa_builtin": 1,
"poseidon_builtin": 4
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 192
},
"total_gas_consumed": {
"l1_gas": 117620,
"l1_data_gas": 192
}
},
"actual_fee": "0xd07af45c84550"
},
{
"execution_status": "SUCCEEDED",
"transaction_index": 1,
"transaction_hash": "0x21bc0afe54123b946855e1bf9389d943313df5c5c396fbf0630234a44f6f592",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x472aa8128e01eb0df145810c9511a92852d62a68ba8198ce5fa414e6337a365",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0x471426f16c4330",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 3950,
"builtin_instance_counter": {
"poseidon_builtin": 4,
"ecdsa_builtin": 1,
"range_check_builtin": 157,
"pedersen_builtin": 16
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 192
},
"total_gas_consumed": {
"l1_gas": 641644,
"l1_data_gas": 192
}
},
"actual_fee": "0x471426f16c4330"
}
],
"starknet_version": "0.13.2"
}
Loading
Loading