From d0e6397b8c566c91f4d018eca8ed8bfbcdb3030c Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Thu, 14 Nov 2024 10:30:04 -0800 Subject: [PATCH] fix(connector-besu): set contract bytecode field's max length to 49154 Prior to this commit the Besu connector's API validated requests when deploying solidity contracts via their bytecode such that the length of the bytecode parameter cannot be longer than 24576 characters, but instead it should have an upper limit of 49154 characters because each byte is represented as two characters in hex. See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit." Fixes #3636 Signed-off-by: Peter Somogyvari --- .../go/generated/openapi/go-client/api/openapi.yaml | 12 ++++++++---- ...tract_solidity_bytecode_no_keychain_v1_request.go | 2 +- ...l_deploy_contract_solidity_bytecode_v1_request.go | 2 +- .../src/main/json/openapi.json | 8 ++++---- .../src/main/json/openapi.tpl.json | 8 ++++---- ...solidity_bytecode_no_keychain_v1_request_pb.proto | 2 +- ...oy_contract_solidity_bytecode_v1_request_pb.proto | 2 +- .../generated/openapi/typescript-axios/api.ts | 4 ++-- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml index 1441ac22c7..14c138a59a 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/api/openapi.yaml @@ -1041,8 +1041,10 @@ components: $ref: '#/components/schemas/Web3SigningCredential' bytecode: description: See https://ethereum.stackexchange.com/a/47556 regarding the - maximum length of the bytecode - maxLength: 24576 + maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex + stores each byte in 2 characters and that there is a 0x prefix (2 characters) + which does not count towards the EVM 24576 bytecode limit. + maxLength: 49154 minLength: 1 nullable: false type: string @@ -1117,8 +1119,10 @@ components: $ref: '#/components/schemas/Web3SigningCredential' bytecode: description: See https://ethereum.stackexchange.com/a/47556 regarding the - maximum length of the bytecode - maxLength: 24576 + maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex + stores each byte in 2 characters and that there is a 0x prefix (2 characters) + which does not count towards the EVM 24576 bytecode limit. + maxLength: 49154 minLength: 1 nullable: false type: string diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_no_keychain_v1_request.go b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_no_keychain_v1_request.go index a23d97391c..35e6a7d6c8 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_no_keychain_v1_request.go +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_no_keychain_v1_request.go @@ -25,7 +25,7 @@ type DeployContractSolidityBytecodeNoKeychainV1Request struct { ContractAbi []interface{} `json:"contractAbi"` ConstructorArgs []interface{} `json:"constructorArgs"` Web3SigningCredential Web3SigningCredential `json:"web3SigningCredential"` - // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. Bytecode string `json:"bytecode"` Gas *float32 `json:"gas,omitempty"` GasPrice *string `json:"gasPrice,omitempty"` diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_v1_request.go b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_v1_request.go index 72087f01d6..11f4d381db 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_v1_request.go +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/go/generated/openapi/go-client/model_deploy_contract_solidity_bytecode_v1_request.go @@ -25,7 +25,7 @@ type DeployContractSolidityBytecodeV1Request struct { ContractAbi []interface{} `json:"contractAbi"` ConstructorArgs []interface{} `json:"constructorArgs"` Web3SigningCredential Web3SigningCredential `json:"web3SigningCredential"` - // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. Bytecode string `json:"bytecode"` // The keychainId for retrieve the contracts json. KeychainId string `json:"keychainId"` diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json index 50f7b3457a..3a401ec1ac 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.json @@ -731,8 +731,8 @@ "type": "string", "nullable": false, "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + "maxLength": 49154, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit." }, "keychainId": { "type": "string", @@ -798,8 +798,8 @@ "type": "string", "nullable": false, "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + "maxLength": 49154, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit." }, "gas": { "type": "number", diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json index 50f7b3457a..3a401ec1ac 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/json/openapi.tpl.json @@ -731,8 +731,8 @@ "type": "string", "nullable": false, "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + "maxLength": 49154, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit." }, "keychainId": { "type": "string", @@ -798,8 +798,8 @@ "type": "string", "nullable": false, "minLength": 1, - "maxLength": 24576, - "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode" + "maxLength": 49154, + "description": "See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit." }, "gas": { "type": "number", diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto index e28f470ea6..2b9a906edb 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_no_keychain_v1_request_pb.proto @@ -29,7 +29,7 @@ message DeployContractSolidityBytecodeNoKeychainV1RequestPB { Web3SigningCredentialPB web3SigningCredential = 451211679; - // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. string bytecode = 256554254; float gas = 102105; diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_v1_request_pb.proto b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_v1_request_pb.proto index 7d02655c1d..20dcc4abbc 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_v1_request_pb.proto +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/models/deploy_contract_solidity_bytecode_v1_request_pb.proto @@ -29,7 +29,7 @@ message DeployContractSolidityBytecodeV1RequestPB { Web3SigningCredentialPB web3SigningCredential = 451211679; - // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + // See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. string bytecode = 256554254; // The keychainId for retrieve the contracts json. diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts index cdc1e95961..15d28f064e 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -176,7 +176,7 @@ export interface DeployContractSolidityBytecodeNoKeychainV1Request { */ 'web3SigningCredential': Web3SigningCredential; /** - * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. * @type {string} * @memberof DeployContractSolidityBytecodeNoKeychainV1Request */ @@ -237,7 +237,7 @@ export interface DeployContractSolidityBytecodeV1Request { */ 'web3SigningCredential': Web3SigningCredential; /** - * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode + * See https://ethereum.stackexchange.com/a/47556 regarding the maximum length of the bytecode. 2 + (24576 * 2) = 49154 meaning that hex stores each byte in 2 characters and that there is a 0x prefix (2 characters) which does not count towards the EVM 24576 bytecode limit. * @type {string} * @memberof DeployContractSolidityBytecodeV1Request */