Skip to content

Commit

Permalink
fix(connector-besu): set contract bytecode field's max length to 49154
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
petermetz committed Nov 30, 2024
1 parent 96de0c7 commit 33b2cf0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 33b2cf0

Please sign in to comment.