0xFableOrg / 0xFable

A fully on-chain trading card game. There will be elves, wizards & shit. Drama and broken friendships also.
https://twitter.com/0xFableGame
BSD 3-Clause Clear License
103 stars 35 forks source link

feat: use single event listener per #91 #120

Open debuggingfuture opened 5 months ago

debuggingfuture commented 5 months ago

Context (Problem, Motivation, Solution)

For #91

to reduce rpc usage with single event listener and rpc filter

Describe Your Changes

Checklist

Testing

debuggingfuture commented 5 months ago

Sample log starting game (sign the first few txns)

with a980cd790fb576f8b7545de4c8e2e163e913b291


    Transaction: 0x1159bc2b89ded963c87108fdae16fa4710f4277b0ac1c89e3911476c9c8ad4e7
    Gas used: 118889

    Block Number: 60
    Block Hash: 0xe016031fd663aca89ef9790084b13742a714cf6b6d9c334dc4177fc329f992e6
    Block Time: "Mon, 19 Feb 2024 09:25:24 +0000"

    Block Number: 61
    Block Hash: 0x677f06ed5a02bc467d6edbacb1cf5edc6fe2fbf6de4312f4722b3585fa2735f7
    Block Time: "Mon, 19 Feb 2024 09:25:26 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_newFilter
eth_call

    Block Number: 62
    Block Hash: 0x761bfa419a15a508ab549f267dc22f24166a465dae1112e2a7eeba38147f2338
    Block Time: "Mon, 19 Feb 2024 09:25:28 +0000"

    Block Number: 63
    Block Hash: 0x1c12309fe9b40153b814f593062cbc437aaf2c24109860d7c86929bb7ba8d828
    Block Time: "Mon, 19 Feb 2024 09:25:30 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_call

    Block Number: 64
    Block Hash: 0x76d343e69fa189945ae02048f2c70a7962aaacc43a346c0f60a2763de5552588
    Block Time: "Mon, 19 Feb 2024 09:25:32 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getBlockByHash
eth_call
eth_call
eth_call
eth_call
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory

    Block Number: 65
    Block Hash: 0xedc81f936398560c2c0e2a75ce45ec21f12599b7138a8670832e0d3bd8813453
    Block Time: "Mon, 19 Feb 2024 09:25:34 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 66
    Block Hash: 0x01a74e90025b3ebb3a1a192e30964aa9745f0226d307e753d6cc0365a47a1597
    Block Time: "Mon, 19 Feb 2024 09:25:36 +0000"

eth_call

    Block Number: 67
    Block Hash: 0x5a9bf527a2ba985f5c4acd3d49d170b91f0226d52c9c4c1e216dc4255c5cf7db
    Block Time: "Mon, 19 Feb 2024 09:25:38 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 68
    Block Hash: 0xb05b33a9b72d8112511cc37c3abd8f4ba9cd21595e07b7a8b74d5d48c264dfed
    Block Time: "Mon, 19 Feb 2024 09:25:40 +0000"

eth_call
eth_getCode
eth_estimateGas
eth_feeHistory
eth_call
eth_call
eth_call
eth_call
eth_call
eth_feeHistory

    Block Number: 69
    Block Hash: 0xa9b37f899fc4a079926f80c12b22ca350804b7862a06f6506370f557d2760502
    Block Time: "Mon, 19 Feb 2024 09:25:42 +0000"

eth_blockNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBlockByNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getTransactionCount
eth_blockNumber
eth_feeHistory
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 70
    Block Hash: 0xf65be816e22c0969fdefef61773492b0d36640e5d9683c839117ab884ffd1365
    Block Time: "Mon, 19 Feb 2024 09:25:44 +0000"

    Block Number: 71
    Block Hash: 0x693ec89a26498c807e6dfa4eba40aff222af481d1f2e95a35051b617e40674d2
    Block Time: "Mon, 19 Feb 2024 09:25:46 +0000"

eth_sendRawTransaction
eth_call
eth_blockNumber
eth_getTransactionByHash
eth_getTransactionReceipt
eth_getBlockByNumber
eth_call

    Transaction: 0x1d8c3bba226970361fc9706d9f0a490c1a6394f74e528d26afa355083f6655b4
    Gas used: 1010094

    Block Number: 72
    Block Hash: 0xe637f515295f3b683793695c501d4973bee33272fccdb458dfd50543f6ec2fdc
    Block Time: "Mon, 19 Feb 2024 09:25:48 +0000"

eth_call
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_call
eth_call
eth_call
eth_getBlockByNumber
eth_feeHistory
eth_feeHistory

    Block Number: 73
    Block Hash: 0xea7904eb6885e8fa470ad856a6b739ffb07ffb6769fa015dc58529f0c647671d
    Block Time: "Mon, 19 Feb 2024 09:25:50 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt

    Block Number: 74
    Block Hash: 0xe5eb3776e7a9fcdd05a93aa8f5715e5f891b96d960c904ab27547595164e5792
    Block Time: "Mon, 19 Feb 2024 09:25:52 +0000"

eth_call
eth_blockNumber
eth_getTransactionReceipt
eth_getBlockByHash
eth_call
eth_call
eth_call
eth_call
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory
eth_call
eth_getCode
eth_estimateGas
eth_feeHistory
eth_call
eth_call
eth_call
eth_call
eth_feeHistory

    Block Number: 75
    Block Hash: 0x154d27065508a2e7e0886737210126a51bf2ad40b544b79ad07a49462c2f7b84
    Block Time: "Mon, 19 Feb 2024 09:25:54 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_blockNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBlockByNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getTransactionCount
eth_blockNumber
eth_feeHistory

    Block Number: 76
    Block Hash: 0x9600e0d519270d5f2db7c6d6f6aa9c66a9a225971e7ada9ab7583619c79a6577
    Block Time: "Mon, 19 Feb 2024 09:25:56 +0000"

eth_call

    Block Number: 77
    Block Hash: 0x6a84d79c9c9137453f9d4f47d92eb95bb4654d3329b53c0af428efb9e164c49f
    Block Time: "Mon, 19 Feb 2024 09:25:58 +0000"

    Block Number: 78
    Block Hash: 0xda029862049ce69eef298127b6e942b932de53db00d3841bbb26549a14b1b41b
    Block Time: "Mon, 19 Feb 2024 09:26:00 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 79
    Block Hash: 0xb46a86aa8017291c97afef7181f4ba6a43f3c51236fc30a380acc27e2198525f
    Block Time: "Mon, 19 Feb 2024 09:26:02 +0000"

eth_call
eth_blockNumber
eth_getBlockByNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance

    Block Number: 80
    Block Hash: 0x58934ec1ae8fdbafc5715f0e5538b0086872f03d408d079cccd1b34f1ea3cb4f
    Block Time: "Mon, 19 Feb 2024 09:26:04 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory

    Block Number: 81
    Block Hash: 0x35dc9ba3b6321cc1bab8c66be4d81b376b7ff536ea60c46c5f74dad92e502771
    Block Time: "Mon, 19 Feb 2024 09:26:06 +0000"

eth_call

    Block Number: 82
    Block Hash: 0x445dd4e38d96e49bc648bfc0a6f9369ebda53073c3b8a8bcb926acf28d8d375c
    Block Time: "Mon, 19 Feb 2024 09:26:08 +0000"

    Block Number: 83
    Block Hash: 0xb8f757046f46d2033d413e52caa8138fdb8107e38c9d6dda8b4b1d77c9aca580
    Block Time: "Mon, 19 Feb 2024 09:26:10 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 84
    Block Hash: 0x3ff6235ea02b96492969e4fc5c0cb60568b7fa8173cb13a5c9e2274018c7eb17
    Block Time: "Mon, 19 Feb 2024 09:26:12 +0000"

eth_call
eth_getTransactionCount
eth_blockNumber
eth_getBlockByNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_sendRawTransaction
eth_blockNumber
eth_getTransactionByHash
eth_getTransactionReceipt
eth_getBlockByNumber
eth_call
eth_call
eth_call
eth_call
eth_blockNumber
eth_feeHistory
eth_feeHistory

    Transaction: 0x3afa9a063c17e52a29dcffb64538f3c7627c6f74b24911fbedf9fd4f3d0c8561
    Gas used: 392311

    Block Number: 85
    Block Hash: 0x1698a3130715b65bae492f7886185a300c9fb786cd95117c562e396ca9b0e588
    Block Time: "Mon, 19 Feb 2024 09:26:14 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getBlockByHash
eth_call
eth_call
eth_call
eth_call
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_call

    Block Number: 86
    Block Hash: 0xa30c97b2150dff5c44b41b4a19ed05de23dbbdd4cb41bbf6dcafeeb7ebd6a9fe
    Block Time: "Mon, 19 Feb 2024 09:26:16 +0000"

eth_blockNumber
eth_call
eth_getTransactionReceipt
eth_getTransactionReceipt

    Block Number: 87
    Block Hash: 0x35addbd28f35cd5caee71b12d7c604cb997a9757b1519d10b1f7a2db7f511a57
    Block Time: "Mon, 19 Feb 2024 09:26:18 +0000"

    Block Number: 88
    Block Hash: 0x60a14a9542d11c1562032057613ff604db8f913be93a5131ad58cc0186e287a0
    Block Time: "Mon, 19 Feb 2024 09:26:20 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 89
    Block Hash: 0xe23e11d3d853bac19037ca6c741d354f52d6fd53279777c9bdb959824d9ab9e8
    Block Time: "Mon, 19 Feb 2024 09:26:22 +0000"

eth_call

    Block Number: 90
    Block Hash: 0x9d5e85194c1560b8efcd9a592dfb1583dc6024078b65bbf2ac7dbc5037c1ebb9
    Block Time: "Mon, 19 Feb 2024 09:26:24 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 91
    Block Hash: 0xd181f466cf5f46021ab5b190df1ec452398ffff6ea12024c7a6b4e71174b7200
    Block Time: "Mon, 19 Feb 2024 09:26:26 +0000"

eth_call

    Block Number: 92
    Block Hash: 0x4562f48530c8ec7e4a3221f96235f47d76f5e545a4ddadb2239d1ecde5841088
    Block Time: "Mon, 19 Feb 2024 09:26:28 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges

    Block Number: 93
    Block Hash: 0x37469b938a094df528b240d3b1c6ceb5938f5069971b78f581d51dfe3e030736
    Block Time: "Mon, 19 Feb 2024 09:26:30 +0000"

    Block Number: 94
    Block Hash: 0xcc74f74ab5ff23ce3ec529a09752a4c60d581ebda8ba54eaea2f1385ae08d2da
    Block Time: "Mon, 19 Feb 2024 09:26:32 +0000"

eth_call

    Block Number: 95
    Block Hash: 0x0b65a8d6cc660e1e6583da40e6bdf79e4a051e9cb9862f027e551e8fa302bff6
    Block Time: "Mon, 19 Feb 2024 09:26:34 +0000"

eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
eth_getFilterChanges
debuggingfuture commented 5 months ago

Sample log starting game after this PR d6c658ffe07f01249875eea2ad237c98f4f59b5b


eth_call

    Block Number: 62
    Block Hash: 0x0bec3c4b3d1db708946ffd606821f6a792f5c0c6f51eaa1084aff974a698b453
    Block Time: "Mon, 19 Feb 2024 09:29:39 +0000"

eth_call
eth_blockNumber
eth_getCode
eth_getBlockByNumber
eth_estimateGas
eth_blockNumber
eth_feeHistory
eth_call
eth_call
eth_call
eth_call
eth_feeHistory
eth_blockNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getTransactionCount
eth_feeHistory

    Block Number: 63
    Block Hash: 0x834e871dd20d0accdd9c58335e7e5887c09ccb8825269755902d869807428573
    Block Time: "Mon, 19 Feb 2024 09:29:41 +0000"

eth_sendRawTransaction
eth_blockNumber
eth_getTransactionByHash
eth_getTransactionReceipt
eth_getBlockByNumber
eth_call
eth_call
eth_call
eth_call
eth_feeHistory
eth_feeHistory

    Transaction: 0x0cb98a8871eadbe1b1711c5c11e3f798bce90a8b8ed466241a37bcfdb1911c08
    Gas used: 118889

    Block Number: 64
    Block Hash: 0x6e595622c4adc808ffe27335596fbaedc10f9a3a204d22aa27cc5e2adf88ddfd
    Block Time: "Mon, 19 Feb 2024 09:29:43 +0000"

    Block Number: 65
    Block Hash: 0x68907c149ec675ba7b6dd82754b3d1c9a18dd063efdbda16ba803856886c431c
    Block Time: "Mon, 19 Feb 2024 09:29:45 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_call
eth_newFilter

    Block Number: 66
    Block Hash: 0x974195d1d6a91b97e42a9d6ee66090ec87ceac43c6a0421a73baee38d9468e14
    Block Time: "Mon, 19 Feb 2024 09:29:47 +0000"

eth_call

    Block Number: 67
    Block Hash: 0xc745ffa895b9e72ce5d7f5de387f917e842b7435a4bba8db948a02c4a274241b
    Block Time: "Mon, 19 Feb 2024 09:29:49 +0000"

eth_getFilterChanges
eth_call
eth_estimateGas
eth_feeHistory
eth_call
eth_call
eth_call
eth_call

    Block Number: 68
    Block Hash: 0x5a62058c444206117157c4ad9a44d3dc6db6e6aaa4b9cf1c521c6e755c32df5b
    Block Time: "Mon, 19 Feb 2024 09:29:51 +0000"

eth_feeHistory
eth_feeHistory
eth_sendRawTransaction
eth_blockNumber
eth_getTransactionByHash
eth_getTransactionReceipt
eth_getBlockByNumber
eth_call

    Transaction: 0x6f8364af4f52a3df1142cf7f0db450acdb42cb491f9ac9b2b6dd36614fd903c9
    Gas used: 1010094

    Block Number: 69
    Block Hash: 0x97a849e68b1a06a81149b87a5e3b944feae6b19a2c8f7c0b43ac38784b3507ea
    Block Time: "Mon, 19 Feb 2024 09:29:53 +0000"

eth_call
eth_call
eth_call
eth_feeHistory
eth_feeHistory
eth_getFilterChanges
eth_call
eth_getBlockByNumber
eth_call

    Block Number: 70
    Block Hash: 0x2606e35221ae79213889ed7db5e0cf999c3e4ccac15db66ebfddeed5389cd39e
    Block Time: "Mon, 19 Feb 2024 09:29:55 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt

    Block Number: 71
    Block Hash: 0x779e72e7342bb0da07c77f0842549f2b7fe2f1613271093d78463da0d0ee2ab6
    Block Time: "Mon, 19 Feb 2024 09:29:57 +0000"

eth_getFilterChanges
eth_call
eth_estimateGas
eth_call
eth_feeHistory
eth_call
eth_call
eth_call
eth_call
eth_feeHistory

    Block Number: 72
    Block Hash: 0xe43d570310e02ee2aa3fd7f3505eef4448c1889e81145a6f3b17fcc9322da0cb
    Block Time: "Mon, 19 Feb 2024 09:29:59 +0000"

eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_getBlockByHash
eth_getBlockByHash
eth_call
eth_call
eth_call
eth_call
eth_blockNumber
eth_getBlockByNumber
eth_feeHistory
eth_feeHistory
eth_blockNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_blockNumber

    Block Number: 73
    Block Hash: 0x1ca2465ca0af82b821ca026685dc8af47b7f7d21a74629b2bd37fd2a0955b19d
    Block Time: "Mon, 19 Feb 2024 09:30:01 +0000"

eth_getTransactionCount
eth_feeHistory
eth_getFilterChanges
eth_sendRawTransaction
eth_blockNumber
eth_getTransactionByHash
eth_getTransactionReceipt
eth_getBlockByNumber
eth_call
eth_call
eth_call
eth_call
eth_feeHistory
eth_feeHistory

    Transaction: 0x36d2b92592fd62019d1a69fef0c74bb978fefa4dba3b0261b8884e7aba262e1c
    Gas used: 392311

    Transaction: 0x8e28d7680cceac1d171474bddf490e3fa83c71d051891a7f61e6a02c276d8704
    Gas used: 28798
    Error: reverted with custom error: 537107df

    Block Number: 74
    Block Hash: 0xf44a6facc2c6e96989cab473491d67905655c5318e9d25028d5c22b1aba4ffaf
    Block Time: "Mon, 19 Feb 2024 09:30:03 +0000"

eth_call

    Block Number: 75
    Block Hash: 0xb6b042951b5e87edb81d1950fe3292cbaa0dc888010baa3ea87181980ca4380f
    Block Time: "Mon, 19 Feb 2024 09:30:05 +0000"

eth_getFilterChanges
eth_call
eth_blockNumber
eth_getTransactionReceipt
eth_getTransactionReceipt

    Block Number: 76
    Block Hash: 0x1a9abd5f404e819936b6a95621f1c12da840a5427d293102a49d87df88eccfbc
    Block Time: "Mon, 19 Feb 2024 09:30:07 +0000"

eth_call
norswap commented 5 months ago

Ok, so the logs from Anvil show that eth_getFilterChanges is only called once (good!), but we need to confirm from the browser console that the filtering is actually correct (i.e. we do get the events for our game, and we don't get the events for other games).

debuggingfuture commented 5 months ago

@norswap

my original thought aftering reading RPC documentation is same as you -- it's a viem limitation and at rpc level just set correct parmas for eth_newFilter

Apologies first time I test at the app it worked but probably my anvil wasnt stable / race conditions and I came to incorrect conclusion

I'd step back and say the reason we're having this convo is we don't hv a way to write a test for reproducable validation -- so I wrote a learning test against viem at here (scrapy & not expecting to merge it)

https://github.com/0xFableOrg/0xFable/pull/122

I find the params send to eth_newFilter is [ [ '0x87969bc7faf902221a147b95ceba76e011c5efb0339a0a8ee7a2bb82d9cfbbd6', '0x0000000000000000000000000000000000000000000000000000000000000001' ] ] while as also can be seen on the log we're still receiving event for another game ID

looks like it incorrectly making the criteria as OR for 1st argument https://github.com/wevm/viem/blob/81ae35284e22164e8f8ac4d3b44f846b83f548f1/src/actions/public/createEventFilter.ts#L193

anyway desired pattern will be

[[E1,E2,E3], gameId] or [[E1,E2,E3], null, gameId] etc with E1,E2,E3 as signatures of event

norswap commented 5 months ago

I'd step back and say the reason we're having this convo is we don't hv a way to write a test for reproducable validation -- so I wrote a learning test against viem at here (scrapy & not expecting to merge it)

There's a really easy way to check this without writing a test, I gave it to you earlier ;) Here it is:

You could verify this by opening two different browsers, create a game in both of them (ONLY create). Then once both are created, make the creator join both of them, and check (via the logs printed in the console) that each browser (1) does receive the PlayerJoined event for his own game, and (2) does not receive the PlayerJoined event for another game.

I maybe should have added that we're logging every event received to the browser console, so this is pretty easy to check. It would also be a lot easier than the test you wrote because there is the potential of issues in the test, meaning the test has to be reviewed too :')

anyway desired pattern will be [[E1,E2,E3], gameId] or [[E1,E2,E3], null, gameId] etc with E1,E2,E3 as signatures of event

Yes, that's exactly what I reckon, although we just want to send [[E1,E2,E3], gameId] because having the others (like [[E1,E2,E3], null, gameId]) means we'd need to poll multiple times which is exactly what we're trying to avoid. Fortunately, all events have gameID as first item, so we don't need to change anything for this to work.

norswap commented 5 months ago

So I performed the check, and I can observe two things:

EDIT: In particular, I get it in the following scenario:

You'll notice that we do not subscribe to the GameCreated event, so there might be something fishy going on with the filters here.

norswap commented 5 months ago

I also looked at the JSON payload in the Chrome web tools "Network tab" and here's what I'm getting:

Screenshot 2024-02-21 at 17 16 05

This seems to confirm your hunch that Viem is broken here, the code you link does indeed flatmap all the individual arrays together. (Also I have no idea where these null values are coming from ....)

To support our use case, it should instead "zip" them together (e.g. [A, B], [C, D] should become [[A, C], [B, D]]. Obviously this has many RPC-related issue, e.g. if D is a valid parameter for event A then this is incorrect filtering.

But for us, the things should be of form [E1, gameID], [E2, gameID], [E3, gameID], so we could merge them as [[E1, E2, E3], gameID]

Next steps would be:

norswap commented 4 months ago

Hey, any updates on this?