# IMDPicks native Intake state census Tested [`40669c610dc527649625874cc0bca769ae6b1b2e`](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/commit/40669c610dc527649625874cc0bca769ae6b1b2e) on 2026-11-29 UTC. Results were **25 pass and 7 fail** across 30 real Intake transaction hashes and two controls. Twenty completed jobs reached `verifying` with `paid=true`. Two paid admissions returned `blocked`, consistent with their public job records. Six real `job.open` requests emitted through contracts stayed pending. An unrelated reverted transaction was incorrectly reported as a failed request. The absent hash stayed pending with `paid=false`. ## Coverage and verdicts I paged the [Intake address log index](https://eth.blockscout.com/api/v2/addresses/0xa43e6f75ee006411f79ac1c84120606c2330de82/logs) from Ethereum block **26,164,897** through relay head **26,519,496**, inclusive. The relay reported `4444: pruned history unavailable` for a direct log query at the deployment block, so discovery used the index. It returned 63 pages with 3,125 address logs after range filtering, including 1116 `Requested` events. I filtered those events for `job.open@job-1` and the IMD token specified in the [pinned config](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/blob/40669c610dc527649625874cc0bca769ae6b1b2e/web/src/config.ts#L8). For 40 matching logs with a blank index transaction hash, I recovered the hash from Mainnet block receipts by matching block hash, address, log index and request ID. All 135 matching requests resolved to public Intake entries. The count is by current Intake state when read, bounded by the discovery window. It does not show whether those orders passed through other states earlier. The public reference lists the states and describes the 404 for an unknown transaction. [IMD Intake status reference](https://imd.fun/docs/llms.txt) | Intake state | Matching Mainnet records found | Cases run | Coverage | |---|---:|---:|---| | received | 0 | 0 | not run | | paid | 0 | 0 | not run | | admitted | 3 | 3 | observed | | completing | 0 | 0 | not run | | completed | 132 | 25 | observed | | refused | 0 | 0 | not run for `job.open`. One other-action control below. | | failed | 0 | 0 | not run for `job.open`. One other-action control below. | The indexed `Completed` logs paired with these 135 request IDs show status 0 for 132 and no paired completion within the block window for three. The two additional Intake cases have real terminal records and nonzero completion statuses. The refused `job.continue` request and failed `workflow.open` request both returned pending and unpaid. These rows pass as **exclusion controls**. Their snapshots do not mirror the terminal Intake states, and they did not enter the `job.open` terminal handling. A paid order can legitimately fail or be refused after transfer. The safety check here is that it never reaches paid **and** verifying. [IMD completion and refunds reference](https://imd.fun/docs/llms.txt) Fourteen completed cases initially returned pending and paid after a job or job-result GET hit HTTP 429. A serial retry returned verifying for all fourteen. Their rows show the retry snapshot and byte counts. A completed in-scope row passes when the client returns `verifying` with paid and both IDs matching. The admitted rows are judged using the job and result reads when available. In-scope indirect transactions are included because the census compares the tracker to the public record for any payer. They count as mismatches even though normal checkout sends directly to Intake. Unknown controls should stay pending and unpaid. The non-Intake control was deliberately chosen from reverted transactions in block 26,519,488 to test the receipt failure branch. ## Cases Each row’s Intake source is `GET https://api.imd.fun/intake/1/`, using the full hash in that row. The numeric pair after each hash is **block / log index**. API fields show Intake state, order status, and completion status code where present. IDs are **public → snapshot**. An equals sign means the snapshot returned the same full ID. A dash means absent or unread. Byte counts are **independent Intake HTTP body / snapshot request body (UTF-8) / client job HTTP body / client job-result HTTP body**. For a case where the client never called Intake, the independent response still supplies the first byte count. No artifact bytes were fetched. | # | Hash and block / log | API state / order / completion | Snapshot phase / paid | Request ID | Job ID | Bytes | Reason and verdict | |---:|---|---|---|---|---|---|---| | 1 | `0x271193f4599cb83d9d2f6b97e586ca25847eb3a8607f732acea9d4c25d29b2cf` 26305482 / 663 | admitted / paid / — | blocked / true | 0xb0e82c001fedaba1f91209127cc55df2a2f5c26570bbf72f09eee340e7105301 → = | 3075901d-fa05-4596-b659-1ada4de7dc49 → = | 1175/4192/11165/755 | job-blocked · **pass** | | 2 | `0x191d76dc2bfd758f43fdad3811910263a53dafbb1fb94cb9aa3bfdaa5a34792c` 26517335 / 226 | completed / paid / 0 | pending / false | 0xbd5c049c9b6db1c54c97a5a850aae6fb1e11119f3dc56f80656f7fc0b5471fbc → — | 603777f6-8b98-4a6d-b976-745dbe940553 → — | 1665/—/—/— | request-transaction-mismatch · **fail** | | 3 | `0x4eb35c6693688cd763f071ef0dc9a77d956b9e891e81849f5aebe92016a34dbe` 26242474 / 164 | refused / — / 1 (job.continue) | pending / false | 0xb880692a72d34337785fdaa8da18d1f030f4e4fdf820a955da64475dfd7b1d10 → — | — | 1306/—/—/— | request-calldata-mismatch (exclusion) · **pass** | | 4 | `0x667389cc2ee23ccb69be9a26a05c0312ef34bba97edc5927877839926485c031` 26203713 / 211 | failed / paid / 2 (workflow.open) | pending / false | 0x7afe27309d66f7ee167377d645eebb586941ceb5f565a22af785cfc1eddd6d19 → — | c11e8d2b-e61e-46d3-95e4-b42b794c79f3 → — | 1633/—/—/— | request-transaction-mismatch (exclusion) · **pass** | | 5 | `0xf969f8ba0fa71962698c533bc2b7884f8875269fc53ffad6753e0d1697d22158` 26244315 / 160 | admitted / paid / — | blocked / true | 0x7b67fa86644644ae705d61dc446b7283089dc22526b0366e23dadf6aa477501a → = | 35d25347-142c-43ad-af67-823cef4e522d → = | 1175/14241/9835/440 | job-blocked · **pass** | | 6 | `0x7365fc0d0ec22d94208518f843e03f44cc9a5c4988e0920baae5f0aaa3ccf228` 26217191 / 439 | admitted / paid / — | pending / false | 0x0dd4c6737e0d59f3d5338211e914b27fe8b6bccc3cde1a02ccf975e0aab537a3 → — | 29794a36-06ef-49f5-be5a-ed039337eb57 → — | 1250/—/—/— | request-transaction-mismatch · **fail** | | 7 | `0x9bf963185645f6ff5d263a49d6614f81f1dab19f3498689a22e174caa7940562` 26514599 / 1397 | completed / paid / 0 | verifying / true | 0x42a2ff6d3a7d60f33237537f4ec4d73272b2e991f89d46e52ce9f994b51145bc → = | dd9cab18-b3a8-4496-8631-eb5fed096c36 → = | 1592/6476/12406/2194 | **pass** | | 8 | `0x613997a0d2058f460f0d4e59e654c57cbff058f4b40257e2282966f90dc9c00f` 26514598 / 1142 | completed / paid / 0 | verifying / true | 0x4a18dc837e09496f9a0c5c3658c981f69c3b4c83e3be12fea60e8825283909c9 → = | e3b172f2-7a54-43af-aa74-0849452bee28 → = | 1592/6446/12165/2194 | **pass** | | 9 | `0xc7020925d3aad132fe22929b9bacc1d30cdbe1dbc8ec7ef646d391b61121a068` 26514596 / 568 | completed / paid / 0 | verifying / true | 0xdd9d0bf6eb9d653da671e868e362ae4b46936c7e2dfe2767690de609ffaafa89 → = | 3edbe202-e94d-4232-9525-27d8cc0389a3 → = | 1591/6505/12643/2195 | **pass** | | 10 | `0xb69288e95998979379c37a2c6e79e8663d32da8f9d4cbd5462504f8a70dac5da` 26514595 / 546 | completed / paid / 0 | verifying / true | 0x062d24c72f47b1852369a99a085cf9d7d73309700c66c006b3f477b973486961 → = | c32bb765-729f-4e6d-8c44-fe76a5dd7f9e → = | 1591/6563/12665/2195 | **pass** | | 11 | `0x6118ce336d98c6e9d1cbdc9975c509ce28f1ac3acb4cc8aa8eb19edc1f9ab8f4` 26514594 / 1670 | completed / paid / 0 | verifying / true | 0xbac53ae94ff69e1b680d0a2d0dd66fff3d7d719f16da9ae7da8419c37f74de7d → = | 2e5c79b9-662c-4125-9eda-c9269ec9420c → = | 1592/6528/12690/2194 | **pass** | | 12 | `0xfead14a3b527cd50b15a1b229bdf0d6d6f0bd1b432df9f8a9ddd8adcad55ab3a` 26514593 / 1292 | completed / paid / 0 | verifying / true | 0x47408656e44f4d553cd366a7fd58d76ae9931eaf53fb1f864c63112185eee602 → = | e09b03a1-424c-4648-9b61-698bcb39c782 → = | 1592/6420/12474/2195 | **pass** | | 13 | `0xa601a0a6c58fb77ca7fcbbeaf25ef181b625beae85751befe41af1c9981dd5ab` 26514592 / 1084 | completed / paid / 0 | verifying / true | 0x23b94664182e72c9c4a6abf54dcbe61ce82835386a87f5e5f3509e008e1ac41d → = | e224c4c0-a766-4643-b4dc-c7c51ed9d02a → = | 1592/6508/12470/2194 | HTTP 429 on first read · **pass** | | 14 | `0x8d89f9fc8d847494edd0ad74dd4406ef82e65fd5d538eefa1a15aa3a3e89f0f7` 26514591 / 895 | completed / paid / 0 | verifying / true | 0x77d5320c1161797785d7f344b9a44befb3dadaf54b9f423d543539747f7ed3c4 → = | 236cd8ea-be8a-47f1-9e4a-7d433f5e408b → = | 1591/6525/12504/2194 | HTTP 429 on first read · **pass** | | 15 | `0xe881aee29502a10dd88ec2217e5c8b0fbea9a281f2cf68e485b0f77f6fcfa267` 26510890 / 1079 | completed / paid / 0 | verifying / true | 0x8d807277a9e0548416d5f6c18b45cf1bb603404ca747f9e777cee130a29fba2c → = | 3be0bfc6-0c5d-429d-b70e-1a4c89fe2c2a → = | 1592/2456/6997/1240 | HTTP 429 on first read · **pass** | | 16 | `0xa7c08206e161279dd328b40f0023106144239df07cd7f1a6f6f13c4220facc46` 26508688 / 304 | completed / paid / 0 | pending / false | 0x93327202180c0b94cb3069c43ddf0109c0f18e937246a2605fd36d39633b6ac1 → — | 8a02f3be-0a4e-4d3f-aae2-2acce2cdc966 → — | 1667/—/—/— | request-transaction-mismatch · **fail** | | 17 | `0x061bc9d948b917218af8f54bf47c546f996400577d189f16c0fac39d871d2f06` 26504491 / 338 | completed / paid / 0 | pending / false | 0xa26d3580af9b4445540cadd2b854f9a87f9c69f618d6f7b4e796e991879baac3 → — | 67cfdc77-e65c-4791-bbdc-deea6cc84776 → — | 1665/—/—/— | request-transaction-mismatch · **fail** | | 18 | `0x02e7806f7acd35260c9a2eb321f9bf55f459932bc0999041e8895bc35d6fd42e` 26502657 / 399 | completed / paid / 0 | pending / false | 0xa6d3cfb05fe9ecff8af481566315c63e6ea87be3c560089fafc0e7fd86e38e36 → — | 6b5d5669-848a-46bf-b85e-7b454fd1dc12 → — | 1665/—/—/— | request-transaction-mismatch · **fail** | | 19 | `0xd9af9ce12e402e22b92c65596653c386abaab502cb8e07526994f540b2a3c58a` 26500371 / 544 | completed / paid / 0 | verifying / true | 0xf7069a3d095042c3423de3d5f346062bc2e9d091cd2a226ecf73f6bf7bbad5b7 → = | 5eb36283-f494-4912-ba4c-c667dfb66c9c → = | 1591/6999/26791/2202 | HTTP 429 on first read · **pass** | | 20 | `0xaccac19952629dd05c2a90a7a35b9b22959bc7dba025ddd84fea4e60e78d00c5` 26500324 / 798 | completed / paid / 0 | pending / false | 0x0340f9e06938aedcc590b9bbfe7cf5da3d8f0b64a564e583f218d3953ba9b7f3 → — | c9eff464-dbfe-46cb-834c-c94102f021b3 → — | 1665/—/—/— | request-transaction-mismatch · **fail** | | 21 | `0xbc71a4e1561fdafc4d32625232b0769340bf428bd6e252505e9b70619f7c647f` 26496980 / 465 | completed / paid / 0 | verifying / true | 0x4df953cc3d0af9036910900f26efd8d1b303d6af31f67883ad64dc055dd98db9 → = | 32640e27-1b56-43fc-8dfc-d59b171c7ba6 → = | 1591/3331/7739/2862 | HTTP 429 on first read · **pass** | | 22 | `0x80ef9f856a560b7707030c840753444f797b0ebbf32d03a27fd078410e694a13` 26489855 / 640 | completed / paid / 0 | verifying / true | 0x6b1d2bfcff69747b81ad44f2f009db5df33fc50241947ef6f06a20a07bc772bb → = | 0adffb52-5c65-4646-876c-4ea49d9e3231 → = | 1591/3098/7850/1627 | HTTP 429 on first read · **pass** | | 23 | `0xad290a8cd639504aad8ecbd107dcce3d9ecd2b4c38895e7a928c39e9eee148a9` 26489615 / 327 | completed / paid / 0 | verifying / true | 0xbfb6cbdb9a344975093f3f94c3eb4f19f8022a8c96f69d5d7102c528a4e3f739 → = | a7cc4df3-ebec-4fca-803e-fe3ba2c2cca4 → = | 1591/1529/4700/1627 | HTTP 429 on first read · **pass** | | 24 | `0x2f9adb79d9e9c7d6e8b950af57acbe4d7f8fda41b10802b0f578ab1b6c3e70a7` 26489588 / 288 | completed / paid / 0 | verifying / true | 0x2a7c20842cbdda4ab6cb8fffd9be093567185ee5bab7080322976a360ecfb5d7 → = | 8cdf7ab2-162b-4e5c-9479-f30c29b88a19 → = | 1591/2877/7390/1627 | HTTP 429 on first read · **pass** | | 25 | `0xef8a03390683f6a2e02df3f0ddd69d2f24b1562be16454531c7e9b078f0c88ec` 26487245 / 856 | completed / paid / 0 | verifying / true | 0x06248e018e9351b2f3cd0b6ec22d4b81ce3cd694419cb7c4fc5d9d597433e915 → = | 5492fb98-4e9e-49ac-b2ee-6fcf864868a5 → = | 1591/1226/4088/1299 | HTTP 429 on first read · **pass** | | 26 | `0xd48a80ca949971a56d4b1d4d46acf2b6d3202bf77196a1112c9e6601c373bf48` 26487235 / 105 | completed / paid / 0 | verifying / true | 0x04c0021c104c8e6a48840f1634f5975f9bbf54f2d13cf290a3bec181d32bfcc4 → = | 1355c807-5d5f-4cf1-8d86-cc30d3f0dc01 → = | 1591/1220/4081/1626 | HTTP 429 on first read · **pass** | | 27 | `0x140e4c35c87748466ce55d81828eef445806e9a92447a7c0442d1fab7d8112d2` 26486652 / 707 | completed / paid / 0 | verifying / true | 0x97b6ab19e3194e0960a710af7954678f841ad839eec9284f34d004bd3db71bad → = | e75885b2-26a4-4652-ae93-401ddefd94c6 → = | 1591/3886/9542/919 | HTTP 429 on first read · **pass** | | 28 | `0x5d819e36071d9fc66f5d75ee090ddfaf0a460ee22f47e2f42cfc3bdc5d79ef6a` 26485734 / 548 | completed / paid / 0 | verifying / true | 0x6515a753e2b83b0ba8d22501cbe5177a39cd25c284e744286a687e268556cbcd → = | 55a3cbf1-4f4f-4f78-89bc-2fc6ab006347 → = | 1591/2330/6313/1300 | HTTP 429 on first read · **pass** | | 29 | `0x50d307e998c5f0b012248126e367fd7e9757fd61c2663c6e5eaa3d6951f80421` 26485670 / 318 | completed / paid / 0 | verifying / true | 0x85d4684fae3cd4a63ac4ece0e67f44f31bf1d4aa7430e1c41cfabed5e6c18c5b → = | 5ea39f1e-0109-4a97-ad76-bf61fb20140e → = | 1591/2935/7515/1628 | HTTP 429 on first read · **pass** | | 30 | `0x142605c2a1bad31a4df9d946b961384ea15f71e584b5170c355134bc70bd120e` 26485665 / 572 | completed / paid / 0 | verifying / true | 0x580d86f1ca6e4be21e7f7c420d4861fd1a17cc483785d2dcd1cc3b80ffddaa59 → = | 4c2aecda-b782-425c-ba1f-02fb18b401a0 → = | 1591/2116/5877/1298 | HTTP 429 on first read · **pass** | | 31 | `0x4a94111a874a4b82f8aae04b4ceede15566d28ce167eea6eaec918397f8d039c` 26519488 / — | 404 `unknown_transaction` | failed / false | — | — | 98/—/—/— | request-reverted (non-intake) · **fail** | | 32 | `0xbf537950b2877543dd0d68327739c11497b09ca1a95de06e57933ec5198f0751` | 404 `unknown_transaction` | pending / false | — | — | 98/—/—/— | read-unavailable (absent) · **pass** | ## Defects and limitations 1. **A reverted unrelated transaction is classified as an IMDPicks failure.** `web/src/native/client.ts:182–188` returns `failed/request-reverted` before binding the transaction to Intake or the expected request call. Row 31 reverted at destination `0x111111125421ca6dc452d289314280a0f8842a65`, had no Intake request log, and had a public Intake 404. The client should establish destination, method, action and asset before attributing a revert to an IMDPicks order. An unrelated hash should remain pending and unpaid in this interface. [Pinned branch](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/blob/40669c610dc527649625874cc0bca769ae6b1b2e/web/src/native/client.ts#L182-L188) · [Blockscout transaction](https://eth.blockscout.com/api/v2/transactions/0x4a94111a874a4b82f8aae04b4ceede15566d28ce167eea6eaec918397f8d039c) 2. **Valid indirect requests cannot be recovered by the direct-wallet matcher.** `web/src/native/client.ts:91–98` requires the outer transaction and receipt destination to be Intake. Lines 114–119 also bind the event payer to the outer sender and match the outer calldata. The six in-scope cases below returned `pending/false` before the Intake API lookup or ID binding. Five had completed Intake records and one was admitted. IMD documents the payer as the address that calls `request`, which can be a contract. For a tracker that accepts any Intake payer, bind the exact canonical request log and its payer, payment and API entry, with independent verification of the inner call if needed. If the product supports only direct checkout, distinguish an unsupported transaction from one still indexing. Keep payment and delivery gated by independent confirmation. [Pinned matcher](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/blob/40669c610dc527649625874cc0bca769ae6b1b2e/web/src/native/client.ts#L88-L133) · [IMD payer definition](https://imd.fun/docs/llms.txt) | Case | Outer transaction destination | Intake event/API payer | |---:|---|---| | [2](https://eth.blockscout.com/api/v2/transactions/0x191d76dc2bfd758f43fdad3811910263a53dafbb1fb94cb9aa3bfdaa5a34792c) | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | | [6](https://eth.blockscout.com/api/v2/transactions/0x7365fc0d0ec22d94208518f843e03f44cc9a5c4988e0920baae5f0aaa3ccf228) | `0x2fc2ca1b6accec8cbe479c4eb970c67af4bdd748` | `0xae7e3107d621d4574cdd74950fc090cea6d2655c` | | [16](https://eth.blockscout.com/api/v2/transactions/0xa7c08206e161279dd328b40f0023106144239df07cd7f1a6f6f13c4220facc46) | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | | [17](https://eth.blockscout.com/api/v2/transactions/0x061bc9d948b917218af8f54bf47c546f996400577d189f16c0fac39d871d2f06) | `0xdb9b1e94b5b69df7e401ddbede43491141047db3` | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | | [18](https://eth.blockscout.com/api/v2/transactions/0x02e7806f7acd35260c9a2eb321f9bf55f459932bc0999041e8895bc35d6fd42e) | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | | [20](https://eth.blockscout.com/api/v2/transactions/0xaccac19952629dd05c2a90a7a35b9b22959bc7dba025ddd84fea4e60e78d00c5) | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | `0x241cc9f4525d6184b29e0bbc9f8af015dcaa4ea2` | The two positive blocked cases had public job and result state `blocked`. Both preserved the paid flag and returned both IDs. The third admitted case was one of the indirect requests. The absent control was generated from a deterministic SHA-256 input and independently returned null from both Mainnet transaction and receipt lookups, plus the Intake 404. Its client read stopped at the missing receipt and returned `pending/false/read-unavailable`. No cases used simulated responses. [Blocked job result](https://api.imd.fun/jobs/3075901d-fa05-4596-b659-1ada4de7dc49/result) · [Second blocked job result](https://api.imd.fun/jobs/35d25347-142c-43ad-af67-823cef4e522d/result) Each case uses a separately collected public Intake reference. The only repeated client reads in the reported run were the HTTP 429 retries. It leaves transition timing, retry behavior in the browser, browser CORS, wallet signing, new payment and admission, IPFS or other report downloads, integrity and rendering of report content, and research/citation quality unverified. It also leaves real in-scope refused and failed handling unverified. `verifying` is the handoff to the caller's byte verifier. No payment was sent, job opened, production write made or publication performed. [Client return and contract](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/blob/40669c610dc527649625874cc0bca769ae6b1b2e/web/src/native/client.ts#L246-L259) I inspected the named production repository and both prior job records. Their public jobs were completed. The pinned [native operating guide](https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment/blob/40669c610dc527649625874cc0bca769ae6b1b2e/docs/IMD_NATIVE_FLOW.md) describes an imported production baseline and treats historical escrow signing separately. This read-only run required no verifier key. A complete launch check still needs an owner-authorized payer and candidate deployment, origin/CORS verification, and an authorized fresh payment through report delivery. [Production repository](https://github.com/AgentStewLC/launch-3500-imd-picks-complete) · [Repair job](https://api.imd.fun/jobs/1c21662c-024a-4c4e-afd3-811c371660f1) · [Development job](https://api.imd.fun/jobs/084260e9-348f-4c40-b6ac-b4838d9d60d5) ## Reproduction Run from a scratch directory. Use a task-authorized Mainnet RPC with access to block receipts and historical `eth_call`. The actual chain reads used the task's relay. The pinned browser config lists [PublicNode](https://ethereum-rpc.publicnode.com) as its first public RPC. The harness routes viem's read calls through the configured task RPC and the API GETs through curl. No source is patched and no reply or state is fabricated. For an exact replay use the same relay head (26,519,496). The API is live, so state, bytes and sample selection may change. The checkout source hash for `web/src/native/client.ts` was `2ad3e5954a7600291a33a894b6b16b90beb95475488ee4df0cef22361fb08cb7`. ```sh git clone https://github.com/identity-md-launches/goal-3534-imdpicks-critical-payment pinned git -C pinned checkout --detach 40669c610dc527649625874cc0bca769ae6b1b2e (cd pinned/web && npm ci && node_modules/.bin/esbuild src/native/client.ts \ --bundle --platform=node --format=esm --define:import.meta.env='{}' --outfile=../../client.mjs) git -C pinned status --short # Save the two scripts below beside client.mjs and run with Python 3 and Node 24. python3 explorer.py > explorer.json node census.mjs > results.json # Retry only rows where the client received HTTP 429. The retry file contains all cases. node census.mjs results.json > retry.json ``` ### explorer.py ```python import json, subprocess, urllib.parse url = "https://eth.blockscout.com/api/v2/addresses/0xa43e6f75ee006411f79ac1c84120606c2330de82/logs" params = None items = [] pages = 0 while True: page = json.loads(subprocess.check_output(["curl","-fsS","--retry","2","--max-time","25",url+("?" + urllib.parse.urlencode(params) if params else "")])) pages += 1 items.extend(x for x in page["items"] if 26164897 <= x["block_number"] <= 26519496) params = page["next_page_params"] if not params or min(x["block_number"] for x in page["items"]) < 26164897: break print(json.dumps(dict(pages=pages,items=items))) ``` ### census.mjs ```js import { AsyncLocalStorage } from "node:async_hooks"; import { createHash } from "node:crypto"; import { execFile } from "node:child_process"; import { readFile } from "node:fs/promises"; import { promisify } from "node:util"; import { readNative } from "./client.mjs"; const run = promisify(execFile); const rpc = process.env.MAINNET_RPC_URL || process.env.RPC_URL_1 || process.env.ETH_RPC_URL; if (!rpc) throw new Error("Supply the task's Mainnet RPC as MAINNET_RPC_URL"); const api = "https://api.imd.fun"; const topic = "0x1c521a43c9b0f72a335bc80a6918abce08af7949ebbd1c41fe2a576074379063"; const action = "0x6a6f622e6f70656e406a6f622d31000000000000000000000000000000000000"; const intake = "0xa43e6f75ee006411f79ac1c84120606c2330de82"; const imd = "0xd34a99bc0f67ae1bbd63c660e6d0b0dd03e263b7"; const context = new AsyncLocalStorage(); async function curl(url, args = [], signal) { const { stdout } = await run("curl", ["-sS", "--max-time", "12", ...args, "-w", "\n%{http_code}", url], { encoding: "buffer", maxBuffer: 40_000_000, signal }).catch(error => { throw new Error("curl failed with code " + error.code); }); return { body: stdout.subarray(0, -4), status: Number(stdout.subarray(-3).toString()) }; } const allowed = new Set(["eth_chainId","eth_blockNumber","eth_getBlockByNumber", "eth_getTransactionByHash","eth_getTransactionReceipt","eth_getBlockReceipts","eth_call"]); async function chain(body, signal) { const { method } = JSON.parse(body); if (!allowed.has(method)) throw new Error("Unexpected RPC method"); return curl(rpc, ["-H","Content-Type: application/json","--data",body], signal); } async function rpcRead(method, params) { const reply = JSON.parse((await chain(JSON.stringify({jsonrpc:"2.0",id:1,method,params}))).body); if (!("result" in reply)) throw new Error("RPC error " + reply.error?.code); return reply.result; } globalThis.fetch = async (input, init) => { const request = new Request(input, init); const url = new URL(request.url); const signal = context.getStore()?.signal || request.signal; if (url.origin === api && request.method === "GET") { const { body, status } = await curl(url.href, [], signal); context.getStore()?.reads.push({ path: url.pathname, status, bytes: body.length, ...(url.pathname.startsWith("/intake/") && status === 200 ? { states: JSON.parse(body).entries.map(e => e.state) } : {}), ...(url.pathname.startsWith("/jobs/") && status === 200 ? { state: JSON.parse(body).state } : {}) }); return new Response(body, { status }); } if (request.method !== "POST") throw new Error("Unexpected fetch"); const payload = await request.text(); const { body, status } = await chain(payload, signal); const method = JSON.parse(payload).method; let error; try { error = JSON.parse(body).error?.code; } catch {} const result = method === "eth_getTransactionByHash" ? JSON.parse(body).result : undefined; context.getStore()?.reads.push({ method, status, error, to:result?.to, from:result?.from }); return new Response(body, { status, headers: {"Content-Type":"application/json"} }); }; async function mapPool(items, fn, n = 4) { const result = []; let next = 0; await Promise.all(Array.from({length: n}, async () => { while (next < items.length) { const i = next++; result[i] = await fn(items[i]); } })); return result; } function readCase(c) { const reads = []; return context.run({reads,signal:AbortSignal.timeout(15_000)}, async () => { const snapshot = await readNative(c.hash); const { body, payer, ...rest } = snapshot; return {...c, snapshot:{...rest,bodyBytes:body == null ? null : Buffer.byteLength(body)}, reads}; }); } if (process.argv[2]) { const previous = JSON.parse(await readFile(process.argv[2])); for (const [i, c] of previous.results.entries()) { if (c.snapshot.reason !== "rate-limited") continue; const { snapshot, reads, ...reference } = c; const retried = await readCase(reference); previous.results[i] = {...retried, initialRateLimit: true}; } console.log(JSON.stringify(previous)); process.exit(0); } const discovered = JSON.parse(await readFile(new URL("./explorer.json", import.meta.url))); const logs = discovered.items.filter(x => x.topics[0] === topic); const targetLogs = logs.filter(x => x.topics[3] === action && "0x" + x.data.slice(218,258) === imd); const completionTopic = "0xd4ad2d2ef4e8ea9995103f34e322dbefb2534f3a52984a308f7db8e257b76fa1"; const completions = new Map(discovered.items.filter(x => x.topics[0] === completionTopic) .map(x => [x.topics[1], Number(BigInt("0x" + x.data.slice(2,66)))])); const otherActions = new Set(["job.continue@job-1","launch.open@launch-1","workflow.open@workflow-1"]); const extraLogs = logs.filter(x => [1,2].includes(completions.get(x.topics[1])) && otherActions.has(Buffer.from(x.topics[3].slice(2),"hex").toString().replace(/\0+$/,""))); const allSelectedLogs = [...targetLogs,...extraLogs]; await mapPool(allSelectedLogs.filter(x => !x.transaction_hash), async event => { const receipts = await rpcRead("eth_getBlockReceipts", ["0x" + event.block_number.toString(16)]); const matches = receipts.flatMap(r => r.logs).filter(log => log.address === intake && Number(log.logIndex) === event.index && log.topics[0] === topic && log.topics[1] === event.topics[1] && log.blockHash === event.block_hash); if (matches.length !== 1) throw new Error("Missing canonical log at " + event.block_number); event.transaction_hash = matches[0].transactionHash; }); const byHash = Map.groupBy(allSelectedLogs, x => x.transaction_hash); const candidates = await mapPool([...byHash], async ([hash, events]) => { const { body, status } = await curl(api + "/intake/1/" + hash, ["--retry","3","--retry-all-errors"]); const json = JSON.parse(body); return { hash, status, bytes: body.length, error: json.error, entries: events.map(event => { const entry = json.entries?.find(e => e.requestId?.toLowerCase() === event.topics[1] && e.logIndex === event.index); const asset = "0x" + event.data.slice(2+3*64+24, 2+4*64); return { block: event.block_number, log: event.index, req: event.topics[1], eligible: event.topics[3] === action && asset === imd, action: entry?.action, payer: entry?.payer, chainCompletion: completions.get(event.topics[1]), state: entry?.state, reason: entry?.reason, order: entry?.order?.status, kind: entry?.admission?.result?.kind, job: entry?.admission?.result?.jobId, completion: entry?.completion?.status, completionTx: entry?.completion?.txHash }; }) }; }); const controls = []; const unknown = "0x" + createHash("sha256").update("IMDPicks state-census 40669c610").digest("hex"); const block = await rpcRead("eth_getBlockByNumber", ["0x194a7c0",true]); const receipts = await rpcRead("eth_getBlockReceipts", ["0x194a7c0"]); const controlTx = block.transactions.find(tx => tx.to && tx.to.toLowerCase() !== intake && receipts.find(r => r.transactionHash === tx.hash)?.status === "0x0"); if (!controlTx) throw new Error("Missing reverted non-Intake control"); for (const [label, hash] of [["non-intake",controlTx.hash],["absent",unknown]]) { const [tx, receipt, {body,status}] = await Promise.all([ rpcRead("eth_getTransactionByHash",[hash]),rpcRead("eth_getTransactionReceipt",[hash]), curl(api + "/intake/1/" + hash) ]); if (label === "non-intake" && (!receipt || receipt.logs.some(x => x.address === intake && x.topics[0] === topic))) { throw new Error("Invalid non-Intake control"); } if (label === "absent" && (tx || receipt)) throw new Error("Invalid absent control"); controls.push({label,hash,status,bytes:body.length,error:JSON.parse(body).error, receipt:receipt?.status, to:tx?.to, entries:[]}); } const eligible = candidates.filter(c => c.entries.some(e => e.eligible)); const priority = ["failed","refused","received","paid","admitted","completing","completed"]; eligible.sort((a,b) => priority.indexOf(a.entries.find(e => e.eligible).state) - priority.indexOf(b.entries.find(e => e.eligible).state)); const firstByState = [...Map.groupBy(eligible, c => c.entries.find(e => e.eligible).state).values()].map(c => c[0]); const extras = ["refused","failed"].filter(state => !firstByState.some(c => c.entries[0].state === state)) .map(state => candidates.find(c => c.entries.some(e => !e.eligible && e.state === state && e.action === (state === "refused" ? "job.continue" : "workflow.open")))).filter(Boolean); const picked = [...new Set([...firstByState,...extras,...eligible])].slice(0,30); const results = await mapPool([...picked,...controls], readCase, 4); console.log(JSON.stringify({ pages:discovered.pages, logs:logs.length, candidates, results })); ```