quorum icon indicating copy to clipboard operation
quorum copied to clipboard

Raw transactions fail with "invalid sender"

Open esanchma opened this issue 8 years ago • 5 comments

System information

Geth version:

Version: 1.7.2-stable
Git Commit: aa163f0367bda248e7e529e9c42f8c4bd7a82bee
Quorum Version: 2.0.2
Architecture: amd64
Network Id: 1
Go Version: go1.8.7
Operating System: linux
GOPATH=/home/ubuntu/alastria/workspace
GOROOT=/usr/local/go

OS & Version: Ubuntu LTS & RHEL 7.4

Branch, Commit Hash or Release: aa163f0367bda248e7e529e9c42f8c4bd7a82bee

Expected behaviour

If you send a raw_transaction with web3.js , the transaction is validated and mined correctly. STR was tested with go-ethereum and ganache successfully.

Actual behaviour

TRACE[04-23|07:29:31|core/tx_pool.go:610] Discarding invalid transaction hash=461b8b…55f891 err="invalid sender"

Steps to reproduce the behaviour

The following code fails with the error Error: Returned error: invalid sender

const CryptoJS = require('crypto-js') //"crypto-js": "^3.1.9-1"
const Web3 = require("web3") //"web3": "^1.0.0-beta.34"
//private test network: eth-netstats in http://ec2-35-180-40-189.eu-west-3.compute.amazonaws.com:3000
//cakeshop in http://ec2-35-180-40-189.eu-west-3.compute.amazonaws.com:8080/cakeshop
const web3 = new Web3("http://ec2-35-180-40-189.eu-west-3.compute.amazonaws.com:22001") 

//Private key
var privateKey = CryptoJS.SHA256("secret").toString(CryptoJS.enc.Hex)

//Generate account from privateKey
var account = web3.eth.accounts.privateKeyToAccount(privateKey)

//Contract information
var abi = [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
var bytecode = "0x6060604052341561000f57600080fd5b60d38061001d6000396000f3006060604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c14606e575b600080fd5b3415605857600080fd5b606c60048080359060200190919050506094565b005b3415607857600080fd5b607e609e565b6040518082815260200191505060405180910390f35b8060008190555050565b600080549050905600a165627a7a7230582024e31ddcaca688117dbcc5b71795151ec9b400c90f753004fbe9fee44ad940a10029"

//Get data to deploy contract
let contract = new web3.eth.Contract(abi)
let instance = contract.deploy({
  data: bytecode
}).encodeABI()

//Construct RawTx
var rawTx = {
  nonce: web3.utils.toHex(0),
  gasPrice: web3.utils.toHex(0),
  gasLimit: web3.utils.toHex(21000),
  gas: web3.utils.toHex(470000),
  value: web3.utils.toHex(0),
  data: instance,
  from: account.address
}

//Sign Tx
account.signTransaction(rawTx)
  .then(signed=>{
    console.log(web3.eth.accounts.recoverTransaction(signed.rawTransaction))
    web3.eth.sendSignedTransaction(signed.rawTransaction)
      .on('receipt', console.log)
      .on('error', console.log)
  })
  .catch(console.log)

When the account is generated with keythereum and the transaction is signed with ethereumjs-tx, web3.eth.sendSignedTransaction sends the transaction correctly

Backtrace

Error: Returned error: invalid sender
    at Object.ErrorResponse (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\web3-core-helpers\src\errors.js:29:16)
    at C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\web3-core-requestmanager\src\index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\web3-providers-http\src\index.js:77:13)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\xhr2\lib\xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\xhr2\lib\xhr2.js:354:12)    at XMLHttpRequest._onHttpResponseEnd (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\xhr2\lib\xhr2.js:509:12)
    at IncomingMessage.<anonymous> (C:\Users\esanchma\Downloads\testSendSignedTx\node_modules\xhr2\lib\xhr2.js:469:24)
    at IncomingMessage.emit (events.js:165:20)
    at endReadableNT (_stream_readable.js:1101:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

esanchma avatar Apr 23 '18 14:04 esanchma

@esanchma I believe this is related to PR #354

jpmsam avatar Apr 25 '18 23:04 jpmsam

@jpmsam Can you confirm the big is fixed in that branch?

davux avatar May 04 '18 13:05 davux

@esanchma @davux this should be fixed in master now. You will also need the latest genesis from quorum examples.

jpmsam avatar May 29 '18 18:05 jpmsam

@jpmjaw how to pass privateFor param in Raw transactions?

thackerronak avatar Jun 14 '18 10:06 thackerronak

Please reopen if this is still an issue.

fixanoid avatar Aug 17 '18 18:08 fixanoid