Remove notaryless code for side-chain contracts #1538

Merged
fyrchik merged 3 commits from fyrchik/frostfs-node:fix-notary into master 2024-12-05 08:09:16 +00:00
13 changed files with 29 additions and 104 deletions

View file

@ -135,7 +135,7 @@ func createContainerInfoProvider(cli *client.Client) (container.InfoProvider, er
if err != nil { if err != nil {
return nil, fmt.Errorf("resolve container contract hash: %w", err) return nil, fmt.Errorf("resolve container contract hash: %w", err)
} }
cc, err := morphcontainer.NewFromMorph(cli, sh, 0, morphcontainer.TryNotary()) cc, err := morphcontainer.NewFromMorph(cli, sh, 0)
if err != nil { if err != nil {
return nil, fmt.Errorf("create morph container client: %w", err) return nil, fmt.Errorf("create morph container client: %w", err)
} }

View file

@ -591,8 +591,6 @@ type cfgMorph struct {
client *client.Client client *client.Client
notaryEnabled bool
// TTL of Sidechain cached values. Non-positive value disables caching. // TTL of Sidechain cached values. Non-positive value disables caching.
cacheTTL time.Duration cacheTTL time.Duration
@ -1466,7 +1464,7 @@ func (c *cfg) createTombstoneSource() *tombstone.ExpirationChecker {
func (c *cfg) createContainerInfoProvider(ctx context.Context) container.InfoProvider { func (c *cfg) createContainerInfoProvider(ctx context.Context) container.InfoProvider {
return container.NewInfoProvider(func() (container.Source, error) { return container.NewInfoProvider(func() (container.Source, error) {
c.initMorphComponents(ctx) c.initMorphComponents(ctx)
cc, err := containerClient.NewFromMorph(c.cfgMorph.client, c.cfgContainer.scriptHash, 0, containerClient.TryNotary()) cc, err := containerClient.NewFromMorph(c.cfgMorph.client, c.cfgContainer.scriptHash, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -28,7 +28,7 @@ import (
func initContainerService(_ context.Context, c *cfg) { func initContainerService(_ context.Context, c *cfg) {
// container wrapper that tries to invoke notary // container wrapper that tries to invoke notary
// requests if chain is configured so // requests if chain is configured so
wrap, err := cntClient.NewFromMorph(c.cfgMorph.client, c.cfgContainer.scriptHash, 0, cntClient.TryNotary()) wrap, err := cntClient.NewFromMorph(c.cfgMorph.client, c.cfgContainer.scriptHash, 0)
fatalOnErr(err) fatalOnErr(err)
c.shared.cnrClient = wrap c.shared.cnrClient = wrap

View file

@ -35,20 +35,16 @@ func (c *cfg) initMorphComponents(ctx context.Context) {
lookupScriptHashesInNNS(c) // smart contract auto negotiation lookupScriptHashesInNNS(c) // smart contract auto negotiation
if c.cfgMorph.notaryEnabled {
err := c.cfgMorph.client.EnableNotarySupport( err := c.cfgMorph.client.EnableNotarySupport(
client.WithProxyContract( client.WithProxyContract(
c.cfgMorph.proxyScriptHash, c.cfgMorph.proxyScriptHash,
), ),
) )
fatalOnErr(err) fatalOnErr(err)
}
c.log.Info(ctx, logs.FrostFSNodeNotarySupport, c.log.Info(ctx, logs.FrostFSNodeNotarySupport)
zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled),
)
wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0, nmClient.TryNotary()) wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0)
fatalOnErr(err) fatalOnErr(err)
var netmapSource netmap.Source var netmapSource netmap.Source
@ -116,15 +112,9 @@ func initMorphClient(ctx context.Context, c *cfg) {
} }
c.cfgMorph.client = cli c.cfgMorph.client = cli
c.cfgMorph.notaryEnabled = cli.ProbeNotary()
} }
func makeAndWaitNotaryDeposit(ctx context.Context, c *cfg) { func makeAndWaitNotaryDeposit(ctx context.Context, c *cfg) {
// skip notary deposit in non-notary environments
if !c.cfgMorph.notaryEnabled {
return
}
tx, vub, err := makeNotaryDeposit(ctx, c) tx, vub, err := makeNotaryDeposit(ctx, c)
fatalOnErr(err) fatalOnErr(err)
@ -282,10 +272,6 @@ func lookupScriptHashesInNNS(c *cfg) {
) )
for _, t := range targets { for _, t := range targets {
if t.nnsName == client.NNSProxyContractName && !c.cfgMorph.notaryEnabled {
continue // ignore proxy contract if notary disabled
}
if emptyHash.Equals(*t.h) { if emptyHash.Equals(*t.h) {
*t.h, err = c.cfgMorph.client.NNSContractAddress(t.nnsName) *t.h, err = c.cfgMorph.client.NNSContractAddress(t.nnsName)
fatalOnErrDetails(fmt.Sprintf("can't resolve %s in NNS", t.nnsName), err) fatalOnErrDetails(fmt.Sprintf("can't resolve %s in NNS", t.nnsName), err)

View file

@ -193,7 +193,6 @@ func addNewEpochNotificationHandlers(c *cfg) {
} }
}) })
if c.cfgMorph.notaryEnabled {
addNewEpochAsyncNotificationHandler(c, func(ctx context.Context, _ event.Event) { addNewEpochAsyncNotificationHandler(c, func(ctx context.Context, _ event.Event) {
_, _, err := makeNotaryDeposit(ctx, c) _, _, err := makeNotaryDeposit(ctx, c)
if err != nil { if err != nil {
@ -203,7 +202,6 @@ func addNewEpochNotificationHandlers(c *cfg) {
} }
}) })
} }
}
// bootstrapNode adds current node to the Network map. // bootstrapNode adds current node to the Network map.
// Must be called after initNetmapService. // Must be called after initNetmapService.

View file

@ -13,7 +13,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/cache" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/cache"
objectTransportGRPC "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/transport/object/grpc" objectTransportGRPC "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/transport/object/grpc"
objectService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object" objectService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/object"
@ -137,24 +136,6 @@ func (fn *innerRingFetcherWithNotary) InnerRingKeys() ([][]byte, error) {
return result, nil return result, nil
} }
type innerRingFetcherWithoutNotary struct {
nm *nmClient.Client
}
func (f *innerRingFetcherWithoutNotary) InnerRingKeys() ([][]byte, error) {
keys, err := f.nm.GetInnerRingList()
if err != nil {
return nil, fmt.Errorf("can't get inner ring keys from netmap contract: %w", err)
}
result := make([][]byte, 0, len(keys))
for i := range keys {
result = append(result, keys[i].Bytes())
}
return result, nil
}
func initObjectService(c *cfg) { func initObjectService(c *cfg) {
keyStorage := util.NewKeyStorage(&c.key.PrivateKey, c.privateTokenStore, c.cfgNetmap.state) keyStorage := util.NewKeyStorage(&c.key.PrivateKey, c.privateTokenStore, c.cfgNetmap.state)
@ -305,15 +286,10 @@ func addPolicer(c *cfg, keyStorage *util.KeyStorage, clientConstructor *cache.Cl
} }
func createInnerRingFetcher(c *cfg) v2.InnerRingFetcher { func createInnerRingFetcher(c *cfg) v2.InnerRingFetcher {
if c.cfgMorph.client.ProbeNotary() {
return &innerRingFetcherWithNotary{ return &innerRingFetcherWithNotary{
sidechain: c.cfgMorph.client, sidechain: c.cfgMorph.client,
} }
} }
return &innerRingFetcherWithoutNotary{
nm: c.cfgNetmap.wrapper,
}
}
func createReplicator(c *cfg, keyStorage *util.KeyStorage, cache *cache.ClientCache) *replicator.Replicator { func createReplicator(c *cfg, keyStorage *util.KeyStorage, cache *cache.ClientCache) *replicator.Replicator {
ls := c.cfgObject.cfgLocalStorage.localStorage ls := c.cfgObject.cfgLocalStorage.localStorage

View file

@ -380,7 +380,6 @@ func (s *Server) initClientsFromMorph() (*serverMorphClients, error) {
// form morph container client's options // form morph container client's options
morphCnrOpts := make([]container.Option, 0, 3) morphCnrOpts := make([]container.Option, 0, 3)
morphCnrOpts = append(morphCnrOpts, morphCnrOpts = append(morphCnrOpts,
container.TryNotary(),
container.AsAlphabet(), container.AsAlphabet(),
) )
@ -390,12 +389,12 @@ func (s *Server) initClientsFromMorph() (*serverMorphClients, error) {
} }
s.containerClient = result.CnrClient s.containerClient = result.CnrClient
s.netmapClient, err = nmClient.NewFromMorph(s.morphClient, s.contracts.netmap, fee, nmClient.TryNotary(), nmClient.AsAlphabet()) s.netmapClient, err = nmClient.NewFromMorph(s.morphClient, s.contracts.netmap, fee, nmClient.AsAlphabet())
if err != nil { if err != nil {
return nil, err return nil, err
} }
s.balanceClient, err = balanceClient.NewFromMorph(s.morphClient, s.contracts.balance, fee, balanceClient.TryNotary(), balanceClient.AsAlphabet()) s.balanceClient, err = balanceClient.NewFromMorph(s.morphClient, s.contracts.balance, fee, balanceClient.AsAlphabet())
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -54,15 +54,7 @@ type Option func(*opts)
type opts []client.StaticClientOption type opts []client.StaticClientOption
func defaultOpts() *opts { func defaultOpts() *opts {
return new(opts) return &opts{client.TryNotary()}
}
// TryNotary returns option to enable
// notary invocation tries.
func TryNotary() Option {
return func(o *opts) {
*o = append(*o, client.TryNotary())
}
} }
// AsAlphabet returns option to sign main TX // AsAlphabet returns option to sign main TX

View file

@ -21,8 +21,6 @@ type TransferPrm struct {
// TransferX transfers p.Amount of GASe-12 from p.From to p.To // TransferX transfers p.Amount of GASe-12 from p.From to p.To
// with details p.Details through direct smart contract call. // with details p.Details through direct smart contract call.
//
// If TryNotary is provided, calls notary contract.
func (c *Client) TransferX(ctx context.Context, p TransferPrm) error { func (c *Client) TransferX(ctx context.Context, p TransferPrm) error {
from, err := p.From.ScriptHash() from, err := p.From.ScriptHash()
if err != nil { if err != nil {

View file

@ -46,7 +46,7 @@ func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8,
opts[i](o) opts[i](o)
} }
sc, err := client.NewStatic(cli, contract, fee, o.staticOpts...) sc, err := client.NewStatic(cli, contract, fee, *o...)
if err != nil { if err != nil {
return nil, fmt.Errorf("create 'container' contract client: %w", err) return nil, fmt.Errorf("create 'container' contract client: %w", err)
} }
@ -68,20 +68,10 @@ func (c Client) ContractAddress() util.Uint160 {
// parameter of Wrapper. // parameter of Wrapper.
type Option func(*opts) type Option func(*opts)
type opts struct { type opts []client.StaticClientOption
staticOpts []client.StaticClientOption
}
func defaultOpts() *opts { func defaultOpts() *opts {
return new(opts) return &opts{client.TryNotary()}
}
// TryNotary returns option to enable
// notary invocation tries.
func TryNotary() Option {
return func(o *opts) {
o.staticOpts = append(o.staticOpts, client.TryNotary())
}
} }
// AsAlphabet returns option to sign main TX // AsAlphabet returns option to sign main TX
@ -91,6 +81,6 @@ func TryNotary() Option {
// Considered to be used by IR nodes only. // Considered to be used by IR nodes only.
func AsAlphabet() Option { func AsAlphabet() Option {
return func(o *opts) { return func(o *opts) {
o.staticOpts = append(o.staticOpts, client.AsAlphabet()) *o = append(*o, client.AsAlphabet())
} }
} }

View file

@ -66,8 +66,6 @@ func (d *DeletePrm) SetKey(key []byte) {
// //
// Returns valid until block and any error encountered that caused // Returns valid until block and any error encountered that caused
// the removal to interrupt. // the removal to interrupt.
//
// If TryNotary is provided, calls notary contract.
func (c *Client) Delete(ctx context.Context, p DeletePrm) (uint32, error) { func (c *Client) Delete(ctx context.Context, p DeletePrm) (uint32, error) {
if len(p.signature) == 0 && !p.IsControl() { if len(p.signature) == 0 && !p.IsControl() {
return 0, errNilArgument return 0, errNilArgument

View file

@ -94,8 +94,6 @@ func (p *PutPrm) SetZone(zone string) {
// //
// Returns calculated container identifier and any error // Returns calculated container identifier and any error
// encountered that caused the saving to interrupt. // encountered that caused the saving to interrupt.
//
// If TryNotary is provided, calls notary contract.
func (c *Client) Put(ctx context.Context, p PutPrm) error { func (c *Client) Put(ctx context.Context, p PutPrm) error {
if len(p.sig) == 0 || len(p.key) == 0 { if len(p.sig) == 0 || len(p.key) == 0 {
return errNilArgument return errNilArgument

View file

@ -65,15 +65,7 @@ type Option func(*opts)
type opts []client.StaticClientOption type opts []client.StaticClientOption
func defaultOpts() *opts { func defaultOpts() *opts {
return new(opts) return &opts{client.TryNotary()}
}
// TryNotary returns option to enable
// notary invocation tries.
func TryNotary() Option {
return func(o *opts) {
*o = append(*o, client.TryNotary())
}
} }
// AsAlphabet returns option to sign main TX // AsAlphabet returns option to sign main TX