Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node/Gateway: Wormconn chainID wrong for testnet #3316

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,11 @@ func runNode(cmd *cobra.Command, args []string) {
// Redirect ipfs logs to plain zap
ipfslog.SetPrimaryCore(logger.Core())

wormchainId := "wormchain"
if *testnetMode {
wormchainId = "wormchain-testnet-0"
}

var accountantWormchainConn *wormconn.ClientConn
if *accountantContract != "" {
// TODO: wormchainKeyPath and wormchainKeyPassPhrase are being replaced by accountantKeyPath and accountantKeyPassPhrase.
Expand Down Expand Up @@ -1040,7 +1045,7 @@ func runNode(cmd *cobra.Command, args []string) {

// Connect to wormchain.
logger.Info("Connecting to wormchain", zap.String("wormchainURL", *wormchainURL), zap.String("keyPath", keyPathName), zap.String("component", "gacct"))
accountantWormchainConn, err = wormconn.NewConn(rootCtx, *wormchainURL, wormchainKey)
accountantWormchainConn, err = wormconn.NewConn(rootCtx, *wormchainURL, wormchainKey, wormchainId)
if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gacct"))
}
Expand Down Expand Up @@ -1074,7 +1079,7 @@ func runNode(cmd *cobra.Command, args []string) {
}

logger.Info("Connecting to wormchain", zap.String("wormchainURL", *wormchainURL), zap.String("keyPath", wormchainKeyPathName), zap.String("component", "gwrelayer"))
gatewayRelayerWormchainConn, err = wormconn.NewConn(rootCtx, *wormchainURL, wormchainKey)
gatewayRelayerWormchainConn, err = wormconn.NewConn(rootCtx, *wormchainURL, wormchainKey, wormchainId)
if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gwrelayer"))
}
Expand Down
2 changes: 1 addition & 1 deletion node/hack/accountant/send_obs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func main() {
logger.Fatal("failed to load devnet wormchain private key", zap.Error(err))
}

wormchainConn, err := wormconn.NewConn(ctx, wormchainURL, wormchainKey)
wormchainConn, err := wormconn.NewConn(ctx, wormchainURL, wormchainKey, "wormchain")
bruce-riley marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err))
}
Expand Down
5 changes: 3 additions & 2 deletions node/pkg/wormconn/clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ type ClientConn struct {
encCfg EncodingConfig
privateKey cryptotypes.PrivKey
senderAddress string
chainId string
mutex sync.Mutex // Protects the account / sequence number
}

// NewConn creates a new connection to the wormhole-chain instance at `target`.
func NewConn(ctx context.Context, target string, privateKey cryptotypes.PrivKey) (*ClientConn, error) {
func NewConn(ctx context.Context, target string, privateKey cryptotypes.PrivKey, chainId string) (*ClientConn, error) {
c, err := grpc.DialContext(
ctx,
target,
Expand All @@ -50,7 +51,7 @@ func NewConn(ctx context.Context, target string, privateKey cryptotypes.PrivKey)
return nil, err
}

return &ClientConn{c: c, encCfg: encCfg, privateKey: privateKey, senderAddress: senderAddress}, nil
return &ClientConn{c: c, encCfg: encCfg, privateKey: privateKey, senderAddress: senderAddress, chainId: chainId}, nil
}

func (c *ClientConn) SenderAddress() string {
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/wormconn/send_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *ClientConn) SignAndBroadcastTx(ctx context.Context, msg sdktypes.Msg) (
}

signerData := authsigning.SignerData{
ChainID: "wormchain",
ChainID: c.chainId,
AccountNumber: account.GetAccountNumber(),
Sequence: sequence,
}
Expand Down