Bug: Anvil->Terra operator can't verify EVM deposit — hash mismatch #89
Labels
No labels
agent:implement
agent:ready
backend
bug
cannot-reproduce
confirmed
desktop
docs
documentation
duplicate
enhancement
feature
frontend
good first issue
help wanted
high-risk
in-review
invalid
mobile
needs-triage
P0-critical
P1-high
P2-medium
P3-low
qa
QA
question
ready
report
responsive
security
security-escalate
smart-contract
solana
tablet
test-pass
ux
wallet-issue
wallet:keplr
wallet:metamask
wallet:station
wallet:walletconnect
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-bridge-monorepo#89
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Anvil->LocalTerra TKNA transfer deposits successfully on EVM, auto-withdraw submits on Terra, but operator can't find matching EVM deposit. operator log shows:
EVM deposit not found on this chain (zero timestamp)
No matching EVM deposit found for withdraw hash. This withdrawal cannot be approved until the deposit is confirmed on EVM.
details from operator log:
the frontend computed an xchainHashId and submitted withdraw on Terra, but the hash doesn't match what the EVM bridge stored for that deposit. operator queries EVM bridge, gets zero timestamp, skips approval.
note: Terra->Anvil direction works fine (tested same session, auto-withdraw success). Anvil->Terra TKNA also worked on 3/30 (pre-register-tokens fix). possible regression from
74b5f3echanges.tested on commit
74b5f3e, clean make start-qa, laptop Vite workflow.@Brouie This should be resolved, please verify
still reproducing on
003bf31. Anvil->LocalTerra 99.50 TKNA: deposit succeeds, auto-withdraw submits on Terra, but operator still can't find EVM deposit. same zero timestamp error. xchain_hash_id=0x2fddd1f694a8804913d91f18e0662110f847dff15dd731fcd3248c8bb402c136, nonce=1, src_chain=0x00000001.mentioned in issue #67
mentioned in issue #96
mentioned in commit
98fccdd05bstill reproducing on
02d8e6a(latest pull 4/2). tested Anvil->Terra with TKNA via MetaMask->Keplr.frontend flow works perfectly now -- deposit done, submit hash auto-submitted to Terra, tx confirmed. but operator keeps looping "EVM deposit not found on this chain (zero timestamp)" for xchain_hash_id=0x2fddd1f...
dug into the root cause. the token encoding is mismatched between EVM and Terra:
EVM side: tokenRegistry.getDestToken(TKNA, 0x00000002) returns 0x18844b4621683e1f... which is keccak256("terra17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsydrqk7") -- the keccak of the full bech32 string.
expected encoding: the new HashLib.t.sol cross-chain parity tests (CW20_TOKEN_BYTES32, test_TransferHash_EvmToTerra_CW20_CrossChainParity) expect CW20 tokens encoded as bech32-decoded bytes left-padded to 32 bytes (0x00000000000000000000000035743074956c710800e83198011ccbd4ddf1556d).
so the EVM contract hashes with keccak256(bech32_string) while the test vectors expect bech32_decode(addr) left-padded. different token bytes in = different xchainHashId out = operator cant match deposit to withdrawal.
looks like the token registration step (qa:full-token-setup / registerAllTokens) is writing the keccak encoding for CW20 destTokens when it should be writing the bech32-decoded left-padded encoding.
operator binary (March 27 build) is fine -- it just does getDeposit(hash) lookups, doesnt compute hashes itself.
mentioned in issue #94
hash fix VERIFIED on
5e9d03b. Anvil->Terra with TKNA -- deposit, submit hash, and operator approval all passed. the token encoding fix resolved the mismatch.however execution is blocked at step 4: "transfer amount exceeds the maximum daily rate limit". this is a Terra-side withdraw rate limit config issue, not related to the hash. may need setExplicitUnlimitedWithdrawRateLimit or equivalent for the QA tokens on Terra.
marking the hash mismatch itself as fixed. the rate limit is a separate issue -- should i file it separately or add to #96?
For automated e2e testing setExplicitUnlimitedWithdrawRateLimit is necessary because it allows for less flakey testing, a lot of times you and I forget to reset infra before running e2e tests which makes some tests fail when they shouldnt. Ideally the infra should always be reset before each e2e run but its not always practical. However, the comment on the function is wrong. It is not something that should be ever used in production environments, because rate limiting is a key part of our security model. Rate limiting doesnt stop an attacker, but it mitigates the amount of damage that an attacker can do. As an example, look at the solana perp dex hack of $200m today. If that perp dex had rate limiting, the attack would not have been able to extract that much assets.
closing -- verified on
5e9d03b, hash fix confirmed working. Anvil->Terra deposit+submit+operator approval all pass. step 4 rate limit is expected behavior (separate from this issue).mentioned in issue #136