Skip to content

Commit

Permalink
Add block.hash 0.13.4 calculation (#2361)
Browse files Browse the repository at this point in the history
* Add block.hash 0.13.4 calculation

* Update core/transaction.go

Co-authored-by: Rodrigo <[email protected]>
Signed-off-by: Kirill <[email protected]>

* Remove debugging string from fmt.Errorf()

* Unexport hash functions

* Add tests

* Fix linter issues

---------

Signed-off-by: Kirill <[email protected]>
Co-authored-by: Rodrigo <[email protected]>
  • Loading branch information
kirugan and rodrigo-pino authored Jan 9, 2025
1 parent 2653ae9 commit f743e37
Show file tree
Hide file tree
Showing 11 changed files with 615 additions and 15 deletions.
1 change: 1 addition & 0 deletions adapters/p2p2core/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func AdaptBlockHeader(h *gen.SignedBlockHeader, eventsBloom *bloom.BloomFilter)
},
GasPrice: AdaptUint128(h.GasPriceWei),
GasPriceSTRK: AdaptUint128(h.GasPriceFri),
L2GasPrice: nil, // todo pass correct value once it's in the p2p spec
}
}

Expand Down
1 change: 1 addition & 0 deletions adapters/sn2core/sn2core.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func AdaptBlock(response *starknet.Block, sig *starknet.Signature) (*core.Block,
GasPriceSTRK: response.GasPriceSTRK(),
L1DAMode: core.L1DAMode(response.L1DAMode),
L1DataGasPrice: (*core.GasPrice)(response.L1DataGasPrice),
L2GasPrice: (*core.GasPrice)(response.L2GasPrice),
Signatures: sigs,
},
Transactions: txns,
Expand Down
327 changes: 327 additions & 0 deletions clients/feeder/testdata/sepolia-integration/block/64164.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
{
"block_hash": "0x386d167f026a854a8f31bfdc338645d601d1be4327e62390cc514522028bcd3",
"parent_block_hash": "0x4202a086d133d2a2e093e5550f37ffbf872a5ec659361ef9f45a6754657deb9",
"block_number": 64164,
"state_root": "0x1595ba3681219079689f1e49ad33026bc9ce96df6b6e0274440bff8adc24507",
"transaction_commitment": "0x51ce2cac09741ec58d4705f3334a421c60df616f5b778c61f45288a1915b782",
"event_commitment": "0x74243db179307a176a4e68c71162206e04d031bbf30665f726bc943563e631b",
"receipt_commitment": "0x5f0b74a50d4b9fb52486001f184418d10e702d6d5114d1f69241a4e272e8c77",
"state_diff_commitment": "0x78e182e5c6b73cdbf64678f09db6d6000ab5dbb7019284a0e6206c84c0be979",
"state_diff_length": 9,
"status": "ACCEPTED_ON_L2",
"l1_da_mode": "BLOB",
"l1_gas_price": {
"price_in_wei": "0xcd62576b",
"price_in_fri": "0x17842b1d0815"
},
"l1_data_gas_price": {
"price_in_wei": "0x31ea",
"price_in_fri": "0x5b70ba9"
},
"l2_gas_price": {
"price_in_wei": "0x15081",
"price_in_fri": "0x268771a6"
},
"transactions": [
{
"transaction_hash": "0x57f07d54cd337ce92ff67b8c831c80c19a6c48c2dcaecbb6d9175a3d2f07034",
"version": "0x3",
"signature": [
"0x2a1658d74c85266cec309b15fb623ae7b18854a8e08e84834067fd68f07d15a",
"0x5304bd3e7151d87fabe5977a1d19c2cc9025cce27a2ce0b26a46633386add94"
],
"nonce": "0x44d",
"nonce_data_availability_mode": 0,
"fee_data_availability_mode": 0,
"resource_bounds": {
"L1_DATA_GAS": {
"max_amount": "0x186a0",
"max_price_per_unit": "0x2d79883d20000"
},
"L1_GAS": {
"max_amount": "0x186a0",
"max_price_per_unit": "0x2d79883d20000"
},
"L2_GAS": {
"max_amount": "0x5f5e100",
"max_price_per_unit": "0xba43b7400"
}
},
"tip": "0x0",
"paymaster_data": [],
"sender_address": "0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"calldata": [
"0x1",
"0x28c62efb55444e72ba017fd975177c3960fc62a1c213713691dff28c0a81424",
"0x5df99ae77df976b4f0e5cf28c7dcfe09bd6e81aab787b19ac0c08e03d928cf",
"0x1",
"0x37df8ea7f7996394a2473a5a1fa72395cff87eeb7f18c1aa5ec687374b942b4"
],
"account_deployment_data": [],
"type": "INVOKE_FUNCTION"
},
{
"transaction_hash": "0x7fc00513fc32dbefd3bc86f776a9e852aedb7244915a7ffa15966bf10633c6d",
"version": "0x3",
"signature": [
"0x4a2af5acf5804dd6599dcb4988a92ab1f0d9b769157c774e397204655cfabc4",
"0x1b06ccd6ddc30a0b50e0719b50c0b964244f642b911d9cac969e8347bf53285"
],
"nonce": "0x44e",
"nonce_data_availability_mode": 0,
"fee_data_availability_mode": 0,
"resource_bounds": {
"L1_DATA_GAS": {
"max_amount": "0x186a0",
"max_price_per_unit": "0x2d79883d20000"
},
"L1_GAS": {
"max_amount": "0x186a0",
"max_price_per_unit": "0x2d79883d20000"
},
"L2_GAS": {
"max_amount": "0x5f5e100",
"max_price_per_unit": "0xba43b7400"
}
},
"tip": "0x0",
"paymaster_data": [],
"sender_address": "0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"calldata": [
"0x1",
"0x28c62efb55444e72ba017fd975177c3960fc62a1c213713691dff28c0a81424",
"0x1a8e87e9d2008fcd3ce423ae5219c21e49be18d05d72825feb7e2bb687ba35c",
"0x2",
"0x4dc1706fe707e529d72edb6cca3065bb",
"0x8b36c22567ccc4bda5afeee404b3699"
],
"account_deployment_data": [],
"type": "INVOKE_FUNCTION"
},
{
"transaction_hash": "0x4ae5a49ac6e5572789802a40bd294758b0bf12a8f96587599afe79b3f6c0609",
"version": "0x1",
"max_fee": "0x11c37937e08000",
"signature": [
"0x75995ac8a373d95c02c3cf634fd086b61db0566ee70d4619a278288bd8dbfee",
"0x34b403b6deaa2068b83236993646ade9621cc1877a1b6f6bb04d2aa7f3f48b8"
],
"nonce": "0x44f",
"sender_address": "0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"calldata": [
"0x2",
"0x28c62efb55444e72ba017fd975177c3960fc62a1c213713691dff28c0a81424",
"0x27a4a7332e590dd789019a6d125ff2aacd358e453090978cbf81f0d85e4c045",
"0x2",
"0xa6ffa15adc862eda3fce22525194b6b6983574bcaeac2a8c53747b258cd958",
"0x792f5d669c1d635f97ebe6002cf2725937281c2b20b31528d37016ff781e584",
"0x28c62efb55444e72ba017fd975177c3960fc62a1c213713691dff28c0a81424",
"0x31aafc75f498fdfa7528880ad27246b4c15af4954f96228c9a132b328de1c92",
"0x6",
"0x526f36d5c58e4e5415236ec9e621cebbf40b13e70f286c72ceafec56ce93160",
"0x3",
"0x4dad4c6a104d839b4785ed5b1e58fba346abb0d5dfd0d42ea2bc0921af7d405",
"0x5136723ddddf642feca9ef13e3b48b02cf00c8b4d9bd0c4077239623dda166",
"0x7fe6fcecc78e12cdef8f201e6259eae77bbd62c76921263428e9f107b3862a0",
"0x4ac932a6b33d761b443ada748daa58833315bcfa30e62b4620097467f4b2450"
],
"type": "INVOKE_FUNCTION"
},
{
"transaction_hash": "0x4aebca1a8399e488bf8c2f8518f397747308372764b34ca1f623d2689c0819",
"version": "0x1",
"max_fee": "0x11c37937e08000",
"signature": [
"0x63a06c7daecc979f5aac1902339d9fe607fa1f091a0195d69756cce5634501a",
"0x5adf5b8015255c7626654b61f2b291f7d29bc4cae6acf0ad48b9ff36d051558"
],
"nonce": "0x450",
"sender_address": "0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"calldata": [
"0x1",
"0x4138fd51f90d171df37e9d4419c8cdb67d525840c58f8a5c347be93a1c5277d",
"0x17da35ce4ed77e22e3b9149fd965dba57351a6c29f588a7d245e208d073e4c1",
"0x0"
],
"type": "INVOKE_FUNCTION"
}
],
"timestamp": 1736378061,
"sequencer_address": "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"transaction_receipts": [
{
"execution_status": "SUCCEEDED",
"transaction_index": 0,
"transaction_hash": "0x57f07d54cd337ce92ff67b8c831c80c19a6c48c2dcaecbb6d9175a3d2f07034",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0x1b9d688c83e7e",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 4467,
"builtin_instance_counter": {
"pedersen_builtin": 19,
"range_check_builtin": 137,
"poseidon_builtin": 3
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 128,
"l2_gas": 0
},
"total_gas_consumed": {
"l1_gas": 0,
"l1_data_gas": 128,
"l2_gas": 751525
}
},
"actual_fee": "0x1b9d688c83e7e"
},
{
"execution_status": "SUCCEEDED",
"transaction_index": 1,
"transaction_hash": "0x7fc00513fc32dbefd3bc86f776a9e852aedb7244915a7ffa15966bf10633c6d",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0x27a6fb6b2ba9e",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 4475,
"builtin_instance_counter": {
"poseidon_builtin": 3,
"pedersen_builtin": 20,
"range_check_builtin": 137
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 128,
"l2_gas": 0
},
"total_gas_consumed": {
"l1_gas": 0,
"l1_data_gas": 128,
"l2_gas": 1079125
}
},
"actual_fee": "0x27a6fb6b2ba9e"
},
{
"execution_status": "SUCCEEDED",
"transaction_index": 2,
"transaction_hash": "0x4ae5a49ac6e5572789802a40bd294758b0bf12a8f96587599afe79b3f6c0609",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x28c62efb55444e72ba017fd975177c3960fc62a1c213713691dff28c0a81424",
"keys": [
"0x15bd0500dc9d7e69ab9577f73a8d753e8761bed10f25ba0f124254dc4edb8b4"
],
"data": [
"0x526f36d5c58e4e5415236ec9e621cebbf40b13e70f286c72ceafec56ce93160",
"0x3",
"0x4dad4c6a104d839b4785ed5b1e58fba346abb0d5dfd0d42ea2bc0921af7d405",
"0x5136723ddddf642feca9ef13e3b48b02cf00c8b4d9bd0c4077239623dda166",
"0x7fe6fcecc78e12cdef8f201e6259eae77bbd62c76921263428e9f107b3862a0"
]
},
{
"from_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0x140ed2b0b3",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 5035,
"builtin_instance_counter": {
"range_check_builtin": 205,
"pedersen_builtin": 29,
"poseidon_builtin": 5
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 256,
"l2_gas": 0
},
"total_gas_consumed": {
"l1_gas": 25,
"l1_data_gas": 288,
"l2_gas": 0
}
},
"actual_fee": "0x140ed2b0b3"
},
{
"execution_status": "SUCCEEDED",
"transaction_index": 3,
"transaction_hash": "0x4aebca1a8399e488bf8c2f8518f397747308372764b34ca1f623d2689c0819",
"l2_to_l1_messages": [],
"events": [
{
"from_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"keys": [
"0x99cd8bde557814842a3121e8ddfd433a539b8c9f14bf31ebf108d12e6196e9"
],
"data": [
"0x745d525a3582e91299d8d7c71730ffc4b1f191f5b219d800334bc0edad0983b",
"0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8",
"0x16033bcdd7d",
"0x0"
]
}
],
"execution_resources": {
"n_steps": 4459,
"builtin_instance_counter": {
"pedersen_builtin": 18,
"range_check_builtin": 137,
"poseidon_builtin": 3
},
"n_memory_holes": 0,
"data_availability": {
"l1_gas": 0,
"l1_data_gas": 128,
"l2_gas": 0
},
"total_gas_consumed": {
"l1_gas": 439,
"l1_data_gas": 128,
"l2_gas": 0
}
},
"actual_fee": "0x16033bcdd7d"
}
],
"starknet_version": "0.13.4"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"block_hash": "0x386d167f026a854a8f31bfdc338645d601d1be4327e62390cc514522028bcd3",
"signature": [
"0x3693cdfee86842e03c9cd98373e13e29d582cabfa21f50f12427d6a9c077e1a",
"0x26aef04285d6cd6af4d13de0139c97dcbf883c4d26aea4d8848cafd372c8dcf"
]
}
Loading

0 comments on commit f743e37

Please sign in to comment.