Terra key moved out from env variable, VAA submission on Terra made async (#129)
* Terra fee payer key moved from environment variable into the separate file * Removed closed issues from the comments, VAA submition made async * Review comments fixed
This commit is contained in:
parent
106fecca00
commit
cc412605c7
|
@ -52,7 +52,7 @@ var (
|
||||||
terraLCD *string
|
terraLCD *string
|
||||||
terraChaidID *string
|
terraChaidID *string
|
||||||
terraContract *string
|
terraContract *string
|
||||||
terraFeePayer *string
|
terraKeyPath *string
|
||||||
|
|
||||||
agentRPC *string
|
agentRPC *string
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func init() {
|
||||||
terraLCD = BridgeCmd.Flags().String("terraLCD", "", "Path to LCD service root for http calls")
|
terraLCD = BridgeCmd.Flags().String("terraLCD", "", "Path to LCD service root for http calls")
|
||||||
terraChaidID = BridgeCmd.Flags().String("terraChainID", "", "Terra chain ID, used in LCD client initialization")
|
terraChaidID = BridgeCmd.Flags().String("terraChainID", "", "Terra chain ID, used in LCD client initialization")
|
||||||
terraContract = BridgeCmd.Flags().String("terraContract", "", "Wormhole contract address on Terra blockhain")
|
terraContract = BridgeCmd.Flags().String("terraContract", "", "Wormhole contract address on Terra blockhain")
|
||||||
terraFeePayer = BridgeCmd.Flags().String("terraFeePayer", "", "Mnemonic to account paying gas for submitting transactions to Terra")
|
terraKeyPath = BridgeCmd.Flags().String("terraKey", "", "Path to mnemonic for account paying gas for submitting transactions to Terra")
|
||||||
|
|
||||||
agentRPC = BridgeCmd.Flags().String("agentRPC", "", "Solana agent sidecar gRPC socket path")
|
agentRPC = BridgeCmd.Flags().String("agentRPC", "", "Solana agent sidecar gRPC socket path")
|
||||||
|
|
||||||
|
@ -250,8 +250,8 @@ func runBridge(cmd *cobra.Command, args []string) {
|
||||||
if *terraContract == "" {
|
if *terraContract == "" {
|
||||||
logger.Fatal("Please specify --terraContract")
|
logger.Fatal("Please specify --terraContract")
|
||||||
}
|
}
|
||||||
if *terraFeePayer == "" {
|
if *terraKeyPath == "" {
|
||||||
logger.Fatal("Please specify --terraFeePayer")
|
logger.Fatal("Please specify --terraKey")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +316,18 @@ func runBridge(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load Terra fee payer key
|
||||||
|
var terraFeePayer string
|
||||||
|
if *terraSupport {
|
||||||
|
if *unsafeDevMode {
|
||||||
|
terra.WriteDevnetKey(*terraKeyPath)
|
||||||
|
}
|
||||||
|
terraFeePayer, err = terra.ReadKey(*terraKeyPath)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatal("Failed to load Terra fee payer key", zap.Error(err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
adminService, err := adminServiceRunnable(logger, *adminSocketPath, injectC)
|
adminService, err := adminServiceRunnable(logger, *adminSocketPath, injectC)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal("failed to create admin service socket", zap.Error(err))
|
logger.Fatal("failed to create admin service socket", zap.Error(err))
|
||||||
|
@ -363,7 +375,7 @@ func runBridge(cmd *cobra.Command, args []string) {
|
||||||
*terraLCD,
|
*terraLCD,
|
||||||
*terraChaidID,
|
*terraChaidID,
|
||||||
*terraContract,
|
*terraContract,
|
||||||
*terraFeePayer,
|
terraFeePayer,
|
||||||
)
|
)
|
||||||
if err := supervisor.Run(ctx, "processor", p.Run); err != nil {
|
if err := supervisor.Run(ctx, "processor", p.Run); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -57,6 +57,9 @@ const (
|
||||||
|
|
||||||
// ERC20 default precision.
|
// ERC20 default precision.
|
||||||
ERC20DefaultPrecision = 1e18
|
ERC20DefaultPrecision = 1e18
|
||||||
|
|
||||||
|
// Terra devnet fee payer mnemonic
|
||||||
|
TerraFeePayerKey = "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius"
|
||||||
)
|
)
|
||||||
|
|
||||||
func DeriveAccount(accountIndex uint) accounts.Account {
|
func DeriveAccount(accountIndex uint) accounts.Account {
|
||||||
|
|
|
@ -160,7 +160,7 @@ func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObs
|
||||||
// be expected to pay the fees. We only submit to Ethereum in devnet mode.
|
// be expected to pay the fees. We only submit to Ethereum in devnet mode.
|
||||||
p.devnetVAASubmission(ctx, signed, hash)
|
p.devnetVAASubmission(ctx, signed, hash)
|
||||||
case vaa.ChainIDTerra:
|
case vaa.ChainIDTerra:
|
||||||
p.terraVAASubmission(ctx, signed, hash)
|
go p.terraVAASubmission(ctx, signed, hash)
|
||||||
default:
|
default:
|
||||||
p.logger.Error("unknown target chain ID",
|
p.logger.Error("unknown target chain ID",
|
||||||
zap.String("digest", hash),
|
zap.String("digest", hash),
|
||||||
|
@ -211,12 +211,6 @@ func (p *Processor) devnetVAASubmission(ctx context.Context, signed *vaa.VAA, ha
|
||||||
|
|
||||||
// Submit VAA to Terra.
|
// Submit VAA to Terra.
|
||||||
func (p *Processor) terraVAASubmission(ctx context.Context, signed *vaa.VAA, hash string) {
|
func (p *Processor) terraVAASubmission(ctx context.Context, signed *vaa.VAA, hash string) {
|
||||||
// Terra support is not yet ready for production.
|
|
||||||
// - https://github.com/certusone/wormhole/issues/83
|
|
||||||
// - https://github.com/certusone/wormhole/issues/95
|
|
||||||
// - https://github.com/certusone/wormhole/issues/97
|
|
||||||
//
|
|
||||||
// Roadmap: https://github.com/certusone/wormhole/milestone/4
|
|
||||||
if !p.devnetMode || !p.terraEnabled {
|
if !p.devnetMode || !p.terraEnabled {
|
||||||
p.logger.Warn("ignoring terra VAA submission",
|
p.logger.Warn("ignoring terra VAA submission",
|
||||||
zap.String("digest", hash))
|
zap.String("digest", hash))
|
||||||
|
|
|
@ -3,8 +3,11 @@ package terra
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/certusone/wormhole/bridge/pkg/devnet"
|
||||||
|
|
||||||
"github.com/certusone/wormhole/bridge/pkg/vaa"
|
"github.com/certusone/wormhole/bridge/pkg/vaa"
|
||||||
"github.com/terra-project/terra.go/client"
|
"github.com/terra-project/terra.go/client"
|
||||||
"github.com/terra-project/terra.go/key"
|
"github.com/terra-project/terra.go/key"
|
||||||
|
@ -12,11 +15,11 @@ import (
|
||||||
"github.com/terra-project/terra.go/tx"
|
"github.com/terra-project/terra.go/tx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SubmitVAAMsg struct {
|
type submitVAAMsg struct {
|
||||||
Params SubmitVAAParams `json:"submit_v_a_a"`
|
Params submitVAAParams `json:"submit_v_a_a"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubmitVAAParams struct {
|
type submitVAAParams struct {
|
||||||
VAA []byte `json:"vaa"`
|
VAA []byte `json:"vaa"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +61,8 @@ func SubmitVAA(ctx context.Context, urlLCD string, chainID string, contractAddre
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create tx
|
// Create tx
|
||||||
contractCall, err := json.Marshal(SubmitVAAMsg{
|
contractCall, err := json.Marshal(submitVAAMsg{
|
||||||
Params: SubmitVAAParams{
|
Params: submitVAAParams{
|
||||||
VAA: vaaBytes,
|
VAA: vaaBytes,
|
||||||
}})
|
}})
|
||||||
|
|
||||||
|
@ -85,3 +88,20 @@ func SubmitVAA(ctx context.Context, urlLCD string, chainID string, contractAddre
|
||||||
// Broadcast
|
// Broadcast
|
||||||
return LCDClient.Broadcast(ctx, transaction)
|
return LCDClient.Broadcast(ctx, transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadKey reads file and returns its content as a string
|
||||||
|
func ReadKey(path string) (string, error) {
|
||||||
|
b, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(b), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteDevnetKey writes default devnet key to the file
|
||||||
|
func WriteDevnetKey(path string) {
|
||||||
|
err := ioutil.WriteFile(path, []byte(devnet.TerraFeePayerKey), 0600)
|
||||||
|
if err != nil {
|
||||||
|
panic("Cannot write Terra key file")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,9 +41,6 @@ spec:
|
||||||
containers:
|
containers:
|
||||||
- name: guardiand
|
- name: guardiand
|
||||||
image: guardiand-image
|
image: guardiand-image
|
||||||
env:
|
|
||||||
- name: TERRA_FEE_PAYER
|
|
||||||
value: "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius"
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- mountPath: /run/bridge
|
- mountPath: /run/bridge
|
||||||
name: bridge-rundir
|
name: bridge-rundir
|
||||||
|
@ -72,8 +69,8 @@ spec:
|
||||||
# - localterra
|
# - localterra
|
||||||
# - --terraContract
|
# - --terraContract
|
||||||
# - terra174kgn5rtw4kf6f938wm7kwh70h2v4vcfd26jlc
|
# - terra174kgn5rtw4kf6f938wm7kwh70h2v4vcfd26jlc
|
||||||
# - --terraFeePayer
|
# - --terraKey
|
||||||
# - $(TERRA_FEE_PAYER)
|
# - /tmp/terra.key
|
||||||
- --agentRPC
|
- --agentRPC
|
||||||
- /run/bridge/agent.sock
|
- /run/bridge/agent.sock
|
||||||
- --ethConfirmations
|
- --ethConfirmations
|
||||||
|
|
Loading…
Reference in New Issue