From d00df049dbd9a5dab8fc41b52d546386476e87dd Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Thu, 3 Sep 2020 11:48:07 +0300 Subject: [PATCH 1/6] EN-7522: compute shard ID for a given address --- api/address/interface.go | 1 + api/address/routes.go | 36 ++++++++++++++ api/address/routes_test.go | 73 ++++++++++++++++++++++++++++ api/errors/errors.go | 3 ++ api/hyperblock/interface.go | 3 +- api/hyperblock/routes.go | 4 +- api/mock/facade.go | 6 +++ facade/elrondProxyFacade.go | 25 ++++++++++ facade/interface.go | 1 + facade/mock/accountProccessorStub.go | 14 ++++-- process/accountProcessor.go | 10 ++++ 11 files changed, 169 insertions(+), 7 deletions(-) diff --git a/api/address/interface.go b/api/address/interface.go index 82213098..4e9ad3ae 100644 --- a/api/address/interface.go +++ b/api/address/interface.go @@ -8,5 +8,6 @@ import ( type FacadeHandler interface { GetAccount(address string) (*data.Account, error) GetTransactions(address string) ([]data.DatabaseTransaction, error) + GetShardIDForAddress(address string) (uint32, error) GetValueForKey(address string, key string) (string, error) } diff --git a/api/address/routes.go b/api/address/routes.go index f0c99c0c..18836d86 100644 --- a/api/address/routes.go +++ b/api/address/routes.go @@ -16,6 +16,7 @@ func Routes(router *gin.RouterGroup) { router.GET("/:address/balance", GetBalance) router.GET("/:address/username", GetUsername) router.GET("/:address/nonce", GetNonce) + router.GET("/:address/shard", GetShard) router.GET("/:address/transactions", GetTransactions) router.GET("/:address/key/:key", GetValueForKey) } @@ -152,3 +153,38 @@ func GetValueForKey(c *gin.Context) { shared.RespondWith(c, http.StatusOK, gin.H{"value": value}, "", data.ReturnCodeSuccess) } + +// GetShard returns the shard for the given address based on the current proxy's configuration +func GetShard(c *gin.Context) { + ef, ok := c.MustGet("elrondProxyFacade").(FacadeHandler) + if !ok { + shared.RespondWithInvalidAppContext(c) + return + } + + addr := c.Param("address") + if addr == "" { + shared.RespondWith( + c, + http.StatusBadRequest, + nil, + fmt.Sprintf("%v: %v", errors.ErrComputeShardForAddress, errors.ErrEmptyAddress), + data.ReturnCodeRequestError, + ) + return + } + + shardID, err := ef.GetShardIDForAddress(addr) + if err != nil { + shared.RespondWith( + c, + http.StatusInternalServerError, + nil, + fmt.Sprintf("%s: %s", errors.ErrComputeShardForAddress.Error(), err.Error()), + data.ReturnCodeInternalError, + ) + return + } + + shared.RespondWith(c, http.StatusOK, gin.H{"shardID": shardID}, "", data.ReturnCodeSuccess) +} diff --git a/api/address/routes_test.go b/api/address/routes_test.go index fa96aa51..fdd578df 100644 --- a/api/address/routes_test.go +++ b/api/address/routes_test.go @@ -8,6 +8,7 @@ import ( "math/big" "net/http" "net/http/httptest" + "strings" "testing" "github.com/ElrondNetwork/elrond-proxy-go/api" @@ -61,6 +62,15 @@ type usernameResponse struct { Data usernameResponseData } +type getShardResponseData struct { + ShardID uint32 `json:"shardID"` +} + +type getShardResponse struct { + GeneralResponse + Data getShardResponseData +} + type nonceResponseData struct { Nonce uint64 `json:"nonce"` } @@ -323,3 +333,66 @@ func TestGetNonce_ReturnsSuccessfully(t *testing.T) { assert.Equal(t, uint64(1), nonceResponse.Data.Nonce) assert.Empty(t, nonceResponse.Error) } + +// ---- GetShard +func TestGetShard_FailsWithWrongFacadeTypeConversion(t *testing.T) { + t.Parallel() + + ws := startNodeServerWrongFacade() + req, _ := http.NewRequest("GET", "/address/address/shard", nil) + resp := httptest.NewRecorder() + ws.ServeHTTP(resp, req) + + statusRsp := getShardResponse{} + loadResponse(resp.Body, &statusRsp) + + assert.Equal(t, resp.Code, http.StatusInternalServerError) + assert.Equal(t, statusRsp.Error, apiErrors.ErrInvalidAppContext.Error()) +} + +func TestGetShard_FailWhenFacadeErrors(t *testing.T) { + t.Parallel() + + expectedErr := errors.New("cannot compute shard ID") + facade := mock.Facade{ + GetShardIDForAddressHandler: func(_ string) (uint32, error) { + return 0, expectedErr + }, + } + ws := startNodeServer(&facade) + + reqAddress := "test" + req, _ := http.NewRequest("GET", fmt.Sprintf("/address/%s/shard", reqAddress), nil) + resp := httptest.NewRecorder() + ws.ServeHTTP(resp, req) + + shardResponse := getShardResponse{} + loadResponse(resp.Body, &shardResponse) + + assert.Equal(t, http.StatusInternalServerError, resp.Code) + assert.True(t, strings.Contains(shardResponse.Error, expectedErr.Error())) +} + +func TestGetShard_ReturnsSuccessfully(t *testing.T) { + t.Parallel() + + expectedShardID := uint32(37) + facade := mock.Facade{ + GetShardIDForAddressHandler: func(_ string) (uint32, error) { + return expectedShardID, nil + }, + } + ws := startNodeServer(&facade) + + reqAddress := "test" + req, _ := http.NewRequest("GET", fmt.Sprintf("/address/%s/shard", reqAddress), nil) + resp := httptest.NewRecorder() + ws.ServeHTTP(resp, req) + + shardResponse := getShardResponse{} + loadResponse(resp.Body, &shardResponse) + + assert.Equal(t, http.StatusOK, resp.Code) + assert.Equal(t, shardResponse.Data.ShardID, expectedShardID) + assert.Empty(t, shardResponse.Error) +} diff --git a/api/errors/errors.go b/api/errors/errors.go index fdc36a85..78409656 100644 --- a/api/errors/errors.go +++ b/api/errors/errors.go @@ -11,6 +11,9 @@ var ErrInvalidAppContext = errors.New("invalid app context") // ErrGetValueForKey signals an error in getting the value of a key for an account var ErrGetValueForKey = errors.New("get value for key error") +// ErrComputeShardForAddress signals an error in computing the shard ID for a given address +var ErrComputeShardForAddress = errors.New("compute shard ID for address error") + // ErrEmptyAddress signals that an empty address was provided var ErrEmptyAddress = errors.New("address is empty") diff --git a/api/hyperblock/interface.go b/api/hyperblock/interface.go index a74cbf99..acf904f8 100644 --- a/api/hyperblock/interface.go +++ b/api/hyperblock/interface.go @@ -4,7 +4,8 @@ import ( "github.com/ElrondNetwork/elrond-proxy-go/data" ) -type facadeHandler interface { +// FacadeHandler defines the actions needed for fetching the hyperblocks from the nodes +type FacadeHandler interface { GetHyperBlockByNonce(nonce uint64) (*data.HyperblockApiResponse, error) GetHyperBlockByHash(hash string) (*data.HyperblockApiResponse, error) } diff --git a/api/hyperblock/routes.go b/api/hyperblock/routes.go index da5dd835..0c28275f 100644 --- a/api/hyperblock/routes.go +++ b/api/hyperblock/routes.go @@ -18,7 +18,7 @@ func Routes(router *gin.RouterGroup) { // ByHashHandler handles "by-hash" requests func ByHashHandler(c *gin.Context) { - epf, ok := c.MustGet("elrondProxyFacade").(facadeHandler) + epf, ok := c.MustGet("elrondProxyFacade").(FacadeHandler) if !ok { shared.RespondWithInvalidAppContext(c) return @@ -42,7 +42,7 @@ func ByHashHandler(c *gin.Context) { // ByNonceHandler handles "by-nonce" requests func ByNonceHandler(c *gin.Context) { - epf, ok := c.MustGet("elrondProxyFacade").(facadeHandler) + epf, ok := c.MustGet("elrondProxyFacade").(FacadeHandler) if !ok { shared.RespondWithInvalidAppContext(c) return diff --git a/api/mock/facade.go b/api/mock/facade.go index b99e4cf5..86046237 100644 --- a/api/mock/facade.go +++ b/api/mock/facade.go @@ -11,6 +11,7 @@ import ( type Facade struct { IsFaucetEnabledHandler func() bool GetAccountHandler func(address string) (*data.Account, error) + GetShardIDForAddressHandler func(address string) (uint32, error) GetValueForKeyHandler func(address string, key string) (string, error) GetTransactionsHandler func(address string) ([]data.DatabaseTransaction, error) GetTransactionHandler func(txHash string) (*data.FullTransaction, error) @@ -75,6 +76,11 @@ func (f *Facade) GetValueForKey(address string, key string) (string, error) { return f.GetValueForKeyHandler(address, key) } +// GetShardIDForAddress - +func (f *Facade) GetShardIDForAddress(address string) (uint32, error) { + return f.GetShardIDForAddressHandler(address) +} + // GetTransactions - func (f *Facade) GetTransactions(address string) ([]data.DatabaseTransaction, error) { return f.GetTransactionsHandler(address) diff --git a/facade/elrondProxyFacade.go b/facade/elrondProxyFacade.go index 8c31644c..3df80ee1 100644 --- a/facade/elrondProxyFacade.go +++ b/facade/elrondProxyFacade.go @@ -5,10 +5,30 @@ import ( "math/big" "github.com/ElrondNetwork/elrond-go/core" + "github.com/ElrondNetwork/elrond-proxy-go/api/address" + "github.com/ElrondNetwork/elrond-proxy-go/api/block" + "github.com/ElrondNetwork/elrond-proxy-go/api/blockatlas" + "github.com/ElrondNetwork/elrond-proxy-go/api/hyperblock" + "github.com/ElrondNetwork/elrond-proxy-go/api/network" + "github.com/ElrondNetwork/elrond-proxy-go/api/node" + "github.com/ElrondNetwork/elrond-proxy-go/api/transaction" + "github.com/ElrondNetwork/elrond-proxy-go/api/validator" + "github.com/ElrondNetwork/elrond-proxy-go/api/vmValues" "github.com/ElrondNetwork/elrond-proxy-go/data" vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) +// interfaces assertions. verifies that all API endpoint have their corresponding methods in the facade +var _ = address.FacadeHandler(&ElrondProxyFacade{}) +var _ = block.FacadeHandler(&ElrondProxyFacade{}) +var _ = blockatlas.FacadeHandler(&ElrondProxyFacade{}) +var _ = hyperblock.FacadeHandler(&ElrondProxyFacade{}) +var _ = network.FacadeHandler(&ElrondProxyFacade{}) +var _ = node.FacadeHandler(&ElrondProxyFacade{}) +var _ = transaction.FacadeHandler(&ElrondProxyFacade{}) +var _ = validator.FacadeHandler(&ElrondProxyFacade{}) +var _ = vmValues.FacadeHandler(&ElrondProxyFacade{}) + // ElrondProxyFacade implements the facade used in api calls type ElrondProxyFacade struct { accountProc AccountProcessor @@ -80,6 +100,11 @@ func (epf *ElrondProxyFacade) GetValueForKey(address string, key string) (string return epf.accountProc.GetValueForKey(address, key) } +// GetShardForAddress returns the computed shard ID for the given address based on the current proxy's configuration +func (epf *ElrondProxyFacade) GetShardIDForAddress(address string) (uint32, error) { + return epf.accountProc.GetShardIDForAddress(address) +} + // GetTransactions returns transactions by address func (epf *ElrondProxyFacade) GetTransactions(address string) ([]data.DatabaseTransaction, error) { return epf.accountProc.GetTransactions(address) diff --git a/facade/interface.go b/facade/interface.go index ff6a0313..0ca77d4a 100644 --- a/facade/interface.go +++ b/facade/interface.go @@ -11,6 +11,7 @@ import ( // AccountProcessor defines what an account request processor should do type AccountProcessor interface { GetAccount(address string) (*data.Account, error) + GetShardIDForAddress(address string) (uint32, error) GetValueForKey(address string, key string) (string, error) GetTransactions(address string) ([]data.DatabaseTransaction, error) } diff --git a/facade/mock/accountProccessorStub.go b/facade/mock/accountProccessorStub.go index 98a687ff..21cfa080 100644 --- a/facade/mock/accountProccessorStub.go +++ b/facade/mock/accountProccessorStub.go @@ -6,10 +6,11 @@ import ( // AccountProcessorStub -- type AccountProcessorStub struct { - GetAccountCalled func(address string) (*data.Account, error) - GetValueForKeyCalled func(address string, key string) (string, error) - GetTransactionsCalled func(address string) ([]data.DatabaseTransaction, error) - ValidatorStatisticsCalled func() (map[string]*data.ValidatorApiResponse, error) + GetAccountCalled func(address string) (*data.Account, error) + GetValueForKeyCalled func(address string, key string) (string, error) + GetShardIDForAddressCalled func(address string) (uint32, error) + GetTransactionsCalled func(address string) ([]data.DatabaseTransaction, error) + ValidatorStatisticsCalled func() (map[string]*data.ValidatorApiResponse, error) } // GetAccount -- @@ -22,6 +23,11 @@ func (aps *AccountProcessorStub) GetValueForKey(address string, key string) (str return aps.GetValueForKeyCalled(address, key) } +// GetShardIDForAddress -- +func (aps *AccountProcessorStub) GetShardIDForAddress(address string) (uint32, error) { + return aps.GetShardIDForAddressCalled(address) +} + // GetTransactions -- func (aps *AccountProcessorStub) GetTransactions(address string) ([]data.DatabaseTransaction, error) { return aps.GetTransactionsCalled(address) diff --git a/process/accountProcessor.go b/process/accountProcessor.go index 56914985..8c91b100 100644 --- a/process/accountProcessor.go +++ b/process/accountProcessor.go @@ -38,6 +38,16 @@ func NewAccountProcessor(proc Processor, pubKeyConverter core.PubkeyConverter, c }, nil } +// GetShardForAddress resolves the request by returning the shard ID for a given address for the current proxy's configuration +func (ap *AccountProcessor) GetShardIDForAddress(address string) (uint32, error) { + addressBytes, err := ap.pubKeyConverter.Decode(address) + if err != nil { + return 0, err + } + + return ap.proc.ComputeShardId(addressBytes) +} + // GetAccount resolves the request by sending the request to the right observer and replies back the answer func (ap *AccountProcessor) GetAccount(address string) (*data.Account, error) { observers, err := ap.getObserversForAddress(address) From 93f7d96cefc62a93792d6a94f2003a99fd8073c6 Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Thu, 3 Sep 2020 12:16:03 +0300 Subject: [PATCH 2/6] EN-7522: fix after review --- facade/elrondProxyFacade.go | 20 ++++----- process/accountProcessor.go | 2 +- process/accountProcessor_test.go | 74 ++++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 14 deletions(-) diff --git a/facade/elrondProxyFacade.go b/facade/elrondProxyFacade.go index 3df80ee1..f3ec7eca 100644 --- a/facade/elrondProxyFacade.go +++ b/facade/elrondProxyFacade.go @@ -19,15 +19,15 @@ import ( ) // interfaces assertions. verifies that all API endpoint have their corresponding methods in the facade -var _ = address.FacadeHandler(&ElrondProxyFacade{}) -var _ = block.FacadeHandler(&ElrondProxyFacade{}) -var _ = blockatlas.FacadeHandler(&ElrondProxyFacade{}) -var _ = hyperblock.FacadeHandler(&ElrondProxyFacade{}) -var _ = network.FacadeHandler(&ElrondProxyFacade{}) -var _ = node.FacadeHandler(&ElrondProxyFacade{}) -var _ = transaction.FacadeHandler(&ElrondProxyFacade{}) -var _ = validator.FacadeHandler(&ElrondProxyFacade{}) -var _ = vmValues.FacadeHandler(&ElrondProxyFacade{}) +var _ address.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ block.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ blockatlas.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ hyperblock.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ network.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ node.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ transaction.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ validator.FacadeHandler = (*ElrondProxyFacade)(nil) +var _ vmValues.FacadeHandler = (*ElrondProxyFacade)(nil) // ElrondProxyFacade implements the facade used in api calls type ElrondProxyFacade struct { @@ -100,7 +100,7 @@ func (epf *ElrondProxyFacade) GetValueForKey(address string, key string) (string return epf.accountProc.GetValueForKey(address, key) } -// GetShardForAddress returns the computed shard ID for the given address based on the current proxy's configuration +// GetShardIDForAddress returns the computed shard ID for the given address based on the current proxy's configuration func (epf *ElrondProxyFacade) GetShardIDForAddress(address string) (uint32, error) { return epf.accountProc.GetShardIDForAddress(address) } diff --git a/process/accountProcessor.go b/process/accountProcessor.go index 8c91b100..7917fd79 100644 --- a/process/accountProcessor.go +++ b/process/accountProcessor.go @@ -38,7 +38,7 @@ func NewAccountProcessor(proc Processor, pubKeyConverter core.PubkeyConverter, c }, nil } -// GetShardForAddress resolves the request by returning the shard ID for a given address for the current proxy's configuration +// GetShardIDForAddress resolves the request by returning the shard ID for a given address for the current proxy's configuration func (ap *AccountProcessor) GetShardIDForAddress(address string) (uint32, error) { addressBytes, err := ap.pubKeyConverter.Decode(address) if err != nil { diff --git a/process/accountProcessor_test.go b/process/accountProcessor_test.go index c8fd4abd..bf9c6916 100644 --- a/process/accountProcessor_test.go +++ b/process/accountProcessor_test.go @@ -4,11 +4,14 @@ import ( "errors" "testing" + "github.com/ElrondNetwork/elrond-go/core/pubkeyConverter" + "github.com/ElrondNetwork/elrond-go/sharding" "github.com/ElrondNetwork/elrond-proxy-go/data" "github.com/ElrondNetwork/elrond-proxy-go/process" "github.com/ElrondNetwork/elrond-proxy-go/process/database" "github.com/ElrondNetwork/elrond-proxy-go/process/mock" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestNewAccountProcessor_NilCoreProcessorShouldErr(t *testing.T) { @@ -40,7 +43,7 @@ func TestNewAccountProcessor_WithCoreProcessorShouldWork(t *testing.T) { //------- GetAccount -func TestAccountProcessor_GetAccountInvalidHexAdressShouldErr(t *testing.T) { +func TestAccountProcessor_GetAccountInvalidHexAddressShouldErr(t *testing.T) { t.Parallel() ap, _ := process.NewAccountProcessor(&mock.ProcessorStub{}, &mock.PubKeyConverterMock{}, database.NewDisabledElasticSearchConnector()) @@ -164,7 +167,7 @@ func TestAccountProcessor_GetAccountSendingFailsOnFirstObserverShouldStillSend(t assert.Nil(t, err) } -func TestAccountProcessor_GetValueForAKeyShoudWork(t *testing.T) { +func TestAccountProcessor_GetValueForAKeyShouldWork(t *testing.T) { t.Parallel() expectedValue := "dummyValue" @@ -195,7 +198,72 @@ func TestAccountProcessor_GetValueForAKeyShoudWork(t *testing.T) { assert.Equal(t, expectedValue, value) } -func TestAccountProcessor_GetValueForAKeyShoudError(t *testing.T) { +func TestAccountProcessor_GetValueForAKeyShouldError(t *testing.T) { + t.Parallel() + + expectedError := errors.New("err") + ap, _ := process.NewAccountProcessor( + &mock.ProcessorStub{ + ComputeShardIdCalled: func(addressBuff []byte) (u uint32, e error) { + return 0, nil + }, + GetObserversCalled: func(shardId uint32) (observers []*data.NodeData, e error) { + return []*data.NodeData{ + {Address: "address", ShardId: 0}, + }, nil + }, + CallGetRestEndPointCalled: func(address string, path string, value interface{}) (int, error) { + return 0, expectedError + }, + }, + &mock.PubKeyConverterMock{}, + database.NewDisabledElasticSearchConnector(), + ) + + key := "key" + addr1 := "DEADBEEF" + value, err := ap.GetValueForKey(addr1, key) + assert.Equal(t, "", value) + assert.Equal(t, process.ErrSendingRequest, err) +} + +func TestAccountProcessor_GetShardIForAddressShouldWork(t *testing.T) { + t.Parallel() + + shardC, err := sharding.NewMultiShardCoordinator(uint32(2), 0) + require.NoError(t, err) + + bech32C, _ := pubkeyConverter.NewBech32PubkeyConverter(32) + + // this addressShard0 should be in shard 0 for a 2 shards configuration + addressShard0 := "erd1ffqlrryvwrnfh2523wmzrhvx5d8p2wmxeau64fps4lnqq5qex68q7ax8k5" + + // this addressShard1 should be in shard 1 for a 2 shards configuration + addressShard1 := "erd1qqe9qll7n66lv4cuuml2wxsv3sd2t0eyajkyjr7rvtqmhha0cgsse4pel3" + + ap, _ := process.NewAccountProcessor( + &mock.ProcessorStub{ + ComputeShardIdCalled: func(addressBuff []byte) (u uint32, e error) { + return shardC.ComputeId(addressBuff), nil + }, + GetObserversCalled: func(shardId uint32) (observers []*data.NodeData, e error) { + return observers, nil + }, + }, + bech32C, + database.NewDisabledElasticSearchConnector(), + ) + + shardID, err := ap.GetShardIDForAddress(addressShard1) + assert.Nil(t, err) + assert.Equal(t, uint32(1), shardID) + + shardID, err = ap.GetShardIDForAddress(addressShard0) + assert.Nil(t, err) + assert.Equal(t, uint32(0), shardID) +} + +func TestAccountProcessor_GetShardIDForAddressShouldError(t *testing.T) { t.Parallel() expectedError := errors.New("err") From 10d6608ffe43bb2e8c90800b90bc2cdcb7b20a3f Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Thu, 3 Sep 2020 12:59:00 +0300 Subject: [PATCH 3/6] EN-7522: fix unit test --- process/accountProcessor_test.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/process/accountProcessor_test.go b/process/accountProcessor_test.go index bf9c6916..5c98f4e3 100644 --- a/process/accountProcessor_test.go +++ b/process/accountProcessor_test.go @@ -270,14 +270,6 @@ func TestAccountProcessor_GetShardIDForAddressShouldError(t *testing.T) { ap, _ := process.NewAccountProcessor( &mock.ProcessorStub{ ComputeShardIdCalled: func(addressBuff []byte) (u uint32, e error) { - return 0, nil - }, - GetObserversCalled: func(shardId uint32) (observers []*data.NodeData, e error) { - return []*data.NodeData{ - {Address: "address", ShardId: 0}, - }, nil - }, - CallGetRestEndPointCalled: func(address string, path string, value interface{}) (int, error) { return 0, expectedError }, }, @@ -285,9 +277,7 @@ func TestAccountProcessor_GetShardIDForAddressShouldError(t *testing.T) { database.NewDisabledElasticSearchConnector(), ) - key := "key" - addr1 := "DEADBEEF" - value, err := ap.GetValueForKey(addr1, key) - assert.Equal(t, "", value) - assert.Equal(t, process.ErrSendingRequest, err) + shardID, err := ap.GetShardIDForAddress("aaaa") + assert.Equal(t, uint32(0), shardID) + assert.Equal(t, expectedError, err) } From 9cfdb1d2158b83b07c8d699f7dcc9fbea7e7df1a Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Mon, 14 Sep 2020 13:35:07 +0300 Subject: [PATCH 4/6] added nonce and num instances fields on heartbeat --- data/nodeStatus.go | 2 ++ facade/elrondProxyFacade_test.go | 27 +++++++++++++++++++++++++++ testing/testHttpServer.go | 2 ++ 3 files changed, 31 insertions(+) diff --git a/data/nodeStatus.go b/data/nodeStatus.go index a28115fb..35ad5eb8 100644 --- a/data/nodeStatus.go +++ b/data/nodeStatus.go @@ -28,6 +28,8 @@ type PubKeyHeartbeat struct { ComputedShardID uint32 `json:"computedShardID"` PeerType string `json:"peerType"` IsActive bool `json:"isActive"` + Nonce uint64 `json:"nonce"` + NumInstances uint64 `json:"numInstances"` } // StatusResponse represents the status received when trying to find an online node diff --git a/facade/elrondProxyFacade_test.go b/facade/elrondProxyFacade_test.go index 04b68e2d..8ba89640 100644 --- a/facade/elrondProxyFacade_test.go +++ b/facade/elrondProxyFacade_test.go @@ -1,6 +1,8 @@ package facade_test import ( + "encoding/json" + "fmt" "math/big" "testing" @@ -13,6 +15,7 @@ import ( "github.com/ElrondNetwork/elrond-proxy-go/facade/mock" vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestNewElrondProxyFacade_NilAccountProcShouldErr(t *testing.T) { @@ -346,3 +349,27 @@ func getPrivKey() crypto.PrivateKey { return sk } + +type ccc struct { + C string +} + +type abc struct { + A string + B int + C ccc +} + +func TestJsonWrapped(t *testing.T) { + xxx := ccc{C: "555"} + xB, _ := json.Marshal(xxx) + aaaa := abc{ + A: string(xB), + B: 45, + C: ccc{C: "11111"}, + } + + ab, err := json.Marshal(aaaa) + require.NoError(t, err) + fmt.Print(string(ab)) +} diff --git a/testing/testHttpServer.go b/testing/testHttpServer.go index 9134175c..b16118fd 100644 --- a/testing/testHttpServer.go +++ b/testing/testHttpServer.go @@ -339,6 +339,8 @@ func getDummyHeartbeats() []data.PubKeyHeartbeat { PeerType: peerTypes[randPeerTypeIdx.Int64()], NodeDisplayName: fmt.Sprintf("DisplayName%d", i), Identity: fmt.Sprintf("Identity%d", i), + Nonce: uint64(i), + NumInstances: 1, }) } From 541c34b353a20bccea7d83158b38e4cc4740b214 Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Mon, 14 Sep 2020 13:37:35 +0300 Subject: [PATCH 5/6] undo test committed by mistake --- facade/elrondProxyFacade_test.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/facade/elrondProxyFacade_test.go b/facade/elrondProxyFacade_test.go index 8ba89640..04b68e2d 100644 --- a/facade/elrondProxyFacade_test.go +++ b/facade/elrondProxyFacade_test.go @@ -1,8 +1,6 @@ package facade_test import ( - "encoding/json" - "fmt" "math/big" "testing" @@ -15,7 +13,6 @@ import ( "github.com/ElrondNetwork/elrond-proxy-go/facade/mock" vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestNewElrondProxyFacade_NilAccountProcShouldErr(t *testing.T) { @@ -349,27 +346,3 @@ func getPrivKey() crypto.PrivateKey { return sk } - -type ccc struct { - C string -} - -type abc struct { - A string - B int - C ccc -} - -func TestJsonWrapped(t *testing.T) { - xxx := ccc{C: "555"} - xB, _ := json.Marshal(xxx) - aaaa := abc{ - A: string(xB), - B: 45, - C: ccc{C: "11111"}, - } - - ab, err := json.Marshal(aaaa) - require.NoError(t, err) - fmt.Print(string(ab)) -} From 06e90acf3179e79226abaaa28b85e90c4633e8d7 Mon Sep 17 00:00:00 2001 From: bogdan-rosianu Date: Mon, 14 Sep 2020 17:49:17 +0300 Subject: [PATCH 6/6] wrapped VM Output for API responses --- api/mock/facade.go | 6 ++-- api/vmValues/interface.go | 4 +-- api/vmValues/routes.go | 3 +- api/vmValues/routes_test.go | 34 +++++++++++----------- data/vmValues.go | 4 +-- facade/elrondProxyFacade.go | 4 +-- facade/elrondProxyFacade_test.go | 6 ++-- facade/interface.go | 4 +-- facade/mock/scQueryServiceStub.go | 6 ++-- go.mod | 2 +- go.sum | 40 ++++++++++++++++++++++---- process/disabled/epochStartNotifier.go | 27 +++++++++++++++++ process/faucetProcessor.go | 8 +++++- process/scQueryProcessor.go | 4 +-- process/scQueryProcessor_test.go | 4 +-- testing/testHttpServer.go | 4 +-- 16 files changed, 112 insertions(+), 48 deletions(-) create mode 100644 process/disabled/epochStartNotifier.go diff --git a/api/mock/facade.go b/api/mock/facade.go index 86046237..13db3bbc 100644 --- a/api/mock/facade.go +++ b/api/mock/facade.go @@ -3,8 +3,8 @@ package mock import ( "math/big" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // Facade is the mock implementation of a node's router handler @@ -19,7 +19,7 @@ type Facade struct { SendMultipleTransactionsHandler func(txs []*data.Transaction) (data.MultipleTransactionsResponseData, error) SimulateTransactionHandler func(tx *data.Transaction) (*data.ResponseTransactionSimulation, error) SendUserFundsCalled func(receiver string, value *big.Int) error - ExecuteSCQueryHandler func(query *data.SCQuery) (*vmcommon.VMOutput, error) + ExecuteSCQueryHandler func(query *data.SCQuery) (*vm.VMOutputApi, error) GetHeartbeatDataHandler func() (*data.HeartbeatResponse, error) ValidatorStatisticsHandler func() (map[string]*data.ValidatorApiResponse, error) TransactionCostRequestHandler func(tx *data.Transaction) (string, error) @@ -127,7 +127,7 @@ func (f *Facade) SendUserFunds(receiver string, value *big.Int) error { } // ExecuteSCQuery - -func (f *Facade) ExecuteSCQuery(query *data.SCQuery) (*vmcommon.VMOutput, error) { +func (f *Facade) ExecuteSCQuery(query *data.SCQuery) (*vm.VMOutputApi, error) { return f.ExecuteSCQueryHandler(query) } diff --git a/api/vmValues/interface.go b/api/vmValues/interface.go index e62691ee..0ec4e842 100644 --- a/api/vmValues/interface.go +++ b/api/vmValues/interface.go @@ -1,11 +1,11 @@ package vmValues import ( + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // FacadeHandler interface defines methods that can be used from `elrondFacade` context variable type FacadeHandler interface { - ExecuteSCQuery(*data.SCQuery) (*vmcommon.VMOutput, error) + ExecuteSCQuery(*data.SCQuery) (*vm.VMOutputApi, error) } diff --git a/api/vmValues/routes.go b/api/vmValues/routes.go index b187183b..7cf37d0d 100644 --- a/api/vmValues/routes.go +++ b/api/vmValues/routes.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" + "github.com/ElrondNetwork/elrond-go/data/vm" apiErrors "github.com/ElrondNetwork/elrond-proxy-go/api/errors" "github.com/ElrondNetwork/elrond-proxy-go/api/shared" "github.com/ElrondNetwork/elrond-proxy-go/data" @@ -72,7 +73,7 @@ func executeQuery(context *gin.Context) { returnOkResponse(context, vmOutput) } -func doExecuteQuery(context *gin.Context) (*vmcommon.VMOutput, error) { +func doExecuteQuery(context *gin.Context) (*vm.VMOutputApi, error) { facade, ok := context.MustGet("elrondProxyFacade").(FacadeHandler) if !ok { return nil, apiErrors.ErrInvalidAppContext diff --git a/api/vmValues/routes_test.go b/api/vmValues/routes_test.go index b5d65450..a70fd009 100644 --- a/api/vmValues/routes_test.go +++ b/api/vmValues/routes_test.go @@ -12,10 +12,10 @@ import ( "net/http/httptest" "testing" + "github.com/ElrondNetwork/elrond-go/data/vm" apiErrors "github.com/ElrondNetwork/elrond-proxy-go/api/errors" "github.com/ElrondNetwork/elrond-proxy-go/api/mock" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/stretchr/testify/require" @@ -31,7 +31,7 @@ type simpleResponse struct { } type vmOutputResponse struct { - Data *vmcommon.VMOutput `json:"data"` + Data *vm.VMOutputApi `json:"data"` } type vmOutputGenericResponse struct { @@ -51,8 +51,8 @@ func TestGetHex_ShouldWork(t *testing.T) { valueBuff, _ := hex.DecodeString("DEADBEEF") facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { - return &vmcommon.VMOutput{ + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { + return &vm.VMOutputApi{ ReturnData: [][]byte{valueBuff}, }, nil }, @@ -78,8 +78,8 @@ func TestGetString_ShouldWork(t *testing.T) { valueBuff := "DEADBEEF" facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { - return &vmcommon.VMOutput{ + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { + return &vm.VMOutputApi{ ReturnData: [][]byte{[]byte(valueBuff)}, }, nil }, @@ -105,10 +105,10 @@ func TestGetInt_ShouldWork(t *testing.T) { value := "1234567" facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { returnData := big.NewInt(0) returnData.SetString(value, 10) - return &vmcommon.VMOutput{ + return &vm.VMOutputApi{ ReturnData: [][]byte{returnData.Bytes()}, }, nil }, @@ -132,9 +132,9 @@ func TestQuery_ShouldWork(t *testing.T) { t.Parallel() facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { - return &vmcommon.VMOutput{ + return &vm.VMOutputApi{ ReturnData: [][]byte{big.NewInt(42).Bytes()}, }, nil }, @@ -171,7 +171,7 @@ func TestAllRoutes_FacadeErrorsShouldErr(t *testing.T) { errExpected := errors.New("some random error") facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { return nil, errExpected }, } @@ -190,8 +190,8 @@ func TestAllRoutes_WhenBadArgumentsShouldErr(t *testing.T) { errExpected := errors.New("not a valid hex string") facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { - return &vmcommon.VMOutput{}, nil + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { + return &vm.VMOutputApi{}, nil }, } @@ -209,8 +209,8 @@ func TestAllRoutes_WhenNoVMReturnDataShouldErr(t *testing.T) { errExpected := errors.New("no return data") facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { - return &vmcommon.VMOutput{}, nil + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { + return &vm.VMOutputApi{}, nil }, } @@ -227,8 +227,8 @@ func TestAllRoutes_WhenBadJsonShouldErr(t *testing.T) { t.Parallel() facade := mock.Facade{ - ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vmcommon.VMOutput, e error) { - return &vmcommon.VMOutput{}, nil + ExecuteSCQueryHandler: func(query *data.SCQuery) (vmOutput *vm.VMOutputApi, e error) { + return &vm.VMOutputApi{}, nil }, } diff --git a/data/vmValues.go b/data/vmValues.go index bce9fac4..a598479d 100644 --- a/data/vmValues.go +++ b/data/vmValues.go @@ -1,12 +1,12 @@ package data import ( - vmcommon "github.com/ElrondNetwork/elrond-vm-common" + "github.com/ElrondNetwork/elrond-go/data/vm" ) // VmValuesResponseData follows the format of the data field in an API response for a VM values query type VmValuesResponseData struct { - Data *vmcommon.VMOutput `json:"data"` + Data *vm.VMOutputApi `json:"data"` } // ResponseVmValue defines a wrapper over string containing returned data in hex format diff --git a/facade/elrondProxyFacade.go b/facade/elrondProxyFacade.go index f3ec7eca..420730b8 100644 --- a/facade/elrondProxyFacade.go +++ b/facade/elrondProxyFacade.go @@ -5,6 +5,7 @@ import ( "math/big" "github.com/ElrondNetwork/elrond-go/core" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/api/address" "github.com/ElrondNetwork/elrond-proxy-go/api/block" "github.com/ElrondNetwork/elrond-proxy-go/api/blockatlas" @@ -15,7 +16,6 @@ import ( "github.com/ElrondNetwork/elrond-proxy-go/api/validator" "github.com/ElrondNetwork/elrond-proxy-go/api/vmValues" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // interfaces assertions. verifies that all API endpoint have their corresponding methods in the facade @@ -217,7 +217,7 @@ func (epf *ElrondProxyFacade) getNetworkConfig() (*networkConfig, error) { } // ExecuteSCQuery retrieves data from existing SC trie through the use of a VM -func (epf *ElrondProxyFacade) ExecuteSCQuery(query *data.SCQuery) (*vmcommon.VMOutput, error) { +func (epf *ElrondProxyFacade) ExecuteSCQuery(query *data.SCQuery) (*vm.VMOutputApi, error) { return epf.scQueryService.ExecuteQuery(query) } diff --git a/facade/elrondProxyFacade_test.go b/facade/elrondProxyFacade_test.go index 04b68e2d..d58fdb41 100644 --- a/facade/elrondProxyFacade_test.go +++ b/facade/elrondProxyFacade_test.go @@ -8,10 +8,10 @@ import ( "github.com/ElrondNetwork/elrond-go/crypto" "github.com/ElrondNetwork/elrond-go/crypto/signing" "github.com/ElrondNetwork/elrond-go/crypto/signing/ed25519" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" "github.com/ElrondNetwork/elrond-proxy-go/facade" "github.com/ElrondNetwork/elrond-proxy-go/facade/mock" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/stretchr/testify/assert" ) @@ -292,9 +292,9 @@ func TestElrondProxyFacade_GetDataValue(t *testing.T) { &mock.AccountProcessorStub{}, &mock.TransactionProcessorStub{}, &mock.SCQueryServiceStub{ - ExecuteQueryCalled: func(query *data.SCQuery) (*vmcommon.VMOutput, error) { + ExecuteQueryCalled: func(query *data.SCQuery) (*vm.VMOutputApi, error) { wasCalled = true - return &vmcommon.VMOutput{}, nil + return &vm.VMOutputApi{}, nil }, }, &mock.HeartbeatProcessorStub{}, diff --git a/facade/interface.go b/facade/interface.go index 0ca77d4a..4a9fa122 100644 --- a/facade/interface.go +++ b/facade/interface.go @@ -4,8 +4,8 @@ import ( "math/big" "github.com/ElrondNetwork/elrond-go/crypto" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // AccountProcessor defines what an account request processor should do @@ -29,7 +29,7 @@ type TransactionProcessor interface { // SCQueryService defines how data should be get from a SC account type SCQueryService interface { - ExecuteQuery(query *data.SCQuery) (*vmcommon.VMOutput, error) + ExecuteQuery(query *data.SCQuery) (*vm.VMOutputApi, error) } // HeartbeatProcessor defines what a heartbeat processor should do diff --git a/facade/mock/scQueryServiceStub.go b/facade/mock/scQueryServiceStub.go index 59aa0284..06bc43b6 100644 --- a/facade/mock/scQueryServiceStub.go +++ b/facade/mock/scQueryServiceStub.go @@ -1,16 +1,16 @@ package mock import ( + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // SCQueryServiceStub is a stub type SCQueryServiceStub struct { - ExecuteQueryCalled func(*data.SCQuery) (*vmcommon.VMOutput, error) + ExecuteQueryCalled func(*data.SCQuery) (*vm.VMOutputApi, error) } // ExecuteQuery is a stub -func (serviceStub *SCQueryServiceStub) ExecuteQuery(query *data.SCQuery) (*vmcommon.VMOutput, error) { +func (serviceStub *SCQueryServiceStub) ExecuteQuery(query *data.SCQuery) (*vm.VMOutputApi, error) { return serviceStub.ExecuteQueryCalled(query) } diff --git a/go.mod b/go.mod index 118f76fb..c5b23a5c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ElrondNetwork/elrond-proxy-go go 1.12 require ( - github.com/ElrondNetwork/elrond-go v1.1.1-0.20200829111037-5899c01e3eec + github.com/ElrondNetwork/elrond-go v1.1.1-0.20200914111912-d1792d662b8f github.com/ElrondNetwork/elrond-go-logger v1.0.4 github.com/ElrondNetwork/elrond-vm-common v0.1.23 github.com/elastic/go-elasticsearch/v7 v7.1.0 diff --git a/go.sum b/go.sum index 3db1cf53..7a7f3540 100644 --- a/go.sum +++ b/go.sum @@ -9,25 +9,31 @@ dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/ElrondNetwork/arwen-wasm-vm v0.3.34/go.mod h1:3p2nYvGvciEhB1xRmVd7HLWHqX8pjjUigxVLIRVAmFc= -github.com/ElrondNetwork/big-int-util v0.0.5/go.mod h1:96viBvoTXLjZOhEvE0D+QnAwg1IJLPAK6GVHMbC7Aw4= +github.com/ElrondNetwork/arwen-wasm-vm v0.3.35 h1:VVRqYmITw80soVUR3oayQWZPt8N7yNxbED/g6DEIFqw= +github.com/ElrondNetwork/arwen-wasm-vm v0.3.35/go.mod h1:Ph31oyKl4TQv4hqqPe3XENkccUu2IRgp+7ww91SF/zg= +github.com/ElrondNetwork/big-int-util v0.1.0 h1:vTMoJ5azhVmr7jhpSD3JUjQdkdyXoEPVkOvhdw1RjV4= +github.com/ElrondNetwork/big-int-util v0.1.0/go.mod h1:96viBvoTXLjZOhEvE0D+QnAwg1IJLPAK6GVHMbC7Aw4= +github.com/ElrondNetwork/concurrent-map v0.1.3 h1:j2LtPrNJuerannC1cQDE79STvi/P04gd61sNYo04Zf0= github.com/ElrondNetwork/concurrent-map v0.1.3/go.mod h1:3XwSwn4JHI0lrKxWLZvtp53Emr8BXYTmNQGwcukHJEE= -github.com/ElrondNetwork/elrond-go v1.1.1-0.20200829111037-5899c01e3eec h1:shuU5LeSiqrBXO4jjLQwUMZ2yF7htnANjoN1+gKoflQ= -github.com/ElrondNetwork/elrond-go v1.1.1-0.20200829111037-5899c01e3eec/go.mod h1:iyPZQLaizbpIHb38+DWH+pTsjWlwRqNj1r56ay4Zd3w= +github.com/ElrondNetwork/elrond-go v1.1.1-0.20200914111912-d1792d662b8f h1:MLakjh6ZX09+b7Tc/SkfhR67INImTyPMEtR9e/tUxSM= +github.com/ElrondNetwork/elrond-go v1.1.1-0.20200914111912-d1792d662b8f/go.mod h1:7JZz4Jad6LpHgOBmm1ChLgf2QRxa8yVQZc9RDDLQZpU= github.com/ElrondNetwork/elrond-go-logger v1.0.2/go.mod h1:e5D+c97lKUfFdAzFX7rrI2Igl/z4Y0RkKYKWyzprTGk= github.com/ElrondNetwork/elrond-go-logger v1.0.4 h1:i5Yu4qyjTZDwvBY/ykbNpp2SP9jxwk/QTivRwSZSTAQ= github.com/ElrondNetwork/elrond-go-logger v1.0.4/go.mod h1:e5D+c97lKUfFdAzFX7rrI2Igl/z4Y0RkKYKWyzprTGk= github.com/ElrondNetwork/elrond-vm-common v0.1.23 h1:4tIzzVdpAI8FonCA1BrbNb+3lukKoyHUaoSOAZWvYnY= github.com/ElrondNetwork/elrond-vm-common v0.1.23/go.mod h1:ZakxPST/Wt8umnRtA9gobcy3Dw2bywxwkC54P5VhO9g= -github.com/ElrondNetwork/elrond-vm-util v0.3.6/go.mod h1:+ecDJZLTwN/yeRXXEqd+sa9WoalLsT4nFtQWCo0YKWA= +github.com/ElrondNetwork/elrond-vm-util v0.4.0/go.mod h1:L/IHojCXiYSd73/5oCJTsBRPwFY7UfR0E2f+o4ztjH8= github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beevik/ntp v0.2.0 h1:sGsd+kAXzT0bfVfzJfce04g+dSRfrs+tbQW8lweuYgw= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/benbjohnson/clock v1.0.2/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= @@ -78,6 +84,7 @@ github.com/elastic/go-elasticsearch/v7 v7.1.0 h1:BLm6CaiURXtycMTHpnJrx/zfoGbztMQ github.com/elastic/go-elasticsearch/v7 v7.1.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/cors v0.0.0-20190301062745-f9e10995c85a h1:zBycVvXa03SIX+jdMv8wGu9TMDMWdN8EhaR1FoeKHNo= @@ -94,7 +101,9 @@ github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmy github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -125,11 +134,13 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= @@ -154,6 +165,7 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/herumi/bls-go-binary v0.0.0-20200324054641-17de9ae04665/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y= @@ -212,6 +224,7 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0= @@ -225,9 +238,11 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= @@ -404,10 +419,13 @@ github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1 github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= @@ -456,17 +474,20 @@ github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXS github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -495,6 +516,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984 h1:wsZAb4P8F7uQSwsnxE1gk9AHCcc5U0wvyDzcLwFY0Eo= github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc= +github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= @@ -545,6 +567,7 @@ github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= @@ -601,6 +624,7 @@ golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -626,6 +650,7 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200519113804-d87ec0cfa476 h1:E7ct1C6/33eOdrGZKMoyntcEvs2dwZnDe30crG5vpYU= golang.org/x/net v0.0.0-20200519113804-d87ec0cfa476/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -666,6 +691,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -686,6 +712,7 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -715,15 +742,18 @@ google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyz google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8= gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/process/disabled/epochStartNotifier.go b/process/disabled/epochStartNotifier.go new file mode 100644 index 00000000..7a4d4ff7 --- /dev/null +++ b/process/disabled/epochStartNotifier.go @@ -0,0 +1,27 @@ +package disabled + +import ( + "github.com/ElrondNetwork/elrond-go/core" +) + +// EpochStartNotifier represents a disabled struct that implements the EpochStartNotifier interface +type EpochStartNotifier struct { +} + +// RegisterNotifyHandler won't do anything as this is a disabled component +func (e *EpochStartNotifier) RegisterNotifyHandler(_ core.EpochSubscriberHandler) { +} + +// CurrentEpoch returns 0 as this is a disabled component +func (e *EpochStartNotifier) CurrentEpoch() uint32 { + return 0 +} + +// CheckEpoch won't do anything as this a disabled component +func (e *EpochStartNotifier) CheckEpoch(_ uint32) { +} + +// IsInterfaceNil returns true if there is no value under the interface +func (e *EpochStartNotifier) IsInterfaceNil() bool { + return e == nil +} diff --git a/process/faucetProcessor.go b/process/faucetProcessor.go index 844a38a1..16769e0d 100644 --- a/process/faucetProcessor.go +++ b/process/faucetProcessor.go @@ -16,6 +16,7 @@ import ( "github.com/ElrondNetwork/elrond-go/process" "github.com/ElrondNetwork/elrond-go/process/economics" "github.com/ElrondNetwork/elrond-proxy-go/data" + "github.com/ElrondNetwork/elrond-proxy-go/process/disabled" ) func getSingleSigner() crypto.SingleSigner { @@ -208,7 +209,12 @@ func (fp *FaucetProcessor) getPrivKeyFromShard(shardID uint32) (crypto.PrivateKe } func parseEconomicsConfig(ecConf *erdConfig.EconomicsConfig) (process.FeeHandler, uint64, error) { - econData, err := economics.NewEconomicsData(ecConf) + argsNewEconomics := economics.ArgsNewEconomicsData{ + Economics: ecConf, + PenalizedTooMuchGasEnableEpoch: 0, + EpochNotifier: &disabled.EpochStartNotifier{}, + } + econData, err := economics.NewEconomicsData(argsNewEconomics) if err != nil { return nil, 0, err } diff --git a/process/scQueryProcessor.go b/process/scQueryProcessor.go index 5bbf2ffd..e614b404 100644 --- a/process/scQueryProcessor.go +++ b/process/scQueryProcessor.go @@ -7,8 +7,8 @@ import ( "github.com/ElrondNetwork/elrond-go/core" "github.com/ElrondNetwork/elrond-go/core/check" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" ) // SCQueryServicePath defines the get values path at which the nodes answer @@ -36,7 +36,7 @@ func NewSCQueryProcessor(proc Processor, pubKeyConverter core.PubkeyConverter) ( } // ExecuteQuery resolves the request by sending the request to the right observer and replies back the answer -func (scQueryProcessor *SCQueryProcessor) ExecuteQuery(query *data.SCQuery) (*vmcommon.VMOutput, error) { +func (scQueryProcessor *SCQueryProcessor) ExecuteQuery(query *data.SCQuery) (*vm.VMOutputApi, error) { addressBytes, err := scQueryProcessor.pubKeyConverter.Decode(query.ScAddress) if err != nil { return nil, err diff --git a/process/scQueryProcessor_test.go b/process/scQueryProcessor_test.go index 48387232..27745ca4 100644 --- a/process/scQueryProcessor_test.go +++ b/process/scQueryProcessor_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/ElrondNetwork/elrond-go/core/pubkeyConverter" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" "github.com/ElrondNetwork/elrond-proxy-go/process/mock" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/stretchr/testify/require" ) @@ -109,7 +109,7 @@ func TestSCQueryProcessor_ExecuteQuery(t *testing.T) { }, nil }, CallPostRestEndPointCalled: func(address string, path string, dataValue interface{}, response interface{}) (int, error) { - response.(*data.ResponseVmValue).Data.Data = &vmcommon.VMOutput{ + response.(*data.ResponseVmValue).Data.Data = &vm.VMOutputApi{ ReturnData: [][]byte{{42}}, } diff --git a/testing/testHttpServer.go b/testing/testHttpServer.go index 9134175c..4a1ed468 100644 --- a/testing/testHttpServer.go +++ b/testing/testHttpServer.go @@ -19,8 +19,8 @@ import ( "github.com/ElrondNetwork/elrond-go/api/block" "github.com/ElrondNetwork/elrond-go/core" "github.com/ElrondNetwork/elrond-go/data/transaction" + "github.com/ElrondNetwork/elrond-go/data/vm" "github.com/ElrondNetwork/elrond-proxy-go/data" - vmcommon "github.com/ElrondNetwork/elrond-vm-common" "github.com/gin-gonic/gin" ) @@ -296,7 +296,7 @@ func (ths *TestHttpServer) processRequestSendFunds(rw http.ResponseWriter, _ *ht func (ths *TestHttpServer) processRequestVmValue(rw http.ResponseWriter, _ *http.Request) { response := data.ResponseVmValue{ - Data: data.VmValuesResponseData{Data: &vmcommon.VMOutput{}}, + Data: data.VmValuesResponseData{Data: &vm.VMOutputApi{}}, } resp := data.GenericAPIResponse{Data: response, Code: data.ReturnCodeSuccess} responseBuff, _ := json.Marshal(resp)