Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc/v1.7.0 #408

Merged
merged 70 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
171d311
FEAT: Add AuctionList api interfaces
mariusmihaic Feb 17, 2023
df49f98
FEAT: Get AuctionList from observers without cache
mariusmihaic Feb 17, 2023
a9c1d33
FEAT: Full branch coverage unit tests in validatorAuctionProcessor_te…
mariusmihaic Feb 20, 2023
3bf3d1a
FEAT: Unit tests for baseValidatorGroup.go
mariusmihaic Feb 20, 2023
c25e372
FIX: Remove todo
mariusmihaic Feb 20, 2023
309deee
FIX: After review
mariusmihaic Feb 21, 2023
5f5466b
Merge pull request #371 from multiversx/MX-13877-auction-list-api
mariusmihaic Feb 21, 2023
b094897
added support for new endpoint /node/waiting-epochs-left/:key
sstanculeanu Nov 16, 2023
4a34b5f
fix path
sstanculeanu Nov 16, 2023
8aef7db
fix after review, added extra check
sstanculeanu Nov 20, 2023
f6dea6f
improved error returned on the new endpoint
sstanculeanu Nov 21, 2023
1e229e0
Merge pull request #407 from multiversx/endpoint_epochs_left_as_eligible
sstanculeanu Nov 23, 2023
260244d
wrapped all ErrSendingRequest
sstanculeanu Nov 23, 2023
f3b1a47
fix after review
sstanculeanu Nov 24, 2023
eb07285
fixes after review
sstanculeanu Nov 24, 2023
cbc3831
further fixes after review
sstanculeanu Nov 27, 2023
f39bbf4
Merge branch 'rc/v1.6.0' of https://github.com/multiversx/mx-chain-pr…
sstanculeanu Nov 27, 2023
928f6cf
Merge pull request #410 from multiversx/merge_rc160_into_rc170_2023.1…
sstanculeanu Nov 27, 2023
6c058c1
Merge branch 'rc/v1.7.0' into wrap_ErrSendingRequest
sstanculeanu Nov 27, 2023
b97c154
moved ValidatorAPIResponse to mx-chain-core-go and fixes some linter …
sstanculeanu Nov 27, 2023
202181b
Merge pull request #409 from multiversx/wrap_ErrSendingRequest
sstanculeanu Nov 28, 2023
b781f15
updated mx-chain-core-go
sstanculeanu Dec 4, 2023
f2d0716
Merge branch 'rc/v1.7.0' into move_validatorAPIResponse
sstanculeanu Dec 8, 2023
a50aa36
updated mx-chain-core-go after merge
sstanculeanu Dec 8, 2023
3995136
Merge pull request #411 from multiversx/move_validatorAPIResponse
sstanculeanu Dec 12, 2023
af1c9dc
fix typo in swagger
sstanculeanu Jan 3, 2024
68ad007
Merge pull request #419 from multiversx/fix_swagger_typo
tanghel Jan 3, 2024
c098d53
Merge branch 'rc/v1.7.0' into merge-rc-1-7-into-staking-v4-8-jan-2024
mariusmihaic Jan 8, 2024
3a20414
Merge pull request #420 from multiversx/merge-rc-1-7-into-staking-v4-…
mariusmihaic Jan 8, 2024
21b57be
fixed multiple typos on swagger /transaction routes
sstanculeanu Jan 9, 2024
9db3ad9
removed duplicated entry
sstanculeanu Jan 9, 2024
f3f9ee9
Merge pull request #421 from multiversx/swagger_transaction_fixes
sstanculeanu Jan 9, 2024
df034f2
Merge branch 'rc/v1.7.0' into merge-rc-1-7-into-staking-v4-30-jan-2024
mariusmihaic Jan 30, 2024
b97fb70
Merge pull request #422 from multiversx/merge-rc-1-7-into-staking-v4-…
mariusmihaic Jan 30, 2024
fcbd2a5
Merge branch 'master' of https://github.com/multiversx/mx-chain-proxy…
sstanculeanu Feb 2, 2024
071ee83
fix after merge
sstanculeanu Feb 2, 2024
b3b8961
Merge pull request #423 from multiversx/merge_master_into_rc170_2024.…
iulianpascalau Feb 2, 2024
7659b1f
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-pr…
sstanculeanu Feb 2, 2024
4ef0914
fix after merge
sstanculeanu Feb 2, 2024
774a2b9
Merge pull request #424 from multiversx/merge_rc170_into_feat_staking…
raduchis Feb 2, 2024
4bfdb83
FIX: After review
mariusmihaic Feb 5, 2024
456ecd0
Merge pull request #425 from multiversx/MX-15129-fix-auction-list-api…
mariusmihaic Feb 5, 2024
7763f9f
FIX: Rename auction list nodes to nodes
mariusmihaic Feb 12, 2024
5f7a82b
Merge pull request #427 from multiversx/MX-15166-refactor-auction-lis…
mariusmihaic Feb 12, 2024
b46e617
Merge branch 'master' of https://github.com/multiversx/mx-chain-proxy…
sstanculeanu Feb 16, 2024
8a69484
Merge pull request #428 from multiversx/merge_master_into_rc170_2024.…
iulianpascalau Feb 20, 2024
89c3bf0
shard id for system account
miiu96 Mar 4, 2024
31b9f91
fix unit tests
miiu96 Mar 4, 2024
d6abc36
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-pr…
sstanculeanu Mar 5, 2024
e5ad59b
Merge pull request #431 from multiversx/merge_rc170_into_feat_staking…
sstanculeanu Mar 5, 2024
62c486f
Merge pull request #373 from multiversx/feat/staking-v4
sstanculeanu Mar 7, 2024
126965d
Merge branch 'rc/v1.7.0' into shard-id-for-system-account
miiu96 Mar 7, 2024
3e46a52
fixes after review
miiu96 Mar 8, 2024
a269948
Merge remote-tracking branch 'origin/shard-id-for-system-account' int…
miiu96 Mar 8, 2024
3787ea2
fixes
miiu96 Mar 8, 2024
cc5505a
small
miiu96 Mar 8, 2024
34c7d95
Merge pull request #430 from multiversx/shard-id-for-system-account
miiu96 Mar 12, 2024
6c1ae6d
added error details on /process-status
sstanculeanu Mar 13, 2024
9ef4a54
fixes after discussions
sstanculeanu Mar 13, 2024
01c32ce
better naming
sstanculeanu Mar 13, 2024
589b61c
fixes after review
sstanculeanu Mar 13, 2024
6dc38f3
further fixes
sstanculeanu Mar 13, 2024
b1862c3
Merge pull request #433 from multiversx/error_details_on_process_stat…
sstanculeanu Mar 14, 2024
8df1317
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-pr…
sstanculeanu Mar 14, 2024
e8c57f5
Merge pull request #435 from multiversx/mergre_rc170_into_rc_17next1_…
sstanculeanu Mar 14, 2024
133b3eb
Merge pull request #434 from multiversx/rc/v1.7.next1
sstanculeanu Mar 14, 2024
1fac70f
remove swagger servers list
bogdan-rosianu Mar 21, 2024
55707c1
Merge pull request #437 from multiversx/remove-servers-list-from-swagger
gabi-vuls Mar 25, 2024
3c47c27
added withKeys on /address
raduchis Apr 19, 2024
5815d8d
Merge pull request #440 from multiversx/MX-15381-add-withKeys-on-api-…
raduchis Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ For more details, go [here](https://docs.multiversx.com/sdk-and-tools/proxy/).
### validator

- `/v1.0/validator/statistics` (GET) --> returns the validator statistics data from an observer from any shard. Has a cache to avoid many requests
- `/v1.0/validator/auction` (GET) --> returns the validator auction list data from an observer from metachain. It doesn't have a cache mechanism, since there is already one in place at the node level

### block

Expand Down
31 changes: 18 additions & 13 deletions api/groups/baseAccountsGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewAccountsGroup(facadeHandler data.FacadeHandler) (*accountsGroup, error)
func (group *accountsGroup) respondWithAccount(c *gin.Context, transform func(*data.AccountModel) gin.H) {
address := c.Param("address")

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, address)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrBadUrlParams, err)
return
Expand Down Expand Up @@ -113,7 +113,7 @@ func (group *accountsGroup) getNonce(c *gin.Context) {
// getCodeHash returns the code hash for the address parameter
func (group *accountsGroup) getCodeHash(c *gin.Context) {
address := c.Param("address")
options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, address)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrBadUrlParams, err)
return
Expand All @@ -137,7 +137,12 @@ func (group *accountsGroup) getAccounts(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
addr := ""
if len(addresses) > 0 {
addr = addresses[0]
}

options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrInvalidFields, err)
return
Expand Down Expand Up @@ -171,7 +176,7 @@ func (group *accountsGroup) getKeyValuePairs(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetKeyValuePairs, err)
return
Expand All @@ -194,7 +199,7 @@ func (group *accountsGroup) getValueForKey(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetValueForKey, err)
return
Expand Down Expand Up @@ -246,7 +251,7 @@ func (group *accountsGroup) getESDTTokenData(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetESDTTokenData, err)
return
Expand Down Expand Up @@ -274,7 +279,7 @@ func (group *accountsGroup) getESDTsRoles(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetRolesForAccount, err)
return
Expand All @@ -297,7 +302,7 @@ func (group *accountsGroup) getESDTsWithRole(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetESDTsWithRole, err)
return
Expand Down Expand Up @@ -326,7 +331,7 @@ func (group *accountsGroup) getRegisteredNFTs(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetNFTTokenIDsRegisteredByAddress, err)
return
Expand All @@ -349,7 +354,7 @@ func (group *accountsGroup) getESDTNftTokenData(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetESDTTokenData, err)
return
Expand Down Expand Up @@ -383,7 +388,7 @@ func (group *accountsGroup) getGuardianData(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetGuardianData, err)
return
Expand All @@ -406,7 +411,7 @@ func (group *accountsGroup) getESDTTokens(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrGetESDTTokenData, err)
return
Expand All @@ -427,7 +432,7 @@ func (group *accountsGroup) isDataTrieMigrated(c *gin.Context) {
return
}

options, err := parseAccountQueryOptions(c)
options, err := parseAccountQueryOptions(c, addr)
if err != nil {
shared.RespondWithValidationError(c, errors.ErrIsDataTrieMigrated, err)
return
Expand Down
1 change: 1 addition & 0 deletions api/groups/baseGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestCrudOperationsBaseGroup(t *testing.T) {
assert.Equal(t, hd2.Path, bg.endpoints[2].Path)

err = bg.AddEndpoint(hd4.Path, *hd4)
assert.NoError(t, err)
assert.Equal(t, 4, len(bg.endpoints))

// ensure the order
Expand Down
12 changes: 12 additions & 0 deletions api/groups/baseNodeGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func NewNodeGroup(facadeHandler data.FacadeHandler) (*nodeGroup, error) {
baseRoutesHandlers := []*data.EndpointHandlerData{
{Path: "/heartbeatstatus", Handler: ng.getHeartbeatData, Method: http.MethodGet},
{Path: "/old-storage-token/:token/nonce/:nonce", Handler: ng.isOldStorageForToken, Method: http.MethodGet},
{Path: "/waiting-epochs-left/:key", Handler: ng.waitingEpochsLeft, Method: http.MethodGet},
}
ng.baseGroup.endpoints = baseRoutesHandlers

Expand Down Expand Up @@ -69,3 +70,14 @@ func (group *nodeGroup) isOldStorageForToken(c *gin.Context) {

shared.RespondWith(c, http.StatusOK, gin.H{"isOldStorage": isOldStorage}, "", data.ReturnCodeSuccess)
}

func (group *nodeGroup) waitingEpochsLeft(c *gin.Context) {
publicKey := c.Param("key")
response, err := group.facade.GetWaitingEpochsLeftForPublicKey(publicKey)
if err != nil {
shared.RespondWith(c, http.StatusInternalServerError, nil, err.Error(), data.ReturnCodeInternalError)
return
}

shared.RespondWith(c, http.StatusOK, response.Data, "", data.ReturnCodeSuccess)
}
50 changes: 50 additions & 0 deletions api/groups/baseNodeGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,53 @@ func TestNodeGroup_IsOldStorageToken(t *testing.T) {
assert.Equal(t, "map[isOldStorage:true]", fmt.Sprintf("%v", result.Data))
})
}

func TestBaseNodeGroup_GetWaitingEpochsLeftForPublicKey(t *testing.T) {
t.Parallel()

t.Run("facade returns bad request", func(t *testing.T) {
t.Parallel()

facade := &mock.FacadeStub{
GetWaitingEpochsLeftForPublicKeyCalled: func(publicKey string) (*data.WaitingEpochsLeftApiResponse, error) {
return nil, errors.New("bad request")
},
}
nodeGroup, err := groups.NewNodeGroup(facade)
require.NoError(t, err)
ws := startProxyServer(nodeGroup, nodePath)

req, _ := http.NewRequest("GET", "/node/waiting-epochs-left/key", nil)
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

assert.Equal(t, http.StatusInternalServerError, resp.Code)
})
t.Run("facade returns bad request", func(t *testing.T) {
t.Parallel()

providedData := data.WaitingEpochsLeftResponse{
EpochsLeft: 10,
}
facade := &mock.FacadeStub{
GetWaitingEpochsLeftForPublicKeyCalled: func(publicKey string) (*data.WaitingEpochsLeftApiResponse, error) {
return &data.WaitingEpochsLeftApiResponse{
Data: providedData,
}, nil
},
}
nodeGroup, err := groups.NewNodeGroup(facade)
require.NoError(t, err)
ws := startProxyServer(nodeGroup, nodePath)

req, _ := http.NewRequest("GET", "/node/waiting-epochs-left/key", nil)
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

assert.Equal(t, http.StatusOK, resp.Code)

var result data.WaitingEpochsLeftApiResponse
loadResponse(resp.Body, &result)
assert.Equal(t, providedData, result.Data)
})
}
6 changes: 6 additions & 0 deletions api/groups/baseProofGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestGetProof_FailWhenFacadeGetProofFails(t *testing.T) {
ws := startProxyServer(proofGroup, "/proof")

req, err := http.NewRequest("GET", "/proof/root-hash/"+rootHash+"/address/"+address, nil)
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down Expand Up @@ -82,6 +83,7 @@ func TestGetProof(t *testing.T) {
ws := startProxyServer(proofGroup, "/proof")

req, err := http.NewRequest("GET", "/proof/root-hash/"+rootHash+"/address/"+address, nil)
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down Expand Up @@ -128,6 +130,7 @@ func TestVerifyProof_FailWhenFacadeVerifyProofFails(t *testing.T) {
}
verifyProofBytes, _ := json.Marshal(varifyProofParams)
req, err := http.NewRequest("POST", "/proof/verify", bytes.NewBuffer(verifyProofBytes))
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down Expand Up @@ -165,6 +168,7 @@ func TestVerifyProof(t *testing.T) {
}
verifyProofBytes, _ := json.Marshal(varifyProofParams)
req, err := http.NewRequest("POST", "/proof/verify", bytes.NewBuffer(verifyProofBytes))
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down Expand Up @@ -200,6 +204,7 @@ func TestGetProofDataTrie_FailWhenFacadeGetProofFails(t *testing.T) {

endpoint := fmt.Sprintf("/proof/root-hash/%s/address/%s/key/%s", rootHash, address, key)
req, err := http.NewRequest("GET", endpoint, nil)
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down Expand Up @@ -235,6 +240,7 @@ func TestGetProofDataTrie(t *testing.T) {

endpoint := fmt.Sprintf("/proof/root-hash/%s/address/%s/key/%s", rootHash, address, key)
req, err := http.NewRequest("GET", endpoint, nil)
require.NoError(t, err)

resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)
Expand Down
2 changes: 1 addition & 1 deletion api/groups/baseTransactionGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (group *transactionGroup) getProcessedTransactionStatus(c *gin.Context) {
return
}

shared.RespondWith(c, http.StatusOK, gin.H{"status": status}, "", data.ReturnCodeSuccess)
shared.RespondWith(c, http.StatusOK, gin.H{"status": status.Status, "reason": status.Reason}, "", data.ReturnCodeSuccess)
}

func getTransactionByHashAndSenderAddress(c *gin.Context, ef TransactionFacadeHandler, txHash string, sndAddr string, withEvents bool) {
Expand Down
15 changes: 10 additions & 5 deletions api/groups/baseTransactionGroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type txProcessedStatusResp struct {
GeneralResponse
Data struct {
Status string `json:"status"`
Reason string `json:"reason"`
} `json:"data"`
}

Expand Down Expand Up @@ -776,9 +777,9 @@ func TestTransactionGroup_getProcessedTransactionStatus(t *testing.T) {
t.Parallel()

facade := &mock.FacadeStub{
GetProcessedTransactionStatusHandler: func(txHash string) (string, error) {
GetProcessedTransactionStatusHandler: func(txHash string) (*data.ProcessStatusResponse, error) {
assert.Equal(t, hash, txHash)
return "", expectedErr
return &data.ProcessStatusResponse{}, expectedErr
},
}
transactionsGroup, err := groups.NewTransactionGroup(facade)
Expand All @@ -799,9 +800,12 @@ func TestTransactionGroup_getProcessedTransactionStatus(t *testing.T) {
t.Run("should work", func(t *testing.T) {
t.Parallel()

status := "status"
status := &data.ProcessStatusResponse{
Status: "status",
Reason: "some error",
}
facade := &mock.FacadeStub{
GetProcessedTransactionStatusHandler: func(txHash string) (string, error) {
GetProcessedTransactionStatusHandler: func(txHash string) (*data.ProcessStatusResponse, error) {
assert.Equal(t, hash, txHash)
return status, nil
},
Expand All @@ -820,6 +824,7 @@ func TestTransactionGroup_getProcessedTransactionStatus(t *testing.T) {

assert.Equal(t, http.StatusOK, resp.Code)
assert.Empty(t, response.Error)
assert.Equal(t, status, response.Data.Status)
assert.Equal(t, status.Status, response.Data.Status)
assert.Equal(t, status.Reason, response.Data.Reason)
})
}
11 changes: 11 additions & 0 deletions api/groups/baseValidatorGroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewValidatorGroup(facadeHandler data.FacadeHandler) (*validatorGroup, error

baseRoutesHandlers := []*data.EndpointHandlerData{
{Path: "/statistics", Handler: vg.statistics, Method: http.MethodGet},
{Path: "/auction", Handler: vg.auctionList, Method: http.MethodGet},
}
vg.baseGroup.endpoints = baseRoutesHandlers

Expand All @@ -43,3 +44,13 @@ func (group *validatorGroup) statistics(c *gin.Context) {

shared.RespondWith(c, http.StatusOK, gin.H{"statistics": validatorStatistics}, "", data.ReturnCodeSuccess)
}

func (group *validatorGroup) auctionList(c *gin.Context) {
auctionList, err := group.facade.AuctionList()
if err != nil {
shared.RespondWith(c, http.StatusBadRequest, nil, err.Error(), data.ReturnCodeRequestError)
return
}

shared.RespondWith(c, http.StatusOK, gin.H{"auctionList": auctionList}, "", data.ReturnCodeSuccess)
}
Loading
Loading