From 8a62b8acb6964a0bd2eefdb9d6c278a26f4195c7 Mon Sep 17 00:00:00 2001 From: kuba-4chain Date: Mon, 10 Jun 2024 13:07:26 +0200 Subject: [PATCH] feat(BEEF): update beef error codes in swagger --- .../validator/default/default_validator.go | 2 +- pkg/api/arc.go | 315 ++++++++++++++---- pkg/api/arc.yml | 99 +++++- pkg/api/handler/default.go | 6 +- pkg/api/status.go | 44 +-- 5 files changed, 367 insertions(+), 99 deletions(-) diff --git a/internal/validator/default/default_validator.go b/internal/validator/default/default_validator.go index f65e6bd75..fab752889 100644 --- a/internal/validator/default/default_validator.go +++ b/internal/validator/default/default_validator.go @@ -80,7 +80,7 @@ func (v *DefaultValidator) ValidateBeef(beefTx *beef.BEEF, skipFeeValidation, sk } if err := beef.EnsureAncestorsArePresentInBump(beefTx.GetLatestTx(), beefTx); err != nil { - return validator.NewError(err, api.ErrBeefMinedAncestorsNotFound) + return validator.NewError(err, api.ErrStatusMinedAncestorsNotFound) } return nil diff --git a/pkg/api/arc.go b/pkg/api/arc.go index a1d4e6410..b9329bb9e 100644 --- a/pkg/api/arc.go +++ b/pkg/api/arc.go @@ -76,6 +76,21 @@ type ErrorBadRequest struct { Type interface{} `json:"type"` } +// ErrorCalculatingMerkleRoots defines model for ErrorCalculatingMerkleRoots. +type ErrorCalculatingMerkleRoots struct { + Detail interface{} `json:"detail"` + + // ExtraInfo Optional extra information about the error from the miner + ExtraInfo *string `json:"extraInfo"` + Instance *interface{} `json:"instance,omitempty"` + Status interface{} `json:"status"` + Title interface{} `json:"title"` + + // Txid Transaction ID this error is referring to + Txid *string `json:"txid"` + Type interface{} `json:"type"` +} + // ErrorFee defines model for ErrorFee. type ErrorFee struct { Detail interface{} `json:"detail"` @@ -190,6 +205,21 @@ type ErrorMalformed struct { Type interface{} `json:"type"` } +// ErrorMinedAncestorsNotFound defines model for ErrorMinedAncestorsNotFound. +type ErrorMinedAncestorsNotFound struct { + Detail interface{} `json:"detail"` + + // ExtraInfo Optional extra information about the error from the miner + ExtraInfo *string `json:"extraInfo"` + Instance *interface{} `json:"instance,omitempty"` + Status interface{} `json:"status"` + Title interface{} `json:"title"` + + // Txid Transaction ID this error is referring to + Txid *string `json:"txid"` + Type interface{} `json:"type"` +} + // ErrorNotFound defines model for ErrorNotFound. type ErrorNotFound struct { Detail interface{} `json:"detail"` @@ -250,6 +280,21 @@ type ErrorUnlockingScripts struct { Type interface{} `json:"type"` } +// ErrorValidatingMerkleRoots defines model for ErrorValidatingMerkleRoots. +type ErrorValidatingMerkleRoots struct { + Detail interface{} `json:"detail"` + + // ExtraInfo Optional extra information about the error from the miner + ExtraInfo *string `json:"extraInfo"` + Instance *interface{} `json:"instance,omitempty"` + Status interface{} `json:"status"` + Title interface{} `json:"title"` + + // Txid Transaction ID this error is referring to + Txid *string `json:"txid"` + Type interface{} `json:"type"` +} + // FeeAmount defines model for FeeAmount. type FeeAmount struct { // Bytes Number of bytes @@ -572,6 +617,84 @@ func (t *Error) MergeErrorMalformed(v ErrorMalformed) error { return err } +// AsErrorMinedAncestorsNotFound returns the union data inside the Error as a ErrorMinedAncestorsNotFound +func (t Error) AsErrorMinedAncestorsNotFound() (ErrorMinedAncestorsNotFound, error) { + var body ErrorMinedAncestorsNotFound + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorMinedAncestorsNotFound overwrites any union data inside the Error as the provided ErrorMinedAncestorsNotFound +func (t *Error) FromErrorMinedAncestorsNotFound(v ErrorMinedAncestorsNotFound) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorMinedAncestorsNotFound performs a merge with any union data inside the Error, using the provided ErrorMinedAncestorsNotFound +func (t *Error) MergeErrorMinedAncestorsNotFound(v ErrorMinedAncestorsNotFound) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorCalculatingMerkleRoots returns the union data inside the Error as a ErrorCalculatingMerkleRoots +func (t Error) AsErrorCalculatingMerkleRoots() (ErrorCalculatingMerkleRoots, error) { + var body ErrorCalculatingMerkleRoots + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorCalculatingMerkleRoots overwrites any union data inside the Error as the provided ErrorCalculatingMerkleRoots +func (t *Error) FromErrorCalculatingMerkleRoots(v ErrorCalculatingMerkleRoots) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorCalculatingMerkleRoots performs a merge with any union data inside the Error, using the provided ErrorCalculatingMerkleRoots +func (t *Error) MergeErrorCalculatingMerkleRoots(v ErrorCalculatingMerkleRoots) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + +// AsErrorValidatingMerkleRoots returns the union data inside the Error as a ErrorValidatingMerkleRoots +func (t Error) AsErrorValidatingMerkleRoots() (ErrorValidatingMerkleRoots, error) { + var body ErrorValidatingMerkleRoots + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromErrorValidatingMerkleRoots overwrites any union data inside the Error as the provided ErrorValidatingMerkleRoots +func (t *Error) FromErrorValidatingMerkleRoots(v ErrorValidatingMerkleRoots) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeErrorValidatingMerkleRoots performs a merge with any union data inside the Error, using the provided ErrorValidatingMerkleRoots +func (t *Error) MergeErrorValidatingMerkleRoots(v ErrorValidatingMerkleRoots) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(t.union, b) + t.union = merged + return err +} + // AsErrorFrozenPolicy returns the union data inside the Error as a ErrorFrozenPolicy func (t Error) AsErrorFrozenPolicy() (ErrorFrozenPolicy, error) { var body ErrorFrozenPolicy @@ -1391,6 +1514,9 @@ type POSTTransactionResponse struct { JSON463 *ErrorMalformed JSON464 *ErrorOutputs JSON465 *ErrorFee + JSON467 *ErrorMinedAncestorsNotFound + JSON468 *ErrorCalculatingMerkleRoots + JSON469 *ErrorValidatingMerkleRoots } // Status returns HTTPResponse.Status @@ -1445,6 +1571,9 @@ type POSTTransactionsResponse struct { JSON463 *ErrorMalformed JSON464 *ErrorOutputs JSON465 *ErrorFee + JSON467 *ErrorMinedAncestorsNotFound + JSON468 *ErrorCalculatingMerkleRoots + JSON469 *ErrorValidatingMerkleRoots } // Status returns HTTPResponse.Status @@ -1676,6 +1805,27 @@ func ParsePOSTTransactionResponse(rsp *http.Response) (*POSTTransactionResponse, } response.JSON465 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 467: + var dest ErrorMinedAncestorsNotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON467 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 468: + var dest ErrorCalculatingMerkleRoots + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON468 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 469: + var dest ErrorValidatingMerkleRoots + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON469 = &dest + } return response, nil @@ -1798,6 +1948,27 @@ func ParsePOSTTransactionsResponse(rsp *http.Response) (*POSTTransactionsRespons } response.JSON465 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 467: + var dest ErrorMinedAncestorsNotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON467 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 468: + var dest ErrorCalculatingMerkleRoots + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON468 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 469: + var dest ErrorValidatingMerkleRoots + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON469 = &dest + } return response, nil @@ -2198,76 +2369,80 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+xce2/buJb/KoTu/tECTkJR7wCDRZsmd7IzTbKJO7O7naDg4yjmrR5eiUqdGeS7L0jJ", - "tmTJjt06mdl72z8K23wdnkOex+8c5g+L5+k0zyBTpXX8hzWlBU1BQWG+cZokjPLP4/wzZPoHASUv5FTJ", - "PLOOrTecQ1kipVtRnBcoy5WMJae6Hc0HI8jENJeZOkTnCn2RSYIYoKoEgWiJKHpTqUleyN/rUROgAgoz", - "m5oAmig1XcxkjSyp1637WCMroylYx9Z/HZx0CB1ZJZ9ASjXF6mGqu5SqkNmd9fg4WmzqQ5H0t/QOYlol", - "Com8YgmgcgqZQDQTKIXicwJoWuR5/NQ+n6ZTr72ZyrhKkhtFVVV+mAqqoOzT+usE1AQK9AVQOcmrRKAJ", - "vQekR6LSDEVVPRbJFpm1nNArmfGkEjK7Qzenpxefzi8+XV5f/fjm4tP70/dXl5c/m22bpsuLTxen418v", - "r39q5oXy9YZNnvVIH9gqy/MEaGb2mtLZWKaQV6q/yaZB76AEnmdCnzf0hUpVnzj4glRBs5JyI4xm3wzi", - "vABUwP9WUCoEs6ksoESvUjpDDp7PNEKiEbf3ev123i+pG9iHzBTcQWH2UX6W0zOAX2giBa3pf1pmehCK", - "AdD9Ylgjog0svumt9ASL9So3ho6voK7usjOBvfW2oHE8+wr68nsoaJIgNduZxs56T9CnD91ZXtRHe4g4", - "ySfzA9g+o3GRp0aZlVDcQ7E8nKoqMn3/XhH0A7o+PTk9/+X03Qg56Ad0M7681p9d9AN6c3Fx+eHi5PTd", - "p/Hl/CKOkGfG/OeH05vx6btPb/972eLr8acX4073QE90cnJ6tdo7NL07t3zDZfi1w4ON9+FxZBVQTvOs", - "rJXXRa7mqh5En303wKtCqgdzaWUBqTZJKKYyAVEfD7OUmepkQmV2nsV5fxrThKRuG1nTIp9CoWRNAEty", - "/vlHWk76o97qJjTRbSMLZjSdJnozePVf6LmBGzGH28QTHu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FUy8gHrGs0MQh5aHjYpcDOCzCjPiu60fcDEzwLIxJQDnY3Iu4jSEEJ6DEJw5su//rtTy7", + "4zup82bp6J4LIXVNa10R0u2KTAk2X16ANK6rcFoZTxhCqAt7IJlmWfysgBZuWI+1KqGngVHURfq3asdV", + "CzwBmkN+XPZZddWGaCknkMrmwVS3ZPvm7BS5noObxwQab9F0C46VdVcvCkS9SWPBoU4B6rcJV1NI0cnt", + "P9DPqokrYZR5vIrP0aLIuNCcHKYgh9kU0gNWPBzUQw5bUjbUeMc3p0YLezEqEOVpYChKOhXGkWHVuIra", + "sloowwdzOJmDVvcg+x4qAP9SIBEtACJ1cmggKZqGKC/TtMqa5tjAuToN/X00rhGxpScWBGP9bC9LJdSw", + "4XQa13If/rMGrhZvNjY503oGLfUl0y31uz8lAhub68aZMzbsPvzQZlQmCc0fdRmIbK1/0qxK0vtC2eRx", + "zo07RaEEujhu9wp0rAvm6jd49euaGo6riosKkFKk98Vhn0CvG6Dh1QS6hFG8gWB71r5OtnJWARrFs4IV", + "RfV2U2ao0I8jUU67b/BkhmhVDKrLIHU1alHd0WuWUpjJqioVyQmVi9pRxHOgEnoUdH11Ox53om37oeqa", + "LGLRZdh+87kui2h1X318uQVR6xXjFr1X3wpuSbTyqm5Lus5Lty1oum9/tyDoPo9TJ9e6WOAkCx/3tot6", + "DrHKhtsDZlyCPChkDjTpDjyPrkykapv0HsBhJocay+/SLiLrFsfj1YGfNh3kOyfkRUxWSdvTizxSzWyV", + "3DYPqxbOYfmGfmA80LiE9r3dvuoOukgizeuKP2S71hFa+tgWaTU2wqjB91tMGO0LQZXjLrBI27UW0Xt1", + "mTWcSHHoBpSEEQ09E3sehpD4hHOwTJc7XkAi18QmdX1su5S4FjU9alLAxPVcbLaTzZ3LsH41qifPdVLW", + "UUtH5GkrcZtr5xtA2/9vgG118VDVAvaLqGpeI53Os01KuR9EDELTtSB0MXZNRi2LcUxZEIIPXhT6zLJp", + "GNic2KbNw2XpepZLiL9ZxBE4NnF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WgzsHatYCf7tTp8XgqDn6Cx/nH9m+96y/v1BD5Q3Oi75bs", + "SToVi5e9NOcqMP5fAAAA///Bl6eDs14AAA==", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/api/arc.yml b/pkg/api/arc.yml index 993d0df5d..4bd262a4c 100644 --- a/pkg/api/arc.yml +++ b/pkg/api/arc.yml @@ -84,6 +84,7 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorGeneric' + # Post transaction /v1/tx: post: @@ -215,6 +216,25 @@ paths: application/json: schema: $ref: '#/components/schemas/Error' + 467: + description: Mined ancestors not found in BEEF + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMinedAncestorsNotFound' + 468: + description: Invalid BUMPs in BEEF + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorCalculatingMerkleRoots' + 469: + description: Invalid Merkle Roots + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorValidatingMerkleRoots' + /v1/txs: post: operationId: POST transactions @@ -308,7 +328,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorBadRequest' - 401: $ref: '#/components/responses/NotAuthorized' 409: @@ -353,10 +372,27 @@ paths: application/json: schema: $ref: '#/components/schemas/ErrorFee' -components: + 467: + description: Mined ancestors not found in BEEF + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorMinedAncestorsNotFound' + 468: + description: Invalid BUMPs in BEEF + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorCalculatingMerkleRoots' + 469: + description: Invalid Merkle Roots + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorValidatingMerkleRoots' +components: schemas: - # Common response object CommonResponse: type: object @@ -636,6 +672,15 @@ components: { "$ref": "#/components/schemas/ErrorMalformed" }, + { + "$ref": "#/components/schemas/ErrorMinedAncestorsNotFound" + }, + { + "$ref": "#/components/schemas/ErrorCalculatingMerkleRoots" + }, + { + "$ref": "#/components/schemas/ErrorValidatingMerkleRoots" + }, { "$ref": "#/components/schemas/ErrorFrozenPolicy" }, @@ -803,6 +848,54 @@ components: example: "Transaction is valid, but there is a conflicting tx in the block template" instance: example: "https://arc.taal.com/errors/123453" + ErrorMinedAncestorsNotFound: + type: object + allOf: + - "$ref": "#/components/schemas/ErrorFields" + - type: object + properties: + type: + example: "https://bitcoin-sv.github.io/arc/#/errors?id=_467" + title: + example: "Mined ancestors not found" + status: + example: 467 + detail: + example: "Error validating BEEF: mined ancestors not found in transaction inputs" + instance: + example: "https://arc.taal.com/errors/123453" + ErrorCalculatingMerkleRoots: + type: object + allOf: + - "$ref": "#/components/schemas/ErrorFields" + - type: object + properties: + type: + example: "https://bitcoin-sv.github.io/arc/#/errors?id=_468" + title: + example: "Invalid BUMPs" + status: + example: 468 + detail: + example: "Error validating BEEF: could not calculate Merkle Roots from given BUMPs" + instance: + example: "https://arc.taal.com/errors/123453" + ErrorValidatingMerkleRoots: + type: object + allOf: + - "$ref": "#/components/schemas/ErrorFields" + - type: object + properties: + type: + example: "https://bitcoin-sv.github.io/arc/#/errors?id=_469" + title: + example: "Merkle Roots validation failed" + status: + example: 469 + detail: + example: "Error validating BEEF: could not validate Merkle Roots" + instance: + example: "https://arc.taal.com/errors/123453" ErrorFrozenPolicy: type: object allOf: diff --git a/pkg/api/handler/default.go b/pkg/api/handler/default.go index 3392fff8f..7d870a72c 100644 --- a/pkg/api/handler/default.go +++ b/pkg/api/handler/default.go @@ -480,19 +480,19 @@ func (m ArcDefaultHandler) validateBEEFTransaction(ctx context.Context, txValida merkleRoots, err := beef.CalculateMerkleRootsFromBumps(beefTx.BUMPs) if err != nil { - return api.NewErrorFields(api.ErrBeefCalculatingMerkleRoots, err.Error()) + return api.NewErrorFields(api.ErrStatusCalculatingMerkleRoots, err.Error()) } merkleRootsRequest := convertMerkleRootsRequest(merkleRoots) unverifiedBlockHeights, err := m.MerkleRootsVerifier.VerifyMerkleRoots(ctx, merkleRootsRequest) if err != nil { - return api.NewErrorFields(api.ErrBeefValidatingMerkleRoots, err.Error()) + return api.NewErrorFields(api.ErrStatusValidatingMerkleRoots, err.Error()) } if len(unverifiedBlockHeights) > 0 { err := fmt.Errorf("unable to verify BUMPs with block heights: %v", unverifiedBlockHeights) - return api.NewErrorFields(api.ErrBeefValidatingMerkleRoots, err.Error()) + return api.NewErrorFields(api.ErrStatusValidatingMerkleRoots, err.Error()) } return nil diff --git a/pkg/api/status.go b/pkg/api/status.go index b97926bc6..ed1dfbeb6 100644 --- a/pkg/api/status.go +++ b/pkg/api/status.go @@ -9,22 +9,22 @@ type StatusCode int const ( arcDocServerErrorsUrl = "https://bitcoin-sv.github.io/arc/#/errors?id=_" - StatusOK StatusCode = 200 - ErrStatusBadRequest StatusCode = 400 - ErrStatusNotFound StatusCode = 404 - ErrStatusGeneric StatusCode = 409 - ErrStatusTxFormat StatusCode = 460 - ErrStatusUnlockingScripts StatusCode = 461 - ErrStatusInputs StatusCode = 462 - ErrStatusMalformed StatusCode = 463 - ErrStatusOutputs StatusCode = 464 - ErrStatusFees StatusCode = 465 - ErrStatusConflict StatusCode = 466 - ErrStatusFrozenPolicy StatusCode = 471 - ErrStatusFrozenConsensus StatusCode = 472 - ErrBeefMinedAncestorsNotFound StatusCode = 473 - ErrBeefCalculatingMerkleRoots StatusCode = 474 - ErrBeefValidatingMerkleRoots StatusCode = 475 + StatusOK StatusCode = 200 + ErrStatusBadRequest StatusCode = 400 + ErrStatusNotFound StatusCode = 404 + ErrStatusGeneric StatusCode = 409 + ErrStatusTxFormat StatusCode = 460 + ErrStatusUnlockingScripts StatusCode = 461 + ErrStatusInputs StatusCode = 462 + ErrStatusMalformed StatusCode = 463 + ErrStatusOutputs StatusCode = 464 + ErrStatusFees StatusCode = 465 + ErrStatusConflict StatusCode = 466 + ErrStatusMinedAncestorsNotFound StatusCode = 467 + ErrStatusCalculatingMerkleRoots StatusCode = 468 + ErrStatusValidatingMerkleRoots StatusCode = 469 + ErrStatusFrozenPolicy StatusCode = 471 + ErrStatusFrozenConsensus StatusCode = 472 ) func NewErrorFields(status StatusCode, extraInfo string) *ErrorFields { @@ -87,18 +87,18 @@ func NewErrorFields(status StatusCode, extraInfo string) *ErrorFields { errFields.Detail = "Input Frozen (blacklist manager consensus blacklisted)" errFields.Title = "Input Frozen" errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrStatusFrozenConsensus)) - case ErrBeefMinedAncestorsNotFound: + case ErrStatusMinedAncestorsNotFound: errFields.Detail = "Error validating BEEF: mined ancestors not found in transaction inputs" errFields.Title = "Mined ancestors not found" - errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrBeefMinedAncestorsNotFound)) - case ErrBeefCalculatingMerkleRoots: + errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrStatusMinedAncestorsNotFound)) + case ErrStatusCalculatingMerkleRoots: errFields.Detail = "Error validating BEEF: could not calculate Merkle Roots from given BUMPs" errFields.Title = "Invalid BUMPs" - errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrBeefCalculatingMerkleRoots)) - case ErrBeefValidatingMerkleRoots: + errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrStatusCalculatingMerkleRoots)) + case ErrStatusValidatingMerkleRoots: errFields.Detail = "Error validating BEEF: could not validate Merkle Roots" errFields.Title = "Merkle Roots validation failed" - errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrBeefValidatingMerkleRoots)) + errFields.Type = arcDocServerErrorsUrl + strconv.Itoa(int(ErrStatusValidatingMerkleRoots)) default: errFields.Status = int(ErrStatusGeneric) errFields.Detail = "Transaction could not be processed"