diff --git a/pkg/innerring/contracts.go b/pkg/innerring/contracts.go index 55c2ff58..4a80296f 100644 --- a/pkg/innerring/contracts.go +++ b/pkg/innerring/contracts.go @@ -22,7 +22,7 @@ type contracts struct { alphabet AlphabetContracts // in morph } -func parseContracts(cfg *viper.Viper, morph nnsResolver, withoutMainNet, withoutMainNotary, withoutSideNotary bool) (*contracts, error) { +func parseContracts(cfg *viper.Viper, morph nnsResolver, withoutMainNet, withoutMainNotary bool) (*contracts, error) { var ( result = new(contracts) err error @@ -42,11 +42,9 @@ func parseContracts(cfg *viper.Viper, morph nnsResolver, withoutMainNet, without } } - if !withoutSideNotary { - result.proxy, err = parseContract(cfg, morph, "contracts.proxy", client.NNSProxyContractName) - if err != nil { - return nil, fmt.Errorf("can't get proxy script hash: %w", err) - } + result.proxy, err = parseContract(cfg, morph, "contracts.proxy", client.NNSProxyContractName) + if err != nil { + return nil, fmt.Errorf("can't get proxy script hash: %w", err) } targets := [...]struct { diff --git a/pkg/innerring/contracts_test.go b/pkg/innerring/contracts_test.go index e04e22f0..5f877133 100644 --- a/pkg/innerring/contracts_test.go +++ b/pkg/innerring/contracts_test.go @@ -35,7 +35,7 @@ contracts: t.Run("all enabled", func(t *testing.T) { t.Parallel() - c, err := parseContracts(v, nil, false, false, false) + c, err := parseContracts(v, nil, false, false) require.NoError(t, err, "failed to parse contracts") frostfsExp, _ := util.Uint160DecodeStringLE("ee3dee6d05dc79c24a5b8f6985e10d68b7cacc62") @@ -70,7 +70,7 @@ contracts: t.Run("all disabled", func(t *testing.T) { t.Parallel() - c, err := parseContracts(v, nil, true, true, true) + c, err := parseContracts(v, nil, true, true) require.NoError(t, err, "failed to parse contracts") require.Equal(t, util.Uint160{}, c.frostfs, "invalid frostfs") @@ -89,7 +89,8 @@ contracts: netmapIDExp, _ := util.Uint160DecodeStringLE("83c600c81d47a1b1b7cf58eb49ae7ee7240dc742") require.Equal(t, netmapIDExp, c.netmap, "invalid netmap") - require.Equal(t, util.Uint160{}, c.proxy, "invalid proxy") + proxyExp, _ := util.Uint160DecodeStringLE("abc8794bb40a21f2db5f21ae62741eb46c8cad1c") + require.Equal(t, proxyExp, c.proxy, "invalid proxy") require.Equal(t, 2, len(c.alphabet), "invalid alphabet contracts length") @@ -100,9 +101,9 @@ contracts: require.Equal(t, bukyExp, c.alphabet[buky], "invalid buky") }) - t.Run("main notary & side notary disabled", func(t *testing.T) { + t.Run("main notary disabled", func(t *testing.T) { t.Parallel() - c, err := parseContracts(v, nil, false, true, true) + c, err := parseContracts(v, nil, false, true) require.NoError(t, err, "failed to parse contracts") frostfsExp, _ := util.Uint160DecodeStringLE("ee3dee6d05dc79c24a5b8f6985e10d68b7cacc62") @@ -122,7 +123,8 @@ contracts: netmapIDExp, _ := util.Uint160DecodeStringLE("83c600c81d47a1b1b7cf58eb49ae7ee7240dc742") require.Equal(t, netmapIDExp, c.netmap, "invalid netmap") - require.Equal(t, util.Uint160{}, c.proxy, "invalid proxy") + proxyExp, _ := util.Uint160DecodeStringLE("abc8794bb40a21f2db5f21ae62741eb46c8cad1c") + require.Equal(t, proxyExp, c.proxy, "invalid proxy") require.Equal(t, 2, len(c.alphabet), "invalid alphabet contracts length") @@ -159,7 +161,7 @@ contracts: err := v.ReadConfig(file) require.NoError(t, err, "read config file failed") - _, err = parseContracts(v, nil, false, false, false) + _, err = parseContracts(v, nil, false, false) require.Error(t, err, "unexpected success") }) @@ -196,7 +198,7 @@ contracts: }, } - _, err = parseContracts(v, morph, false, false, false) + _, err = parseContracts(v, morph, false, false) require.ErrorContains(t, err, "could not read all contracts: required 3, read 2", "unexpected success") }) } diff --git a/pkg/innerring/initialization.go b/pkg/innerring/initialization.go index 9b563438..076d7be4 100644 --- a/pkg/innerring/initialization.go +++ b/pkg/innerring/initialization.go @@ -116,18 +116,16 @@ func (s *Server) initMainnet(ctx context.Context, cfg *viper.Viper, morphChain * } func (s *Server) enableNotarySupport() error { - if !s.sideNotaryConfig.disabled { - // enable notary support in the side client - err := s.morphClient.EnableNotarySupport( - client.WithProxyContract(s.contracts.proxy), - ) - if err != nil { - return fmt.Errorf("could not enable side chain notary support: %w", err) - } - - s.morphListener.EnableNotarySupport(s.contracts.proxy, s.morphClient.Committee, s.morphClient) + // enable notary support in the side client + err := s.morphClient.EnableNotarySupport( + client.WithProxyContract(s.contracts.proxy), + ) + if err != nil { + return fmt.Errorf("could not enable side chain notary support: %w", err) } + s.morphListener.EnableNotarySupport(s.contracts.proxy, s.morphClient.Committee, s.morphClient) + if !s.mainNotaryConfig.disabled { // enable notary support in the main client err := s.mainnetClient.EnableNotarySupport( @@ -143,13 +141,12 @@ func (s *Server) enableNotarySupport() error { } func (s *Server) initNotaryConfig() { - s.mainNotaryConfig, s.sideNotaryConfig = notaryConfigs( - s.morphClient.ProbeNotary(), + s.mainNotaryConfig = notaryConfigs( !s.withoutMainNet && s.mainnetClient.ProbeNotary(), // if mainnet disabled then notary flag must be disabled too ) s.log.Info(logs.InnerringNotarySupport, - zap.Bool("sidechain_enabled", !s.sideNotaryConfig.disabled), + zap.Bool("sidechain_enabled", true), zap.Bool("mainchain_enabled", !s.mainNotaryConfig.disabled), ) } @@ -500,7 +497,6 @@ func (s *Server) initContracts(cfg *viper.Viper) error { s.morphClient, s.withoutMainNet, s.mainNotaryConfig.disabled, - s.sideNotaryConfig.disabled, ) return err diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 17acdedd..3a690bbb 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -63,7 +63,6 @@ type ( // notary configuration feeConfig *config.FeeConfig mainNotaryConfig *notaryConfig - sideNotaryConfig *notaryConfig // internal variables key *keys.PrivateKey @@ -267,14 +266,11 @@ func (s *Server) initMainNotary(ctx context.Context) error { } func (s *Server) initSideNotary(ctx context.Context) error { - if !s.sideNotaryConfig.disabled { - return s.initNotary(ctx, - s.depositSideNotary, - s.awaitSideNotaryDeposit, - "waiting to accept side notary deposit", - ) - } - return nil + return s.initNotary(ctx, + s.depositSideNotary, + s.awaitSideNotaryDeposit, + "waiting to accept side notary deposit", + ) } func (s *Server) tickInitialExpoch() { diff --git a/pkg/innerring/notary.go b/pkg/innerring/notary.go index 30916cb9..c601f558 100644 --- a/pkg/innerring/notary.go +++ b/pkg/innerring/notary.go @@ -57,11 +57,8 @@ func (s *Server) notaryHandler(_ event.Event) { } } - if !s.sideNotaryConfig.disabled { - _, err := s.depositSideNotary() - if err != nil { - s.log.Error(logs.InnerringCantMakeNotaryDepositInSideChain, zap.Error(err)) - } + if _, err := s.depositSideNotary(); err != nil { + s.log.Error(logs.InnerringCantMakeNotaryDepositInSideChain, zap.Error(err)) } } @@ -115,16 +112,8 @@ func awaitNotaryDepositInClient(ctx context.Context, cli *client.Client, txHash return errDepositTimeout } -func notaryConfigs(withSideNotary, withMainNotary bool) (main, side *notaryConfig) { +func notaryConfigs(withMainNotary bool) (main *notaryConfig) { main = new(notaryConfig) - side = new(notaryConfig) - - if !withSideNotary { - main.disabled = true - side.disabled = true - - return - } main.disabled = !withMainNotary