Node/Gateway: Wormconn chainID wrong for testnet (#3316)

This commit is contained in:
bruce-riley 2023-08-23 09:12:58 -05:00 committed by GitHub
parent 782111e528
commit e4fc44771a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View File

@ -998,6 +998,11 @@ func runNode(cmd *cobra.Command, args []string) {
// Redirect ipfs logs to plain zap // Redirect ipfs logs to plain zap
ipfslog.SetPrimaryCore(logger.Core()) ipfslog.SetPrimaryCore(logger.Core())
wormchainId := "wormchain"
if *testnetMode {
wormchainId = "wormchain-testnet-0"
}
var accountantWormchainConn *wormconn.ClientConn var accountantWormchainConn *wormconn.ClientConn
if *accountantContract != "" { if *accountantContract != "" {
// TODO: wormchainKeyPath and wormchainKeyPassPhrase are being replaced by accountantKeyPath and accountantKeyPassPhrase. // TODO: wormchainKeyPath and wormchainKeyPassPhrase are being replaced by accountantKeyPath and accountantKeyPassPhrase.
@ -1040,7 +1045,7 @@ func runNode(cmd *cobra.Command, args []string) {
// Connect to wormchain. // Connect to wormchain.
logger.Info("Connecting to wormchain", zap.String("wormchainURL", *wormchainURL), zap.String("keyPath", keyPathName), zap.String("component", "gacct")) 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 { if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gacct")) logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gacct"))
} }
@ -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")) 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 { if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gwrelayer")) logger.Fatal("failed to connect to wormchain", zap.Error(err), zap.String("component", "gwrelayer"))
} }

View File

@ -42,7 +42,7 @@ func main() {
logger.Fatal("failed to load devnet wormchain private key", zap.Error(err)) 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")
if err != nil { if err != nil {
logger.Fatal("failed to connect to wormchain", zap.Error(err)) logger.Fatal("failed to connect to wormchain", zap.Error(err))
} }

View File

@ -29,11 +29,12 @@ type ClientConn struct {
encCfg EncodingConfig encCfg EncodingConfig
privateKey cryptotypes.PrivKey privateKey cryptotypes.PrivKey
senderAddress string senderAddress string
chainId string
mutex sync.Mutex // Protects the account / sequence number mutex sync.Mutex // Protects the account / sequence number
} }
// NewConn creates a new connection to the wormhole-chain instance at `target`. // 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( c, err := grpc.DialContext(
ctx, ctx,
target, target,
@ -50,7 +51,7 @@ func NewConn(ctx context.Context, target string, privateKey cryptotypes.PrivKey)
return nil, err 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 { func (c *ClientConn) SenderAddress() string {

View File

@ -53,7 +53,7 @@ func (c *ClientConn) SignAndBroadcastTx(ctx context.Context, msg sdktypes.Msg) (
} }
signerData := authsigning.SignerData{ signerData := authsigning.SignerData{
ChainID: "wormchain", ChainID: c.chainId,
AccountNumber: account.GetAccountNumber(), AccountNumber: account.GetAccountNumber(),
Sequence: sequence, Sequence: sequence,
} }