diff --git a/bridge/pkg/processor/observation.go b/bridge/pkg/processor/observation.go index 7c39e23719..a910e100b1 100644 --- a/bridge/pkg/processor/observation.go +++ b/bridge/pkg/processor/observation.go @@ -150,9 +150,9 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.LockupObs zap.Any("vaa", signed), zap.String("bytes", hex.EncodeToString(vaaBytes))) + // Check whether we run in devmode and submit the VAA ourselves, if so. switch t.TargetChain { case vaa.ChainIDEthereum: - // Check whether we run in devmode and submit the VAA ourselves, if so. p.devnetVAASubmission(ctx, signed, hash) case vaa.ChainIDTerra: p.terraVAASubmission(ctx, signed, hash) @@ -199,7 +199,7 @@ func (p *Processor) devnetVAASubmission(ctx context.Context, signed *vaa.VAA, ha } } -// Submit VAA to Terra +// Submit VAA to Terra devnet. func (p *Processor) terraVAASubmission(ctx context.Context, signed *vaa.VAA, hash string) { tx, err := terra.SubmitVAA(ctx, p.terraLCD, p.terraChaidID, p.terraContract, p.terraFeePayer, signed) if err != nil { diff --git a/bridge/pkg/terra/watcher.go b/bridge/pkg/terra/watcher.go index de4524d42e..4300e9e0ce 100644 --- a/bridge/pkg/terra/watcher.go +++ b/bridge/pkg/terra/watcher.go @@ -78,7 +78,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error { if err != nil { return fmt.Errorf("event subscription failed: %w", err) } - logger.Info("Subscribed to new transaction events") + logger.Info("subscribed to new transaction events") go func() { defer close(errC) @@ -106,7 +106,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error { if targetChain.Exists() && tokenChain.Exists() && tokenDecimals.Exists() && token.Exists() && sender.Exists() && recipient.Exists() && amount.Exists() && amount.Exists() && nonce.Exists() && txHash.Exists() { - logger.Info("Token lock detected on Terra: ", + logger.Info("token lock detected on Terra", zap.String("txHash", txHash.String()), zap.String("targetChain", targetChain.String()), zap.String("tokenChain", tokenChain.String()), @@ -119,22 +119,22 @@ func (e *BridgeWatcher) Run(ctx context.Context) error { senderAddress, err := StringToAddress(sender.String()) if err != nil { - logger.Error("cannot decode hex ", zap.String("value", sender.String())) + logger.Error("cannot decode hex", zap.String("value", sender.String())) continue } recipientAddress, err := StringToAddress(recipient.String()) if err != nil { - logger.Error("cannot decode hex ", zap.String("value", recipient.String())) + logger.Error("cannot decode hex", zap.String("value", recipient.String())) continue } tokenAddress, err := StringToAddress(token.String()) if err != nil { - logger.Error("cannot decode hex ", zap.String("value", token.String())) + logger.Error("cannot decode hex", zap.String("value", token.String())) continue } txHashValue, err := StringToHash(txHash.String()) if err != nil { - logger.Error("cannot decode hex ", zap.String("value", txHash.String())) + logger.Error("cannot decode hex", zap.String("value", txHash.String())) continue } lock := &common.ChainLock{ @@ -161,6 +161,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error { errC <- err return } + client := &http.Client{ Timeout: time.Second * 15, } @@ -178,17 +179,18 @@ func (e *BridgeWatcher) Run(ctx context.Context) error { resp.Body.Close() return } + json = string(body) guardianSetIndex := gjson.Get(json, "result.guardian_set_index") addresses := gjson.Get(json, "result.addresses.#.bytes") - logger.Debug("Current guardian set on Terra: ", + logger.Debug("current guardian set on Terra", zap.Any("guardianSetIndex", guardianSetIndex), zap.Any("addresses", addresses)) resp.Body.Close() - // Do not report it since ETH guardians are the source of truth + // We do not send guardian changes to the processor - ETH guardians are the source of truth. } }() diff --git a/bridge/pkg/vaa/structs.go b/bridge/pkg/vaa/structs.go index bcc6f25d52..0b2007cd4d 100644 --- a/bridge/pkg/vaa/structs.go +++ b/bridge/pkg/vaa/structs.go @@ -97,6 +97,8 @@ func (c ChainID) String() string { return "solana" case ChainIDEthereum: return "ethereum" + case ChainIDTerra: + return "terra" default: return fmt.Sprintf("unknown chain ID: %d", c) } diff --git a/terra/docs/testing.md b/terra/docs/testing.md index 0bb280b69b..e95e5d1063 100644 --- a/terra/docs/testing.md +++ b/terra/docs/testing.md @@ -1,13 +1,13 @@ # Wormhole + Terra local test environment -For the list of dependencies please follow [DEVELOP.md](../../DEVELOP.md) +For the list of dependencies please follow [DEVELOP.md](../../DEVELOP.md). Additional dependencies: - [Node.js](https://nodejs.org/) >= 14.x, [ts-node](https://www.npmjs.com/package/ts-node) >= 8.x Start Tilt from the project root: - tilt up + tilt up --update-mode=exec -- --num=1 Afterwards use test scripts in `terra/tools` folder: @@ -15,10 +15,15 @@ Afterwards use test scripts in `terra/tools` folder: npm run prepare-token npm run prepare-wormhole -These commands will give you two important addresses: test token address and Wormhole contract address on Terra. Now you need to change guardian configuration to monitor the right contract. Copy Wormhole contract address and replace existing address in file `devnet/bridge-terra.yaml` (line 67). Save the changes and monitor Tilt dashboard until guardian services restart. +These commands will give you two important addresses: test token address and Wormhole contract address on Terra. +Now you need to change guardian configuration to monitor the right contract. Copy Wormhole contract address and +replace existing `TERRA_FEE_PAYER` address in `devnet/bridge.yaml`. + +Save the changes and monitor Tilt dashboard until guardian services restart. Now use both token address and Wormhole contract address to issue tocken lock transaction: npm run lock-tocken -- TOKEN_CONTRACT WORMHOLE_CONTRACT 1000 -Where 1000 is a sample amount to transfer. After this command is issued monitor Guardian service in Tilt dashboard to see its effects propagated to the destination blockchain (in this case it is Ethereum). \ No newline at end of file +Where 1000 is a sample amount to transfer. After this command is issued monitor Guardian service in Tilt dashboard +to see its effects propagated to the destination blockchain (in this case it is Ethereum). diff --git a/terra/tools/prepare-token.ts b/terra/tools/prepare-token.ts index 006a707cd7..2f3682f613 100644 --- a/terra/tools/prepare-token.ts +++ b/terra/tools/prepare-token.ts @@ -2,7 +2,8 @@ import { deploy_contract, instantiate_contract, query_contract } from './utils'; async function script() { const TEST_ADDRESS: string = 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v'; - // cw20_base.wasm is build from https://github.com/CosmWasm/cosmwasm-plus repository, v.0.2.0 and is a standard base cw20 contract + // cw20_base.wasm is a binary artifact built from https://github.com/CosmWasm/cosmwasm-plus repository at v0.2.0 + // and is a standard base cw20 contract. Is it used for testing only. let code_id = await deploy_contract('../artifacts/cw20_base.wasm'); if (code_id == -1) return; console.log(`Program deployed with code id ${code_id}`); @@ -23,4 +24,4 @@ async function script() { console.log(`${TEST_ADDRESS} balance is ${result.balance}`); } -script(); \ No newline at end of file +script();