From 8ab451978818b81ddf62738ca978d22e9ae496aa Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 22 Oct 2024 14:03:08 +0200 Subject: [PATCH 01/18] bump go tss to remove dht --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 524a63d8be..cf327b4380 100644 --- a/go.mod +++ b/go.mod @@ -367,5 +367,5 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20240916173049-89fee4b0ae7f + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff ) diff --git a/go.sum b/go.sum index 04150048bc..d1dd6d9a88 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20240916173049-89fee4b0ae7f h1:XqUvw9a3EnDa271r5/tjRy90U2l1E8thdWzlrkbrEGE= -github.com/zeta-chain/go-tss v0.0.0-20240916173049-89fee4b0ae7f/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff h1:cdzLEeRSuJVb6aMRPHoF+lk9rmPtPcXOfYc4G4xL/PU= +github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From 2c3a622129aeeb568626f05eca3eaefbb15627df Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 22 Oct 2024 16:19:39 +0200 Subject: [PATCH 02/18] add whitelist fields --- zetaclient/config/types.go | 4 ++++ zetaclient/tss/tss_signer.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index a60875b5e8..2e10abff29 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -109,6 +109,10 @@ type Config struct { // compliance config ComplianceConfig ComplianceConfig `json:"ComplianceConfig"` + // whitelist config + WhitelistedPeers []string `json:"WhitelistedPeers"` + DisableWhitelist bool `json:"DisableWhitelist"` // TODO: remove since this is just for local debugging + mu *sync.RWMutex } diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index 0c7daa98e7..142233466d 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -185,6 +185,8 @@ func SetupTSSServer( preParams, // use pre-generated pre-params if non-nil IP, // for docker test tssPassword, + cfg.WhitelistedPeers, + cfg.DisableWhitelist, ) if err != nil { log.Error().Err(err).Msg("NewTSS error") From 57da513ef02d6d938550df64748dfdf840b23811 Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 22 Oct 2024 17:41:28 +0200 Subject: [PATCH 03/18] disable whitelist for localnet --- contrib/localnet/scripts/start-zetaclientd.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index e403e2d599..30a4e691ed 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -14,6 +14,11 @@ set_sepolia_endpoint() { jq '.EVMChainConfigs."11155111".Endpoint = "http://eth2:8545"' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json } +# this is just for local development, to be removed and initialized whitelistPeers with zetaclient0 and zetaclient1 peerID +set_disable_whitelist() { + jq '.DisableWhitelist = true' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json +} + # import a relayer private key (e.g. Solana relayer key) import_relayer_key() { local num="$1" @@ -78,6 +83,8 @@ then # import relayer private key for zetaclient0 import_relayer_key 0 + set_disable_whitelist + # if eth2 is enabled, set the endpoint in the zetaclient_config.json # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json @@ -101,6 +108,8 @@ then # import relayer private key for zetaclient{$num} import_relayer_key "${num}" + set_disable_whitelist + # check if the option is additional-evm # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json From 2f24a46b81200eb1205baa1467652f718382b997 Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 22 Oct 2024 17:48:41 +0200 Subject: [PATCH 04/18] bump go-tss --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cf327b4380..1a0a256a66 100644 --- a/go.mod +++ b/go.mod @@ -367,5 +367,5 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3 ) diff --git a/go.sum b/go.sum index d1dd6d9a88..b8279985c0 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff h1:cdzLEeRSuJVb6aMRPHoF+lk9rmPtPcXOfYc4G4xL/PU= -github.com/zeta-chain/go-tss v0.0.0-20241022114029-69d39f76c4ff/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3 h1:K24CG75GxrJRWfm6mt0BKJNmdWaTsNLtuhMosF+WvI4= +github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From f3ced890f6c80471faa3dfa24c6c0e4ee7e4123b Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 23 Oct 2024 21:46:05 +0200 Subject: [PATCH 05/18] resolve whitelisted peers wip --- cmd/zetaclientd/start.go | 22 ++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index f00abdcde1..f250d27361 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -13,6 +13,9 @@ import ( "time" "github.com/cometbft/cometbft/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" + crypto2 "github.com/libp2p/go-libp2p/core/crypto" + "github.com/libp2p/go-libp2p/core/peer" maddr "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -157,6 +160,25 @@ func start(_ *cobra.Command, _ []string) error { go zetacoreClient.UpdateAppContextWorker(ctx, appContext) + keygen := appContext.GetKeygen() + cfg.WhitelistedPeers = []string{} + for _, pk := range keygen.GranteePubkeys { + pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pk) + if err != nil { + return err + } + bz := pk.Bytes() + k, err := crypto2.UnmarshalSecp256k1PublicKey(bz) + if err != nil { + return err + } + pid, err := peer.IDFromPublicKey(k) + if err != nil { + return err + } + cfg.WhitelistedPeers = append(cfg.WhitelistedPeers, pid.String()) + } + // Generate TSS address . The Tss address is generated through Keygen ceremony. The TSS key is used to sign all outbound transactions . // The hotkeyPk is private key for the Hotkey. The Hotkey is used to sign all inbound transactions // Each node processes a portion of the key stored in ~/.tss by default . Custom location can be specified in config file during init. diff --git a/go.mod b/go.mod index 1a0a256a66..873cf48405 100644 --- a/go.mod +++ b/go.mod @@ -367,5 +367,5 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1 ) diff --git a/go.sum b/go.sum index b8279985c0..d05b276f5c 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3 h1:K24CG75GxrJRWfm6mt0BKJNmdWaTsNLtuhMosF+WvI4= -github.com/zeta-chain/go-tss v0.0.0-20241022153911-db434de5dee3/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1 h1:t7/6SVGVk7OD/2g+b1ieMtdjpM/zewgnqgW0yEXMJT0= +github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From 68cdc50cfdb54147b4d6ec4965cf51ae41398df6 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 23 Oct 2024 21:48:10 +0200 Subject: [PATCH 06/18] dont disable whitelist in e2e tests --- contrib/localnet/scripts/start-zetaclientd.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 30a4e691ed..e403e2d599 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -14,11 +14,6 @@ set_sepolia_endpoint() { jq '.EVMChainConfigs."11155111".Endpoint = "http://eth2:8545"' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json } -# this is just for local development, to be removed and initialized whitelistPeers with zetaclient0 and zetaclient1 peerID -set_disable_whitelist() { - jq '.DisableWhitelist = true' /root/.zetacored/config/zetaclient_config.json > tmp.json && mv tmp.json /root/.zetacored/config/zetaclient_config.json -} - # import a relayer private key (e.g. Solana relayer key) import_relayer_key() { local num="$1" @@ -83,8 +78,6 @@ then # import relayer private key for zetaclient0 import_relayer_key 0 - set_disable_whitelist - # if eth2 is enabled, set the endpoint in the zetaclient_config.json # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json @@ -108,8 +101,6 @@ then # import relayer private key for zetaclient{$num} import_relayer_key "${num}" - set_disable_whitelist - # check if the option is additional-evm # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json From 62c00bbb63431d6fea8dabc6b68b629169e2e0f3 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 23 Oct 2024 23:45:51 +0200 Subject: [PATCH 07/18] cleanup whitelist fields from config and fix e2e tests --- cmd/zetaclientd/start.go | 40 ++++++++++++++++++------------------ go.mod | 3 ++- go.sum | 4 ++-- zetaclient/config/types.go | 4 ---- zetaclient/tss/tss_signer.go | 4 ++-- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index f250d27361..63a0875da3 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -160,25 +160,6 @@ func start(_ *cobra.Command, _ []string) error { go zetacoreClient.UpdateAppContextWorker(ctx, appContext) - keygen := appContext.GetKeygen() - cfg.WhitelistedPeers = []string{} - for _, pk := range keygen.GranteePubkeys { - pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pk) - if err != nil { - return err - } - bz := pk.Bytes() - k, err := crypto2.UnmarshalSecp256k1PublicKey(bz) - if err != nil { - return err - } - pid, err := peer.IDFromPublicKey(k) - if err != nil { - return err - } - cfg.WhitelistedPeers = append(cfg.WhitelistedPeers, pid.String()) - } - // Generate TSS address . The Tss address is generated through Keygen ceremony. The TSS key is used to sign all outbound transactions . // The hotkeyPk is private key for the Hotkey. The Hotkey is used to sign all inbound transactions // Each node processes a portion of the key stored in ~/.tss by default . Custom location can be specified in config file during init. @@ -227,7 +208,26 @@ func start(_ *cobra.Command, _ []string) error { telemetryServer.SetIPAddress(cfg.PublicIP) // Create TSS server - server, err := mc.SetupTSSServer(peers, priKey, preParams, appContext.Config(), tssKeyPass, true) + keygen := appContext.GetKeygen() + whitelistedPeers := []string{} + for _, pk := range keygen.GranteePubkeys { + pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pk) + if err != nil { + return err + } + bz := pk.Bytes() + k, err := crypto2.UnmarshalSecp256k1PublicKey(bz) + if err != nil { + return err + } + pid, err := peer.IDFromPublicKey(k) + if err != nil { + return err + } + whitelistedPeers = append(whitelistedPeers, pid.String()) + } + fmt.Println("whitelisted peers", whitelistedPeers) + server, err := mc.SetupTSSServer(peers, priKey, preParams, appContext.Config(), tssKeyPass, true, whitelistedPeers) if err != nil { return fmt.Errorf("SetupTSSServer error: %w", err) } diff --git a/go.mod b/go.mod index 873cf48405..b81e3ac79a 100644 --- a/go.mod +++ b/go.mod @@ -367,5 +367,6 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3 + ) diff --git a/go.sum b/go.sum index d05b276f5c..4a6e26608b 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1 h1:t7/6SVGVk7OD/2g+b1ieMtdjpM/zewgnqgW0yEXMJT0= -github.com/zeta-chain/go-tss v0.0.0-20241023194402-26ad436b42a1/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3 h1:/G+jzX/zSKGwkhJQp7kFIg/yAKdBtw2WcIKE5bKy40o= +github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index 2e10abff29..a60875b5e8 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -109,10 +109,6 @@ type Config struct { // compliance config ComplianceConfig ComplianceConfig `json:"ComplianceConfig"` - // whitelist config - WhitelistedPeers []string `json:"WhitelistedPeers"` - DisableWhitelist bool `json:"DisableWhitelist"` // TODO: remove since this is just for local debugging - mu *sync.RWMutex } diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index 142233466d..f36ef840e6 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -148,6 +148,7 @@ func SetupTSSServer( cfg config.Config, tssPassword string, enableMonitor bool, + whitelistedPeers []string, ) (*tss.TssServer, error) { bootstrapPeers := peer log.Info().Msgf("Peers AddrList %v", bootstrapPeers) @@ -185,8 +186,7 @@ func SetupTSSServer( preParams, // use pre-generated pre-params if non-nil IP, // for docker test tssPassword, - cfg.WhitelistedPeers, - cfg.DisableWhitelist, + whitelistedPeers, ) if err != nil { log.Error().Err(err).Msg("NewTSS error") From 5492d1ee911679652cfe5e5cea176eaa456d3b58 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 24 Oct 2024 00:43:29 +0200 Subject: [PATCH 08/18] bump go-tss --- cmd/zetaclientd/start.go | 15 ++------------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 63a0875da3..4744379a1a 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -13,13 +13,11 @@ import ( "time" "github.com/cometbft/cometbft/crypto/secp256k1" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" - crypto2 "github.com/libp2p/go-libp2p/core/crypto" - "github.com/libp2p/go-libp2p/core/peer" maddr "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" "github.com/rs/zerolog/log" "github.com/spf13/cobra" + "gitlab.com/thorchain/tss/go-tss/conversion" "github.com/zeta-chain/node/pkg/authz" "github.com/zeta-chain/node/pkg/chains" @@ -211,16 +209,7 @@ func start(_ *cobra.Command, _ []string) error { keygen := appContext.GetKeygen() whitelistedPeers := []string{} for _, pk := range keygen.GranteePubkeys { - pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pk) - if err != nil { - return err - } - bz := pk.Bytes() - k, err := crypto2.UnmarshalSecp256k1PublicKey(bz) - if err != nil { - return err - } - pid, err := peer.IDFromPublicKey(k) + pid, err := conversion.Bech32PubkeyToPeerID(pk) if err != nil { return err } diff --git a/go.mod b/go.mod index b81e3ac79a..246e3f6d76 100644 --- a/go.mod +++ b/go.mod @@ -367,6 +367,6 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48 ) diff --git a/go.sum b/go.sum index 4a6e26608b..2996ceef51 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3 h1:/G+jzX/zSKGwkhJQp7kFIg/yAKdBtw2WcIKE5bKy40o= -github.com/zeta-chain/go-tss v0.0.0-20241023212105-f40fec610ee3/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48 h1:zm8eq6F1L/e9wjzCyf7zxRdqbHhxX/KoBkXQntwHNpw= +github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From 98b776818699a2420a467ac5e17d5964a86028ae Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 24 Oct 2024 01:21:58 +0200 Subject: [PATCH 09/18] cleanup --- cmd/zetaclientd/start.go | 5 +++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 4744379a1a..e019498902 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -205,7 +205,7 @@ func start(_ *cobra.Command, _ []string) error { } telemetryServer.SetIPAddress(cfg.PublicIP) - // Create TSS server + keygen := appContext.GetKeygen() whitelistedPeers := []string{} for _, pk := range keygen.GranteePubkeys { @@ -215,7 +215,8 @@ func start(_ *cobra.Command, _ []string) error { } whitelistedPeers = append(whitelistedPeers, pid.String()) } - fmt.Println("whitelisted peers", whitelistedPeers) + + // Create TSS server server, err := mc.SetupTSSServer(peers, priKey, preParams, appContext.Config(), tssKeyPass, true, whitelistedPeers) if err != nil { return fmt.Errorf("SetupTSSServer error: %w", err) diff --git a/go.mod b/go.mod index 246e3f6d76..7fc33ec47e 100644 --- a/go.mod +++ b/go.mod @@ -367,6 +367,6 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55 ) diff --git a/go.sum b/go.sum index 2996ceef51..6703dd645f 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48 h1:zm8eq6F1L/e9wjzCyf7zxRdqbHhxX/KoBkXQntwHNpw= -github.com/zeta-chain/go-tss v0.0.0-20241023223803-1a7b79b89b48/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55 h1:vRiQBX0VC4GbkV0nj8TKSkSapL+ylpKALhAs1oE9xos= +github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From 78dde91361bc121576379fe79967c07a6df340e4 Mon Sep 17 00:00:00 2001 From: skosito Date: Thu, 24 Oct 2024 02:35:52 +0200 Subject: [PATCH 10/18] bump go tss --- cmd/zetaclientd/start.go | 5 +++-- go.mod | 2 +- go.sum | 4 ++-- zetaclient/tss/tss_signer.go | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index e019498902..67bd9830ee 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -13,6 +13,7 @@ import ( "time" "github.com/cometbft/cometbft/crypto/secp256k1" + "github.com/libp2p/go-libp2p/core/peer" maddr "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -207,13 +208,13 @@ func start(_ *cobra.Command, _ []string) error { telemetryServer.SetIPAddress(cfg.PublicIP) keygen := appContext.GetKeygen() - whitelistedPeers := []string{} + whitelistedPeers := []peer.ID{} for _, pk := range keygen.GranteePubkeys { pid, err := conversion.Bech32PubkeyToPeerID(pk) if err != nil { return err } - whitelistedPeers = append(whitelistedPeers, pid.String()) + whitelistedPeers = append(whitelistedPeers, pid) } // Create TSS server diff --git a/go.mod b/go.mod index 7fc33ec47e..17f62cfe80 100644 --- a/go.mod +++ b/go.mod @@ -367,6 +367,6 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98 ) diff --git a/go.sum b/go.sum index 6703dd645f..18c0f9fafc 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55 h1:vRiQBX0VC4GbkV0nj8TKSkSapL+ylpKALhAs1oE9xos= -github.com/zeta-chain/go-tss v0.0.0-20241023231822-e2c887883a55/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98 h1:Fro+oYtodhDD7gpys4oIIfRiPSHTi3uSi4xrzWJJxQg= +github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index f36ef840e6..594784797c 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -148,7 +148,7 @@ func SetupTSSServer( cfg config.Config, tssPassword string, enableMonitor bool, - whitelistedPeers []string, + whitelistedPeers []gopeer.ID, ) (*tss.TssServer, error) { bootstrapPeers := peer log.Info().Msgf("Peers AddrList %v", bootstrapPeers) From ca9ff57f5e9158942ef571ff522bab3c4be0ca16 Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 18:51:06 +0100 Subject: [PATCH 11/18] use node accounts to get whitelisted peers --- cmd/zetaclientd/start.go | 6 +++--- .../chains/evm/observer/observer_test.go | 1 + zetaclient/chains/evm/signer/signer_test.go | 1 + zetaclient/context/app.go | 13 +++++++++++++ zetaclient/context/app_test.go | 18 ++++++++++++------ zetaclient/orchestrator/bootstap_test.go | 1 + zetaclient/orchestrator/orchestrator_test.go | 1 + zetaclient/zetacore/client.go | 6 ++++++ 8 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 67bd9830ee..029711fb57 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -207,10 +207,10 @@ func start(_ *cobra.Command, _ []string) error { telemetryServer.SetIPAddress(cfg.PublicIP) - keygen := appContext.GetKeygen() + nodeAccounts := appContext.GetNodeAccounts() whitelistedPeers := []peer.ID{} - for _, pk := range keygen.GranteePubkeys { - pid, err := conversion.Bech32PubkeyToPeerID(pk) + for _, nodeAccount := range nodeAccounts { + pid, err := conversion.Bech32PubkeyToPeerID(nodeAccount.GranteePubkey.Secp256k1.String()) if err != nil { return err } diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index d30be608e5..a824e465f8 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -76,6 +76,7 @@ func getAppContext( chainParams, "tssPubKey", *sample.CrosschainFlags(), + []*observertypes.NodeAccount{}, ) require.NoError(t, err) diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index b2c266b438..1119e348c2 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -260,6 +260,7 @@ func makeCtx(t *testing.T) context.Context { }, "tssPubKey", observertypes.CrosschainFlags{}, + []*observertypes.NodeAccount{}, ) require.NoError(t, err, "unable to update app context") diff --git a/zetaclient/context/app.go b/zetaclient/context/app.go index 8474c3ec87..d36547695a 100644 --- a/zetaclient/context/app.go +++ b/zetaclient/context/app.go @@ -37,6 +37,9 @@ type AppContext struct { // keygen is the current tss keygen state keygen observertypes.Keygen + // nodeAccounts is array of current node accounts + nodeAccounts []*observertypes.NodeAccount + mu sync.RWMutex } @@ -51,6 +54,7 @@ func New(cfg config.Config, relayerKeyPasswords map[string]string, logger zerolo crosschainFlags: observertypes.CrosschainFlags{}, currentTssPubKey: "", keygen: observertypes.Keygen{}, + nodeAccounts: []*observertypes.NodeAccount{}, mu: sync.RWMutex{}, } @@ -120,6 +124,13 @@ func (a *AppContext) GetKeygen() observertypes.Keygen { } } +func (a *AppContext) GetNodeAccounts() []*observertypes.NodeAccount { + a.mu.RLock() + defer a.mu.RUnlock() + + return a.nodeAccounts +} + // GetCurrentTssPubKey returns the current tss pubKey. func (a *AppContext) GetCurrentTssPubKey() string { a.mu.RLock() @@ -144,6 +155,7 @@ func (a *AppContext) Update( freshChainParams map[int64]*observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, + nodeAccounts []*observertypes.NodeAccount, ) error { // some sanity checks switch { @@ -173,6 +185,7 @@ func (a *AppContext) Update( a.crosschainFlags = crosschainFlags a.keygen = keygen a.currentTssPubKey = tssPubKey + a.nodeAccounts = nodeAccounts return nil } diff --git a/zetaclient/context/app_test.go b/zetaclient/context/app_test.go index 2297a3cdec..67eaa9c5aa 100644 --- a/zetaclient/context/app_test.go +++ b/zetaclient/context/app_test.go @@ -69,6 +69,7 @@ func TestAppContext(t *testing.T) { require.Empty(t, appContext.GetCrossChainFlags()) require.False(t, appContext.IsInboundObservationEnabled()) require.False(t, appContext.IsOutboundObservationEnabled()) + require.Empty(t, appContext.GetNodeAccounts()) // Given some data that is supposed to come from ZetaCore RPC newChains := []chains.Chain{ @@ -88,8 +89,12 @@ func TestAppContext(t *testing.T) { fancyL2, } + nodeAccounts := []*types.NodeAccount{ + sample.NodeAccount(), + } + // ACT - err = appContext.Update(keyGen, newChains, additionalChains, chainParams, ttsPubKey, ccFlags) + err = appContext.Update(keyGen, newChains, additionalChains, chainParams, ttsPubKey, ccFlags, nodeAccounts) // ASSERT require.NoError(t, err) @@ -101,6 +106,7 @@ func TestAppContext(t *testing.T) { assert.Equal(t, ccFlags, appContext.GetCrossChainFlags()) assert.True(t, appContext.IsInboundObservationEnabled()) assert.True(t, appContext.IsOutboundObservationEnabled()) + assert.Equal(t, nodeAccounts, appContext.GetNodeAccounts()) // Check ETH Chain ethChain, err := appContext.GetChain(1) @@ -132,7 +138,7 @@ func TestAppContext(t *testing.T) { { name: "update with empty chains results in an error", act: func(a *AppContext) error { - return appContext.Update(keyGen, newChains, nil, nil, ttsPubKey, ccFlags) + return appContext.Update(keyGen, newChains, nil, nil, ttsPubKey, ccFlags, nodeAccounts) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "no chain params present") @@ -153,7 +159,7 @@ func TestAppContext(t *testing.T) { chainParamsWithOpt := maps.Clone(chainParams) chainParamsWithOpt[opParams.ChainId] = opParams - return a.Update(keyGen, chainsWithOpt, additionalChains, chainParamsWithOpt, ttsPubKey, ccFlags) + return a.Update(keyGen, chainsWithOpt, additionalChains, chainParamsWithOpt, ttsPubKey, ccFlags, nodeAccounts) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorIs(t, err, ErrChainNotSupported) @@ -164,7 +170,7 @@ func TestAppContext(t *testing.T) { name: "trying to add zeta chain without chain params is allowed", act: func(a *AppContext) error { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParams, ttsPubKey, ccFlags) + return a.Update(keyGen, chainsWithZeta, additionalChains, chainParams, ttsPubKey, ccFlags, nodeAccounts) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -186,7 +192,7 @@ func TestAppContext(t *testing.T) { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParamsWithZeta, ttsPubKey, ccFlags) + return a.Update(keyGen, chainsWithZeta, additionalChains, chainParamsWithZeta, ttsPubKey, ccFlags, nodeAccounts) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -209,7 +215,7 @@ func TestAppContext(t *testing.T) { updatedChainParams[maticParams.ChainId] = maticParams delete(updatedChainParams, chains.ZetaChainMainnet.ChainId) - return a.Update(keyGen, newChains, additionalChains, updatedChainParams, ttsPubKey, ccFlags) + return a.Update(keyGen, newChains, additionalChains, updatedChainParams, ttsPubKey, ccFlags, nodeAccounts) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "unable to locate fresh chain 137 based on chain params") diff --git a/zetaclient/orchestrator/bootstap_test.go b/zetaclient/orchestrator/bootstap_test.go index eaae3a8e6d..975af19545 100644 --- a/zetaclient/orchestrator/bootstap_test.go +++ b/zetaclient/orchestrator/bootstap_test.go @@ -453,6 +453,7 @@ func mustUpdateAppContext( chainParams, "tssPubKey", app.GetCrossChainFlags(), + app.GetNodeAccounts(), ) require.NoError(t, err) diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index 2ab34b900e..7178ef764f 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -551,6 +551,7 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext { params, "tssPubKey", *ccFlags, + []*observertypes.NodeAccount{}, ) require.NoError(t, err, "failed to update app context") diff --git a/zetaclient/zetacore/client.go b/zetaclient/zetacore/client.go index 9ad91002ce..c2e946fd10 100644 --- a/zetaclient/zetacore/client.go +++ b/zetaclient/zetacore/client.go @@ -373,6 +373,11 @@ func (c *Client) UpdateAppContext(ctx context.Context, appContext *zctx.AppConte freshParams := make(map[int64]*observertypes.ChainParams, len(chainParams)) + nodeAccounts, err := c.GetAllNodeAccounts(ctx) + if err != nil { + return errors.Wrap(err, "unable to fetch node accounts") + } + // check and update chain params for each chain // Note that we are EXCLUDING ZetaChain from the chainParams if it's present for i := range chainParams { @@ -402,6 +407,7 @@ func (c *Client) UpdateAppContext(ctx context.Context, appContext *zctx.AppConte freshParams, tss.GetTssPubkey(), crosschainFlags, + nodeAccounts, ) } From 5623c2a0abe0e950e288530fabc88ff09d1fee01 Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 19:51:51 +0100 Subject: [PATCH 12/18] bump go tss --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 17f62cfe80..9d88ffef64 100644 --- a/go.mod +++ b/go.mod @@ -367,6 +367,6 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98 + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb ) diff --git a/go.sum b/go.sum index 18c0f9fafc..d1a62503aa 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98 h1:Fro+oYtodhDD7gpys4oIIfRiPSHTi3uSi4xrzWJJxQg= -github.com/zeta-chain/go-tss v0.0.0-20241024003245-8938bc1e1b98/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb h1:lkxqDPXqThW9CzyeEgX8uR5BUvGjFUhCXPUaTCKZo+U= +github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From 36d41ad9b2a9e8ba3719293a704773eaa77482eb Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 19:53:13 +0100 Subject: [PATCH 13/18] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 412141d2f8..9814a0662b 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,7 @@ * [2979](https://github.com/zeta-chain/node/pull/2979) - add fungible keeper ability to lock/unlock ZRC20 tokens * [3012](https://github.com/zeta-chain/node/pull/3012) - integrate authenticated calls erc20 smart contract functionality into protocol * [3025](https://github.com/zeta-chain/node/pull/3025) - standard memo for Bitcoin inbound +* [3028](https://github.com/zeta-chain/node/pull/3028) - whitelist connection gater ### Refactor From 1e5acebc939ca7d4939bb78dbf088daf992dd8b0 Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 20:11:41 +0100 Subject: [PATCH 14/18] fix unit test --- zetaclient/zetacore/tx_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index b58981f67b..24cdd61886 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -343,6 +343,15 @@ func TestZetacore_UpdateAppContext(t *testing.T) { }, }, }) + method = "/zetachain.zetacore.observer.Query/NodeAccountAll" + s.ExpectUnary(method). + UnlimitedTimes(). + WithPayload(observertypes.QueryAllNodeAccountRequest{}). + Return(observertypes.QueryAllNodeAccountResponse{ + NodeAccount: []*observertypes.NodeAccount{ + sample.NodeAccount(), + }, + }) }, )(t) From bff17e085802dc35ea0c9f90a78fb21e35bfbf5e Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 21:33:25 +0100 Subject: [PATCH 15/18] bump go tss --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 9d88ffef64..172fe58b53 100644 --- a/go.mod +++ b/go.mod @@ -367,6 +367,5 @@ replace ( github.com/bnb-chain/tss-lib => github.com/zeta-chain/tss-lib v0.0.0-20240916163010-2e6b438bd901 github.com/ethereum/go-ethereum => github.com/zeta-chain/go-ethereum v1.10.26-spc github.com/libp2p/go-libp2p => github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 - gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb - + gitlab.com/thorchain/tss/go-tss => github.com/zeta-chain/go-tss v0.0.0-20241028203048-62ae2bb54949 ) diff --git a/go.sum b/go.sum index d1a62503aa..d2da2120e8 100644 --- a/go.sum +++ b/go.sum @@ -4204,8 +4204,8 @@ github.com/zeta-chain/go-ethereum v1.10.26-spc h1:NvY4rR9yw52wfxWt7YoFsWbaIwVMyO github.com/zeta-chain/go-ethereum v1.10.26-spc/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4 h1:FmO3HfVdZ7LzxBUfg6sVzV7ilKElQU2DZm8PxJ7KcYI= github.com/zeta-chain/go-libp2p v0.0.0-20240710192637-567fbaacc2b4/go.mod h1:TBv5NY/CqWYIfUstXO1fDWrt4bDoqgCw79yihqBspg8= -github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb h1:lkxqDPXqThW9CzyeEgX8uR5BUvGjFUhCXPUaTCKZo+U= -github.com/zeta-chain/go-tss v0.0.0-20241028184352-5558cea583cb/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= +github.com/zeta-chain/go-tss v0.0.0-20241028203048-62ae2bb54949 h1:dBwx99+oymiyecnRGu1dnkJmYn2SAgBexBJ6nsdJt+E= +github.com/zeta-chain/go-tss v0.0.0-20241028203048-62ae2bb54949/go.mod h1:B1FDE6kHs8hozKSX1/iXgCdvlFbS6+FeAupoBHDK0Cc= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138 h1:vck/FcIIpFOvpBUm0NO17jbEtmSz/W/a5Y4jRuSJl6I= github.com/zeta-chain/keystone/keys v0.0.0-20240826165841-3874f358c138/go.mod h1:U494OsZTWsU75hqoriZgMdSsgSGP1mUL1jX+wN/Aez8= github.com/zeta-chain/protocol-contracts v1.0.2-athens3.0.20241021075719-d40d2e28467c h1:ZoFxMMZtivRLquXVq1sEVlT45UnTPMO1MSXtc88nDv4= From b5498d6c6c03b9f9df93c4edfb3281a6761ddf70 Mon Sep 17 00:00:00 2001 From: skosito Date: Mon, 28 Oct 2024 22:57:09 +0100 Subject: [PATCH 16/18] remove usage of pointers in node accounts --- pkg/rpc/clients_observer.go | 13 +++++++-- pkg/rpc/clients_test.go | 2 +- .../chains/evm/observer/observer_test.go | 2 +- zetaclient/chains/evm/signer/signer_test.go | 2 +- zetaclient/context/app.go | 27 +++++++++++++++---- zetaclient/context/app_test.go | 4 +-- zetaclient/orchestrator/orchestrator_test.go | 2 +- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/pkg/rpc/clients_observer.go b/pkg/rpc/clients_observer.go index ee296b8fc9..eefc712209 100644 --- a/pkg/rpc/clients_observer.go +++ b/pkg/rpc/clients_observer.go @@ -114,13 +114,22 @@ func (c *Clients) GetKeyGen(ctx context.Context) (types.Keygen, error) { } // GetAllNodeAccounts returns all node accounts -func (c *Clients) GetAllNodeAccounts(ctx context.Context) ([]*types.NodeAccount, error) { +func (c *Clients) GetAllNodeAccounts(ctx context.Context) ([]types.NodeAccount, error) { resp, err := c.Observer.NodeAccountAll(ctx, &types.QueryAllNodeAccountRequest{}) if err != nil { return nil, errors.Wrap(err, "failed to get all node accounts") } - return resp.NodeAccount, nil + result := make([]types.NodeAccount, len(resp.NodeAccount)) + for i, nodeAccount := range resp.NodeAccount { + if nodeAccount != nil { + result[i] = *nodeAccount + } else { + return nil, fmt.Errorf("node account is nil") + } + } + + return result, nil } // GetBallot returns a ballot by ID diff --git a/pkg/rpc/clients_test.go b/pkg/rpc/clients_test.go index 9e14266770..b5723b49b0 100644 --- a/pkg/rpc/clients_test.go +++ b/pkg/rpc/clients_test.go @@ -513,7 +513,7 @@ func TestZetacore_GetAllNodeAccounts(t *testing.T) { resp, err := client.GetAllNodeAccounts(ctx) require.NoError(t, err) - require.Equal(t, expectedOutput.NodeAccount, resp) + require.Equal(t, []observertypes.NodeAccount{*expectedOutput.NodeAccount[0]}, resp) } func TestZetacore_GetKeyGen(t *testing.T) { diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index a824e465f8..e967695915 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -76,7 +76,7 @@ func getAppContext( chainParams, "tssPubKey", *sample.CrosschainFlags(), - []*observertypes.NodeAccount{}, + []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err) diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index 1119e348c2..1e10b09ae1 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -260,7 +260,7 @@ func makeCtx(t *testing.T) context.Context { }, "tssPubKey", observertypes.CrosschainFlags{}, - []*observertypes.NodeAccount{}, + []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err, "unable to update app context") diff --git a/zetaclient/context/app.go b/zetaclient/context/app.go index d36547695a..b4a27241d0 100644 --- a/zetaclient/context/app.go +++ b/zetaclient/context/app.go @@ -13,6 +13,7 @@ import ( "golang.org/x/exp/slices" "github.com/zeta-chain/node/pkg/chains" + "github.com/zeta-chain/node/pkg/crypto" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/config" ) @@ -38,7 +39,7 @@ type AppContext struct { keygen observertypes.Keygen // nodeAccounts is array of current node accounts - nodeAccounts []*observertypes.NodeAccount + nodeAccounts []observertypes.NodeAccount mu sync.RWMutex } @@ -54,7 +55,7 @@ func New(cfg config.Config, relayerKeyPasswords map[string]string, logger zerolo crosschainFlags: observertypes.CrosschainFlags{}, currentTssPubKey: "", keygen: observertypes.Keygen{}, - nodeAccounts: []*observertypes.NodeAccount{}, + nodeAccounts: []observertypes.NodeAccount{}, mu: sync.RWMutex{}, } @@ -124,11 +125,25 @@ func (a *AppContext) GetKeygen() observertypes.Keygen { } } -func (a *AppContext) GetNodeAccounts() []*observertypes.NodeAccount { +func (a *AppContext) GetNodeAccounts() []observertypes.NodeAccount { a.mu.RLock() defer a.mu.RUnlock() - return a.nodeAccounts + // deep copy node accounts + nodeAccounts := []observertypes.NodeAccount{} + for _, nodeAccount := range a.nodeAccounts { + nodeAccounts = append(nodeAccounts, observertypes.NodeAccount{ + Operator: nodeAccount.Operator, + GranteeAddress: nodeAccount.GranteeAddress, + GranteePubkey: &crypto.PubKeySet{ + Secp256k1: nodeAccount.GranteePubkey.Secp256k1, + Ed25519: nodeAccount.GranteePubkey.Ed25519, + }, + NodeStatus: nodeAccount.NodeStatus, + }) + } + + return nodeAccounts } // GetCurrentTssPubKey returns the current tss pubKey. @@ -155,7 +170,7 @@ func (a *AppContext) Update( freshChainParams map[int64]*observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, - nodeAccounts []*observertypes.NodeAccount, + nodeAccounts []observertypes.NodeAccount, ) error { // some sanity checks switch { @@ -163,6 +178,8 @@ func (a *AppContext) Update( return fmt.Errorf("no chains present") case len(freshChainParams) == 0: return fmt.Errorf("no chain params present") + case len(nodeAccounts) == 0: + return fmt.Errorf("node accounts empty") case tssPubKey == "" && a.currentTssPubKey != "": // note that if we're doing a fresh start, we ALLOW an empty tssPubKey return fmt.Errorf("tss pubkey is empty") diff --git a/zetaclient/context/app_test.go b/zetaclient/context/app_test.go index 67eaa9c5aa..0572da04db 100644 --- a/zetaclient/context/app_test.go +++ b/zetaclient/context/app_test.go @@ -89,8 +89,8 @@ func TestAppContext(t *testing.T) { fancyL2, } - nodeAccounts := []*types.NodeAccount{ - sample.NodeAccount(), + nodeAccounts := []types.NodeAccount{ + *sample.NodeAccount(), } // ACT diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index 7178ef764f..9c2f9cbf9e 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -551,7 +551,7 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext { params, "tssPubKey", *ccFlags, - []*observertypes.NodeAccount{}, + []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err, "failed to update app context") From f882af4a39a9e5fe3287366dbeb3001b87440c2a Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 29 Oct 2024 03:19:51 +0100 Subject: [PATCH 17/18] fix unit test --- zetaclient/orchestrator/bootstap_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zetaclient/orchestrator/bootstap_test.go b/zetaclient/orchestrator/bootstap_test.go index 975af19545..54dae755e3 100644 --- a/zetaclient/orchestrator/bootstap_test.go +++ b/zetaclient/orchestrator/bootstap_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/ptr" + "github.com/zeta-chain/node/testutil/sample" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/chains/base" "github.com/zeta-chain/node/zetaclient/chains/interfaces" @@ -453,7 +454,7 @@ func mustUpdateAppContext( chainParams, "tssPubKey", app.GetCrossChainFlags(), - app.GetNodeAccounts(), + []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err) From 9ba8d51e6de1ea2dda7360d28af8761982d5bc5f Mon Sep 17 00:00:00 2001 From: skosito Date: Tue, 29 Oct 2024 17:22:57 +0100 Subject: [PATCH 18/18] revert back to using keygen for whitelist peers --- cmd/zetaclientd/start.go | 6 ++-- pkg/rpc/clients_observer.go | 13 ++------ pkg/rpc/clients_test.go | 2 +- .../chains/evm/observer/observer_test.go | 1 - zetaclient/chains/evm/signer/signer_test.go | 1 - zetaclient/context/app.go | 30 ------------------- zetaclient/context/app_test.go | 18 ++++------- zetaclient/orchestrator/bootstap_test.go | 2 -- zetaclient/orchestrator/orchestrator_test.go | 1 - zetaclient/zetacore/client.go | 6 ---- zetaclient/zetacore/tx_test.go | 9 ------ 11 files changed, 12 insertions(+), 77 deletions(-) diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 029711fb57..67bd9830ee 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -207,10 +207,10 @@ func start(_ *cobra.Command, _ []string) error { telemetryServer.SetIPAddress(cfg.PublicIP) - nodeAccounts := appContext.GetNodeAccounts() + keygen := appContext.GetKeygen() whitelistedPeers := []peer.ID{} - for _, nodeAccount := range nodeAccounts { - pid, err := conversion.Bech32PubkeyToPeerID(nodeAccount.GranteePubkey.Secp256k1.String()) + for _, pk := range keygen.GranteePubkeys { + pid, err := conversion.Bech32PubkeyToPeerID(pk) if err != nil { return err } diff --git a/pkg/rpc/clients_observer.go b/pkg/rpc/clients_observer.go index eefc712209..ee296b8fc9 100644 --- a/pkg/rpc/clients_observer.go +++ b/pkg/rpc/clients_observer.go @@ -114,22 +114,13 @@ func (c *Clients) GetKeyGen(ctx context.Context) (types.Keygen, error) { } // GetAllNodeAccounts returns all node accounts -func (c *Clients) GetAllNodeAccounts(ctx context.Context) ([]types.NodeAccount, error) { +func (c *Clients) GetAllNodeAccounts(ctx context.Context) ([]*types.NodeAccount, error) { resp, err := c.Observer.NodeAccountAll(ctx, &types.QueryAllNodeAccountRequest{}) if err != nil { return nil, errors.Wrap(err, "failed to get all node accounts") } - result := make([]types.NodeAccount, len(resp.NodeAccount)) - for i, nodeAccount := range resp.NodeAccount { - if nodeAccount != nil { - result[i] = *nodeAccount - } else { - return nil, fmt.Errorf("node account is nil") - } - } - - return result, nil + return resp.NodeAccount, nil } // GetBallot returns a ballot by ID diff --git a/pkg/rpc/clients_test.go b/pkg/rpc/clients_test.go index b5723b49b0..9e14266770 100644 --- a/pkg/rpc/clients_test.go +++ b/pkg/rpc/clients_test.go @@ -513,7 +513,7 @@ func TestZetacore_GetAllNodeAccounts(t *testing.T) { resp, err := client.GetAllNodeAccounts(ctx) require.NoError(t, err) - require.Equal(t, []observertypes.NodeAccount{*expectedOutput.NodeAccount[0]}, resp) + require.Equal(t, expectedOutput.NodeAccount, resp) } func TestZetacore_GetKeyGen(t *testing.T) { diff --git a/zetaclient/chains/evm/observer/observer_test.go b/zetaclient/chains/evm/observer/observer_test.go index e967695915..d30be608e5 100644 --- a/zetaclient/chains/evm/observer/observer_test.go +++ b/zetaclient/chains/evm/observer/observer_test.go @@ -76,7 +76,6 @@ func getAppContext( chainParams, "tssPubKey", *sample.CrosschainFlags(), - []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err) diff --git a/zetaclient/chains/evm/signer/signer_test.go b/zetaclient/chains/evm/signer/signer_test.go index 1e10b09ae1..b2c266b438 100644 --- a/zetaclient/chains/evm/signer/signer_test.go +++ b/zetaclient/chains/evm/signer/signer_test.go @@ -260,7 +260,6 @@ func makeCtx(t *testing.T) context.Context { }, "tssPubKey", observertypes.CrosschainFlags{}, - []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err, "unable to update app context") diff --git a/zetaclient/context/app.go b/zetaclient/context/app.go index b4a27241d0..8474c3ec87 100644 --- a/zetaclient/context/app.go +++ b/zetaclient/context/app.go @@ -13,7 +13,6 @@ import ( "golang.org/x/exp/slices" "github.com/zeta-chain/node/pkg/chains" - "github.com/zeta-chain/node/pkg/crypto" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/config" ) @@ -38,9 +37,6 @@ type AppContext struct { // keygen is the current tss keygen state keygen observertypes.Keygen - // nodeAccounts is array of current node accounts - nodeAccounts []observertypes.NodeAccount - mu sync.RWMutex } @@ -55,7 +51,6 @@ func New(cfg config.Config, relayerKeyPasswords map[string]string, logger zerolo crosschainFlags: observertypes.CrosschainFlags{}, currentTssPubKey: "", keygen: observertypes.Keygen{}, - nodeAccounts: []observertypes.NodeAccount{}, mu: sync.RWMutex{}, } @@ -125,27 +120,6 @@ func (a *AppContext) GetKeygen() observertypes.Keygen { } } -func (a *AppContext) GetNodeAccounts() []observertypes.NodeAccount { - a.mu.RLock() - defer a.mu.RUnlock() - - // deep copy node accounts - nodeAccounts := []observertypes.NodeAccount{} - for _, nodeAccount := range a.nodeAccounts { - nodeAccounts = append(nodeAccounts, observertypes.NodeAccount{ - Operator: nodeAccount.Operator, - GranteeAddress: nodeAccount.GranteeAddress, - GranteePubkey: &crypto.PubKeySet{ - Secp256k1: nodeAccount.GranteePubkey.Secp256k1, - Ed25519: nodeAccount.GranteePubkey.Ed25519, - }, - NodeStatus: nodeAccount.NodeStatus, - }) - } - - return nodeAccounts -} - // GetCurrentTssPubKey returns the current tss pubKey. func (a *AppContext) GetCurrentTssPubKey() string { a.mu.RLock() @@ -170,7 +144,6 @@ func (a *AppContext) Update( freshChainParams map[int64]*observertypes.ChainParams, tssPubKey string, crosschainFlags observertypes.CrosschainFlags, - nodeAccounts []observertypes.NodeAccount, ) error { // some sanity checks switch { @@ -178,8 +151,6 @@ func (a *AppContext) Update( return fmt.Errorf("no chains present") case len(freshChainParams) == 0: return fmt.Errorf("no chain params present") - case len(nodeAccounts) == 0: - return fmt.Errorf("node accounts empty") case tssPubKey == "" && a.currentTssPubKey != "": // note that if we're doing a fresh start, we ALLOW an empty tssPubKey return fmt.Errorf("tss pubkey is empty") @@ -202,7 +173,6 @@ func (a *AppContext) Update( a.crosschainFlags = crosschainFlags a.keygen = keygen a.currentTssPubKey = tssPubKey - a.nodeAccounts = nodeAccounts return nil } diff --git a/zetaclient/context/app_test.go b/zetaclient/context/app_test.go index 0572da04db..2297a3cdec 100644 --- a/zetaclient/context/app_test.go +++ b/zetaclient/context/app_test.go @@ -69,7 +69,6 @@ func TestAppContext(t *testing.T) { require.Empty(t, appContext.GetCrossChainFlags()) require.False(t, appContext.IsInboundObservationEnabled()) require.False(t, appContext.IsOutboundObservationEnabled()) - require.Empty(t, appContext.GetNodeAccounts()) // Given some data that is supposed to come from ZetaCore RPC newChains := []chains.Chain{ @@ -89,12 +88,8 @@ func TestAppContext(t *testing.T) { fancyL2, } - nodeAccounts := []types.NodeAccount{ - *sample.NodeAccount(), - } - // ACT - err = appContext.Update(keyGen, newChains, additionalChains, chainParams, ttsPubKey, ccFlags, nodeAccounts) + err = appContext.Update(keyGen, newChains, additionalChains, chainParams, ttsPubKey, ccFlags) // ASSERT require.NoError(t, err) @@ -106,7 +101,6 @@ func TestAppContext(t *testing.T) { assert.Equal(t, ccFlags, appContext.GetCrossChainFlags()) assert.True(t, appContext.IsInboundObservationEnabled()) assert.True(t, appContext.IsOutboundObservationEnabled()) - assert.Equal(t, nodeAccounts, appContext.GetNodeAccounts()) // Check ETH Chain ethChain, err := appContext.GetChain(1) @@ -138,7 +132,7 @@ func TestAppContext(t *testing.T) { { name: "update with empty chains results in an error", act: func(a *AppContext) error { - return appContext.Update(keyGen, newChains, nil, nil, ttsPubKey, ccFlags, nodeAccounts) + return appContext.Update(keyGen, newChains, nil, nil, ttsPubKey, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "no chain params present") @@ -159,7 +153,7 @@ func TestAppContext(t *testing.T) { chainParamsWithOpt := maps.Clone(chainParams) chainParamsWithOpt[opParams.ChainId] = opParams - return a.Update(keyGen, chainsWithOpt, additionalChains, chainParamsWithOpt, ttsPubKey, ccFlags, nodeAccounts) + return a.Update(keyGen, chainsWithOpt, additionalChains, chainParamsWithOpt, ttsPubKey, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorIs(t, err, ErrChainNotSupported) @@ -170,7 +164,7 @@ func TestAppContext(t *testing.T) { name: "trying to add zeta chain without chain params is allowed", act: func(a *AppContext) error { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParams, ttsPubKey, ccFlags, nodeAccounts) + return a.Update(keyGen, chainsWithZeta, additionalChains, chainParams, ttsPubKey, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -192,7 +186,7 @@ func TestAppContext(t *testing.T) { chainsWithZeta := append(newChains, chains.ZetaChainMainnet) - return a.Update(keyGen, chainsWithZeta, additionalChains, chainParamsWithZeta, ttsPubKey, ccFlags, nodeAccounts) + return a.Update(keyGen, chainsWithZeta, additionalChains, chainParamsWithZeta, ttsPubKey, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.NoError(t, err) @@ -215,7 +209,7 @@ func TestAppContext(t *testing.T) { updatedChainParams[maticParams.ChainId] = maticParams delete(updatedChainParams, chains.ZetaChainMainnet.ChainId) - return a.Update(keyGen, newChains, additionalChains, updatedChainParams, ttsPubKey, ccFlags, nodeAccounts) + return a.Update(keyGen, newChains, additionalChains, updatedChainParams, ttsPubKey, ccFlags) }, assert: func(t *testing.T, a *AppContext, err error) { assert.ErrorContains(t, err, "unable to locate fresh chain 137 based on chain params") diff --git a/zetaclient/orchestrator/bootstap_test.go b/zetaclient/orchestrator/bootstap_test.go index 54dae755e3..eaae3a8e6d 100644 --- a/zetaclient/orchestrator/bootstap_test.go +++ b/zetaclient/orchestrator/bootstap_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/node/pkg/chains" "github.com/zeta-chain/node/pkg/ptr" - "github.com/zeta-chain/node/testutil/sample" observertypes "github.com/zeta-chain/node/x/observer/types" "github.com/zeta-chain/node/zetaclient/chains/base" "github.com/zeta-chain/node/zetaclient/chains/interfaces" @@ -454,7 +453,6 @@ func mustUpdateAppContext( chainParams, "tssPubKey", app.GetCrossChainFlags(), - []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err) diff --git a/zetaclient/orchestrator/orchestrator_test.go b/zetaclient/orchestrator/orchestrator_test.go index 9c2f9cbf9e..2ab34b900e 100644 --- a/zetaclient/orchestrator/orchestrator_test.go +++ b/zetaclient/orchestrator/orchestrator_test.go @@ -551,7 +551,6 @@ func createAppContext(t *testing.T, chainsOrParams ...any) *zctx.AppContext { params, "tssPubKey", *ccFlags, - []observertypes.NodeAccount{*sample.NodeAccount()}, ) require.NoError(t, err, "failed to update app context") diff --git a/zetaclient/zetacore/client.go b/zetaclient/zetacore/client.go index c2e946fd10..9ad91002ce 100644 --- a/zetaclient/zetacore/client.go +++ b/zetaclient/zetacore/client.go @@ -373,11 +373,6 @@ func (c *Client) UpdateAppContext(ctx context.Context, appContext *zctx.AppConte freshParams := make(map[int64]*observertypes.ChainParams, len(chainParams)) - nodeAccounts, err := c.GetAllNodeAccounts(ctx) - if err != nil { - return errors.Wrap(err, "unable to fetch node accounts") - } - // check and update chain params for each chain // Note that we are EXCLUDING ZetaChain from the chainParams if it's present for i := range chainParams { @@ -407,7 +402,6 @@ func (c *Client) UpdateAppContext(ctx context.Context, appContext *zctx.AppConte freshParams, tss.GetTssPubkey(), crosschainFlags, - nodeAccounts, ) } diff --git a/zetaclient/zetacore/tx_test.go b/zetaclient/zetacore/tx_test.go index 24cdd61886..b58981f67b 100644 --- a/zetaclient/zetacore/tx_test.go +++ b/zetaclient/zetacore/tx_test.go @@ -343,15 +343,6 @@ func TestZetacore_UpdateAppContext(t *testing.T) { }, }, }) - method = "/zetachain.zetacore.observer.Query/NodeAccountAll" - s.ExpectUnary(method). - UnlimitedTimes(). - WithPayload(observertypes.QueryAllNodeAccountRequest{}). - Return(observertypes.QueryAllNodeAccountResponse{ - NodeAccount: []*observertypes.NodeAccount{ - sample.NodeAccount(), - }, - }) }, )(t)