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

fix(connector-besu): do not crash if ledger unreachable - send HTTP 503 #3573

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"trivyignores",
"txid",
"txqueue",
"UIDH",
"Uisrs",
"undici",
"unixfs",
Expand All @@ -214,7 +215,8 @@
"websocat",
"WSPROVIDER",
"Xdai",
"xeipuuv"
"xeipuuv",
"XUIDH"
],
"dictionaries": [
"typescript,node,npm,go,rust"
Expand Down
13 changes: 13 additions & 0 deletions .yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/lib/index.js b/lib/index.js
index de2853c247b334e6b22cee42b3e597281c44efdc..787aecf6758228c092f1a3cd8097f64e76cc573d 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -344,7 +344,7 @@ function _handleTxPricing(_this, tx) {
throw Error("Network doesn't support eip-1559");
resolve({ gasPrice });
}
- });
+ }).catch((ex) => reject(ex));
}
}
catch (error) {
petermetz marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"ws": ">=1.1.5",
"xml2js": ">=0.5.0",
"yargs-parser": ">=18.1.1",
"web3-eth-accounts@npm:1.6.1": "patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch",
"zod": ">=3.22.3"
},
"devDependencies": {
Expand Down
157 changes: 157 additions & 0 deletions packages/cactus-common/src/main/typescript/http/http-header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/**
* A list of well-known headers as published on Wikipedia.
* @see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
*
* TODO Finish documenting each enum item and make sure to also include
* the examples provided on the linked Wikipedia page above. The first
* few headers are documented this way but we need all of them like that.
*
* TODO Ensure that there are no typos in the header names.
*/
export enum HttpHeader {
// Standard request fields

/**
* Acceptable instance-manipulations for the request.
* @example A-IM: feed
* @see https://datatracker.ietf.org/doc/html/rfc3229
*/
A_IM = "A-IM",
/**
* Media type(s) that is/are acceptable for the response. See Content negotiation.
* @example Accept: text/html
* @see https://datatracker.ietf.org/doc/html/rfc9110
*/
Accept = "Accept",
/**
* Character sets that are acceptable.
* @example Accept-Charset: utf-8
* @see https://datatracker.ietf.org/doc/html/rfc9110
*/
AcceptCharset = "Accept-Charset",
/**
* Acceptable version in time.
* @example Accept-Datetime: Thu, 31 May 2007 20:35:00 GMT
* @see https://datatracker.ietf.org/doc/html/rfc7089
*/
AcceptDatetime = "Accept-Datetime",
AcceptEncoding = "Accept-Encoding",
AcceptLanguage = "Accept-Language",
AccessControlAllowOrigin = "Access-Control-Allow-Origin",
AccessControlAllowCredentials = "Access-Control-Allow-Credentials",
AccessControlExposeHeaders = "Access-Control-Expose-Headers",
AccessControlMaxAge = "Access-Control-Max-Age",
AccessControlAllowMethods = "Access-Control-Allow-Methods",
AccessControlAllowHeaders = "Access-Control-Allow-Headers",
Authorization = "Authorization",
CacheControl = "Cache-Control",
Connection = "Connection",
ContentDisposition = "Content-Disposition",
ContentEncoding = "Content-Encoding",
ContentLength = "Content-Length",
ContentLocation = "Content-Location",
ContentMD5 = "Content-MD5",
ContentType = "Content-Type",
Cookie = "Cookie",
Date = "Date",
Expect = "Expect",
Forwarded = "Forwarded",
From = "From",
Host = "Host",
IfMatch = "If-Match",
IfModifiedSince = "If-Modified-Since",
IfNoneMatch = "If-None-Match",
IfRange = "If-Range",
IfUnmodifiedSince = "If-Unmodified-Since",
MaxForwards = "Max-Forwards",
Origin = "Origin",
Pragma = "Pragma",
Prefer = "Prefer",
ProxyAuthorization = "Proxy-Authorization",
Range = "Range",
Referer = "Referer",
TE = "TE",
Trailer = "Trailer",
TransferEncoding = "Transfer-Encoding",
Upgrade = "Upgrade",
UserAgent = "User-Agent",

// Common non-standard request fields
UpgradeInsecureRequests = "Upgrade-Insecure-Requests",
XRequestedWith = "X-Requested-With",
DNT = "DNT",
XForwardedFor = "X-Forwarded-For",
XForwardedHost = "X-Forwarded-Host",
XForwardedProto = "X-Forwarded-Proto",
FrontEndHttps = "Front-End-Https",
XHttpMethodOverride = "X-Http-Method-Override",
XAttDeviceId = "X-Att-DeviceId",
XWapProfile = "X-Wap-Profile",
ProxyConnection = "Proxy-Connection",
XUIDH = "X-UIDH",
XCsrfToken = "X-Csrf-Token",
XRequestId = "X-Request-ID", // Alternative X-Request-Id
CorrelationId = "X-Correlation-ID", // Alternative Correlation-ID
SaveData = "Save-Data",
SecGpc = "Sec-GPC",

// Standard response fields
AcceptCH = "Accept-CH",
AcceptPatch = "Accept-Patch",
AltSvc = "Alt-Svc",
Age = "Age",
Allow = "Allow",
Expires = "Expires",
IM = "IM",
LastModified = "Last-Modified",
Link = "Link",
Location = "Location",
P3P = "P3P",
ProxyAuthenticate = "Proxy-Authenticate",
PublicKeyPins = "Public-Key-Pins",
/**
* f an entity is temporarily unavailable, this instructs the client
* to try again later. Value could be a specified period of time
* (in seconds) or a HTTP-date.
*
* There are two accepted formats when it comes to the values of the header:
* ```http
* Retry-After: <http-date>
* Retry-After: <delay-seconds>
* ```
*
* `<http-date>`
* A date after which to retry. See the Date header for more details on the HTTP date format.
*
* `<delay-seconds>`
* A non-negative decimal integer indicating the seconds to delay after the response is received.
*
* @example Retry-After: 120
* @example Retry-After: Fri, 07 Nov 2014 23:59:59 GMT
*
* @see https://datatracker.ietf.org/doc/html/rfc9110#section-10.2.3
*/
RetryAfter = "Retry-After",
Server = "Server",
SetCookie = "Set-Cookie",
StrictTransportSecurity = "Strict-Transport-Security",
Tk = "Tk",
Vary = "Vary",
Via = "Via", // Same as request field
/**
* Indicates the authentication scheme that should be used to access the requested entity.
* @example WWW-Authenticate: Basic
* @see https://datatracker.ietf.org/doc/html/rfc9110
*/
WWWAuthenticate = "WWW-Authenticate",
XFrameOptions = "X-Frame-Options",

// Common non-standard response fields
ContentSecurityPolicy = "Content-Security-Policy",
ExpectCT = "Expect-CT",
NEL = "NEL",
PermissionsPolicy = "Permissions-Policy",
Refresh = "Refresh",
ReportTo = "Report-To",
Timing_Allow_Origin = "Timing-Allow-Origin",
}
2 changes: 2 additions & 0 deletions packages/cactus-common/src/main/typescript/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ export {
} from "./http/express-http-verb-method-name";

export { isGrpcStatusObjectWithCode } from "./grpc/is-grpc-status-object-with-code";

export { HttpHeader } from "./http/http-header";
6 changes: 4 additions & 2 deletions packages/cactus-plugin-ledger-connector-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"web3-eth": "1.6.1",
"web3-eth-contract": "1.6.1",
"web3-utils": "1.6.1",
"web3js-quorum": "22.4.0"
"web3js-quorum": "22.4.0",
"websocket-event-codes": "1.1.0"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "2.0.0",
Expand All @@ -105,7 +106,8 @@
"tsx": "4.16.2",
"uuid": "10.0.0",
"web3-core": "1.6.1",
"web3-eth": "1.6.1"
"web3-eth": "1.6.1",
"web3-eth-accounts": "patch:web3-eth-accounts@npm%3A1.6.1#~/.yarn/patches/web3-eth-accounts-npm-1.6.1-c95f31ca81.patch"
},
"engines": {
"node": ">=18",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ client.go
configuration.go
go.mod
go.sum
model_backing_ledger_unavailable_error.go
model_besu_private_transaction_config.go
model_besu_transaction_config.go
model_besu_transaction_config_to.go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Class | Method | HTTP request | Description

## Documentation For Models

- [BackingLedgerUnavailableError](docs/BackingLedgerUnavailableError.md)
- [BesuPrivateTransactionConfig](docs/BesuPrivateTransactionConfig.md)
- [BesuTransactionConfig](docs/BesuTransactionConfig.md)
- [BesuTransactionConfigTo](docs/BesuTransactionConfigTo.md)
Expand Down
Loading
Loading