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.WithSwitchInterval(morphconfig.SwitchInterval(c.appCfg)),
|
||||||
client.WithMorphCacheMetrics(c.metricsCollector.MorphCacheMetrics()),
|
client.WithMorphCacheMetrics(c.metricsCollector.MorphCacheMetrics()),
|
||||||
|
client.WithCompatibilityMode(c.cmode),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
c.log.Info(logs.FrostFSNodeFailedToCreateNeoRPCClient,
|
||||||
|
|
|
@ -462,6 +462,7 @@ func (s *Server) initMorph(ctx context.Context, cfg *viper.Viper, errChan chan<-
|
||||||
name: morphPrefix,
|
name: morphPrefix,
|
||||||
from: fromSideChainBlock,
|
from: fromSideChainBlock,
|
||||||
morphCacheMetric: s.irMetrics.MorphCacheMetrics(),
|
morphCacheMetric: s.irMetrics.MorphCacheMetrics(),
|
||||||
|
cmode: s.cmode,
|
||||||
}
|
}
|
||||||
|
|
||||||
// create morph client
|
// create morph client
|
||||||
|
|
|
@ -115,6 +115,7 @@ type (
|
||||||
sgn *transaction.Signer
|
sgn *transaction.Signer
|
||||||
from uint32 // block height
|
from uint32 // block height
|
||||||
morphCacheMetric metrics.MorphCacheMetrics
|
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.WithSwitchInterval(p.cfg.GetDuration(p.name+".switch_interval")),
|
||||||
client.WithMorphCacheMetrics(p.morphCacheMetric),
|
client.WithMorphCacheMetrics(p.morphCacheMetric),
|
||||||
|
client.WithCompatibilityMode(p.cmode),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
|
@ -48,6 +49,8 @@ type cfg struct {
|
||||||
switchInterval time.Duration
|
switchInterval time.Duration
|
||||||
|
|
||||||
morphCacheMetrics metrics.MorphCacheMetrics
|
morphCacheMetrics metrics.MorphCacheMetrics
|
||||||
|
|
||||||
|
cmode *atomic.Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -311,3 +314,11 @@ func WithMorphCacheMetrics(morphCacheMetrics metrics.MorphCacheMetrics) Option {
|
||||||
c.morphCacheMetrics = morphCacheMetrics
|
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)
|
s := make([]actor.SignerAccount, 2, 3)
|
||||||
// Proxy contract that will pay for the execution.
|
// Proxy contract that will pay for the execution.
|
||||||
|
// 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
|
||||||
|
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{
|
s[0] = actor.SignerAccount{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: c.notary.proxy,
|
Account: c.notary.proxy,
|
||||||
// Do not change this:
|
Scopes: scopes,
|
||||||
// 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,
|
|
||||||
},
|
},
|
||||||
Account: notary.FakeContractAccount(c.notary.proxy),
|
Account: notary.FakeContractAccount(c.notary.proxy),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue