Web3ValidatorError error when use sendSignedTransaction on HB blockchain #6393
Description
Description
As an blockchain developper, i'm actualy working on smart contract ERC-721 POC. I have a Hyperledger Besu blockchain working on my VM with 4 nodes, built with Qorum Quickstart (https://besu.hyperledger.org/stable/private-networks/tutorials/quickstart). This blockchain is configured for 0 fees.
I can develop, build, deploy, use my contract on Remix connected on my Hyperldeger Besu blockchain, but when i want to deploy the same smart contract from Visual Studio Code i have some mistakes with the signature of my transaction for deploy the contract.
Acceptance Criteria
Can build and sign my transaction for deploy the contract on my Hyperledger Besu blockchain.
Steps to Reproduce (Bug)
- Launch Hyperledger Besu blockchain with
./resume.sh
from the blockchain folder - Compile my smart contract and retrieve BIN, ABI and JSON files from bash script. Truffle dependencies on my VIsual Code had never worked, it's why i'm using this script.
Contract code on Test.sol :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Test {
uint public count;
function increment() external {
count += 1;
}
}
command to launch the script :
./compile.sh contract.sol
bash script :
fileNameWithoutpath=$(basename $1)
#retrive file name without extension
fileNameWithoutPathAndExtension=${fileNameWithoutpath%.*}
echo "${bold}*************************************"
echo "Compile smart contract to BIN and ABI files from SOL files"
echo "*************************************${normal}"
solcjs --bin --abi $1 -o ../../build/contracts/
echo "fileNameWithoutPathAndExtension => $fileNameWithoutPathAndExtension"
solc $1 --combined-json abi,bin > ../../build/contracts/$fileNameWithoutPathAndExtension.json
for file in ../../build/contracts/*; do
# Rename each file from this folder
mv "$file" "../../build/contracts/${file##*_}"
done
- Once my contract was built, i want to create transaction to deploy it on my Heperldger Besu Blockchain.
This is the genesis file of it :
{
"config" : {
"chainId": 1337,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirglacierblock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"zeroBaseFee": true,
"contractSizeLimit": 2147483647,
"qbft": {
"blockperiodseconds": 5,
"epochlength": 30000,
"requesttimeoutseconds": 10
}
},
"nonce" : "0x0",
"timestamp" : "0x58ee40ba",
"gasLimit" : "0x1fffffffffffff",
"difficulty" : "0x1",
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"mixHash" : "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
"extraData": "0xf87aa00000000000000000000000000000000000000000000000000000000000000000f8549493917cadbace5dfce132b991732c6cda9bcc5b8a9427a97c9aaf04f18f3014c32e036dd0ac76da5f1894ce412f988377e31f4d0ff12d74df73b51c42d0ca9498c1334496614aed49d2e81526d089f7264fed9cc080c0",
"coinbase" : "0x0000000000000000000000000000000000000000",
"alloc" : { DELETED FOR THE GITHUB ISSUE }
}
- I create my transaction, sign it and send it from the file "public_tx.js" called from this command :
node public_tx.js
This is the content of the file :
const { FeeMarketEIP1559Transaction } = require("@ethereumjs/tx");
// const Common = require("@ethereumjs/common").default;
const { Common, Chain, Hardfork } = require("@ethereumjs/common");
const ethUtil = require("ethereumjs-util");
const {Web3} = require("web3");
const path = require("path");
const fs = require("fs-extra");
const web3 = new Web3("http://0.0.0.0:8545");
const to = "0x0000000000000000000000000000000000009999"
// Define the network parameters
const chainId = 1337; // The chain ID of your Besu network
const hardfork = "london"; // The hardfork name of your Besu network
async function publicTx() {
const customCommon = Common.custom({
chainId: chainId,
hardfork: hardfork
});
const account = web3.eth.accounts.privateKeyToAccount(
"PRIVATEKEY",
true
);
const contractJsonPath = path.resolve(
__dirname,
"../../build/contracts/Test.json"
);
const contractJson = JSON.parse(fs.readFileSync(contractJsonPath));
const contractAbi = contractJson.abi;
const contractBinPath = path.resolve(
__dirname,
"../../build/contracts/Test.bin"
);
const contractBin = fs.readFileSync(contractBinPath);
const contractConstructorInit =
"000000000000000000000000000000000000000000000000000000000000002F";
const txnCount = await web3.eth.getTransactionCount(account.address);
const dataBuild = "0x" + contractBin + contractConstructorInit
console.log('dataBuild ==> ',dataBuild)
const rawTxOptions = {
nonce: web3.utils.numberToHex(txnCount),
maxPriorityFeePerGas: "0x0", // The max priority fee per gas in wei
maxFeePerGas: "0x0", // The max fee per gas in wei
gasLimit: "0x186A0", // The gas limit in wei
to: "0x0000000000000000000000000000000000009999", // The address of the contract you want to deploy
value: "0x00", // The value in wei
data: dataBuild
};
console.log('account ==> ', account)
const privateKeyBuff = Buffer.from(
account.privateKey,
'hex'
);
const tx = FeeMarketEIP1559Transaction.fromTxData(rawTxOptions, { customCommon });
const signedTx = tx.sign(privateKeyBuff);
var serializedTx = signedTx.serialize();
console.log("serializedTx ==> " ,serializedTx);
const pTx = await web3.eth.sendSignedTransaction(
"0x" + serializedTx.toString("hex").toString("hex")
, function(error, receipt) {
if (!error) {
console.log('receipt => ' ,receipt)
} else {
console.log('error => ' ,error)
}
});
console.log("tx transactionHash: " + pTx.transactionHash);
console.log("tx contractAddress: " + pTx.contractAddress);
}
publicTx();
result of console.log for dataBuild :
0x608060405234801561000f575f80fd5b506101468061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c806306661abd14610038578063d09de08a14610056575b5f80fd5b610040610060565b60405161004d9190610097565b60405180910390f35b61005e610065565b005b5f5481565b60015f8082825461007691906100dd565b92505081905550565b5f819050919050565b6100918161007f565b82525050565b5f6020820190506100aa5f830184610088565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6100e78261007f565b91506100f28361007f565b925082820190508082111561010a576101096100b0565b5b9291505056fea26469706673582212201c3c48dec99e9cf77132e4073590b6c55580f5c057b9a16678a26b3bd45b716c64736f6c63430008150033000000000000000000000000000000000000000000000000000000000000002F
result of console.log for account:
address: '0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73',
privateKey: 'PRIVATEKEY',
signTransaction: [Function: signTransaction],
sign: [Function: sign],
encrypt: [Function: encrypt]
}
result of console.log for serializedTx:
Uint8Array(492) [
2, 249, 1, 232, 1, 128, 128, 128, 131, 1, 134, 160,
148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 153, 153, 128, 185, 1,
131, 96, 128, 96, 64, 82, 52, 128, 21, 97, 0, 15,
87, 95, 128, 253, 91, 80, 97, 1, 70, 128, 97, 0,
29, 95, 57, 95, 243, 254, 96, 128, 96, 64, 82, 52,
128, 21, 97, 0, 15, 87, 95, 128, 253, 91, 80, 96,
4, 54, 16, 97, 0, 52, 87, 95, 53, 96, 224, 28,
128, 99, 6, 102,
... 392 more items
Just after these console.log i have a error :
/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/validator.js:73
throw new errors_js_1.Web3ValidatorError(errors);
^
Web3ValidatorError: Web3 validator found 1 error[s]:
value "0x2,249,1,232,1,128,128,128,131,1,134,160,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,128,185,1,131,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,97,1,70,128,97,0,29,95,57,95,243,254,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,96,4,54,16,97,0,52,87,95,53,96,224,28,128,99,6,102,26,189,20,97,0,56,87,128,99,208,157,224,138,20,97,0,86,87,91,95,128,253,91,97,0,64,97,0,96,86,91,96,64,81,97,0,77,145,144,97,0,151,86,91,96,64,81,128,145,3,144,243,91,97,0,94,97,0,101,86,91,0,91,95,84,129,86,91,96,1,95,128,130,130,84,97,0,118,145,144,97,0,221,86,91,146,80,80,129,144,85,80,86,91,95,129,144,80,145,144,80,86,91,97,0,145,129,97,0,127,86,91,130,82,80,80,86,91,95,96,32,130,1,144,80,97,0,170,95,131,1,132,97,0,136,86,91,146,145,80,80,86,91,127,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,95,82,96,17,96,4,82,96,36,95,253,91,95,97,0,231,130,97,0,127,86,91,145,80,97,0,242,131,97,0,127,86,91,146,80,130,130,1,144,80,128,130,17,21,97,1,10,87,97,1,9,97,0,176,86,91,91,146,145,80,80,86,254,162,100,105,112,102,115,88,34,18,32,28,60,72,222,201,158,156,247,113,50,228,7,53,144,182,197,85,128,245,192,87,185,161,102,120,162,107,59,212,91,113,108,100,115,111,108,99,67,0,8,21,0,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,192,128,160,52,50,225,140,187,125,5,209,45,142,251,176,206,178,8,64,131,49,4,73,77,57,12,182,167,170,7,151,166,172,88,15,160,8,244,95,158,148,147,217,202,246,101,194,121,38,108,83,78,161,148,56,68,231,33,13,173,150,83,21,75,44,115,17,222" at "/0" must pass "bytes" validation
at Validator.validate (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/validator.js:73:23)
at Web3Validator.validate (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-validator/lib/commonjs/web3_validator.js:35:32)
at bytesToUint8Array (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/node_modules/web3-utils/lib/commonjs/converters.js:69:32)
at hexToBytes (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/node_modules/web3-utils/lib/commonjs/converters.js:114:42)
at Object.<anonymous> (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:429:171)
at Generator.next (<anonymous>)
at /home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:24:71
at new Promise (<anonymous>)
at __awaiter (/home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:20:12)
at /home/adminlogin/BESU_NETWORK/v5/contracts/EOBLOCK v2/node_modules/web3-eth/lib/commonjs/rpc_method_wrappers.js:426:20 {
innerError: undefined,
code: 1100,
errors: [
{
keyword: '0',
instancePath: '/0',
schemaPath: '#0',
params: {
value: '0x2,249,1,232,1,128,128,128,131,1,134,160,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,128,185,1,131,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,97,1,70,128,97,0,29,95,57,95,243,254,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,96,4,54,16,97,0,52,87,95,53,96,224,28,128,99,6,102,26,189,20,97,0,56,87,128,99,208,157,224,138,20,97,0,86,87,91,95,128,253,91,97,0,64,97,0,96,86,91,96,64,81,97,0,77,145,144,97,0,151,86,91,96,64,81,128,145,3,144,243,91,97,0,94,97,0,101,86,91,0,91,95,84,129,86,91,96,1,95,128,130,130,84,97,0,118,145,144,97,0,221,86,91,146,80,80,129,144,85,80,86,91,95,129,144,80,145,144,80,86,91,97,0,145,129,97,0,127,86,91,130,82,80,80,86,91,95,96,32,130,1,144,80,97,0,170,95,131,1,132,97,0,136,86,91,146,145,80,80,86,91,127,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,95,82,96,17,96,4,82,96,36,95,253,91,95,97,0,231,130,97,0,127,86,91,145,80,97,0,242,131,97,0,127,86,91,146,80,130,130,1,144,80,128,130,17,21,97,1,10,87,97,1,9,97,0,176,86,91,91,146,145,80,80,86,254,162,100,105,112,102,115,88,34,18,32,28,60,72,222,201,158,156,247,113,50,228,7,53,144,182,197,85,128,245,192,87,185,161,102,120,162,107,59,212,91,113,108,100,115,111,108,99,67,0,8,21,0,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,192,128,160,52,50,225,140,187,125,5,209,45,142,251,176,206,178,8,64,131,49,4,73,77,57,12,182,167,170,7,151,166,172,88,15,160,8,244,95,158,148,147,217,202,246,101,194,121,38,108,83,78,161,148,56,68,231,33,13,173,150,83,21,75,44,115,17,222'
},
message: 'value "0x2,249,1,232,1,128,128,128,131,1,134,160,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,153,153,128,185,1,131,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,97,1,70,128,97,0,29,95,57,95,243,254,96,128,96,64,82,52,128,21,97,0,15,87,95,128,253,91,80,96,4,54,16,97,0,52,87,95,53,96,224,28,128,99,6,102,26,189,20,97,0,56,87,128,99,208,157,224,138,20,97,0,86,87,91,95,128,253,91,97,0,64,97,0,96,86,91,96,64,81,97,0,77,145,144,97,0,151,86,91,96,64,81,128,145,3,144,243,91,97,0,94,97,0,101,86,91,0,91,95,84,129,86,91,96,1,95,128,130,130,84,97,0,118,145,144,97,0,221,86,91,146,80,80,129,144,85,80,86,91,95,129,144,80,145,144,80,86,91,97,0,145,129,97,0,127,86,91,130,82,80,80,86,91,95,96,32,130,1,144,80,97,0,170,95,131,1,132,97,0,136,86,91,146,145,80,80,86,91,127,78,72,123,113,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,95,82,96,17,96,4,82,96,36,95,253,91,95,97,0,231,130,97,0,127,86,91,145,80,97,0,242,131,97,0,127,86,91,146,80,130,130,1,144,80,128,130,17,21,97,1,10,87,97,1,9,97,0,176,86,91,91,146,145,80,80,86,254,162,100,105,112,102,115,88,34,18,32,28,60,72,222,201,158,156,247,113,50,228,7,53,144,182,197,85,128,245,192,87,185,161,102,120,162,107,59,212,91,113,108,100,115,111,108,99,67,0,8,21,0,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,192,128,160,52,50,225,140,187,125,5,209,45,142,251,176,206,178,8,64,131,49,4,73,77,57,12,182,167,170,7,151,166,172,88,15,160,8,244,95,158,148,147,217,202,246,101,194,121,38,108,83,78,161,148,56,68,231,33,13,173,150,83,21,75,44,115,17,222" at "/0" must pass "bytes" validation'
}
]
}
I maked some research on google but i don't find any topic with this error.
Expected behavior: can deploy my contract
Actual behavior: error displayed on console when sendSignedTransaction is used
Frequency: Every time i use this function
- Software version: [
besu --version
] : using dockerimage: hyperledger/besu:${BESU_VERSION:-latest}
- OS Name & Version: [
cat /etc/*release
] : Ubuntu 22.04.1 LTS - Kernel Version: [
uname -a
] : Linux blockchain 5.15.0-52-generic Update to latest #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux - Docker Version: [
docker version
] : 20.10.12 - Consensus Client & Version if using Proof of Stake: [e.g. Teku, Lighthouse, Prysm, Nimbus, Lodestar] : using QBFT
Smart contract information (If you're reporting an issue arising from deploying or calling a smart contract, please supply related information)
- Solidity version [
solc --version
] : Version: 0.8.21+commit.d9974bed.Linux.g++ - Repo with minimal set of deployable/reproducible contract code - please provide a link : can't provide link with my companie safety rules
- Please include specifics on how you are deploying/calling the contract : step 3
- Have you reproduced the issue on other eth clients : smart contract can be build / compil / deploy and use on Remix connected to my blockchain with remixd
Additional Information (Add any of the following or anything else that may be relevant)
- Besu setup info - genesis file, config options : Genesis provided on top of the issue
- System info - memory, CPU : VM with 4 CPU / Go RAM / 150Go SSD