feat(vara.eth/gear): syscall interface for cryptographic host calls - #5582
Draft
grishasobol wants to merge 12 commits into
Draft
feat(vara.eth/gear): syscall interface for cryptographic host calls#5582grishasobol wants to merge 12 commits into
grishasobol wants to merge 12 commits into
Conversation
Ethexe-only syscall forwarding cryptographic operations (keccak256, sha256, blake2b-256, BLS12-381 verify/aggregate) to the host. CryptoOp ids and buffer layouts live in gsys; the syscall is excluded from the Vara instrumentable set (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Backend handler validates op and output capacity, charges op-dependent CostToken::Crypto (base + per-byte), and dispatches Externalities::crypto. Vara Ext rejects with Unsupported — the syscall is never linked there; ethexe delegates to the stub until host forwarding lands (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Forward crypto ops from the runtime Ext through RuntimeInterface and the ext_crypto_version_1 host fn into native implementations (sha3/sha2/ blake2, BLS12-381 via arkworks, same ciphersuite DST as the Vara builtin). Malformed input maps to the new CryptoInputInvalid error code. RUNTIME_ID and CODES_INSTRUMENTATION_VERSION are bumped: the syscall set changed (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
keccak256 / sha256 / blake2b256 / bls12_381_verify / bls12_381_aggregate_g1 under the ethexe feature; the verify input is assembled on the stack buffer to keep gcore alloc-free (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
demo-crypto-ethexe exercises every CryptoOp from program code; processor integration tests assert syscall-path digests match the native impl and BLS verify accepts/rejects end-to-end. Proptests pin no-panic and output-size invariants plus G1 aggregation order independence. wasm-builder now picks the ethexe syscall set when the program's own `ethexe` feature is on (CARGO_FEATURE_ETHEXE), instead of forcing Vara validation for all in-tree programs (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Move native gr_crypto implementations into ethexe-runtime-common (std-gated crypto_ops) so both ethexe-processor and the gtest ethexe runtime use one implementation; cover SyscallName::Crypto in the pallet-gear syscall integrity bench match (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Linking gear-wasm-builder/ethexe from the demo flipped the builder's global SYSCALL_KIND to Eth for every program in --all-features workspace builds, rejecting Vara-only imports in unrelated demos. The per-crate CARGO_FEATURE_ETHEXE detection is sufficient and precise. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
process_costs_are_same requires the pallet and gas-metering schedules to agree; keeping the crypto placeholders only on the gas-metering side broke it (and a weight-dump regeneration would have dropped them). The weights are constants — the syscall is never linked on Vara — pending ethexe benchmarks (#5456). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ring Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- charge unknown crypto ops by declared input length with the most expensive per-byte coefficients — the buffer is read before rejection (codex P1 + opus) - raise BLS placeholder weights: verify base to 1.5ms-equivalent (pairing + hash-to-curve + subgroup checks), aggregation per-byte to cover subgroup-checked point deserialization (~150us/48B point) — the old per-byte rate under-priced attacker-supplied points by orders of magnitude (opus high) - replace the global CARGO_FEATURE_ETHEXE heuristic in wasm-builder with an explicit `build_ethexe()` build.rs entry point, so external crates with an unrelated `ethexe` feature keep Vara validation - reject identity BLS signatures up front per the IETF spec - pin the exact gr_crypto signature shape in wasm-instrument tests - regenerate gsdk metadata for the new weight values Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5456
Summary
Adds the ethexe-only
gr_cryptosyscall: programs forward cryptographic operations to the host instead of bundling crypto into their Wasm binary.gsys): one generic syscallgr_crypto(op, input_ptr, input_len, output_ptr, output_len, err_ptr)with an append-onlyCryptoOpenum:Keccak256,Sha256,Blake2b256,Bls12381Verify(min-pk,BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_— same DST as the Vara builtin),Bls12381AggregateG1. Fixed per-op output sizes.gear-wasm-instrument):SyscallName::Cryptois the first ethexe-only syscall —is_vara()now excludes it, the Vara backend env count assert is fixed accordingly.CostToken::Crypto(op, input_bytes)(base + per-byte; placeholder weights,TODO #5456: benchmark). VaraExtrejects withUnsupported(the syscall is never linked there).Externalities::crypto→RuntimeInterface::crypto→ext_crypto_version_1wasmtime host fn → native sha3/sha2/blake2 + arkworks BLS12-381. Malformed input maps to new error codeExecutionError::CryptoInputInvalid = 109.RUNTIME_ID/CODES_INSTRUMENTATION_VERSIONbumped (syscall set changed).gcore::crypto, re-exported asgstd::cryptounder theethexefeature. Note: the issue says "ethexe-sdk", but that crate is the client-side SDK — program authors use gstd, so the wrappers live there.ethexefeature are now validated against the ethexe syscall set (CARGO_FEATURE_ETHEXE), instead of being forced to Vara validation by the workspace-hack heuristic.Test plan
ethexe-processor):demo-crypto-ethexeend-to-end through the full syscall path — digests match native impl; BLS verify accepts valid / rejects forged / errors on garbageexecutenever panics on arbitrary input and respects declared output sizes; G1 aggregation is order-independentgr_cryptopresent in the Eth set, absent from VaraKnown limitations
TODO #5456: benchmark).protocol/core/src/gas_metering/schedule.rsis generated from the Vara pallet schedule; the crypto fields added there would be dropped by a future regeneration (compile error would flag it) — needs a decision on where ethexe-only weights should live long-term.🤖 Generated with Claude Code