From e4370c41291586e17519ad4b002bd9718c654f93 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 18 Aug 2022 13:28:10 +0300 Subject: [PATCH] [#1702] neofs-adm: Set HighPriority attribute for committee transactions Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 1af3c1d8..1f3d886a 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -363,14 +363,28 @@ loop: // If sysFee is -1, it is calculated automatically. If tryGroup is false, // global scope is used for the signer (useful when working with native contracts). func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64, tryGroup bool) error { - tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, []rpcclient.SignerAccount{{ + cosigners := []rpcclient.SignerAccount{{ Signer: c.getSigner(tryGroup), Account: c.CommitteeAcc, - }}) + }} + tx, err := c.Client.CreateTxFromScript(script, c.CommitteeAcc, sysFee, 0, cosigners) if err != nil { return fmt.Errorf("can't create tx: %w", err) } + tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.HighPriority}) + + // Calculate network fee again, because tx size has changed. + _, accounts, err := getSigners(c.CommitteeAcc, cosigners) + if err != nil { + panic(fmt.Errorf("BUG: can't calculate network fee: %w", err)) + } + + tx.NetworkFee = 0 + err = c.Client.AddNetworkFee(tx, 0, accounts...) + if err != nil { + return fmt.Errorf("failed to add network fee: %w", err) + } return c.multiSignAndSend(tx, committeeAccountName) }