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

eth_sendRawTransaction JSON RPC #1267

Merged
merged 10 commits into from
Jun 18, 2015
Merged

Conversation

SilentCicero
Copy link
Contributor

I'm still testing this, but this should allow signed transactions to be sent to JSON RPC. It uses the pushTx method, which I believe is the right approach for sending signed transaction packets to the chain. Thoughts?

Closes #1071

@d11e9
Copy link

d11e9 commented Jun 15, 2015

👍 handy

@tgerring
Copy link
Contributor

I definitely would like to see this get merged. Once concern I have is that with this in place, it seem like eth_sendTransaction should then be using the same underlying XEth signing and pushing functions.

For example, we have XEth.Sign() and XEth.PushTx(), but neither of these are used by XEth.SendTransaction(), which seems a bit strange. Maybe we leave refactoring for a later date, since there's probably quite a bit of cleanup that can be done, but I wanted to document this concern at a minimum.

@@ -170,6 +170,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
}
*reply = v

case "eth_pushTx":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to eth_sendRawTransaction

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt it in my bones that you wanted this name :)

@obscuren obscuren modified the milestone: 0.9.32 Jun 15, 2015
@SilentCicero SilentCicero changed the title eth_pushTx JSON RPC eth_sendRawTransaction JSON RPC Jun 15, 2015
@SilentCicero
Copy link
Contributor Author

@tgerring Yeah, I wasn't to sure how this fits in with the broader plan for geth's sendTransaction system/xEth SIgn and pushTX. But my main point here would be eth_sendRawTransaction should remain an open method outside the account lock mechanism that allows for valid and complete signed TX's to stream into RPC. I see there being many use cases for this, I need it for several projects myself. In general browser-based account management. I'm working with Martin and Aaron on this. Cool stuff ahead!

@kumavis
Copy link
Member

kumavis commented Jun 15, 2015

Definitely want eth_sendRawTransaction. Haven't reviewed the implementation here though.

@ethers
Copy link
Member

ethers commented Jun 15, 2015

+1 for this but please add test/s too (wherever they are and maybe in https://github.com/ethereum/rpc-tests)

@@ -51,6 +51,7 @@ var (
"getData",
"getCode",
"sign",
"eth_sendRawTransaction",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks different than all the others.

@subtly
Copy link
Member

subtly commented Jun 16, 2015

Not quite groking what feedback the errors provide. What if there's an error? Does this PR check the nonce, verify transaction will run, etc?

Would be great to see this go in, and even better if the feedback is as informative as submitting a transaction without a signature.

@SilentCicero
Copy link
Contributor Author

Just tested eth_sendRawTransaction with ethereumjs-tx, and curl I get successful results back. All invalid TX data reported back successfully through RPC errors, i.e. low gas, invalid nonce, invalid from data. It acted much like Transaction or eth_sendTransaction. Although more tests should be run to fully vet PushTx.

My curl sample is like this:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0f6cf08300b7bdc6d83d1898321a19770cb25578","0xf869808609184e72a000831cfde094db7f3f1863c261524fa069127edc7fa9d568359683015f90001ba08a0ea4c989a033c2b41128b11cdc7224303eddb9965e30c2403e3037eb4be8cca0fb199be30641029857c4ef19fea6f0c444957a0a9e6110eb9a005d498a8dc82b"],"id":67}' http://localhost:8545

Where unfortunately, the first param used here, must be a "from" address. @tgerring this is unnecessary, but I feel uncomfortable manipulating core to remove this required "from", at this time. And seeing as the "from" param is required in both new and old style transactions, leaving it in seems entirely adequate.

The address used here is:
0f6cf08300b7bdc6d83d1898321a19770cb25578

The private key used here is:
904c942217570531bcf3e51f76686132904c942217570531bcf3e51f76686132

The raw signed transaction used here is:
0xf869808609184e72a000831cfde094db7f3f1863c261524fa069127edc7fa9d568359683015f90001ba08a0ea4c989a033c2b41128b11cdc7224303eddb9965e30c2403e3037eb4be8cca0fb199be30641029857c4ef19fea6f0c444957a0a9e6110eb9a005d498a8dc82b

The library used to generate this transaction data can be found here: https://github.com/ethereum/ethereumjs-tx

Cheers :)

@ethers
Copy link
Member

ethers commented Jun 16, 2015

This really should have tests in code which will help reviewers and future refactoring and maintenance of this code. Anyway, I won't mention again and will let the reviewers decide between the balance of quickly merging code/functionality vs time to write tests (sometimes the tests could take much longer to write than the code).

I feel uncomfortable manipulating core to remove this required "from", at this time.

Is it possible to have the first param still be an object with a from key ?

"params":[{"from":"0f6cf08300b7bdc6d83d1898321a19770cb25578", "data":"0xf869808609184e72a000831cfde094db7f3f1863c261524fa069127edc7fa9d568359683015f90001ba08a0ea4c989a033c2b41128b11cdc7224303eddb9965e30c2403e3037eb4be8cca0fb199be30641029857c4ef19fea6f0c444957a0a9e6110eb9a005d498a8dc82b"}]

@SilentCicero
Copy link
Contributor Author

@ethers with the latest commit, thanks to the help of @tgerring you no longer need to add the "from" param inside the RPC "params", example:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf869808609184e72a000831cfde094db7f3f1863c261524fa069127edc7fa9d568359683015f90001ba08a0ea4c989a033c2b41128b11cdc7224303eddb9965e30c2403e3037eb4be8cca0fb199be30641029857c4ef19fea6f0c444957a0a9e6110eb9a005d498a8dc82b"],"id":67}' http://localhost:8545

The address used:

0f6cf08300b7bdc6d83d1898321a19770cb25578

The private key used:

904c942217570531bcf3e51f76686132904c942217570531bcf3e51f76686132

I don't feel comfortable writing tests for this in go at this point, however, you can do a run through with CURL using the CURL example I provided above. Set the address above as your --etherbase="0f6cf08300b7bdc6d83d1898321a19770cb25578" mine ether to it, then use the CURL sample above to run eth_sendRawTransaction.

There is definitely more testing to do here.

@SilentCicero
Copy link
Contributor Author

We also need to catch invalid gas, gasPrice, nonce and to much like eth_sendTransaction does. Both with the RPC and with xeth.

obscuren added a commit that referenced this pull request Jun 18, 2015
eth_sendRawTransaction JSON RPC
@obscuren obscuren merged commit e4f9ec8 into ethereum:develop Jun 18, 2015
@tgerring
Copy link
Contributor

The tests were never merged... I'll create a separate PR with them

maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Mar 16, 2023
maoueh pushed a commit to streamingfast/go-ethereum that referenced this pull request Aug 1, 2024
p2p: cherry-pick commits from geth for peering issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants