@probecli/cli 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/probe.mjs +190 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,6 +29,16 @@ It also reports whether the hook is upgradeable, owned by a single key, uses SEL
|
|
|
29
29
|
|
|
30
30
|
`--publish` has the verifier rerun the check at the same block and sign it. The result then appears at [probecli.com/hooks](https://probecli.com/hooks) with a badge you can put in a README. A pass is evidence about one property at one block, not an audit.
|
|
31
31
|
|
|
32
|
+
Anyone can check a published result without trusting the website:
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
probe hooks # hooks with a published check
|
|
36
|
+
probe verify hook 0x0af57f62982d03066ef917acad87f771c06528ec # signature, signer, and signer approved on-chain
|
|
37
|
+
probe verify hook 0x0af57f62982d03066ef917acad87f771c06528ec --rerun --rpc <archive-rpc> # also rerun the checks at that block
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The public RPC keeps recent state only, so `--rerun` on an older check needs an archive RPC.
|
|
41
|
+
|
|
32
42
|
## Run a job
|
|
33
43
|
|
|
34
44
|
```shell
|
|
@@ -51,8 +61,16 @@ probe case check <job> FeeAfterNextBlock.t.sol
|
|
|
51
61
|
probe work <job> --case FeeAfterNextBlock.t.sol
|
|
52
62
|
```
|
|
53
63
|
|
|
64
|
+
Before you work a job, confirm its scope and rules are the ones fixed at funding:
|
|
65
|
+
|
|
66
|
+
```shell
|
|
67
|
+
probe verify job volume-discount-fee-swaps # recomputes the spec hash and compares it with getJob(id)
|
|
68
|
+
```
|
|
69
|
+
|
|
54
70
|
`probe help` lists every command.
|
|
55
71
|
|
|
72
|
+
If `npm install -g` fails with EACCES, your Node lives in a folder your user cannot write. Set `npm config set prefix ~/.npm-global`, add `~/.npm-global/bin` to your PATH, and install again, or run `npx @probecli/cli` without installing.
|
|
73
|
+
|
|
56
74
|
## Links
|
|
57
75
|
|
|
58
76
|
- Website and docs: [probecli.com](https://probecli.com)
|
package/dist/probe.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/cli/main.ts
|
|
4
4
|
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
5
5
|
import { join as join4, resolve as resolve3 } from "node:path";
|
|
6
|
-
import { parseArgs as
|
|
6
|
+
import { parseArgs as parseArgs3 } from "node:util";
|
|
7
7
|
import { parseUnits, toHex as toHex5 } from "viem";
|
|
8
8
|
import { privateKeyToAccount as privateKeyToAccount5 } from "viem/accounts";
|
|
9
9
|
|
|
@@ -1880,6 +1880,15 @@ function finish(r) {
|
|
|
1880
1880
|
}
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
1883
|
+
function reportDigest(r) {
|
|
1884
|
+
const { checkedAt: _t, ...rest2 } = r;
|
|
1885
|
+
return keccak2564(toHex4(JSON.stringify(rest2, (_k, v) => typeof v === "bigint" ? v.toString() : v)));
|
|
1886
|
+
}
|
|
1887
|
+
var reportMessage = (r) => `PROBE hook check v${r.version}
|
|
1888
|
+
chain ${r.chainId}
|
|
1889
|
+
hook ${r.hook}
|
|
1890
|
+
block ${r.block}
|
|
1891
|
+
digest ${reportDigest(r)}`;
|
|
1883
1892
|
|
|
1884
1893
|
// src/cli/check.ts
|
|
1885
1894
|
var SITE = process.env.PROBE_SITE_URL ?? "https://probecli.com";
|
|
@@ -1947,8 +1956,170 @@ async function check(args) {
|
|
|
1947
1956
|
if (report.summary.failed) process.exitCode = 1;
|
|
1948
1957
|
}
|
|
1949
1958
|
|
|
1959
|
+
// src/cli/verify.ts
|
|
1960
|
+
import { parseArgs as parseArgs2 } from "node:util";
|
|
1961
|
+
import { getAddress as getAddress4, isAddress as isAddress3 } from "viem";
|
|
1962
|
+
|
|
1963
|
+
// src/shared/verify.ts
|
|
1964
|
+
import { getAddress as getAddress3, isAddressEqual, recoverMessageAddress } from "viem";
|
|
1965
|
+
var PROBE_JOBS = {
|
|
1966
|
+
4663: "0x75a7af44fe0117b1f5ff11eddad11fe1e0d34189",
|
|
1967
|
+
46630: "0x75a7af44fe0117b1f5ff11eddad11fe1e0d34189"
|
|
1968
|
+
};
|
|
1969
|
+
function registeredSpec(job2) {
|
|
1970
|
+
const { specHash: _h, chain: _c, state: _s, ...spec } = job2;
|
|
1971
|
+
return spec;
|
|
1972
|
+
}
|
|
1973
|
+
function verifyJobSpec(job2, onchainSpecHash) {
|
|
1974
|
+
const computed = specHash(registeredSpec(job2));
|
|
1975
|
+
return {
|
|
1976
|
+
computed,
|
|
1977
|
+
findings: [
|
|
1978
|
+
{
|
|
1979
|
+
ok: computed === job2.specHash,
|
|
1980
|
+
title: "The verifier's spec hashes to the hash it reports",
|
|
1981
|
+
detail: computed === job2.specHash ? computed : `computed ${computed}, verifier reports ${job2.specHash}`
|
|
1982
|
+
},
|
|
1983
|
+
{
|
|
1984
|
+
ok: computed === onchainSpecHash.toLowerCase(),
|
|
1985
|
+
title: "The hash stored on-chain matches",
|
|
1986
|
+
detail: computed === onchainSpecHash.toLowerCase() ? `getJob(${job2.chain.jobId}).specHash` : `on-chain ${onchainSpecHash}, computed ${computed}`
|
|
1987
|
+
}
|
|
1988
|
+
]
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
async function verifyHookCheck(c2, approvedOnChain) {
|
|
1992
|
+
const rebuilt = reportMessage(c2.report);
|
|
1993
|
+
const findings = [
|
|
1994
|
+
{
|
|
1995
|
+
ok: rebuilt === c2.message,
|
|
1996
|
+
title: "The signed message matches the published results",
|
|
1997
|
+
detail: rebuilt === c2.message ? rebuilt.split("\n").find((l) => l.startsWith("digest ")) ?? "" : "the results do not hash to the digest that was signed"
|
|
1998
|
+
}
|
|
1999
|
+
];
|
|
2000
|
+
let recovered = null;
|
|
2001
|
+
try {
|
|
2002
|
+
recovered = await recoverMessageAddress({ message: c2.message, signature: c2.signature });
|
|
2003
|
+
} catch {
|
|
2004
|
+
recovered = null;
|
|
2005
|
+
}
|
|
2006
|
+
const sameSigner = recovered !== null && isAddressEqual(recovered, getAddress3(c2.signer));
|
|
2007
|
+
findings.push({
|
|
2008
|
+
ok: sameSigner,
|
|
2009
|
+
title: "The signature recovers to the stated signer",
|
|
2010
|
+
detail: recovered ? `${recovered}` : "the signature is malformed"
|
|
2011
|
+
});
|
|
2012
|
+
if (recovered) {
|
|
2013
|
+
const approved = await approvedOnChain(recovered);
|
|
2014
|
+
findings.push({
|
|
2015
|
+
ok: approved,
|
|
2016
|
+
title: "The signer is an approved verifier on ProbeJobs",
|
|
2017
|
+
detail: approved ? `approvedVerifier(${recovered}) is true` : `approvedVerifier(${recovered}) is false`
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
return findings;
|
|
2021
|
+
}
|
|
2022
|
+
function compareRerun(published, rerun) {
|
|
2023
|
+
const mine = new Map(rerun.checks.map((c2) => [c2.id, c2.status]));
|
|
2024
|
+
const theirs = new Map(published.checks.map((c2) => [c2.id, c2.status]));
|
|
2025
|
+
const diffs = [.../* @__PURE__ */ new Set([...theirs.keys(), ...mine.keys()])].filter((id) => theirs.get(id) !== mine.get(id)).map((id) => `${id}: published ${theirs.get(id) ?? "missing"}, rerun ${mine.get(id) ?? "missing"}`);
|
|
2026
|
+
return {
|
|
2027
|
+
ok: diffs.length === 0,
|
|
2028
|
+
title: "Rerunning the checks at the same block gives the same results",
|
|
2029
|
+
detail: diffs.length ? diffs.join("; ") : `${rerun.checks.length} of ${published.checks.length} checks match at block ${published.block}`
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
// src/cli/verify.ts
|
|
2034
|
+
var SITE2 = process.env.PROBE_SITE_URL ?? "https://probecli.com";
|
|
2035
|
+
var USAGE = "Usage: probe verify job <job> | probe verify hook <address> [--rerun] [--rpc <url>] [--json]";
|
|
2036
|
+
function printFindings(findings) {
|
|
2037
|
+
console.log("");
|
|
2038
|
+
for (const f of findings) {
|
|
2039
|
+
console.log(`${f.ok ? dim("\u2713") : hot("\xD7")} ${f.ok ? f.title : hot(f.title)}`);
|
|
2040
|
+
console.log(` ${dim(f.detail)}`);
|
|
2041
|
+
}
|
|
2042
|
+
console.log("");
|
|
2043
|
+
const failed = findings.filter((f) => !f.ok).length;
|
|
2044
|
+
console.log(failed ? `${hot("\xD7")} ${bold(`${failed} of ${findings.length} did not hold`)}` : `${dim("\u2713")} ${bold(`All ${findings.length} held`)}`);
|
|
2045
|
+
if (failed) process.exitCode = 1;
|
|
2046
|
+
}
|
|
2047
|
+
async function verifyJob(slug, json) {
|
|
2048
|
+
const job2 = await api(`/jobs/${slug}`);
|
|
2049
|
+
const onchain = await readJob(clientFor(job2), job2.chain.contract, BigInt(job2.chain.jobId));
|
|
2050
|
+
const { computed, findings } = verifyJobSpec(job2, onchain.specHash);
|
|
2051
|
+
if (json) {
|
|
2052
|
+
printJson({ job: slug, jobId: job2.chain.jobId, contract: job2.chain.contract, computed, verifier: job2.specHash, onchain: onchain.specHash, findings });
|
|
2053
|
+
if (findings.some((f) => !f.ok)) process.exitCode = 1;
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
console.log(`${bold("probe verify job")} ${slug} ${dim(`job #${job2.chain.jobId} on chain ${job2.chain.chainId}`)}`);
|
|
2057
|
+
printFindings(findings);
|
|
2058
|
+
console.log(dim(" The scope and rules you work under cannot have changed since the job was funded."));
|
|
2059
|
+
}
|
|
2060
|
+
async function verifyHook(address, json, rpc, rerun) {
|
|
2061
|
+
if (!isAddress3(address)) fail(USAGE);
|
|
2062
|
+
const hook = getAddress4(address);
|
|
2063
|
+
const published = await api(`/hooks/${hook}`).catch(
|
|
2064
|
+
(e) => fail(/not found|404|not been checked/i.test(e.message) ? `No published check for ${hook}. Publish one with: probe check ${hook} --publish` : e.message)
|
|
2065
|
+
);
|
|
2066
|
+
const report = published.report;
|
|
2067
|
+
const contract = PROBE_JOBS[report.chainId];
|
|
2068
|
+
if (!contract) fail(`No ProbeJobs deployment known for chain ${report.chainId}.`);
|
|
2069
|
+
const client = publicClient(rpc, report.chainId);
|
|
2070
|
+
const approved = (signer) => client.readContract({ address: contract, abi: probeJobsAbi, functionName: "approvedVerifier", args: [signer] });
|
|
2071
|
+
const findings = json ? await verifyHookCheck(published, approved) : await task("Checking the signature and the signer", () => verifyHookCheck(published, approved), () => "done");
|
|
2072
|
+
if (rerun) {
|
|
2073
|
+
const at = Number(report.block).toLocaleString("en-US");
|
|
2074
|
+
const run2 = () => checkHook(client, hook, { chainId: report.chainId, block: BigInt(report.block) }).catch((e) => e);
|
|
2075
|
+
const mine = json ? await run2() : await task(`Rerunning the checks at block ${at}`, run2, (r) => r instanceof Error ? "could not run" : `${r.checks.length} checks`);
|
|
2076
|
+
if (mine instanceof Error) {
|
|
2077
|
+
const pruned = /historical state|missing trie node|state.*not available|header not found/i.test(mine.message);
|
|
2078
|
+
findings.push({
|
|
2079
|
+
ok: false,
|
|
2080
|
+
title: "Rerunning the checks at the same block gives the same results",
|
|
2081
|
+
detail: pruned ? `${rpc} no longer has the state for block ${at}. Rerun against an archive RPC: --rpc <url>` : `the rerun failed: ${mine.message.split("\n")[0]}`
|
|
2082
|
+
});
|
|
2083
|
+
} else findings.push(compareRerun(report, mine));
|
|
2084
|
+
}
|
|
2085
|
+
if (json) {
|
|
2086
|
+
printJson({ hook, block: report.block, chainId: report.chainId, signer: published.signer, findings });
|
|
2087
|
+
if (findings.some((f) => !f.ok)) process.exitCode = 1;
|
|
2088
|
+
return;
|
|
2089
|
+
}
|
|
2090
|
+
console.log(`${dim(" hook")} ${hook} ${dim(`at block ${Number(report.block).toLocaleString("en-US")}, ${report.summary.passed} of ${report.summary.total} checks passed`)}`);
|
|
2091
|
+
printFindings(findings);
|
|
2092
|
+
if (!rerun) console.log(dim(` Rerun the checks too: probe verify hook ${hook} --rerun`));
|
|
2093
|
+
console.log(dim(` ${SITE2}/hooks/${hook}`));
|
|
2094
|
+
}
|
|
2095
|
+
async function verify(args) {
|
|
2096
|
+
const { values, positionals } = parseArgs2({
|
|
2097
|
+
args,
|
|
2098
|
+
allowPositionals: true,
|
|
2099
|
+
options: { json: { type: "boolean", default: false }, rpc: { type: "string" }, rerun: { type: "boolean", default: false } }
|
|
2100
|
+
});
|
|
2101
|
+
const [kind, target] = positionals;
|
|
2102
|
+
if (!kind || !target) fail(USAGE);
|
|
2103
|
+
if (kind === "job") return verifyJob(target, values.json);
|
|
2104
|
+
if (kind === "hook") return verifyHook(target, values.json, values.rpc ?? process.env.PROBE_RPC_URL ?? DEFAULT_RPC, values.rerun);
|
|
2105
|
+
fail(USAGE);
|
|
2106
|
+
}
|
|
2107
|
+
async function hooks(args) {
|
|
2108
|
+
const { values } = parseArgs2({ args, options: { json: { type: "boolean", default: false } } });
|
|
2109
|
+
const list = await api("/hooks");
|
|
2110
|
+
if (values.json) return printJson(list);
|
|
2111
|
+
if (!list.length) return console.log(dim("No published hook checks yet. Publish one with: probe check <hook> --publish"));
|
|
2112
|
+
for (const h of list) {
|
|
2113
|
+
const s = h.summary;
|
|
2114
|
+
const line = s.failed ? hot(`${s.failed} failed`) : `${s.passed} of ${s.total} passed${s.warnings ? `, ${s.warnings} warning${s.warnings === 1 ? "" : "s"}` : ""}`;
|
|
2115
|
+
console.log(`${s.failed ? hot("\xD7") : dim("\u2713")} ${h.hook} ${line} ${dim(`block ${Number(h.block).toLocaleString("en-US")}`)}`);
|
|
2116
|
+
}
|
|
2117
|
+
console.log(dim(`
|
|
2118
|
+
${list.length} published. Check one's signature: probe verify hook <address>`));
|
|
2119
|
+
}
|
|
2120
|
+
|
|
1950
2121
|
// src/cli/version.ts
|
|
1951
|
-
var VERSION = true ? "0.
|
|
2122
|
+
var VERSION = true ? "0.6.0" : JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version;
|
|
1952
2123
|
|
|
1953
2124
|
// src/cli/main.ts
|
|
1954
2125
|
var HELP = `${bold("probe")}: test Uniswap v4 hooks, get paid for verified work.
|
|
@@ -1978,6 +2149,14 @@ Hooks
|
|
|
1978
2149
|
--rpc <url> Chain RPC (default: Robinhood Chain mainnet)
|
|
1979
2150
|
--publish Have the verifier reproduce, sign and publish the result
|
|
1980
2151
|
--json Print the report as JSON
|
|
2152
|
+
probe hooks [--json] List hooks with a published, signed check
|
|
2153
|
+
|
|
2154
|
+
Verify
|
|
2155
|
+
probe verify job <job> Recompute a job's spec hash and compare it with the chain
|
|
2156
|
+
probe verify hook <address> Check a published hook check's signature and that its signer
|
|
2157
|
+
is an approved verifier on ProbeJobs
|
|
2158
|
+
--rerun Also rerun the checks at the same block and compare
|
|
2159
|
+
--rpc <url> Chain RPC for the rerun and the approval lookup
|
|
1981
2160
|
|
|
1982
2161
|
Sponsor
|
|
1983
2162
|
probe sponsor keygen Create your report-decryption key pair
|
|
@@ -1992,7 +2171,7 @@ Environment: PROBE_VERIFIER_URL, PROBE_RPC_URL, PROBE_OPERATOR_KEY, PROBE_SPONSO
|
|
|
1992
2171
|
`;
|
|
1993
2172
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1994
2173
|
async function init(args) {
|
|
1995
|
-
const { values } =
|
|
2174
|
+
const { values } = parseArgs3({ args, options: { verifier: { type: "string" }, force: { type: "boolean" } } });
|
|
1996
2175
|
const cfg = loadConfig();
|
|
1997
2176
|
if (values.verifier) saveConfig({ verifierUrl: values.verifier.replace(/\/$/, "") });
|
|
1998
2177
|
if (cfg.operatorKey && !values.force) {
|
|
@@ -2013,7 +2192,7 @@ async function whoami() {
|
|
|
2013
2192
|
console.log(`${dim("agent ")} ${agentAvailable() ? `${AGENT_MODEL} (credentials found)` : "no credentials; seed cases only"}`);
|
|
2014
2193
|
}
|
|
2015
2194
|
async function jobs(args) {
|
|
2016
|
-
const { values } =
|
|
2195
|
+
const { values } = parseArgs3({ args, options: { json: { type: "boolean" } } });
|
|
2017
2196
|
const list = await api("/jobs");
|
|
2018
2197
|
if (values.json) return printJson(list);
|
|
2019
2198
|
if (!list.length) return note("No jobs registered on this verifier yet.");
|
|
@@ -2028,7 +2207,7 @@ async function jobs(args) {
|
|
|
2028
2207
|
}
|
|
2029
2208
|
}
|
|
2030
2209
|
async function work(args) {
|
|
2031
|
-
const { values, positionals } =
|
|
2210
|
+
const { values, positionals } = parseArgs3({
|
|
2032
2211
|
args,
|
|
2033
2212
|
allowPositionals: true,
|
|
2034
2213
|
options: {
|
|
@@ -2141,7 +2320,7 @@ async function work(args) {
|
|
|
2141
2320
|
}
|
|
2142
2321
|
}
|
|
2143
2322
|
async function job(args) {
|
|
2144
|
-
const { values, positionals } =
|
|
2323
|
+
const { values, positionals } = parseArgs3({ args, allowPositionals: true, options: { json: { type: "boolean" } } });
|
|
2145
2324
|
const slug = positionals[0];
|
|
2146
2325
|
if (!slug) fail("Usage: probe job <job> [--json]");
|
|
2147
2326
|
const [j, subs] = await Promise.all([
|
|
@@ -2208,7 +2387,7 @@ function localFailure(local) {
|
|
|
2208
2387
|
return failed.map((t) => `${t.name}${t.reason ? ` (${t.reason})` : ""}`).join(", ") || "no tests ran";
|
|
2209
2388
|
}
|
|
2210
2389
|
async function caseNew(args) {
|
|
2211
|
-
const { values, positionals } =
|
|
2390
|
+
const { values, positionals } = parseArgs3({ args, allowPositionals: true, options: { out: { type: "string", default: "." } } });
|
|
2212
2391
|
const [slug, raw] = positionals;
|
|
2213
2392
|
if (!slug || !raw) fail("Usage: probe case new <job> <Name> [--out <dir>]");
|
|
2214
2393
|
const name = caseName(raw);
|
|
@@ -2252,7 +2431,7 @@ async function caseCheck(args) {
|
|
|
2252
2431
|
else process.exitCode = 1;
|
|
2253
2432
|
}
|
|
2254
2433
|
async function submissions(args) {
|
|
2255
|
-
const { values, positionals } =
|
|
2434
|
+
const { values, positionals } = parseArgs3({ args, allowPositionals: true, options: { all: { type: "boolean" }, json: { type: "boolean" } } });
|
|
2256
2435
|
const key = loadConfig().operatorKey;
|
|
2257
2436
|
if (!values.all && !key) fail("No operator key, so no submissions of yours. Run probe init, or pass --all to see everyone's.");
|
|
2258
2437
|
const me = key && !values.all ? privateKeyToAccount5(key).address.toLowerCase() : null;
|
|
@@ -2331,7 +2510,7 @@ async function sponsorKeygen() {
|
|
|
2331
2510
|
note(` Put it in your job spec as "reportKey". The secret key is in ${configPath}. Only it can open your reports.`);
|
|
2332
2511
|
}
|
|
2333
2512
|
async function sponsorCreate(args) {
|
|
2334
|
-
const { values } =
|
|
2513
|
+
const { values } = parseArgs3({
|
|
2335
2514
|
args,
|
|
2336
2515
|
options: {
|
|
2337
2516
|
spec: { type: "string" },
|
|
@@ -2416,6 +2595,8 @@ var commands = {
|
|
|
2416
2595
|
whoami,
|
|
2417
2596
|
doctor,
|
|
2418
2597
|
check,
|
|
2598
|
+
hooks,
|
|
2599
|
+
verify,
|
|
2419
2600
|
jobs,
|
|
2420
2601
|
job,
|
|
2421
2602
|
work,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@probecli/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "probe: run reproducible tests for Uniswap v4 hooks, get paid for verified work, and check any deployed hook.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"probe": "node bin/probe.mjs",
|
|
42
42
|
"abi": "node scripts/gen-abi.ts",
|
|
43
43
|
"typecheck": "tsc --noEmit",
|
|
44
|
-
"test": "node --test test/unit.test.ts test/hookcheck.test.ts",
|
|
44
|
+
"test": "node --test test/unit.test.ts test/hookcheck.test.ts test/verify.test.ts",
|
|
45
45
|
"e2e": "node scripts/e2e.ts",
|
|
46
46
|
"preflight": "node scripts/preflight.ts",
|
|
47
47
|
"dev:stack": "node scripts/dev-stack.ts",
|