forked from TrueCloudLab/frostfs-node
[#1072] node, ir, morph: Set scope None
when in upgrade mode
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
c8ce6e9fe4
commit
f74d058c2e
5 changed files with 25 additions and 5 deletions
|
@ -48,6 +48,7 @@ func initMorphComponents(ctx context.Context, c *cfg) {
|
|||
}),
|
||||
client.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
|
||||
client.WithMorphCacheMetrics(c.metricsCollector.MorphCacheMetrics()),
|
||||
client.WithCompatibilityMode(c.cmode),
|
||||
)
|
||||
if err != nil {
|
||||
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
||||
|
|
|
@ -462,6 +462,7 @@ func (s *Server) initMorph(ctx context.Context, cfg *viper.Viper, errChan chan<-
|
|||
name: morphPrefix,
|
||||
from: fromSideChainBlock,
|
||||
morphCacheMetric: s.irMetrics.MorphCacheMetrics(),
|
||||
cmode: s.cmode,
|
||||
}
|
||||
|
||||
// create morph client
|
||||
|
|
|
@ -115,6 +115,7 @@ type (
|
|||
sgn *transaction.Signer
|
||||
from uint32 // block height
|
||||
morphCacheMetric metrics.MorphCacheMetrics
|
||||
cmode *atomic.Bool
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -488,6 +489,7 @@ func createClient(ctx context.Context, p *chainParams, errChan chan<- error) (*c
|
|||
}),
|
||||
client.WithSwitchInterval(p.cfg.GetDuration(p.name+".switch_interval")),
|
||||
client.WithMorphCacheMetrics(p.morphCacheMetric),
|
||||
client.WithCompatibilityMode(p.cmode),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -48,6 +49,8 @@ type cfg struct {
|
|||
switchInterval time.Duration
|
||||
|
||||
morphCacheMetrics metrics.MorphCacheMetrics
|
||||
|
||||
cmode *atomic.Bool
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -311,3 +314,11 @@ func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option {
|
|||
c.morphCacheMetrics = morphCacheMetrics
|
||||
}
|
||||
}
|
||||
|
||||
// WithCompatibilityMode indicates that Client is working in compatibility mode
|
||||
// in this mode we need to keep backward compatibility with services with previous version.
|
||||
func WithCompatibilityMode(cmode *atomic.Bool) Option {
|
||||
return func(c *cfg) {
|
||||
c.cmode = cmode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -566,14 +566,19 @@ func (c *Client) notaryCosigners(invokedByAlpha bool, ir []*keys.PublicKey, comm
|
|||
}
|
||||
s := make([]actor.SignerAccount, 2, 3)
|
||||
// Proxy contract that will pay for the execution.
|
||||
s[0] = actor.SignerAccount{
|
||||
Signer: transaction.Signer{
|
||||
Account: c.notary.proxy,
|
||||
// Do not change this:
|
||||
// We must be able to call NNS contract indirectly from the Container contract.
|
||||
// Thus, CalledByEntry is not sufficient.
|
||||
// In future we may restrict this to all the usecases we have.
|
||||
Scopes: transaction.Global,
|
||||
scopes := transaction.Global
|
||||
if c.cfg.cmode != nil && c.cfg.cmode.Load() {
|
||||
// Set it to None to keep ability to send notary requests during upgrade
|
||||
scopes = transaction.None
|
||||
}
|
||||
s[0] = actor.SignerAccount{
|
||||
Signer: transaction.Signer{
|
||||
Account: c.notary.proxy,
|
||||
Scopes: scopes,
|
||||
},
|
||||
Account: notary.FakeContractAccount(c.notary.proxy),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue