aionnetwork / aion

Aion Network - Java Implementation
https://theoan.com/
MIT License
337 stars 112 forks source link

eth_signtransaction RPC method not implemented #634

Closed aion-kelvin closed 5 years ago

aion-kelvin commented 6 years ago

Updated by @qoire and @kzeine :

Introduction

The Web3 1.0 has a method named eth.signTransaction, that calls an RPC method named eth_signTransaction. eth_signTransaction is not implemented in the kernel. The purpose of it is to ask the kernel to sign a given transaction, but not send it (unlike eth_sendTransaction), so that the client can have the signed transaction to send at a later time (via eth_sendRawTranaction).

Current situation

This feature is missing in the current Aion implementation. The following error occurs: Web3 1.0 JS invocation:

aion-127.0.0.1:8545> eth.signTransaction({ from:'0xa0450c4333e72ed26552d7462c0b3669924eec816a219b3960d5b3f0b33f7444', to:'0xa0b88269779d225510ca880ed742e445db0c70efb1ee3159b6d56479ae3501f9', gasPrice:10000000, gas:12345, value:"1337", data:""} ).then(console.log);
Promise {
  <pending>,
  domain:
   Domain {
     domain: null,
     _events:
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
aion-127.0.0.1:8545> (node:13250) UnhandledPromiseRejectionWarning: Error: Returned error: Method not found
    at Object.ErrorResponse (/home/sergiu/repos/aion_web3/packages/web3-core-helpers/src/errors.js:29:16)
    at /home/sergiu/repos/aion_web3/packages/web3-core-requestmanager/src/index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (/home/sergiu/repos/aion_web3/packages/web3-providers-http/src/index.js:91:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:460:23)
    at endReadableNT (_stream_readable.js:1085:12)

Log from kernel:

18-09-12 12:18:35.237 DEBUG API  [XNIO-1 task-83]: rpc-server - invalid method: eth_signTransaction [1]

Task Description

We're asking for contributors to implement this feature for https://github.com/aionnetwork/aion. Correct implementation should receive a transaction, sign it, and return the signed transaction as described here: https://web3js.readthedocs.io/en/1.0/web3-eth.html#signtransaction.

Acceptance Criteria


Original post:

Before filing a new issue, please provide the following information.

I'm running:

  • Which Aion version?: 0.3.1.8dc6870
  • Which operating system?: Linux
  • Which distributor and version?: Ubuntu 16.04
  • How installed?: source
  • Are you fully synchronized?: yes
  • Did you try to restart the node?: yes

Your issue description goes here below. Try to include actual vs. expected behavior and steps to reproduce the issue.

The Web3 1.0 has a method named eth.signTransaction, that calls an RPC method named eth_signTransaction. eth_signTransaction is not implemented in the kernel. The purpose of it is to ask the kernel to sign a given transaction, but not send it (unlike eth_sendTransaction), so that the client can have the signed transaction to send at a later time (via eth_sendRawTranaction).

Since there's still other ways to send transaction or sign transactions, this isn't very high priority, just making an issue to keep track of it

Web3 1.0 JS invocation:

aion-127.0.0.1:8545> eth.signTransaction({ from:'0xa0450c4333e72ed26552d7462c0b3669924eec816a219b3960d5b3f0b33f7444', to:'0xa0b88269779d225510ca880ed742e445db0c70efb1ee3159b6d56479ae3501f9', gasPrice:10000000, gas:12345, value:"1337", data:""} ).then(console.log);
Promise {
  <pending>,
  domain:
   Domain {
     domain: null,
     _events:
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
aion-127.0.0.1:8545> (node:13250) UnhandledPromiseRejectionWarning: Error: Returned error: Method not found
    at Object.ErrorResponse (/home/sergiu/repos/aion_web3/packages/web3-core-helpers/src/errors.js:29:16)
    at /home/sergiu/repos/aion_web3/packages/web3-core-requestmanager/src/index.js:140:36
    at XMLHttpRequest.request.onreadystatechange (/home/sergiu/repos/aion_web3/packages/web3-providers-http/src/index.js:91:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/sergiu/repos/aion_web3/packages/web3-providers-http/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:460:23)
    at endReadableNT (_stream_readable.js:1085:12)

Log from kernel:

18-09-12 12:18:35.237 DEBUG API  [XNIO-1 task-83]: rpc-server - invalid method: eth_signTransaction [1]
qoire commented 6 years ago

@JayT106 can we get resolution and someone assigned to this task?

Also just to confirm:

This is not part of the Ethereum JSON-RPC spec, but an assumption in web3.js 1.0. We've made the decision for maximum compatibility with existing web3 features, so will be implementing this.

qoire commented 5 years ago

@kzeine candidate for bounty

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 205.0 AION (87.53 USD @ $0.43/AION) attached to it as part of the Aion Foundation fund.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 weeks, 6 days from now. Please review their action plans below:

1) satran004 has been approved to start work.

Hi, I have looked into the issue and went through the codebase. I plan to start working on this issue.

Planned Steps:

Introduce a new method "eth_signTransaction" in ApiWeb3Aion.java Add a mapping for the new method in RpcMethods.java Write the test for new method. Verify test case. Test from web3 js console.

Questions / Clarification:

My expectation for method parameters are as follows: Please verify.

If _params is an array -> First elemenent is a txn object, Second element is an address as string. If _params is an JSON Object -> the method will look for "transaction" and "address" attribute in the json object.

Please also verify the following: If the address argument is empty or null, txn.getFrom() will be used to sign the transaction.

Thanks.

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 5 years ago

@satran004 Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

satran004 commented 5 years ago

I have started working on this enhancement.

gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 205.0 AION (87.02 USD @ $0.42/AION) has been submitted by:

  1. @satran004

@kzeine please take a look at the submitted work:


gitcoinbot commented 5 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 205.0 AION (87.02 USD @ $0.42/AION) attached to this issue has been approved & issued to @satran004.