Clean up some style nits.

This commit is contained in:
Leo 2020-11-16 13:23:29 +01:00
parent 1ca2e29916
commit f072e8c36a
5 changed files with 26 additions and 16 deletions

View File

@ -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 {

View File

@ -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.
}
}()

View File

@ -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)
}

View File

@ -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).
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).

View File

@ -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();
script();