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

Merge rc v1 6 into feat snasphotless #398

Binary file modified cmd/proxy/config/swagger/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cmd/proxy/config/swagger/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cmd/proxy/config/swagger/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<title>MultiversX Gateway</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="index.css" />
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
Expand Down
Binary file added cmd/proxy/config/swagger/mvx-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 55 additions & 41 deletions cmd/proxy/config/swagger/openapi.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"openapi": "3.0.3",
"info": {
"title": "MultiversX Proxy API",
"description": "## Welcome to the MultiversX Proxy API\n\nThe documentation describes the endpoints that are available on the mx-chain-proxy-go project. This is used on `gateway.multiversx.com` while the public api (`api.multiversx.com`) is a wrapper over it.\n\nThis API is organized around REST principles, so if you've interacted with RESTful APIs before, many of the concepts will look familiar.\n\n## Request / Response Format\n\nJSON will be returned for all responses, including errors. Empty or blank fields are omitted. Requests with a message body use JSON as well. Successful requests will return a `2xx` HTTP status.\n\nThe general structure of a response is:\n``` JSON\n{\n data anything\n error string\n code string\n}\n```\nWhere:\n- data: the expected result if the request was successful. `null` otherwise\n- error: if the request failed, the reason will be returned in this field. empty otherwise\n- code: the internal code for the request. can be `successful`, `internal_issue` or `bad_request`\n",
"title": "MultiversX Gateway API",
"description": "![MultiversX](/mvx-icon.png)\n\nThe documentation describes the endpoints that are available on the mx-chain-proxy-go project. \n\nGithub URL: `https://github.com/multiversx/mx-chain-proxy-go`\n\nThis is used on `gateway.multiversx.com` while the public api (`api.multiversx.com`) is a wrapper over it.\n\nThis API is organized around REST principles, so if you've interacted with RESTful APIs before, many of the concepts will look familiar.\n\n## Request / Response Format\n\nJSON will be returned for all responses, including errors. Empty or blank fields are omitted. Requests with a message body use JSON as well. Successful requests will return a `2xx` HTTP status.\n\nThe general structure of a response is:\n``` JSON\n{\n data anything\n error string\n code string\n}\n```\nWhere:\n- data: the expected result if the request was successful. `null` otherwise\n- error: if the request failed, the reason will be returned in this field. empty otherwise\n- code: the internal code for the request. can be `successful`, `internal_issue` or `bad_request`\n",
"version": "1.1.0"
},
"paths": {
Expand Down Expand Up @@ -2261,7 +2261,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Transaction"
"$ref": "#/components/schemas/TxStatusResponse"
}
}
}
Expand Down Expand Up @@ -2293,10 +2293,39 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"items": {
"$ref": "#/components/schemas/AddressEsdtToken"
}
"$ref": "#/components/schemas/TxStatusResponse"
}
}
}
}
}
}
},
"/transaction/{txhash}/process-status": {
"get": {
"tags": [
"transaction"
],
"summary": "returns the processing status of the transaction which corresponds to the hash. It searches for SCRs generated by the transaction and computes the actual processing status",
"parameters": [
{
"name": "txhash",
"in": "path",
"description": "the transaction hash to search for",
"required": true,
"schema": {
"type": "string",
"default": null
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TxStatusResponse"
}
}
}
Expand Down Expand Up @@ -2453,40 +2482,6 @@
}
}
},
"/transaction/{hash}/status": {
"get": {
"tags": [
"transaction"
],
"summary": "retrieves the status of the transaction with the provided hash",
"parameters": [
{
"name": "hash",
"in": "path",
"required": true,
"description": "the hash of the transaction to look after",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GenericResponse"
}
}
}
},
"400": {
"description": "validation error"
}
}
}
},
"/validator/statistics": {
"get": {
"tags": [
Expand Down Expand Up @@ -3152,6 +3147,25 @@
}
}
},
"TxStatusResponse": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"status": {
"type": "string"
}
}
},
"error": {
"type": "string"
},
"code": {
"type": "string"
}
}
},
"Guardian": {
"type": "object",
"properties": {
Expand Down
14 changes: 12 additions & 2 deletions cmd/proxy/config/swagger/swagger-initializer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
window.onload = function() {
//<editor-fold desc="Changeable Configuration Block">

// Custom plugin to hide the API definition URL
const HideInfoUrlPartsPlugin = () => {
return {
wrapComponents: {
InfoUrl: () => () => null
}
}
}

// the following lines will be replaced by docker/configurator, when it runs in a docker-container
window.ui = SwaggerUIBundle({
url: "openapi.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
SwaggerUIStandalonePreset.slice(1)
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
SwaggerUIBundle.plugins.DownloadUrl,
HideInfoUrlPartsPlugin
],
layout: "StandaloneLayout"
});
Expand Down
3 changes: 0 additions & 3 deletions process/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,3 @@ var ErrEmptyAppVersionString = errors.New("empty app version string")

// ErrEmptyCommitString signals than an empty commit id string has been provided
var ErrEmptyCommitString = errors.New("empty commit id string")

// ErrInconsistentTokensSuppliesResponses signals an inconsistent response from the nodes
var ErrInconsistentTokensSuppliesResponses = errors.New("inconsistent tokens supplies shard responses")
8 changes: 0 additions & 8 deletions process/esdtSupplyProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ func (esp *esdtSupplyProcessor) getSupplyFromShards(tokenIdentifier string) (*da
}

if numNodesWithRecomputedSupply > 0 {
if numNodesWithRecomputedSupply != numNodesQueried {
// this means that some nodes have recomputed supply and some don't
log.Error("inconsistent observers setup: some nodes have recomputed supply and some don't",
"numNodesWithRecomputedSupply", numNodesWithRecomputedSupply,
"numNodesQueried", numNodesQueried)
return nil, ErrInconsistentTokensSuppliesResponses
}

totalSupply.RecomputedSupply = true
}

Expand Down
57 changes: 0 additions & 57 deletions process/esdtSupplyProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,63 +120,6 @@ func TestEsdtSupplyProcessor_GetESDTSupplyNonFungible(t *testing.T) {
require.Equal(t, "0", supplyRes.Data.InitialMinted)
}

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

called := false
baseProc := &mock.ProcessorStub{
GetShardIDsCalled: func() []uint32 {
return []uint32{0, 1, core.MetachainShardId}
},
GetObserversCalled: func(shardID uint32, _ data.ObserverDataAvailabilityType) ([]*data.NodeData, error) {
return []*data.NodeData{
{
ShardId: shardID,
Address: fmt.Sprintf("shard-%d", shardID),
},
{
ShardId: shardID,
Address: fmt.Sprintf("shard-%d", shardID),
},
}, nil
},
CallGetRestEndPointCalled: func(address string, path string, value interface{}) (int, error) {
switch address {
case "shard-0":
if !called {
called = true
return 400, errors.New("local err")
}
valResp := value.(*data.ESDTSupplyResponse)
valResp.Data.Supply = "300"
valResp.Data.RecomputedSupply = true
return 200, nil
case "shard-1":
valResp := value.(*data.ESDTSupplyResponse)
valResp.Data.Supply = "600"
valResp.Data.Minted = "50"
valResp.Data.Burned = "100"
valResp.Data.RecomputedSupply = false
return 200, nil
}
return 0, nil
},
}
scQueryProc := &mock.SCQueryServiceStub{
ExecuteQueryCalled: func(query *data.SCQuery) (*vm.VMOutputApi, data.BlockInfo, error) {
return &vm.VMOutputApi{
ReturnData: [][]byte{nil, nil, nil, []byte("500")},
}, data.BlockInfo{}, nil
},
}
esdtProc, err := NewESDTSupplyProcessor(baseProc, scQueryProc)
require.Nil(t, err)

supplyRes, err := esdtProc.GetESDTSupply("SEMI-ABCDEF")
require.Empty(t, supplyRes)
require.Equal(t, ErrInconsistentTokensSuppliesResponses, err)
}

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

Expand Down
125 changes: 125 additions & 0 deletions process/testdata/finishedFailedSCDeployWithTransfer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"transaction": {
"type": "normal",
"processingTypeOnSource": "SCInvoking",
"processingTypeOnDestination": "SCInvoking",
"hash": "a4823050d2396540b17bd9290523973763142c9f655bb26cd9e33f359b6d73ad",
"nonce": 9,
"round": 2735017,
"epoch": 2277,
"value": "1000",
"receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"data": "ZG9fZGVwbG95QDAwMDAwMDAwMDAwMDAwMDAwNTAwRkIxNUE1MEZGNUQ2MEQyQUI5NjA3MTgyRDdCQjM2MjlEQThFNkQxOEEwMTJAMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxRkZGRg==",
"smartContractResults": [
{
"hash": "SCR-hash1",
"receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"operation": "transfer"
},
{
"hash": "SCR-hash2",
"receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"data": "@73656e64696e672076616c756520746f206e6f6e2070617961626c6520636f6e7472616374",
"returnMessage": "sending value to non payable contract",
"operation": "transfer"
}
],
"logs": {
"address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"events": [
{
"address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"identifier": "transferValueOnly",
"topics": [
"AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=",
"AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAB//8=",
"A+g="
],
"data": null
},
{
"address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"identifier": "SCDeploy",
"topics": [
"AAAAAAAAAAAFAOchRUX9HQDwjcJbkLd9jkXd5nAjoBI=",
"AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI="
],
"data": null
},
{
"address": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"identifier": "writeLog",
"topics": [
"VuJjyDpv3q8GVEqm7SLrVgl7ySOB9Ya6HTmmeI4+oBI=",
"QHRvbyBtdWNoIGdhcyBwcm92aWRlZCBmb3IgcHJvY2Vzc2luZzogZ2FzIHByb3ZpZGVkID0gNDk3NDE1MDAsIGdhcyB1c2VkID0gMTUxMzQyMA=="
],
"data": "QDZmNmI="
}
]
},
"status": "success",
"operation": "transfer",
"function": "do_deploy",
"chainID": "T"
},
"scrs": [
{
"type": "unsigned",
"processingTypeOnSource": "MoveBalance",
"processingTypeOnDestination": "MoveBalance",
"hash": "SCR-hash1",
"receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"gasPrice": 1000000000,
"sourceShard": 2,
"destinationShard": 4294967295,
"blockNonce": 2733469,
"miniblockType": "SmartContractResultBlock",
"logs": {
"address": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l",
"events": [
{
"address": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqplllst77y4l",
"identifier": "signalError",
"topics": [
"AAAAAAAAAAAFAAc2sq9MjfurX+5zluCpV5y58QqNoBI=",
"c2VuZGluZyB2YWx1ZSB0byBub24gcGF5YWJsZSBjb250cmFjdA=="
],
"data": "QDczNjU2ZTY0Njk2ZTY3MjA3NjYxNmM3NTY1MjA3NDZmMjA2ZTZmNmUyMDcwNjE3OTYxNjI2YzY1MjA2MzZmNmU3NDcyNjE2Mzc0"
}
]
},
"status": "success",
"operation": "transfer",
"fee": "0",
"callType": "directCall",
"options": 0
},
{
"type": "unsigned",
"processingTypeOnSource": "MoveBalance",
"processingTypeOnDestination": "MoveBalance",
"hash": "SCR-hash2",
"nonce": 0,
"round": 2735021,
"epoch": 2277,
"value": "1000",
"receiver": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"gasUsed": 162500,
"data": "QDczNjU2ZTY0Njk2ZTY3MjA3NjYxNmM3NTY1MjA3NDZmMjA2ZTZmNmUyMDcwNjE3OTYxNjI2YzY1MjA2MzZmNmU3NDcyNjE2Mzc0",
"returnMessage": "sending value to non payable contract",
"originalSender": "erd1adfmxhyczrl2t97yx92v5nywqyse0c7qh4xs0p4artg2utnu90pspgvqty",
"sourceShard": 4294967295,
"destinationShard": 2,
"status": "success",
"operation": "transfer",
"fee": "0",
"callType": "directCall",
"options": 0
}
]
}
Loading
Loading