fix: adapt to chain33 go-ethereum v1.14.8 upgrade - #1305
Open
bysomeone wants to merge 15 commits into
Open
Conversation
…ection Add fork gate to block EVM transfers that cause uint64→int64 overflow in state balance updates. Includes integration test reproducing WBTY attack vector and detailed security analysis document. Co-Authored-By: Claude <noreply@anthropic.com>
- Replace secp256k1.Sign with crypto.Sign (5 call sites) - SimulatedBackend.Blockchain() → Client.HeaderByNumber - Update Makefile: remove -i flag, force CGO_ENABLED=1 - Add DisableForkCheck/ForkAccountBlacklist/ForkParaFee to CI configs Co-Authored-By: Claude <noreply@anthropic.com>
gnark-crypto v0.12.1 changed MiMC constants from sha3.Sum256 to keccak256, breaking all existing chain data (note hashes, merkle roots, zk proofs). legacymimc uses the old constants and preserves gnark v0.5.2 Miyaguchi-Preneel algorithm for in-circuit use. Co-Authored-By: Claude <noreply@anthropic.com>
mix circuits:
- Define(curveID, api) → Define(api)
- frontend.Variable is interface{}, Assign() → direct assignment
- GetWitnessValue() → VariableToElement()
- mimc.NewMiMC → legacymimc.NewCircuitMiMC
- twistededwards path: std/algebra → std/algebra/native
- ScalarMulFixedBase/ScalarMulNonFixedBase → ScalarMul
- AddGeneric → Add
- Groth16 Prove/Verify use witness.Witness API
mix wallet:
- CBC decryption adapted for chain33 random IV format
- Mimc hash → legacymimc
zksync:
- Mimc hash → legacymimc for proof compatibility
Co-Authored-By: Claude <noreply@anthropic.com>
gnark v0.9.0 PK/VK binary format is incompatible with v0.5.2. Add genzkkey to compile circuits and generate fresh keys. CI now generates keys at build time instead of downloading old tarball. testcase.sh reads VK from generated files (groth16.Setup is random). Also add make build_ci before docker-compose to ensure Docker uses freshly compiled binaries. Co-Authored-By: Claude <noreply@anthropic.com>
protobuf v1.34.2 adds internal sizeCache field that breaks assert.Equal comparison. Use proto.Equal instead. Co-Authored-By: Claude <noreply@anthropic.com>
chain33 ForkParaFee defaults to -1 (always active). Test mode
SetAllFork(0) activates it, causing para chain to charge fees on
synced blocks which breaks consensus.
Fix: call SetFork("ForkParaFee", MaxHeight) after para node init.
Requires chain33 5b2b6d28c for Chain33Config.SetFork API.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
bysomeone
force-pushed
the
fix/chain33-go-ethereum-upgrade
branch
from
August 4, 2026 10:59
a873314 to
ab1747e
Compare
chain33 PR merged; drop the temporary bysomeone/chain33 replace and use upstream master (v1.69.1-0.20260806044231-1edb5ac8d): - go-ethereum v1.14.8 upgrade - Chain33Config.SetFork() programmatic fork override (1edb5ac8d) - ethrpc checkIPWhitelist '*' wildcard (528b6ef7d) - CBCDecrypterPrivkey 64-byte ed25519 key support (798621305) Co-Authored-By: Claude <noreply@anthropic.com>
bysomeone
force-pushed
the
fix/chain33-go-ethereum-upgrade
branch
from
August 6, 2026 04:58
ab1747e to
623b15d
Compare
- decryptDataWithPading: disambiguate new (IV16+ciphertext, len%32==16) vs legacy (ciphertext-only, len%32==0) CBC formats by length; previously the legacy blob was mis-parsed as new format producing silent corrupted plaintext - add ReadWitnessCompatible: parse both gnark v0.5.2 ([uint32(n)][n*32B], len%32==4) and v0.9.0 (len%32==12) witness pubInput formats so on-chain legacy pubInput remains verifiable - wire ReadWitnessCompatible into zksnark Verify and ConstructCircuitPubInput - tests cover new+legacy CBC round-trip and both witness formats Co-Authored-By: Claude <noreply@anthropic.com>
…esses gnark-crypto v0.5.3->v0.12.1 fixed eddsa.GenerateKey scalar byte-reversal boundary (j=sizeFr -> j=sizeFr-1), changing keypair derivation for the same seed. zksync layer2 addresses (mimc(pubkey)) were already persisted on-chain under the v0.5.3 derivation, so after the upgrade SetPubKey validation would fail and historical users could no longer operate. Add GenerateKeyCompat that replicates the v0.5.3 scalar construction and builds the v0.12.1 PrivateKey via SetBytes (Sign/Verify are identical across versions). Replace all eddsa.GenerateKey call sites (wallet signing, CLI, tests) and re-enable the 11 previously skipped integration tests. verifyProof now reads pubInput through mix.ReadWitnessCompatible. Co-Authored-By: Claude <noreply@anthropic.com>
- ReadWitnessCompatible: reject input that is neither old (%32==4) nor new (%32==12) witness format with a clear error, instead of silently forwarding to ReadFrom - decryptDataWithPading: guard empty and non-16-aligned input to avoid panics on crafted data (pre-existing gap) - migrate TestDepositSetVal to ReadWitnessCompatible (covers legacy-format pubInput end-to-end) and remove now-unused Witness.LimitReadFrom Co-Authored-By: Claude <noreply@anthropic.com>
chain33-cli RPC commands print errors to stderr but exit 0 on failure (jsonclient Run/RunExt return without os.Exit; cobra Run handlers don't propagate errors). rgbx readiness/tx waits that checked the exit code therefore always passed immediately, even when node RPC was not listening, causing flaky CI failures (DKG timeout, restart recovery pending query). - wait_cli_ready: block last_header exit code -> validate JSON output via jq '.height != null' - tx_wait: tx query_hash exit code -> validate '.txs | length > 0' - wait_auto_dkg_commit: getCross rc==0 -> validate '.tssAddress != ""', widen 60s->120s - ensure_btc_crosschain_prerequisite: getCross rc!=0 -> validate output - wait_no_withdraw_pending_for_user / scenario_restart_recovery: guard empty values from failed queries (listPend polled until it returns a number) Co-Authored-By: Claude <noreply@anthropic.com>
- tx_wait: GetTxByHashes returns {"txs":[null]} for not-yet-mined tx, so
'.txs? | length > 0' passed immediately; filter out null entries:
'.txs? | map(select(. != null)) | length > 0'
- scenario_restart_recovery / wait_no_withdraw_pending_for_user: under
set -e + pipefail a failed jq in command substitution aborts the script
on the first poll instead of retrying; add '||' fallback so polling can
retry until the rgbx query is ready
Co-Authored-By: Claude <noreply@anthropic.com>
…tation - zksync SetPubKey section: key derivation is now fixed via GenerateKeyCompat (was t.Skip); historical addresses preserved, 11 tests re-enabled - groth16 section: old v0.5.2 proof bytes cannot be re-read by v0.9.0 (missing Commitments fields), so a fresh full re-sync of chains with historical mix/zksync txs fails; deployment must choose snapshot-based sync or mix/zksync dapp reset Co-Authored-By: Claude <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.
Summary
chain33 上游升级 go-ethereum 到 v1.14.8,本 PR 适配 plugin 的依赖与 API 变化。
依赖升级
v1.69.1-0.20260508025622-0fa35083839dv1.69.1-0.20260806044231-1edb5ac8d4fd(33cn/chain33 master)移除了
replace gnark-crypto => v0.5.3(与 go-ethereum v1.14.8 依赖冲突)。主要适配
1. go-ethereum API 变化
SimulatedBackend.Blockchain()移除 → 用Client.HeaderByNumber替代(cross2eth/x2ethereum ethinterface)secp256k1.Sign(cgo only) →crypto.Sign(5 处签名调用)ForkEVMFixOverflow)2. gnark v0.9.0 适配
Define(curveID, api)→Define(api)(5 个电路)frontend.Variable变为interface{}:Assign()/GetWitnessValue()移除 →VariableToElement()+ 直接赋值twistededwards路径迁移至std/algebra/native/twistededwardsScalarMul→ScalarMultiplicationgroth16.Prove/Verify改用witness.WitnessAPIConstructCircuitPubInput改用 gnark v0.9.0 的witness.New + ReadFrom(修复 on-chain proof 验证失败,导致 ci_mix deposit 收据 ExecPack)3. MiMC 协议兼容
gnark-crypto v0.12.1 将 MiMC constants 从
sha3.Sum256改为keccak256,所有 hash 输出变化。新增plugin/crypto/legacymimc(基于 v0.5.3 的 MiMC 实现):legacymimc.NewMiMC(seed)legacymimc.NewCircuitMiMC(api, seed)(保持 Miyaguchi-Preneel 算法)zksync/mix 全部切换到旧实现,保持链上协议兼容。
4. groth16 密钥重新生成
gnark v0.9.0 的 VK/PK/proof 二进制格式与 v0.5.2 不兼容。新增
mix/cmd/genzkkey:testcase.sh运行时从生成文件读取 VK(groth16.Setup 随机,硬编码 VK 不匹配)5. Para 链共识修复
chain33 升级引入
ForkParaFee(默认 -1 始终激活),SetAllFork(0)再加 0,导致 para 链对同步交易收手续费,破坏共识。Chain33Config.SetFork()方法NewParaNode初始化后调用SetFork("ForkParaFee", MaxHeight)禁用6. 其他修复
assert.Equal→proto.Equal(protobuf v1.34.2 新增 sizeCache 字段)//go:build !386(gnark v0.9.0 32-bit 未对齐 atomic panic)make build_ci确保 Docker 使用最新编译的二进制chain33 侧改动
已合并到 chain33 master(PR #1370),本 PR 已回退临时 replace 并 bump 到
v1.69.1-0.20260806044231-1edb5ac8d4fd:798621305fix(wallet): CBCDecrypterPrivkey 支持 64-byte ed25519 密钥及随机 IV528b6ef7dfix(ethrpc): checkIPWhitelist 通配符"*"处理1edb5ac8dfeat: 新增Chain33Config.SetFork()公开方法CI 状态
已知限制
CBCEncrypterPrivkey改随机 IV,mix 解密已适配SetPubKey校验的 key 派生链变化,相关集成测试 skip🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com