From 861307b192a39e6066064c0ba535c00c15696d77 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 11 Mar 2021 13:48:17 +0300 Subject: [PATCH] [#446] morph/client: Use on-chain source of alphabet nodes Signed-off-by: Alex Vanin --- pkg/morph/client/notary.go | 53 +++----------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 5e2666200..24d41344b 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -1,8 +1,6 @@ package client import ( - "crypto/elliptic" - "github.com/nspcc-dev/neo-go/pkg/core/native" "github.com/nspcc-dev/neo-go/pkg/core/native/nativenames" "github.com/nspcc-dev/neo-go/pkg/core/transaction" @@ -44,7 +42,6 @@ const ( defaultNotaryRoundTime = 100 defaultNotaryFallbackTime = 40 - innerRingListMethod = "innerRingList" notaryBalanceOfMethod = "balanceOf" setDesignateMethod = "designateAsRole" @@ -202,15 +199,15 @@ func (c *Client) notaryInvoke(committee bool, contract util.Uint160, method stri // prepare arguments for test invocation - irList, err := c.notaryInnerRingList() + alphabetList, err := c.Committee() if err != nil { return err } - _, n := mn(irList, committee) + _, n := mn(alphabetList, committee) u8n := uint8(n) - cosigners, err := c.notaryCosigners(irList, committee) + cosigners, err := c.notaryCosigners(alphabetList, committee) if err != nil { return err } @@ -233,7 +230,7 @@ func (c *Client) notaryInvoke(committee bool, contract util.Uint160, method stri // after test invocation we build main multisig transaction - multiaddrAccount, err := c.notaryMultisigAccount(irList, committee) + multiaddrAccount, err := c.notaryMultisigAccount(alphabetList, committee) if err != nil { return err } @@ -386,48 +383,6 @@ func (c *Client) notaryWitnesses(multiaddr *wallet.Account, tx *transaction.Tran return w } -func (c *Client) notaryInnerRingList() ([]*keys.PublicKey, error) { - data, err := c.TestInvoke(c.notary.netmap, innerRingListMethod) - if err != nil { - return nil, errors.Wrap(err, "test invoke error") - } - - if len(data) == 0 { - return nil, errors.Wrap(errInvalidIR, "test invoke returned empty stack") - } - - prms, err := ArrayFromStackItem(data[0]) - if err != nil { - return nil, errors.Wrap(err, "test invoke returned non array element") - } - - res := make([]*keys.PublicKey, 0, len(prms)) - for i := range prms { - nodePrms, err := ArrayFromStackItem(prms[i]) - if err != nil { - return nil, errors.Wrap(err, "inner ring node structure is not an array") - } - - if len(nodePrms) == 0 { - return nil, errors.Wrap(errInvalidIR, "inner ring node structure is empty array") - } - - rawKey, err := BytesFromStackItem(nodePrms[0]) - if err != nil { - return nil, errors.Wrap(err, "inner ring public key is not slice of bytes") - } - - key, err := keys.NewPublicKeyFromBytes(rawKey, elliptic.P256()) - if err != nil { - return nil, errors.Wrap(err, "can't parse inner ring public key bytes") - } - - res = append(res, key) - } - - return res, nil -} - func (c *Client) notaryMultisigAccount(ir []*keys.PublicKey, committee bool) (*wallet.Account, error) { m, _ := mn(ir, committee)