mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
test(evm): pin real Uniswap interface migration controls
Preserve published compiler-template identities and unknown immutable metadata, reuse the complete WETH measurement workflow, and verify original ABI dispatch selector sets independently. Record latest-main SDK controls without claiming descriptor or model performance gains. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
1770f38cfc
commit
2b61852fe2
6 files changed
+272
-17
No files matched your search
@@ -11,6 +11,10 @@ Follow-up: [native PE/DOS entry views and real model verification](native-entry-
|
||||
records the post-merge native continuation, including a small-function case where
|
||||
four selected replies cost more bytes than the complete dossier.
|
||||
|
||||
Follow-up: [EVM descriptor and real-template controls](evm-descriptor.md) extends
|
||||
the offline corpus with digest-pinned Uniswap runtime templates and an independent
|
||||
published ABI selector oracle, preserving unknown deployment/immutable metadata.
|
||||
|
||||
The 12 detailed checkpoint receipts were archived byte-for-byte before removal
|
||||
from the final PR tree. The archive `review-receipts-00d51e0fc-20261012` is in the
|
||||
private experiment lab outside the checkout; its `archive-index.json` records
|
||||
|
||||
@@ -179,6 +179,62 @@
|
||||
"transport_integrity": "sha512-RJFoomET6FajjG511fmQxeBQfU6M24a0aFZPqpid+ttIxanWf1VGytBG0UmsGjt07qmIPJS8U31D+aecuCucsQ==",
|
||||
"derivation": "selected regular tar member package/wasm/tree-sitter-css.wasm; no target execution"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "uniswap-v3.factory.hex",
|
||||
"file": "UniswapV3Factory.runtime.hex",
|
||||
"bytes": 49073,
|
||||
"sha256": "fb152cc9b597ef4e54e9d72e81dd72c202050aae5e98c63df139864274504276",
|
||||
"decoded_bytes": 24535,
|
||||
"decoded_sha256": "95c34fe1e6b26c79ae42800041a3e2bdb6a978d19297cd74001ac6b316a48d8d",
|
||||
"provenance": {
|
||||
"project": "Uniswap v3-core UniswapV3Factory",
|
||||
"version": "1.0.1",
|
||||
"url": "https://registry.npmjs.org/@uniswap/v3-core/-/v3-core-1.0.1.tgz",
|
||||
"transport_bytes": 86371,
|
||||
"transport_sha256": "141b001e2a376fff867cb24e0713b2834095cb1250c13aae263d9a646446d329",
|
||||
"transport_integrity": "sha512-7pVk4hEm00j9tc71Y9+ssYpO6ytkeI0y7WE9P6UcmNzhxPePwyAxImuhVsTqWK9YFvzgtvzJHi64pBl4jUzKMQ==",
|
||||
"archive_member": "package/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json",
|
||||
"compiler_artifact_bytes": 104076,
|
||||
"compiler_artifact_sha256": "599479f60ebb056804aff7b2d05bdd0830ddbb1fdfaa0b6c62c02294ca7188b0",
|
||||
"derivation": "Parse the exact published Hardhat deployedBytecode field and preserve its original hex carrier with one trailing LF; preserve template placeholders",
|
||||
"authority": "Published compiler runtime template, not a live deployed instance; original placeholders/immutables preserved; no execution or chain lookup",
|
||||
"published_abi_function_count": 7,
|
||||
"deployed_link_references": {},
|
||||
"immutable_references": {
|
||||
"recorded": false,
|
||||
"value": null
|
||||
},
|
||||
"immutable_scope": "Published Hardhat artifact does not record an immutable-reference map; absence is unknown, not proof of no immutables. Runtime template bytes remain exact."
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "uniswap-v3.pool.hex",
|
||||
"file": "UniswapV3Pool.runtime.hex",
|
||||
"bytes": 44287,
|
||||
"sha256": "84d90218eb125074383287877cdc564eca3765241e3bf6f6afdd64a922fbed2b",
|
||||
"decoded_bytes": 22142,
|
||||
"decoded_sha256": "3ef71385c2a22b945bead7904f24b25db877de9db51d1401f2f9daea07ea5c0c",
|
||||
"provenance": {
|
||||
"project": "Uniswap v3-core UniswapV3Pool",
|
||||
"version": "1.0.1",
|
||||
"url": "https://registry.npmjs.org/@uniswap/v3-core/-/v3-core-1.0.1.tgz",
|
||||
"transport_bytes": 86371,
|
||||
"transport_sha256": "141b001e2a376fff867cb24e0713b2834095cb1250c13aae263d9a646446d329",
|
||||
"transport_integrity": "sha512-7pVk4hEm00j9tc71Y9+ssYpO6ytkeI0y7WE9P6UcmNzhxPePwyAxImuhVsTqWK9YFvzgtvzJHi64pBl4jUzKMQ==",
|
||||
"archive_member": "package/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json",
|
||||
"compiler_artifact_bytes": 111557,
|
||||
"compiler_artifact_sha256": "204fb2fa7ad1a639b1df5601f035f9924b064b721b97adf60c7d5d4712643e34",
|
||||
"derivation": "Parse the exact published Hardhat deployedBytecode field and preserve its original hex carrier with one trailing LF; preserve template placeholders",
|
||||
"authority": "Published compiler runtime template, not a live deployed instance; original placeholders/immutables preserved; no execution or chain lookup",
|
||||
"published_abi_function_count": 26,
|
||||
"deployed_link_references": {},
|
||||
"immutable_references": {
|
||||
"recorded": false,
|
||||
"value": null
|
||||
},
|
||||
"immutable_scope": "Published Hardhat artifact does not record an immutable-reference map; absence is unknown, not proof of no immutables. Runtime template bytes remain exact."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
# EVM descriptor and real-template checkpoint
|
||||
|
||||
Continues [#2016](https://github.com/morluto/rea/issues/2016) after the native
|
||||
checkpoint merged. The next internal descriptor will bind the existing exact EVM
|
||||
contract, CLI name and typed service lifetime. Existing complete inputs, output,
|
||||
provider selection and cleanup remain the baseline. Wiring alone does not establish
|
||||
token or latency savings.
|
||||
|
||||
## Public inputs and independent checks
|
||||
|
||||
[corpus.json](corpus.json) retains the original WETH historical example and adds
|
||||
Uniswap v3-core 1.0.1 Factory/Pool compiler runtime templates from the official npm
|
||||
package. Archive integrity, exact regular member, compiler JSON, original carrier
|
||||
and decoded-byte digests are pinned. The carrier is the original `deployedBytecode`
|
||||
field plus one trailing LF. No placeholder is rewritten and no contract is executed.
|
||||
|
||||
These are compiler templates, not live deployed instances. Their published Hardhat
|
||||
artifacts omit immutable-reference maps; that metadata remains explicitly unknown.
|
||||
The recorded empty link-reference maps do not establish absence of immutables.
|
||||
WETH remains a published historical RPC example, with unknown live authenticity.
|
||||
|
||||
Actual control CLI observations infer 7 Factory and 26 Pool functions. The
|
||||
[independent verifier](verify-evm-template.mjs) hashes each canonical published ABI
|
||||
signature with caller-supplied Ethereum Keccak and checks the complete ABI-dispatch
|
||||
selector multiset against the original REA response. Both sets match. This does not
|
||||
establish inferred argument/mutability equivalence, deployment authenticity or
|
||||
runtime semantics; all producer unknowns remain visible.
|
||||
|
||||
## Latest-main control
|
||||
|
||||
Production control: `1770f38cfc6cbe87491d0de8b8730c305c5cf8ea`, Node 24.18.0,
|
||||
npm 11.16.0, matching locked dependencies and unchanged EVMole 0.9.3.
|
||||
The frozen `dist/`/`bridge/` file-table SHA-256 is
|
||||
`7fd6c2c37b4e166df158ec29d48d31f3712b9b087d9807ee019ee997d06ea144`.
|
||||
Measurement driver SHA-256 is
|
||||
`f767c0c0232be1e11918e70e3197a6919680d16688076bef28d4320662f712f7`.
|
||||
Each public SDK run validates the selected named advertised schema and verifies
|
||||
original carrier and decoded identities, inference/unknown scope and unchanged
|
||||
input bytes. All three runs return the same complete 2,420,709-byte catalog.
|
||||
|
||||
| Question | Inferred functions | SDK tool-result JSON bytes | First workflow seconds |
|
||||
| ------------------------ | -----------------: | -------------------------: | ---------------------: |
|
||||
| WETH historical carrier | 11 | 26,760 | 11.432 |
|
||||
| Uniswap Factory template | 7 | 110,424 | 3.628 |
|
||||
| Uniswap Pool template | 26 | 110,998 | 11.211 |
|
||||
|
||||
These are initial observations, not paired performance conclusions or model-token
|
||||
counts. Each workflow includes connection, complete catalog discovery and one
|
||||
interface query. Full bytecode remains inline. Candidate/control repetitions must
|
||||
use the same source driver, inputs, provider settings and Node/worker limits.
|
||||
|
||||
Preparation against earlier frozen main `b1bf4a70d44191348ca20a91a52fb663da4daed0`
|
||||
also passed all 59 cases of the existing real CLI/MCP EVM verifier with privately
|
||||
supplied solc 0.8.30 and strace 6.1. Those cases cover compiler configurations,
|
||||
raw/hex identity, malformed/unsupported carriers, missing limiter and resource
|
||||
constraints. Its measured scope took 233.1 seconds, sampled peak 1,192,730,624
|
||||
bytes and last-observed CPU 181.018 seconds. This is a control, not candidate proof.
|
||||
|
||||
All heavy runs are serial under one CPU, 4 GiB hard memory/3 GiB early-stop, no swap
|
||||
and bounded tasks. Final cgroup counters disappear at scope teardown and remain
|
||||
unverified; last-observed zero limit events are not substituted for final counters.
|
||||
Raw replies, tools, compiler artifacts and detailed receipts remain outside Git.
|
||||
|
||||
## Reproduction
|
||||
|
||||
Build and freeze each pinned runtime using the repository toolchain, then run
|
||||
`measure.mjs --artifact uniswap-v3.factory.hex` or `uniswap-v3.pool.hex` with the
|
||||
exact derived carrier, `--schemas selected`, explicit runtime/revision and a fresh
|
||||
private output directory. Existing `weth.hex` answer fields and invocation remain
|
||||
unchanged. The same common workflow verifies all three offline carriers.
|
||||
|
||||
Run `verify-evm-template.mjs` with `--artifact` selecting the corpus ID,
|
||||
`--artifact-json` selecting its original published compiler JSON, `--evidence`
|
||||
selecting the recorded CLI Evidence or SDK structured reply, `--keccak-module`
|
||||
selecting the absolute `js-sha3/src/sha3.js` module from the private solc toolchain,
|
||||
and `--output` selecting a new private receipt. It acquires no dependencies and
|
||||
does not overwrite an existing receipt.
|
||||
|
||||
The [template model question](questions/evm-uniswap.txt) requires the same complete
|
||||
inferred interface facts and explicit unknowns. Real model trials and a candidate
|
||||
recommendation are pending; an ABI-count match is not used as a model grade.
|
||||
@@ -350,6 +350,38 @@ const inspectWasmTarget = async () => {
|
||||
};
|
||||
};
|
||||
|
||||
/** Identical complete interface question for pinned offline EVM carriers. */
|
||||
const inspectEvmTarget = async () => {
|
||||
const info = await call("inspect_evm_interface", {
|
||||
path: values.path,
|
||||
encoding: "hex",
|
||||
});
|
||||
const n = normalized(info);
|
||||
if (
|
||||
n.evidence_kind !== "inferred" ||
|
||||
n.discovery_completeness !== "unknown" ||
|
||||
n.runtime_execution !== "not-performed" ||
|
||||
["kind", "hardfork", "deployment_authenticity"].some(
|
||||
(key) => n.bytecode[key] !== "unknown",
|
||||
) ||
|
||||
(artifact.decoded_sha256 !== undefined &&
|
||||
n.bytecode.sha256 !== artifact.decoded_sha256) ||
|
||||
(artifact.decoded_bytes !== undefined &&
|
||||
n.bytecode.bytes !== artifact.decoded_bytes)
|
||||
)
|
||||
throw new Error("EVM interface identity or uncertainty changed");
|
||||
return {
|
||||
artifact_sha256: targetSha(info),
|
||||
artifact: n.artifact,
|
||||
bytecode: n.bytecode,
|
||||
functions: n.functions,
|
||||
discovery_completeness: n.discovery_completeness,
|
||||
runtime_execution: n.runtime_execution,
|
||||
limitations: n.limitations,
|
||||
evidence_ids: [info.evidence_id],
|
||||
};
|
||||
};
|
||||
|
||||
const workflows = {
|
||||
"obsidian.asar": async () => {
|
||||
if (values["javascript-question"] === "selected") {
|
||||
@@ -534,23 +566,9 @@ const workflows = {
|
||||
"sqlite.wasm": inspectWasmTarget,
|
||||
"vscode.tree-sitter.wasm": inspectWasmTarget,
|
||||
"vscode.tree-sitter-css.wasm": inspectWasmTarget,
|
||||
"weth.hex": async () => {
|
||||
const info = await call("inspect_evm_interface", {
|
||||
path: values.path,
|
||||
encoding: "hex",
|
||||
});
|
||||
const n = normalized(info);
|
||||
return {
|
||||
artifact_sha256: targetSha(info),
|
||||
artifact: n.artifact,
|
||||
bytecode: n.bytecode,
|
||||
functions: n.functions,
|
||||
discovery_completeness: n.discovery_completeness,
|
||||
runtime_execution: n.runtime_execution,
|
||||
limitations: n.limitations,
|
||||
evidence_ids: [info.evidence_id],
|
||||
};
|
||||
},
|
||||
"weth.hex": inspectEvmTarget,
|
||||
"uniswap-v3.factory.hex": inspectEvmTarget,
|
||||
"uniswap-v3.pool.hex": inspectEvmTarget,
|
||||
...Object.fromEntries(
|
||||
NATIVE_ARTIFACTS.map((artifact) => [
|
||||
artifact,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Statically inspect the published Uniswap v3-core 1.0.1 compiler runtime template at {{artifact_path}} using only REA inspect_evm_interface with encoding hex. Report original carrier SHA-256/byte count, decoded bytecode SHA-256/byte count, every inferred function selector with bytecode_offset, dispatch, inferred_arguments and inferred_state_mutability exactly including null. Preserve evidence_kind, discovery_completeness, bytecode kind/hardfork/deployment_authenticity, runtime_execution, real Evidence IDs and limitations. The unchanged template came from the official published compiler artifact; constructor-dependent values and immutable-reference metadata are not established. Do not infer a live deployed instance, original source signatures or runtime behavior. No RPC, transactions, target execution, shell/file tools or other agents. Final JSON fields: artifact_sha256, artifact_bytes, bytecode_sha256, bytecode_bytes, functions, evidence_kind, discovery_completeness, bytecode_kind, hardfork, deployment_authenticity, runtime_execution, evidence_ids, limitations.
|
||||
@@ -0,0 +1,95 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { isAbsolute } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
const { values } = parseArgs({
|
||||
options: Object.fromEntries(
|
||||
["artifact", "artifact-json", "evidence", "keccak-module", "output"].map(
|
||||
(key) => [key, { type: "string" }],
|
||||
),
|
||||
),
|
||||
});
|
||||
assert.ok(values.artifact, "Select the exact corpus artifact ID");
|
||||
for (const key of ["artifact-json", "evidence", "keccak-module", "output"])
|
||||
assert.ok(isAbsolute(values[key] ?? ""), `${key} requires an absolute path`);
|
||||
const corpus = JSON.parse(
|
||||
await readFile(new URL("./corpus.json", import.meta.url), "utf8"),
|
||||
);
|
||||
const selected = corpus.artifacts.find(({ id }) => id === values.artifact);
|
||||
assert.ok(selected?.provenance.compiler_artifact_sha256);
|
||||
const source = await readFile(values["artifact-json"]);
|
||||
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
||||
assert.equal(hash(source), selected.provenance.compiler_artifact_sha256);
|
||||
assert.equal(source.length, selected.provenance.compiler_artifact_bytes);
|
||||
const artifact = JSON.parse(source);
|
||||
const carrier = Buffer.from(artifact.deployedBytecode + "\n");
|
||||
assert.equal(hash(carrier), selected.sha256);
|
||||
assert.equal(carrier.length, selected.bytes);
|
||||
const { keccak_256 } = (await import(pathToFileURL(values["keccak-module"])))
|
||||
.default;
|
||||
assert.equal(
|
||||
typeof keccak_256,
|
||||
"function",
|
||||
"Supply js-sha3's Ethereum Keccak implementation",
|
||||
);
|
||||
const canonicalType = (input) =>
|
||||
input.type.startsWith("tuple")
|
||||
? `(${input.components.map(canonicalType).join(",")})${input.type.slice(5)}`
|
||||
: input.type;
|
||||
const selectors = artifact.abi
|
||||
.filter((entry) => entry.type === "function")
|
||||
.map((entry) => {
|
||||
const signature = `${entry.name}(${entry.inputs.map(canonicalType).join(",")})`;
|
||||
return { signature, selector: `0x${keccak_256(signature).slice(0, 8)}` };
|
||||
});
|
||||
const reply = JSON.parse(await readFile(values.evidence, "utf8"));
|
||||
const evidence = reply.structuredContent ?? reply;
|
||||
assert.equal(evidence.operation, "inspect_evm_interface");
|
||||
assert.equal(evidence.subject.digest.sha256, selected.sha256);
|
||||
assert.equal(evidence.normalized_result.artifact.sha256, selected.sha256);
|
||||
assert.equal(
|
||||
evidence.normalized_result.bytecode.sha256,
|
||||
selected.decoded_sha256,
|
||||
);
|
||||
assert.equal(
|
||||
hash(Buffer.from(evidence.normalized_result.bytecode.hex, "hex")),
|
||||
selected.decoded_sha256,
|
||||
);
|
||||
assert.equal(evidence.normalized_result.bytecode.bytes, selected.decoded_bytes);
|
||||
assert.equal(evidence.normalized_result.evidence_kind, "inferred");
|
||||
assert.equal(evidence.normalized_result.discovery_completeness, "unknown");
|
||||
const observed = evidence.normalized_result.functions
|
||||
.filter((entry) => entry.dispatch === "abi")
|
||||
.map((entry) => entry.selector);
|
||||
assert.deepEqual(
|
||||
observed.toSorted(),
|
||||
selectors.map((entry) => entry.selector).toSorted(),
|
||||
);
|
||||
await writeFile(
|
||||
values.output,
|
||||
JSON.stringify(
|
||||
{
|
||||
artifact: selected.id,
|
||||
compiler_artifact_sha256: hash(source),
|
||||
keccak_module_sha256: hash(await readFile(values["keccak-module"])),
|
||||
evidence_id: evidence.evidence_id,
|
||||
selector_set_matches_published_abi: true,
|
||||
selectors,
|
||||
scope:
|
||||
"Independent published ABI-derived selector oracle; no deployed authenticity, inferred argument/mutability equivalence or runtime verification is established.",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
{ flag: "wx", mode: 0o600 },
|
||||
);
|
||||
process.stdout.write(
|
||||
JSON.stringify({
|
||||
artifact: selected.id,
|
||||
selector_count: selectors.length,
|
||||
selector_set_matches_published_abi: true,
|
||||
}) + "\n",
|
||||
);
|
||||
Reference in new issue
Block a user