diff --git a/changelog.md b/changelog.md index b666c26f7d..babe5d10d8 100644 --- a/changelog.md +++ b/changelog.md @@ -56,6 +56,7 @@ * [2925](https://github.com/zeta-chain/node/pull/2925) - add recover to init chainer to diplay informative message when starting a node from block 1 * [2909](https://github.com/zeta-chain/node/pull/2909) - add legacy messages back to codec for querier backward compatibility * [3018](https://github.com/zeta-chain/node/pull/3018) - support `DepositAndCall` and `WithdrawAndCall` with empty payload +* [3030](https://github.com/zeta-chain/node/pull/3030) - Avoid storing invalid Solana gateway address in the `SetGatewayAddress` ## v20.0.0 diff --git a/tests/simulation/sim/sim_state.go b/tests/simulation/sim/sim_state.go index 2f314b6c78..c8df9f4f31 100644 --- a/tests/simulation/sim/sim_state.go +++ b/tests/simulation/sim/sim_state.go @@ -248,7 +248,7 @@ func AppStateFromGenesisFileFn( cdc codec.JSONCodec, genesisFile string, ) (tmtypes.GenesisDoc, []simtypes.Account, error) { - bytes, err := os.ReadFile(genesisFile) + bytes, err := os.ReadFile(genesisFile) // #nosec G304 -- genesisFile value is controlled if err != nil { panic(err) } diff --git a/zetaclient/chains/solana/signer/signer.go b/zetaclient/chains/solana/signer/signer.go index 3b64a1ff7c..0d762d9006 100644 --- a/zetaclient/chains/solana/signer/signer.go +++ b/zetaclient/chains/solana/signer/signer.go @@ -192,7 +192,8 @@ func (signer *Signer) SetGatewayAddress(address string) { // parse gateway ID and PDA gatewayID, pda, err := contracts.ParseGatewayIDAndPda(address) if err != nil { - signer.Logger().Std.Error().Err(err).Msgf("cannot parse gateway address %s", address) + signer.Logger().Std.Error().Err(err).Msgf("cannot parse gateway address: %s", address) + return } // update gateway ID and PDA diff --git a/zetaclient/chains/solana/signer/signer_test.go b/zetaclient/chains/solana/signer/signer_test.go index c27fb06f7c..b05fc75638 100644 --- a/zetaclient/chains/solana/signer/signer_test.go +++ b/zetaclient/chains/solana/signer/signer_test.go @@ -102,6 +102,48 @@ func Test_NewSigner(t *testing.T) { } } +func Test_SetGatewayAddress(t *testing.T) { + // test parameters + chain := chains.SolanaDevnet + chainParams := sample.ChainParams(chain.ChainId) + chainParams.GatewayAddress = testutils.GatewayAddresses[chain.ChainId] + + // helper functor to create signer + signerCreator := func() *signer.Signer { + s, err := signer.NewSigner(chain, *chainParams, nil, nil, nil, nil, base.DefaultLogger()) + require.NoError(t, err) + return s + } + + // test cases + tests := []struct { + name string + signer *signer.Signer + newAddress string + expected string + }{ + { + name: "should set new gateway address", + signer: signerCreator(), + newAddress: "9Z5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d", + expected: "9Z5AHQMKkV5txNJ17QPXWoh474PheGou6cNP2FEuL1d", + }, + { + name: "should not set invalid gateway address", + signer: signerCreator(), + newAddress: "invalid", + expected: chainParams.GatewayAddress, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.signer.SetGatewayAddress(tt.newAddress) + require.Equal(t, tt.expected, tt.signer.GetGatewayAddress()) + }) + } +} + func Test_SetRelayerBalanceMetrics(t *testing.T) { // test parameters chain := chains.SolanaDevnet