From 55362f0607789e8453af5902b212884d07cdcfe9 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 5 Apr 2022 17:01:59 +0300 Subject: [PATCH] [#1294] neofs-adm: Check persisted tx status Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 4ef64e5b83..ae97c80f2b 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -14,6 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" + "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config" "github.com/nspcc-dev/neofs-node/pkg/innerring" @@ -292,17 +293,27 @@ func (c *clientContext) awaitTx(cmd *cobra.Command) error { at := trigger.Application + var retErr error + loop: for i := range c.Hashes { - _, err := c.Client.GetApplicationLog(c.Hashes[i], &at) + res, err := c.Client.GetApplicationLog(c.Hashes[i], &at) if err == nil { + if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState { + retErr = fmt.Errorf("tx persisted in %s state: %s", + res.Executions[0].VMState, res.Executions[0].FaultException) + } continue loop } for { select { case <-tick.C: - _, err := c.Client.GetApplicationLog(c.Hashes[i], &at) + res, err := c.Client.GetApplicationLog(c.Hashes[i], &at) if err == nil { + if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState { + retErr = fmt.Errorf("tx persisted in %s state: %s", + res.Executions[0].VMState, res.Executions[0].FaultException) + } continue loop } case <-timer.C: @@ -311,7 +322,7 @@ loop: } } - return nil + return retErr } func (c *initializeContext) sendCommitteeTx(script []byte, sysFee int64) error {