From 66eb7613f38149d7e62a10bb02a32882fd8eff05 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Feb 2023 15:37:35 +0300 Subject: [PATCH 1/2] [#48] adm: Allow using nonzero magic with local client neo-go actor API uses `getVersion` call which returned incorrect magic. Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize_test.go | 1 + .../internal/modules/morph/local_client.go | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go index 02d0021ee..08fde0ce9 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go @@ -96,6 +96,7 @@ func generateTestData(t *testing.T, dir string, size int) { } cfg := config.Config{} + cfg.ProtocolConfiguration.Magic = 12345 cfg.ProtocolConfiguration.ValidatorsCount = size cfg.ProtocolConfiguration.SecondsPerBlock = 1 cfg.ProtocolConfiguration.StandbyCommittee = pubs // sorted by glagolic letters diff --git a/cmd/frostfs-adm/internal/modules/morph/local_client.go b/cmd/frostfs-adm/internal/modules/morph/local_client.go index 9faf9644f..e3d08d3fb 100644 --- a/cmd/frostfs-adm/internal/modules/morph/local_client.go +++ b/cmd/frostfs-adm/internal/modules/morph/local_client.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "sort" + "time" "github.com/google/uuid" "github.com/nspcc-dev/neo-go/pkg/config" @@ -20,6 +21,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" + "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/neorpc/result" @@ -226,7 +228,24 @@ func (l *localClient) TraverseIterator(_, _ uuid.UUID, _ int) ([]stackitem.Item, // GetVersion return default version. func (l *localClient) GetVersion() (*result.Version, error) { - return &result.Version{}, nil + c := l.bc.GetConfig() + return &result.Version{ + Protocol: result.Protocol{ + AddressVersion: address.NEO3Prefix, + Network: c.Magic, + MillisecondsPerBlock: int(c.TimePerBlock / time.Millisecond), + MaxTraceableBlocks: c.MaxTraceableBlocks, + MaxValidUntilBlockIncrement: c.MaxValidUntilBlockIncrement, + MaxTransactionsPerBlock: c.MaxTransactionsPerBlock, + MemoryPoolMaxTransactions: c.MemPoolSize, + ValidatorsCount: byte(c.ValidatorsCount), + InitialGasDistribution: c.InitialGASSupply, + CommitteeHistory: c.CommitteeHistory, + P2PSigExtensions: c.P2PSigExtensions, + StateRootInHeader: c.StateRootInHeader, + ValidatorsHistory: c.ValidatorsHistory, + }, + }, nil } func (l *localClient) InvokeContractVerify(contract util.Uint160, params []smartcontract.Parameter, signers []transaction.Signer, witnesses ...transaction.Witness) (*result.Invoke, error) { -- 2.45.2 From 2cf906ff0bceede45a4a261a2f1fff5881950f23 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Feb 2023 15:38:50 +0300 Subject: [PATCH 2/2] [#48] adm: Add initialize test for 1 node Single node is used in dev-env, worth testing. Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-adm/internal/modules/morph/initialize_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go index 08fde0ce9..e4927ce5a 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go @@ -27,6 +27,9 @@ func TestInitialize(t *testing.T) { // It is here for performing local testing after the changes. t.Skip() + t.Run("1 nodes", func(t *testing.T) { + testInitialize(t, 1) + }) t.Run("4 nodes", func(t *testing.T) { testInitialize(t, 4) }) -- 2.45.2