Commit 6ce7e42
authored
feat(tnt-core-v0.13.0): bind quotes to requester, end live operator-tooling outage (#1406)
* chore(deps): bump tnt-core-bindings to v0.13.0 (git, audit Round 2 economic F1)
tnt-core PRs #124 and #125 add `address requester` to QuoteDetails and
JobQuoteDetails, binding every signed quote to the address allowed to
redeem it on-chain. Wildcard (`address(0)`) quotes are rejected by the
v0.13.0 verifier.
Bindings v0.13.0 is not yet on crates.io, so this pins to the upstream
`main` branch in git. Flip back to `"0.13.0"` (crates.io) once the
publish lands.
This commit alone breaks `blueprint-tangle-extra` and `pricing-engine`;
the follow-up commits in this branch update the Rust types and gRPC
surface to thread `requester` end-to-end.
* fix(tangle-extra): bind JobQuoteDetails to requester (audit Round 2 economic F1)
tnt-core v0.13.0 (PRs #124 and #125) adds `address requester` as the
first field of `JobQuoteDetails`, baking it into the EIP-712 typehash:
JobQuoteDetails(address requester,uint64 serviceId,uint8 jobIndex,
uint256 price,uint64 timestamp,uint64 expiry,
uint8 confidentiality)
The on-chain verifier rejects `requester == address(0)` (no more wildcard
quotes) and rejects any submitter whose `msg.sender` doesn't match the
quote's requester.
This commit:
- Adds `requester: Address` as the first field of `JobQuoteDetails`.
- Updates `JOB_QUOTE_TYPEHASH_STR` and `hash_job_quote_details` to include
`requester` directly after the typehash in the abi-encoded preimage.
- Updates the `From<SignedJobQuote>` impl for the on-chain
`ITangleTypes::JobQuoteDetails` to forward `requester`.
- Refreshes the 4 cross-repo EIP-712 deterministic test vectors against
`tnt-core/test/tangle/EIP712Compatibility.t.sol`:
Vector 1 struct hash: 0x81efa1579f66bc16802d9c482eb23561fa1a86e1288cb65902b4619005a04a87
Vector 1 digest: 0xfd2339fda45c2e7e30f8d5dbcc062f82af12757ad80175cbdd6972627fb3c54c
Vector 2 digest: 0xc21c630f71383acd4d8f5465a13264f9e376dfb323acfe97d5202bc9a5baa221
Vector 3 digest: 0xebd98b504cfdbe392ddf9813148e2f7808bb6f7ef85c376315fe0446c2ffc9ee
Vector 4 r: 0x9d22c9909f6ebbcadc4ec85467c487e3d29afa8409f058371894af17f176db4c
- Adds a new `test_requester_changes_hash` regression that asserts
rebinding to a different requester produces a different struct hash.
- Updates module-level rustdoc and the Solidity reference docstring
to reflect the v0.13.0 layout.
Domain separator is unchanged (TangleQuote/v1).
* feat(pricing-engine): add `requester` to proto schema (audit Round 2 economic F1)
tnt-core v0.13.0 (PRs #124 and #125) binds every signed quote to a
requester address. Plumb that through the gRPC surface:
- `GetPriceRequest.requester` (field 9) — buyer address (20 bytes)
- `GetJobPriceRequest.requester` (field 6) — buyer address (20 bytes)
- `QuoteDetails.requester` (field 8) — echoed back in the response
- `JobQuoteDetails.requester` (field 7) — echoed back in the response
All four fields are documented as MUST be non-zero; the on-chain
verifier rejects wildcard (`address(0)`) quotes. Validation is enforced
at the gRPC boundary in a follow-up commit.
This commit only changes the schema; the regenerated prost types break
`signer.rs` and `server.rs`, which are fixed in the next commit.
* fix(pricing-engine): thread requester end-to-end (audit Round 2 economic F1)
This is the live operator-tooling outage fix. Before this commit,
`build_abi_quote_details` hardcoded `requester: Address::ZERO`, so every
quote signed by the pricing engine was rejected by `verifyQuoteBatch`
on tnt-core v0.12.0+ deployments (wildcard quotes are no longer permitted).
Fix:
- gRPC entry: `parse_requester` validates the 20-byte field is non-zero
and rejects with `Status::invalid_argument("requester required and
must be non-zero")` otherwise. Validation lives at the boundary so
downstream signing code can rely on a non-zero requester.
- `SignableQuote::new` and `SignableQuote::with_confidentiality` take
`requester: Address` and pass it into `build_abi_quote_details`.
- `build_abi_quote_details` writes the validated requester into the
on-chain `ITangleTypes::QuoteDetails`. The hardcoded `Address::ZERO`
is gone.
- `proto_to_native_job_quote` parses + validates the proto job-quote
`requester` bytes (20-byte length, non-zero) before delegating to
`blueprint_tangle_extra::job_quote`.
- `get_price` and `get_job_price` echo the requester back into the
proto response (`QuoteDetails.requester` / `JobQuoteDetails.requester`)
so clients can verify the bound address matches what they asked for.
Tests:
- All 24 inline RPC tests in `server.rs` updated to send the new
`requester` field via a `test_requester_bytes()` helper.
- `tests/utils.rs` populates `requester` in `create_test_quote_details`
and exposes `test_requester_address` / `test_requester_bytes` helpers.
- `tests/signer_test.rs` updated to pass requester into
`SignableQuote::new`.
`evm_listener` integration tests (gated behind the
`pricing-engine-e2e-tests` feature) are updated in the next commit.
* fix(pricing-engine): bind requester in evm_listener integration fixtures
tnt-core v0.13.0+ rejects `requester == address(0)` quotes on-chain
(audit Round 2 economic F1, PRs #124 and #125), and the on-chain
verifier cross-checks `msg.sender == quote.details.requester`.
Update the e2e fixtures gated behind `pricing-engine-e2e-tests`:
- Define `SERVICE_OWNER_ADDRESS` (the buyer's anvil-derived address) and
pin all gRPC `GetPriceRequest`s + `convert_to_onchain_quote` callers
to that requester. The buyer is the same anvil account that submits
the on-chain transaction, so `msg.sender` matches the bound requester.
- Define `REJECTION_PATH_REQUESTER = 0xbEEF` for the 3 fixtures that
exercise revert paths (invalid signature, expired quote, mismatched
blueprint). Using a non-zero placeholder keeps these tests targeting
their intended rejection reason rather than the new wildcard-quote
rejection that would short-circuit them.
- Add a `requester: Address` parameter to the `convert_to_onchain_quote`
helper, threaded through to the on-chain `ITangleServicesTypes::QuoteDetails`.
- Plumb `SERVICE_OWNER_ADDRESS` into the two `SignableQuote::new` callers
that re-derive the EIP-712 digest for client-side verification.
After this commit, an unmodified e2e run signs a quote with
`requester = SERVICE_OWNER_ADDRESS` and submits the on-chain
`createServiceFromQuotes` from the same address — round-tripping the
new v0.13.0 verifier.
* docs(pricing-engine): update typehash strings + flow diagram for v0.13.0
Refresh the inline `QUOTE_TYPEHASH` / `JOB_QUOTE_TYPEHASH` strings and
the per-job RFQ flow diagram in the pricing-engine README to reflect
the v0.13.0 on-chain layout (audit Round 2 economic F1, tnt-core PRs
#124 and #125):
- Both typehash strings now lead with `address requester`.
- The `JobQuoteDetails` typehash also includes the `uint8 confidentiality`
field (which had been added previously but never made it into the
README copy).
- The flow diagram shows the `requester` parameter on `GetJobPrice` and
the `requester` field on the signed payload.
- The standalone signing example sets a non-zero requester explicitly
and includes `confidentiality`, matching the current Rust struct.
A short callout below the flow diagram explains that wildcard
(`address(0)`) quotes are rejected by the on-chain verifier and that
the gRPC layer enforces non-zero at the boundary.
* test(pricing-engine): pin requester gRPC validation behavior
Add 5 regression tests for the new gRPC requester validation introduced
earlier in this branch:
- `test_get_job_price_rejects_zero_requester` — confirms a 20-byte
zero-address request is rejected with InvalidArgument.
- `test_get_job_price_rejects_empty_requester` — confirms an empty
bytes field is rejected (the proto default).
- `test_get_job_price_rejects_short_requester` — confirms a wrong-length
buffer is rejected with the expected error message.
- `test_get_price_rejects_zero_requester` — same coverage on the
GetPrice path.
- `test_get_job_price_echoes_requester_in_response` — confirms the
signed response echoes back the requester so the client can verify
the binding.
These tests pin the contract that downstream signing code can rely on
a non-zero requester (audit Round 2 economic F1; tnt-core PRs #124 / #125).
* style(pricing-engine): cargo fmt evm_listener fixtures1 parent 1ef2235 commit 6ce7e42
10 files changed
Lines changed: 466 additions & 53 deletions
File tree
- crates
- pricing-engine
- proto
- src
- service/rpc
- tests
- tangle-extra/src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
130 | 134 | | |
131 | 135 | | |
132 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
154 | 160 | | |
155 | 161 | | |
156 | 162 | | |
157 | | - | |
| 163 | + | |
158 | 164 | | |
159 | | - | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | | - | |
| 168 | + | |
163 | 169 | | |
164 | | - | |
| 170 | + | |
165 | 171 | | |
166 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
167 | 177 | | |
168 | 178 | | |
169 | 179 | | |
170 | 180 | | |
171 | 181 | | |
172 | 182 | | |
173 | 183 | | |
| 184 | + | |
174 | 185 | | |
175 | 186 | | |
176 | 187 | | |
177 | 188 | | |
178 | 189 | | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
| |||
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
122 | 130 | | |
123 | 131 | | |
124 | 132 | | |
| |||
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
| |||
189 | 201 | | |
190 | 202 | | |
191 | 203 | | |
192 | | - | |
| 204 | + | |
193 | 205 | | |
194 | 206 | | |
195 | 207 | | |
| |||
205 | 217 | | |
206 | 218 | | |
207 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
208 | 224 | | |
0 commit comments