From 807ca3422022abf3e84939f308a8c31e8e5b6e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Mon, 25 Sep 2023 17:33:56 +0300 Subject: [PATCH] Add signatures to core.Header (#1246) Fixes #1225 --- adapters/feeder2core/feeder2core.go | 7 +++- adapters/feeder2core/feeder2core_test.go | 14 ++++++- .../feeder/testdata/goerli/signature/1.json | 1 + .../testdata/goerli/signature/119802.json | 1 + .../testdata/goerli/signature/156000.json | 1 + .../testdata/goerli/signature/231579.json | 1 + .../testdata/goerli/signature/485004.json | 1 + .../feeder/testdata/goerli2/signature/0.json | 1 + .../feeder/testdata/goerli2/signature/1.json | 1 + .../feeder/testdata/goerli2/signature/10.json | 1 + .../testdata/goerli2/signature/110238.json | 1 + .../feeder/testdata/goerli2/signature/2.json | 1 + .../feeder/testdata/goerli2/signature/3.json | 1 + .../feeder/testdata/goerli2/signature/4.json | 1 + .../feeder/testdata/goerli2/signature/49.json | 1 + .../feeder/testdata/goerli2/signature/5.json | 1 + .../feeder/testdata/goerli2/signature/6.json | 1 + .../testdata/integration/signature/1.json | 1 + .../integration/signature/283364.json | 1 + .../integration/signature/286310.json | 1 + .../integration/signature/304740.json | 1 + .../testdata/integration/signature/78541.json | 1 + .../feeder/testdata/mainnet/signature/0.json | 1 + .../feeder/testdata/mainnet/signature/1.json | 1 + .../testdata/mainnet/signature/1059.json | 1 + .../testdata/mainnet/signature/11817.json | 1 + .../testdata/mainnet/signature/147.json | 1 + .../testdata/mainnet/signature/16259.json | 1 + .../testdata/mainnet/signature/16697.json | 1 + .../testdata/mainnet/signature/16730.json | 1 + .../testdata/mainnet/signature/16789.json | 1 + .../testdata/mainnet/signature/19199.json | 1 + .../testdata/mainnet/signature/192.json | 1 + .../feeder/testdata/mainnet/signature/2.json | 1 + .../testdata/mainnet/signature/2889.json | 1 + .../testdata/mainnet/signature/7320.json | 1 + .../feeder/testdata/mainnet/signature/8.json | 1 + .../testdata/mainnet/signature/833.json | 1 + .../testdata/mainnet/signature/latest.json | 1 + core/block.go | 2 + starknetdata/feeder/feeder.go | 38 +++++++++++++++---- starknetdata/feeder/feeder_test.go | 14 +++++-- 42 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 clients/feeder/testdata/goerli/signature/1.json create mode 100644 clients/feeder/testdata/goerli/signature/119802.json create mode 100644 clients/feeder/testdata/goerli/signature/156000.json create mode 100644 clients/feeder/testdata/goerli/signature/231579.json create mode 100644 clients/feeder/testdata/goerli/signature/485004.json create mode 100644 clients/feeder/testdata/goerli2/signature/0.json create mode 100644 clients/feeder/testdata/goerli2/signature/1.json create mode 100644 clients/feeder/testdata/goerli2/signature/10.json create mode 100644 clients/feeder/testdata/goerli2/signature/110238.json create mode 100644 clients/feeder/testdata/goerli2/signature/2.json create mode 100644 clients/feeder/testdata/goerli2/signature/3.json create mode 100644 clients/feeder/testdata/goerli2/signature/4.json create mode 100644 clients/feeder/testdata/goerli2/signature/49.json create mode 100644 clients/feeder/testdata/goerli2/signature/5.json create mode 100644 clients/feeder/testdata/goerli2/signature/6.json create mode 100644 clients/feeder/testdata/integration/signature/1.json create mode 100644 clients/feeder/testdata/integration/signature/283364.json create mode 100644 clients/feeder/testdata/integration/signature/286310.json create mode 100644 clients/feeder/testdata/integration/signature/304740.json create mode 100644 clients/feeder/testdata/integration/signature/78541.json create mode 100644 clients/feeder/testdata/mainnet/signature/0.json create mode 100644 clients/feeder/testdata/mainnet/signature/1.json create mode 100644 clients/feeder/testdata/mainnet/signature/1059.json create mode 100644 clients/feeder/testdata/mainnet/signature/11817.json create mode 100644 clients/feeder/testdata/mainnet/signature/147.json create mode 100644 clients/feeder/testdata/mainnet/signature/16259.json create mode 100644 clients/feeder/testdata/mainnet/signature/16697.json create mode 100644 clients/feeder/testdata/mainnet/signature/16730.json create mode 100644 clients/feeder/testdata/mainnet/signature/16789.json create mode 100644 clients/feeder/testdata/mainnet/signature/19199.json create mode 100644 clients/feeder/testdata/mainnet/signature/192.json create mode 100644 clients/feeder/testdata/mainnet/signature/2.json create mode 100644 clients/feeder/testdata/mainnet/signature/2889.json create mode 100644 clients/feeder/testdata/mainnet/signature/7320.json create mode 100644 clients/feeder/testdata/mainnet/signature/8.json create mode 100644 clients/feeder/testdata/mainnet/signature/833.json create mode 100644 clients/feeder/testdata/mainnet/signature/latest.json diff --git a/adapters/feeder2core/feeder2core.go b/adapters/feeder2core/feeder2core.go index dee910be56..0bf16d0c84 100644 --- a/adapters/feeder2core/feeder2core.go +++ b/adapters/feeder2core/feeder2core.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" ) -func AdaptBlock(response *feeder.Block) (*core.Block, error) { +func AdaptBlock(response *feeder.Block, sig *feeder.Signature) (*core.Block, error) { if response == nil { return nil, errors.New("nil client block") } @@ -31,6 +31,10 @@ func AdaptBlock(response *feeder.Block) (*core.Block, error) { eventCount += uint64(len(response.Receipts[i].Events)) } + sigs := [][]*felt.Felt{} + if sig != nil { + sigs = append(sigs, sig.Signature) + } return &core.Block{ Header: &core.Header{ Hash: response.Hash, @@ -45,6 +49,7 @@ func AdaptBlock(response *feeder.Block) (*core.Block, error) { EventCount: eventCount, EventsBloom: core.EventsBloom(receipts), GasPrice: response.GasPrice, + Signatures: sigs, }, Transactions: txns, Receipts: receipts, diff --git a/adapters/feeder2core/feeder2core_test.go b/adapters/feeder2core/feeder2core_test.go index 9bd50a2a41..12a1c083c7 100644 --- a/adapters/feeder2core/feeder2core_test.go +++ b/adapters/feeder2core/feeder2core_test.go @@ -8,6 +8,7 @@ import ( "github.com/NethermindEth/juno/adapters/feeder2core" "github.com/NethermindEth/juno/clients/feeder" "github.com/NethermindEth/juno/core" + "github.com/NethermindEth/juno/core/felt" "github.com/NethermindEth/juno/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -18,6 +19,7 @@ func TestAdaptBlock(t *testing.T) { number uint64 protocolVersion string network utils.Network + sig *feeder.Signature }{ { number: 147, @@ -32,6 +34,9 @@ func TestAdaptBlock(t *testing.T) { number: 304740, protocolVersion: "0.12.1", network: utils.INTEGRATION, + sig: &feeder.Signature{ + Signature: []*felt.Felt{utils.HexToFelt(t, "0x44"), utils.HexToFelt(t, "0x37")}, + }, }, } @@ -43,7 +48,7 @@ func TestAdaptBlock(t *testing.T) { response, err := client.Block(ctx, strconv.FormatUint(test.number, 10)) require.NoError(t, err) - block, err := feeder2core.AdaptBlock(response) + block, err := feeder2core.AdaptBlock(response, test.sig) require.NoError(t, err) expectedEventCount := uint64(0) @@ -68,6 +73,13 @@ func TestAdaptBlock(t *testing.T) { assert.Equal(t, expectedEventCount, block.EventCount) assert.Equal(t, test.protocolVersion, block.ProtocolVersion) assert.Nil(t, block.ExtraData) + + if test.sig != nil { + require.Len(t, block.Signatures, 1) + assert.Equal(t, test.sig.Signature, block.Signatures[0]) + } else { + assert.Empty(t, block.Signatures) + } }) } } diff --git a/clients/feeder/testdata/goerli/signature/1.json b/clients/feeder/testdata/goerli/signature/1.json new file mode 100644 index 0000000000..9651efa089 --- /dev/null +++ b/clients/feeder/testdata/goerli/signature/1.json @@ -0,0 +1 @@ +{"block_number": 1, "signature": ["0x4f76bab71a66a2f62d9944719e8c28df54ae8ddfbfd5a0d4845b9f76dc643d5", "0x2239058cc984c0fb13fce6d45b0709b50054f4ad397d674eaf099be0f2a9202"], "signature_input": {"block_hash": "0x75e00250d4343326f322e370df4c9c73c7be105ad9f532eeb97891a34d9e4a5", "state_diff_commitment": "0x503a2ee3fc8754b92c4f6a6fe6aec18d90661f1b6ab76ec0234213cda0857f1"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli/signature/119802.json b/clients/feeder/testdata/goerli/signature/119802.json new file mode 100644 index 0000000000..aa6b25bd6c --- /dev/null +++ b/clients/feeder/testdata/goerli/signature/119802.json @@ -0,0 +1 @@ +{"block_number": 119802, "signature": ["0x4351eb839a548f3906a93cb5a0cef1b71eeff029b32f8f758b4b8a43a3af2ef", "0xa6e407d15dc52b54b59f7314adeb418d36d607366cddfe629043ae523b1113"], "signature_input": {"block_hash": "0x62483d7a29a2aae440c4418e5ddf5acdbacc391af959d681e2dc9441b2895b6", "state_diff_commitment": "0x3d01e49b9966a62ea4ad1ea3286025c719ecc26a6156d06f34fcec1964e7f6a"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli/signature/156000.json b/clients/feeder/testdata/goerli/signature/156000.json new file mode 100644 index 0000000000..77508e0ce9 --- /dev/null +++ b/clients/feeder/testdata/goerli/signature/156000.json @@ -0,0 +1 @@ +{"block_number": 156000, "signature": ["0x71fef1b202f5c25df64ae720d0fda22d70c8d3669ccf6878e78ec2915a6ff20", "0x66d482726992814f6bd6057d925a026cef835d5d00577dec33e82724e2a5048"], "signature_input": {"block_hash": "0x1288267b119adefd52795c3421f8fabba78f49e911f39c1fb2f4e5eb8fb771", "state_diff_commitment": "0x6122d962032b670f38d81f6f6b812b399c8ff46b856b367abc9849d918734ed"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli/signature/231579.json b/clients/feeder/testdata/goerli/signature/231579.json new file mode 100644 index 0000000000..838ae0c181 --- /dev/null +++ b/clients/feeder/testdata/goerli/signature/231579.json @@ -0,0 +1 @@ +{"block_number": 231579, "signature": ["0x73e9bebd835bbab3db32c8b7db3fe7073eedd7faa08874c8441dbd0fede2ae5", "0x1bd2ab2d5c5fb736f1765fc77f497be0b37a47b7b7c573f2eb1435f9f110675"], "signature_input": {"block_hash": "0x40ffdbd9abbc4fc64652c50db94a29bce65c183316f304a95df624de708e746", "state_diff_commitment": "0x5ebf52d066afc7118a69ef78debdaa860c76f5dcd721a5af1f316be71931568"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli/signature/485004.json b/clients/feeder/testdata/goerli/signature/485004.json new file mode 100644 index 0000000000..e5af1f34f7 --- /dev/null +++ b/clients/feeder/testdata/goerli/signature/485004.json @@ -0,0 +1 @@ +{"block_number": 485004, "signature": ["0x1c62e12643fef46059052bf88003a94f7c2a815d1b3d55687218c0f0208e595", "0x1ff9308a9e1c56cce7e006991dfbb0e330b48d86e4e1190bff7e6e1e806dfce"], "signature_input": {"block_hash": "0x7f9413a02d787cb52046925414b4f4f4cfde93b4a96f92fa7c57eb0ac302f3", "state_diff_commitment": "0x3af5ef927e108424066aa0bb3dbda65df8f93a3cb15561e375f49b3de680c32"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/0.json b/clients/feeder/testdata/goerli2/signature/0.json new file mode 100644 index 0000000000..33b763f9c6 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/0.json @@ -0,0 +1 @@ +{"block_number": 0, "signature": ["0x43fed195d6bd5fcb674df93edae3907fdcad1bcefa5fb1529c3555b3bddee1", "0x1c8983a5f72b4ac34453ff8d798cf1a475a28dc0eec0c9ad10ae50755eb208e"], "signature_input": {"block_hash": "0x4163f64ea0258f21fd05b478e2306ab2daeb541bdbd3bf29a9874dc5cd4b64e", "state_diff_commitment": "0x77ca47cff95178cd1893185a220bd47e88aef2f4f09dbfde0afeb32875708fd"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/1.json b/clients/feeder/testdata/goerli2/signature/1.json new file mode 100644 index 0000000000..3efb32916b --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/1.json @@ -0,0 +1 @@ +{"block_number": 1, "signature": ["0x3c306d3cfbe60eac71d515a949db3da673ba65b486071a163b4bf186d2c2ef6", "0x6dfd9f978c65cb69f368008e135d3b249bc2c7d1c6aed0015fcfed1f80ba98b"], "signature_input": {"block_hash": "0x734df0487fd829b780691dcacacf31481ca88231c504bca3ab030049f7af6d9", "state_diff_commitment": "0x7132c5a956fc14e16a96a61b6a95198f6e215ec71d5dbc459c565c6c7c45044"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/10.json b/clients/feeder/testdata/goerli2/signature/10.json new file mode 100644 index 0000000000..522cd18430 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/10.json @@ -0,0 +1 @@ +{"block_number": 10, "signature": ["0x2e9cac4a73e7e922838dc47d847f7bb2527bbc2eb523e5d301cc2cfe5f8a1ea", "0x62349ae6ffd6a0fc61a129fda97b345aa27667512465b4c7f1c5b80a0200f4f"], "signature_input": {"block_hash": "0x6902dad2e7ad976c59e032825b43474097396ad4a323d3782ede467540085f5", "state_diff_commitment": "0x304092240777a84f83e18abc6e83df1da4945fe1001ca06171753670fbf503d"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/110238.json b/clients/feeder/testdata/goerli2/signature/110238.json new file mode 100644 index 0000000000..b8bff68011 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/110238.json @@ -0,0 +1 @@ +{"block_number": 110238, "signature": ["0xc7a99f33b39f220b37257d18877155dc4c2f68ba79e6c5b19a7a16a70f18ba", "0x483c4456960585adb31ed991591c560cc0b5795275dc95e5792911e41978e04"], "signature_input": {"block_hash": "0x763c13362d2dbed297e6fd43992f818c650f239b6762deb754da61605ddb5bb", "state_diff_commitment": "0x3c7a6b49a8eb4cfcc5dd627d5558ed03e00f7fef87a975673112dd8eb35e2b1"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/2.json b/clients/feeder/testdata/goerli2/signature/2.json new file mode 100644 index 0000000000..71bccbca22 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/2.json @@ -0,0 +1 @@ +{"block_number": 2, "signature": ["0xa5b6394b61ccb1da3e816f825c752ccdc772ffcdbf23eed788bcd1baee5b24", "0x5f77996d674b0184c7d1615e318958a1e499da3899769d476505d34a2f0b8ba"], "signature_input": {"block_hash": "0x693982aed75e6a4bb902130eb8b0aa3b799ce5fdab8f5a3a0c3d9a265aa219e", "state_diff_commitment": "0x4edd5f532fd693b6d8fb2a75ef60edaaeb07f0a23d4391fee82e545b3c11f22"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/3.json b/clients/feeder/testdata/goerli2/signature/3.json new file mode 100644 index 0000000000..117bd609b0 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/3.json @@ -0,0 +1 @@ +{"block_number": 3, "signature": ["0x37303b1c77ae348ceaee555c998b2790bb35c179249d3b0e73c4e9253683567", "0x64f2e80853546dd168198be3af209df29deffa41eb4530fdfd000b09d5d0c2b"], "signature_input": {"block_hash": "0x61d1f84a603eb863a74b3a2e68ffa31d0c811a80dee0f4021ad3e7c4557d6a9", "state_diff_commitment": "0x2a22856ec4c29384c5441115b0b69793c420785ba1bac6e00f1b5f660a74742"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/4.json b/clients/feeder/testdata/goerli2/signature/4.json new file mode 100644 index 0000000000..241fd40ffd --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/4.json @@ -0,0 +1 @@ +{"block_number": 4, "signature": ["0x3cf7887c0daebd362fccecf724c6bd89f43d6c4ed682a2bf135eb7a4edf3200", "0x9d8b8ba7fcfedb1d196d66294a79fc45ef6b6992588f4ba2e57e67818c0eb7"], "signature_input": {"block_hash": "0x791fb65b9780f90f7f64d4ec49509da1071af166de61573d06fde906626a09b", "state_diff_commitment": "0x607fb89853462ee15c6e84d1389f49e87ce9d05e18ecaa367de9afe0bf4343b"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/49.json b/clients/feeder/testdata/goerli2/signature/49.json new file mode 100644 index 0000000000..b3f277b816 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/49.json @@ -0,0 +1 @@ +{"block_number": 49, "signature": ["0x7cf3ef69918530c32dd19bd1a1f2f37c8c68a1fc9e4666ba5c055899c570042", "0x48a622bbb1e5ed05f0429170dff21ee88d513ce8a49a3fce205c3ba58e12b19"], "signature_input": {"block_hash": "0x5d561b8a6b0d1f4b30dcea8391929b9c5a9a96c40881941b254aa82f67191b6", "state_diff_commitment": "0x3d1997f93d88c453ac194d69621e583284deaaa589f12657988590b30edda93"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/5.json b/clients/feeder/testdata/goerli2/signature/5.json new file mode 100644 index 0000000000..769f54c936 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/5.json @@ -0,0 +1 @@ +{"block_number": 5, "signature": ["0x2cfb4beb32bd0346011c89e63efe3556a05ca90a108bc65724ee0727db1fa22", "0x3adf87c3e9bce66511e7ceac207102607fbe02a9d50effe30e600cf4f6224ee"], "signature_input": {"block_hash": "0x3b43b334f46b921938854ba85ffc890c1b1321f8fd69e7b2961b18b4260de14", "state_diff_commitment": "0x39e4ec4c7d67af55903c1b92d057c2570f1a0f456376171c3e24c806cda992"}} \ No newline at end of file diff --git a/clients/feeder/testdata/goerli2/signature/6.json b/clients/feeder/testdata/goerli2/signature/6.json new file mode 100644 index 0000000000..1332533c14 --- /dev/null +++ b/clients/feeder/testdata/goerli2/signature/6.json @@ -0,0 +1 @@ +{"block_number": 6, "signature": ["0x768fae89ebc4a7c7a5bbda0ea6af50d79be274414302dcb62cb25cb4e3af3b2", "0xb7a42edc20605f34c223571869651dd3b9ae25c00ed2a2d675a8e617c7fde6"], "signature_input": {"block_hash": "0xdc4f7b00430daf9a6985145de533323be2a034252014eb39a958457f690b3b", "state_diff_commitment": "0x613611e7059594aa1e8c7df1f89f9304b1338d824cd071167d49d3de186ea52"}} \ No newline at end of file diff --git a/clients/feeder/testdata/integration/signature/1.json b/clients/feeder/testdata/integration/signature/1.json new file mode 100644 index 0000000000..ff824cae80 --- /dev/null +++ b/clients/feeder/testdata/integration/signature/1.json @@ -0,0 +1 @@ +{"block_number": 1, "signature": ["0x7fe660044180e7d436e77ab017faff0686c0b02a425ade81de8fd5aa95663bb", "0xc475f270d1e6d735829ac7db0c7580f86b8f788e44106220312125496d1931"], "signature_input": {"block_hash": "0x34e815552e42c5eb5233b99de2d3d7fd396e575df2719bf98e7ed2794494f86", "state_diff_commitment": "0x6785083b32b863270b67ee300230b9054ef4556c3677662f995e9e16f90a237"}} \ No newline at end of file diff --git a/clients/feeder/testdata/integration/signature/283364.json b/clients/feeder/testdata/integration/signature/283364.json new file mode 100644 index 0000000000..7cc73c21ec --- /dev/null +++ b/clients/feeder/testdata/integration/signature/283364.json @@ -0,0 +1 @@ +{"block_number": 283364, "signature": ["0x405a7a6641a0c5990db264b67676e6bde816716be5665790bb314c80ca9f5f0", "0x2665b141b14b80a3f96d7487665b49dba53d2a873a8d45561bfefd9499ca10a"], "signature_input": {"block_hash": "0x67d24961077de7a1f49b6b1da78903ee80217662d026c155e14d7abedc04034", "state_diff_commitment": "0x85894cd1d031ed87d7cba9b5eebd44beb7e9ec5b578d19e052844f4a2561ee"}} \ No newline at end of file diff --git a/clients/feeder/testdata/integration/signature/286310.json b/clients/feeder/testdata/integration/signature/286310.json new file mode 100644 index 0000000000..280c4ccc5a --- /dev/null +++ b/clients/feeder/testdata/integration/signature/286310.json @@ -0,0 +1 @@ +{"block_number": 286310, "signature": ["0x432f6dc603d32d6b8006cabfb958c6b9c46c4a1b6b0a1f5a745cd634c1c06ae", "0x5cc5b3b157423889b7585a1e81175f9cce3eca0b1a2b18cdc176e0a67c751a5"], "signature_input": {"block_hash": "0x759cf41ef2c1b0bdf349860435782e54527db82c9af567069c0751d58cfa9a3", "state_diff_commitment": "0x6dff3b00dc3259fd0c60c2c403440c4fb5f5174bd02673dea568a27256e9f1d"}} \ No newline at end of file diff --git a/clients/feeder/testdata/integration/signature/304740.json b/clients/feeder/testdata/integration/signature/304740.json new file mode 100644 index 0000000000..e242eb7057 --- /dev/null +++ b/clients/feeder/testdata/integration/signature/304740.json @@ -0,0 +1 @@ +{"block_number": 304740, "signature": ["0x3cec41f7ef839991e23532c54d7bc4743df5fd8745e46072f4547a4829fe7e4", "0x7edc19de4ff3f88f1bffb7427bacb354d3844c87f4b55b56c62bd326ce92652"], "signature_input": {"block_hash": "0x76e0229fd0c36dda2ee7905f7e4c9b3ebb78d98c4bfab550bcb3a03bf859a6", "state_diff_commitment": "0x3e6886a602eabd209a8f342b0694e3317d7fa0f80e4c4fba1b3ea1b5ced4bae"}} \ No newline at end of file diff --git a/clients/feeder/testdata/integration/signature/78541.json b/clients/feeder/testdata/integration/signature/78541.json new file mode 100644 index 0000000000..3014aef0eb --- /dev/null +++ b/clients/feeder/testdata/integration/signature/78541.json @@ -0,0 +1 @@ +{"block_number": 78541, "signature": ["0xe59046f297679492dec6987bf580707fc7a438bd3da98b9c73a6e495d915d", "0x23e7e5fddc5e6be25f264e8571f98948600be4768a9f6ab7406ef1ef3da43c3"], "signature_input": {"block_hash": "0x5d59ee907519ce982f76223f3e3a24b485386c2eb5f69b20c146cb68d46a0fa", "state_diff_commitment": "0x115c0175ad67f6176efe9a9da0ee2744ba2d5bdc12f6bfa949af89d4282518f"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/0.json b/clients/feeder/testdata/mainnet/signature/0.json new file mode 100644 index 0000000000..38a3dff165 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/0.json @@ -0,0 +1 @@ +{"block_number": 0, "signature": ["0x484a36b518e33198bfe7a29d82842ae092f9181120e1d49b926c651adf315ed", "0x7e21090ab0c6c70fa2b73e17e6288db298dbe191b04bfd1721436530e84861e"], "signature_input": {"block_hash": "0x47c3637b57c2b079b93c61539950c17e868a28f46cdef28f88521067f21e943", "state_diff_commitment": "0x6c4a7559b57caded12ad2275f78c4ac310ff54b2e233d25c9cf4891c251b450"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/1.json b/clients/feeder/testdata/mainnet/signature/1.json new file mode 100644 index 0000000000..14aa7e14d7 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/1.json @@ -0,0 +1 @@ +{"block_number": 1, "signature": ["0x5c328d673c07e530a45d6f12e569df0d059d97bf920d978e44daa54fb3db655", "0x37feba468c96099a9a610c34bab6230af8c7e9d78c1ddb7436488961fc5161d"], "signature_input": {"block_hash": "0x2a70fb03fe363a2d6be843343a1d81ce6abeda1e9bd5cc6ad8fa9f45e30fdeb", "state_diff_commitment": "0x13beed68d79c0ff1d6b465660bcf245a7f0ec11af5e9c6564fba30543705fe3"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/1059.json b/clients/feeder/testdata/mainnet/signature/1059.json new file mode 100644 index 0000000000..22e86fbb9e --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/1059.json @@ -0,0 +1 @@ +{"block_number": 1059, "signature": ["0x3e44240ef5b149fb8e3b3f58463e3c0202b12d01a25bd48de61be2283d6f3f5", "0x2636d7bbd023374a5e817aeee7929af74e7b477f1a11d256c73900074ccf83b"], "signature_input": {"block_hash": "0x4f9f582d9cc210d7139b6cb7461f1f1a82a633e0e2e910d48f4e9f518f080ac", "state_diff_commitment": "0xaba7242d879750aa925bd919d4ae9cb11f3b690a99e2311c5b7d5a0cceb4d3"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/11817.json b/clients/feeder/testdata/mainnet/signature/11817.json new file mode 100644 index 0000000000..6be923c00f --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/11817.json @@ -0,0 +1 @@ +{"block_number": 11817, "signature": ["0x5fdd06e6af3c04dccacac0de515576d20d1b211cb97388b6c5bb0dcfcbc0c0a", "0x4353c35204b90c629b2e583c1bd70b724095d27660d7bb9ac11fb975093a89c"], "signature_input": {"block_hash": "0x24c692acaed3b486990bd9d2b2fbbee802b37b3bd79c59f295bad3277200a83", "state_diff_commitment": "0x7f0ebcf7ac9c506f0899b71ad1411506f75e985b262407ec43df0ecd86ef413"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/147.json b/clients/feeder/testdata/mainnet/signature/147.json new file mode 100644 index 0000000000..5df57a7a28 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/147.json @@ -0,0 +1 @@ +{"block_number": 147, "signature": ["0x38689be8c500a6f8a6671239e25d284e38253c6c130aaf1d4a6256bb26d4a33", "0x79041498b948eb9685c634cfe8c06818a29c137e1dead1806a01f50453b0f03"], "signature_input": {"block_hash": "0x77ca928108515f7a7770d27f37a5c1b86b84a7f74cc15bc47c2a2a320c712d4", "state_diff_commitment": "0x66cdac339a79f26faee32c28e7b74288af4b03694e76ccb7a80ad45f8d47d4c"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/16259.json b/clients/feeder/testdata/mainnet/signature/16259.json new file mode 100644 index 0000000000..e2e04a5c6b --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/16259.json @@ -0,0 +1 @@ +{"block_number": 16259, "signature": ["0x24212d89a549c8b1b50bb789d144354ddcabf5c642d92a023dba11ed38263c9", "0x39bd1d7a660eeb001809a5b84750bdd23e4285a1d277cbcd60ab7d5d9aff20"], "signature_input": {"block_hash": "0x73679379c70f5780b819c6fde4e04f03ca1444ee1bf640130c9fe083dfa5a89", "state_diff_commitment": "0x17372410f80039157375e783601269630f74dc6d87685d249e5d5676726b2a8"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/16697.json b/clients/feeder/testdata/mainnet/signature/16697.json new file mode 100644 index 0000000000..c26994d589 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/16697.json @@ -0,0 +1 @@ +{"block_number": 16697, "signature": ["0x2fb6fa73bf46ede7240e5034d8ce28ef63e90b3475f476d1ebb89bf3da04725", "0x46e54ef8121fb3a69989329cbe993602534ff27c7330a4d92bcfc697cac5678"], "signature_input": {"block_hash": "0x11fddaab08f9298937f850ec7c95d67a957824d1e5e5e7027eb0a40c0cff945", "state_diff_commitment": "0x5e153345ae9498cce79d3f3e7ef5be0675f3462a81689459e55bedc8bd74d28"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/16730.json b/clients/feeder/testdata/mainnet/signature/16730.json new file mode 100644 index 0000000000..2710e8d753 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/16730.json @@ -0,0 +1 @@ +{"block_number": 16730, "signature": ["0xd4a348476baa4535102ea28e15aac2c3659e953da6518d855b851b5ca56c6e", "0x15a3ca91c0ed4e63a325d723e9e652be213718fd59d36772c6c888c4164c292"], "signature_input": {"block_hash": "0x7ff6d26e7cf4726c50f21ea6d96fe27e2f5b02be0addc2e98e64c70823ba24", "state_diff_commitment": "0x2492f7ad8805795bfb3e70e7b903a96ea95163a8f2650efa84270fd8e583a0c"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/16789.json b/clients/feeder/testdata/mainnet/signature/16789.json new file mode 100644 index 0000000000..f61eb2255b --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/16789.json @@ -0,0 +1 @@ +{"block_number": 16789, "signature": ["0x249a7681de534a50f6bd880a2539310c31d587710a38d80ab8dec691c3355a4", "0x38d96b041608e71d8f9e0d6b220a2d17b3949020807cd2cf29b06455bc55ee4"], "signature_input": {"block_hash": "0x157b9e756f15e002e63580dddb8c8e342b9336c6d69a8cd6dc8eb8a75644040", "state_diff_commitment": "0x40c833582b437c707cd8590627c1d11f3c3ce258bfe5969cf48ef3244e21f64"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/19199.json b/clients/feeder/testdata/mainnet/signature/19199.json new file mode 100644 index 0000000000..271a875027 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/19199.json @@ -0,0 +1 @@ +{"block_number": 19199, "signature": ["0xba322e5df3fbebb28f61395a8e8103d224a8dc60a17668d90a806fc12ce04b", "0x521f3894198aa13e668682279e58cb525ed4c0d80a58ec1ad1c11b8ea2701b8"], "signature_input": {"block_hash": "0x41811b69473f26503e0375806ee97d05951ccc7840e3d2bbe14ffb2522e5be1", "state_diff_commitment": "0x5b063f2921d0a3eb38e77d71d9dba14972f27f787df8056e06dca2242b6de1d"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/192.json b/clients/feeder/testdata/mainnet/signature/192.json new file mode 100644 index 0000000000..24655c5cb4 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/192.json @@ -0,0 +1 @@ +{"block_number": 192, "signature": ["0x1374b515d5d20761621ad2aedf332c4770e4aa5a3127c10c047be4ef52b9850", "0x6cbb0db5bd61b7e6f71eb70a5b46cb475a462170c64dc0e6f65f23432e7ddce"], "signature_input": {"block_hash": "0x27d1e625a4293d2ed162eb2a1ad031cf71eaa2bab3a3d10fe9bddc51b877ccd", "state_diff_commitment": "0x2e9b3a7ee48814f4ec422938d2fe3a353053f18f24ca733c0be961ea9ce6825"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/2.json b/clients/feeder/testdata/mainnet/signature/2.json new file mode 100644 index 0000000000..720348ee1a --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/2.json @@ -0,0 +1 @@ +{"block_number": 2, "signature": ["0x4009f6bce4d9c392b031dd335777dd4b425b3c1da9d82b9b2a4aec3b7b77fd4", "0x654baea62f7d9f90cdcb1623428b7f437eb45aa880c5c628c6ba77aa9370ee"], "signature_input": {"block_hash": "0x4e1f77f39545afe866ac151ac908bd1a347a2a8a7d58bef1276db4f06fdf2f6", "state_diff_commitment": "0x68e08eb5ae2790c1aeaeeef3c6fddebc27290d6415ef6b8e1e815f87afba5a7"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/2889.json b/clients/feeder/testdata/mainnet/signature/2889.json new file mode 100644 index 0000000000..e34891b532 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/2889.json @@ -0,0 +1 @@ +{"block_number": 2889, "signature": ["0x187be32f0eea2c70d5f8662f45a42ae810f7af6a61677fb0af7d5f1728bff96", "0x2c8c943f016f512e8d9381492b91825b6b140bd8f0da213b61e281d3f3214a0"], "signature_input": {"block_hash": "0x3033991dfe0ccc508ef8096d63468252cc43d46eb5e1c35e22ae3cd35af95b9", "state_diff_commitment": "0x6cb6881bb8971191aa759a96db1b7e4633b1f5273fcce10ad731291823da832"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/7320.json b/clients/feeder/testdata/mainnet/signature/7320.json new file mode 100644 index 0000000000..a2b1435652 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/7320.json @@ -0,0 +1 @@ +{"block_number": 7320, "signature": ["0x1ced8776e5e2b93cfb654ca2f55d2a9adab042fef4fde7d0c9950489697f771", "0x3a5f26f2364657e4b884c98859b8a9d37f0970bccd27bc7fa5cc64f9f775e5"], "signature_input": {"block_hash": "0x63f909587f20f6c450fdbb3ae671572444e6b82e791f404fde563f16ec1b2a8", "state_diff_commitment": "0x1186626d19bd27471ea0856d49e265372a805c59fb1252fb1324a8480991171"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/8.json b/clients/feeder/testdata/mainnet/signature/8.json new file mode 100644 index 0000000000..33701f3498 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/8.json @@ -0,0 +1 @@ +{"block_number": 8, "signature": ["0x298e55d51e83bd5bacfc52acbe9bdc2141b1a16ed7de6815a783b4ef321a924", "0x7d2b18ea0f9a10efe15b138a3ffe233022b31be80221b6283a31b36697f5403"], "signature_input": {"block_hash": "0x7644422a0e4974388bade973906fb2e87b5ff573f7198a788a6f9cbe68421ee", "state_diff_commitment": "0x22a28397b8ae53c368c5b1126fc28d2c89ec47ba9c6bd1953ea8d6d5f6ea71a"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/833.json b/clients/feeder/testdata/mainnet/signature/833.json new file mode 100644 index 0000000000..98c200bb4d --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/833.json @@ -0,0 +1 @@ +{"block_number": 833, "signature": ["0x691baeb7520288db0c5a7acb5bf266e8155a6f7674cdd64d681945b6261f157", "0x348281df5a362403513b67e8ddf4d69c9f30a72cf9c475fc2e5603e7acd7493"], "signature_input": {"block_hash": "0x197cd4f24d30274f0674aec74b86e0405c13de06771cfa1ee472b0d2437db7c", "state_diff_commitment": "0x51979fc17bb5d0c59a0bcc38241fe537ca9337aab34940e9fdcd3c43dda2302"}} \ No newline at end of file diff --git a/clients/feeder/testdata/mainnet/signature/latest.json b/clients/feeder/testdata/mainnet/signature/latest.json new file mode 100644 index 0000000000..e1e0379147 --- /dev/null +++ b/clients/feeder/testdata/mainnet/signature/latest.json @@ -0,0 +1 @@ +{"block_number": 237827, "signature": ["0x28fa75e535dad3aab8d562a8aad6cb9af969aadb4764e32e220ef19ef5ae259", "0x147ff919b0263ba9499b01a2cf229c2ee10e5b669af8f794da7379a577cdcbe"], "signature_input": {"block_hash": "0x58ca8f38428130f9c4a021c87a87e049ac4bbdaf5d61d5df132a895c6eed532", "state_diff_commitment": "0x4acd02a507e875d604b324f42b98e042b493074be5552ec08dbf81fd540338e"}} \ No newline at end of file diff --git a/core/block.go b/core/block.go index 0b302ab890..9e9c3c56ee 100644 --- a/core/block.go +++ b/core/block.go @@ -37,6 +37,8 @@ type Header struct { EventsBloom *bloom.BloomFilter // Amount of ETH charged per Gas spent GasPrice *felt.Felt + // Sequencer signatures + Signatures [][]*felt.Felt } type Block struct { diff --git a/starknetdata/feeder/feeder.go b/starknetdata/feeder/feeder.go index 7fcacf6b4b..485b884e8d 100644 --- a/starknetdata/feeder/feeder.go +++ b/starknetdata/feeder/feeder.go @@ -14,6 +14,11 @@ import ( var _ starknetdata.StarknetData = (*Feeder)(nil) +const ( + latestID = "latest" + pendingID = "pending" +) + type Feeder struct { client *feeder.Client } @@ -33,13 +38,13 @@ func (f *Feeder) BlockByNumber(ctx context.Context, blockNumber uint64) (*core.B // BlockLatest gets the latest block from the feeder, // then adapts it to the core.Block type. func (f *Feeder) BlockLatest(ctx context.Context) (*core.Block, error) { - return f.block(ctx, "latest") + return f.block(ctx, latestID) } // BlockPending gets the pending block from the feeder, // then adapts it to the core.Block type. func (f *Feeder) BlockPending(ctx context.Context) (*core.Block, error) { - return f.block(ctx, "pending") + return f.block(ctx, pendingID) } func (f *Feeder) block(ctx context.Context, blockID string) (*core.Block, error) { @@ -48,10 +53,19 @@ func (f *Feeder) block(ctx context.Context, blockID string) (*core.Block, error) return nil, err } - if blockID == "pending" && response.Status != "PENDING" { + if blockID == pendingID && response.Status != "PENDING" { return nil, errors.New("no pending block") } - return feeder2core.AdaptBlock(response) + + var sig *feeder.Signature + if blockID != pendingID { + sig, err = f.client.Signature(ctx, blockID) + if err != nil { + return nil, err + } + } + + return feeder2core.AdaptBlock(response, sig) } // Transaction gets the transaction for a given transaction hash from the feeder, @@ -111,7 +125,7 @@ func (f *Feeder) StateUpdate(ctx context.Context, blockNumber uint64) (*core.Sta // StateUpdatePending gets the state update for the pending block from the feeder, // then adapts it to the core.StateUpdate type. func (f *Feeder) StateUpdatePending(ctx context.Context) (*core.StateUpdate, error) { - return f.stateUpdate(ctx, "pending") + return f.stateUpdate(ctx, pendingID) } func (f *Feeder) stateUpdateWithBlock(ctx context.Context, blockID string) (*core.StateUpdate, *core.Block, error) { @@ -120,10 +134,18 @@ func (f *Feeder) stateUpdateWithBlock(ctx context.Context, blockID string) (*cor return nil, nil, err } - if blockID == "pending" && response.Block.Status != "PENDING" { + if blockID == pendingID && response.Block.Status != "PENDING" { return nil, nil, errors.New("no pending block") } + var sig *feeder.Signature + if blockID != pendingID { + sig, err = f.client.Signature(ctx, blockID) + if err != nil { + return nil, nil, err + } + } + var adaptedState *core.StateUpdate var adaptedBlock *core.Block @@ -131,7 +153,7 @@ func (f *Feeder) stateUpdateWithBlock(ctx context.Context, blockID string) (*cor return nil, nil, err } - if adaptedBlock, err = feeder2core.AdaptBlock(response.Block); err != nil { + if adaptedBlock, err = feeder2core.AdaptBlock(response.Block, sig); err != nil { return nil, nil, err } @@ -141,7 +163,7 @@ func (f *Feeder) stateUpdateWithBlock(ctx context.Context, blockID string) (*cor // StateUpdatePendingWithBlock gets both pending state update and pending block from the feeder, // then adapts them to the core.StateUpdate and core.Block types respectively func (f *Feeder) StateUpdatePendingWithBlock(ctx context.Context) (*core.StateUpdate, *core.Block, error) { - return f.stateUpdateWithBlock(ctx, "pending") + return f.stateUpdateWithBlock(ctx, pendingID) } // StateUpdateWithBlock gets both state update and block for a given block number from the feeder, diff --git a/starknetdata/feeder/feeder_test.go b/starknetdata/feeder/feeder_test.go index 77ac72821c..f7ff7eb3ba 100644 --- a/starknetdata/feeder/feeder_test.go +++ b/starknetdata/feeder/feeder_test.go @@ -25,9 +25,11 @@ func TestBlockByNumber(t *testing.T) { t.Run("mainnet block number "+strconv.FormatUint(number, 10), func(t *testing.T) { response, err := client.Block(ctx, strconv.FormatUint(number, 10)) require.NoError(t, err) + sig, err := client.Signature(ctx, strconv.FormatUint(number, 10)) + require.NoError(t, err) block, err := adapter.BlockByNumber(ctx, number) require.NoError(t, err) - adaptedResponse, err := feeder2core.AdaptBlock(response) + adaptedResponse, err := feeder2core.AdaptBlock(response, sig) require.NoError(t, err) assert.Equal(t, adaptedResponse, block) }) @@ -41,9 +43,11 @@ func TestBlockLatest(t *testing.T) { response, err := client.Block(ctx, "latest") require.NoError(t, err) + sig, err := client.Signature(ctx, "latest") + require.NoError(t, err) block, err := adapter.BlockLatest(ctx) require.NoError(t, err) - adaptedResponse, err := feeder2core.AdaptBlock(response) + adaptedResponse, err := feeder2core.AdaptBlock(response, sig) require.NoError(t, err) assert.Equal(t, adaptedResponse, block) } @@ -200,9 +204,11 @@ func TestStateUpdateWithBlock(t *testing.T) { t.Run("integration block number "+strconv.FormatUint(number, 10), func(t *testing.T) { response, err := client.StateUpdateWithBlock(ctx, strconv.FormatUint(number, 10)) require.NoError(t, err) + sig, err := client.Signature(ctx, strconv.FormatUint(number, 10)) + require.NoError(t, err) stateUpdate, block, err := adapter.StateUpdateWithBlock(ctx, number) require.NoError(t, err) - adaptedBlock, err := feeder2core.AdaptBlock(response.Block) + adaptedBlock, err := feeder2core.AdaptBlock(response.Block, sig) require.NoError(t, err) adaptedStateUpdate, err := feeder2core.AdaptStateUpdate(response.StateUpdate) require.NoError(t, err) @@ -219,7 +225,7 @@ func TestStateUpdatePendingWithBlock(t *testing.T) { response, err := client.StateUpdateWithBlock(ctx, "pending") require.NoError(t, err) - adaptedBlock, err := feeder2core.AdaptBlock(response.Block) + adaptedBlock, err := feeder2core.AdaptBlock(response.Block, nil) require.NoError(t, err) adaptedStateUpdate, err := feeder2core.AdaptStateUpdate(response.StateUpdate) require.NoError(t, err)