morph: Cleanup InvocationScript
before sign #776
5 changed files with 30 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
configViper "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/config"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -67,6 +68,7 @@ func watchForSignal(cancel func()) {
|
|||
if err != nil {
|
||||
log.Error(logs.FrostFSNodeConfigurationReading, zap.Error(err))
|
||||
}
|
||||
client.KeepInvScript = cfg.GetBool("morph.keepinvscript")
|
||||
log.Info(logs.FrostFSNodeConfigurationHasBeenReloadedSuccessfully)
|
||||
case syscall.SIGTERM, syscall.SIGINT:
|
||||
log.Info(logs.FrostFSNodeTerminationSignalHasBeenReceivedStopping)
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/misc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
|
@ -60,6 +61,7 @@ func main() {
|
|||
var err error
|
||||
cfg, err = newConfig()
|
||||
exitErr(err)
|
||||
client.KeepInvScript = cfg.GetBool("morph.keepinvscript")
|
||||
|
||||
logPrm.MetricsNamespace = "frostfs_ir"
|
||||
err = logPrm.SetLevelString(
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
blobovniczaconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/blobstor/blobovnicza"
|
||||
fstreeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/blobstor/fstree"
|
||||
loggerconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/logger"
|
||||
morphconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/morph"
|
||||
nodeconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/node"
|
||||
objectconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/object"
|
||||
replicatorconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/replicator"
|
||||
|
@ -212,6 +213,9 @@ func (a *applicationConfiguration) readConfig(c *config.Config) error {
|
|||
a.EngineCfg.lowMem = engineconfig.EngineLowMemoryConsumption(c)
|
||||
a.EngineCfg.rebuildWorkers = engineconfig.EngineRebuildWorkersCount(c)
|
||||
|
||||
// Kludge
|
||||
client.KeepInvScript = morphconfig.KeepInvocationScript(c)
|
||||
|
||||
|
||||
return engineconfig.IterateShards(c, false, func(sc *shardconfig.Config) error { return a.updateShardConfig(c, sc) })
|
||||
}
|
||||
|
||||
|
|
|
@ -97,3 +97,8 @@ func SwitchInterval(c *config.Config) time.Duration {
|
|||
|
||||
return SwitchIntervalDefault
|
||||
}
|
||||
|
||||
// KeepInvocationScript this is a kludge purely for update to work.
|
||||
func KeepInvocationScript(c *config.Config) bool {
|
||||
return config.Bool(c.Sub(subsection), "keepinvscript")
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ const (
|
|||
|
||||
var errUnexpectedItems = errors.New("invalid number of NEO VM arguments on stack")
|
||||
|
||||
// This is a kludge purely for update to work.
|
||||
var KeepInvScript bool
|
||||
|
||||
func defaultNotaryConfig(c *Client) *notaryCfg {
|
||||
return ¬aryCfg{
|
||||
txValidTime: defaultNotaryValidTime,
|
||||
|
@ -418,6 +421,20 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
|
|||
return err
|
||||
fyrchik marked this conversation as resolved
Outdated
fyrchik
commented
Can we mention that this is a kludge purely for update to work? Can we mention that this is a kludge purely for update to work?
acid-ant
commented
Updated. Updated.
|
||||
}
|
||||
|
||||
if !KeepInvScript {
|
||||
// This is necessary to suppress this check on neo-go side:
|
||||
// https://github.com/nspcc-dev/neo-go/blob/8ed6d97085d3229d4faf56a47bbd6cf73c132a76/pkg/services/notary/notary.go#L538
|
||||
// This is a kludge purely for update to work.
|
||||
for i := range mainTx.Signers {
|
||||
for _, sig := range cosigners {
|
||||
if mainTx.Signers[i].Account.Equals(sig.Account.ScriptHash()) {
|
||||
mainTx.Scripts[i].InvocationScript = []byte{}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sign exactly the same transaction we've got from the received Notary request.
|
||||
err = nAct.Sign(mainTx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue
Do we read this with SIGHUP? Could be a data race.
Yes, we read it at SIGHUP too, and yes it is possible for data race. But we use this variable when react on events which happens not so far. Also, when system upgraded, it works in both scenarios as I remember - when kludged enabled/disabled.