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

AIP010 Beacon hash check #984

Closed
wants to merge 3 commits into from
Closed

AIP010 Beacon hash check #984

wants to merge 3 commits into from

Conversation

aion-kelvin
Copy link
Contributor

Notice

Please submit your PR to the master branch and rebase your code on master before opening the pull request.

Description

Please include a brief summary of the change that this pull request proposes. Include any relevant motivation and context. List any dependencies required for this change.

  • modify AionTransaction and its RLP encoding to store beacon hash and "extension byte"
  • RLP explanation: https://gist.github.com/aion-kelvin/f624c4f217441d4173d23e5a8839d3ad (will be moved to Confluence soon)
  • modify RPC method eth_sendTransaction to take a 'beacon' field
  • implemented a BeaconHashValidator and added it to the checks of AionPendingStateImpl and AIonBlockchainImpl

Fixes AIP010

Type of change

Insert x into the following checkboxes to confirm (eg. [x]):

  • Bug fix.
  • New feature.
  • Enhancement.
  • Unit test.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

Testing

Please describe the tests you used to validate this pull request. Provide any relevant details for test configurations as well as any instructions to reproduce these results.

Bad beacon hash provided:

sergiu@aion-XPS-8930:~/repos/aion$ curl -sX POST --data '{"jsonrpc":"2.0", "id":"1", "method": "eth_sendTransaction", "params":[ { "from":"0xa04577e56a63000b7e2a4c690cb0418cc3f203e709b4d78ffdd2f25ac24f5e67", "to":"0xa0da8cda8e423792022ad58bb165268801c56112dedb1199d22b14c96fe16013", "value":"0xaa", "gasPrice": "0x2540be400", "beaconHash": "0xcafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe" } ] }' localhost:8545 | jq .
{
  "id": "1",
  "jsonrpc": "2.0",
  "error": {
    "code": -32602,
    "data": "Invalid transaction object",
    "message": "Invalid params"
  }
}

Without any beacon hash:

sergiu@aion-XPS-8930:~/repos/aion$ curl -sX POST --data '{"jsonrpc":"2.0", "id":"1", "method": "eth_sendTransaction", "params":[ { "from":"0xa04577e56a63000b7e2a4c690cb0418cc3f203e709b4d78ffdd2f25ac24f5e67", "to":"0xa0da8cda8e423792022ad58bb165268801c56112dedb1199d22b14c96fe16013", "value":"0xaa", "gasPrice": "0x2540be400" } ] }' localhost:8545 | jq .
{
  "result": "0x9e00812b6e9898e8d79d2e332bfd1ff8d61e1f9c1dcb48a6eed3c84c3542640c",
  "id": "1",
  "jsonrpc": "2.0"
}
sergiu@aion-XPS-8930:~/repos/aion$ curl -sX POST --data '{"jsonrpc":"2.0", "id":"1", "method": "eth_getTransactionByHash", "params":[ "0x9e00812b6e9898e8d79d2e332bfd1ff8d61e1f9c1dcb48a6eed3c84c3542640c" ] }' localhost:8545 | jq . 
{
  "result": {
    "nrgPrice": "0x2540be400",
    "blockHash": "0xb9bb01f54b2deb77dad6ab95d8f0bea136397bee8860653b54b858eb0001f0df",
    "nrg": 90000,
    "transactionIndex": 0,
    "nonce": 0,
    "input": "0x",
    "blockNumber": "0x21",
    "gas": 90000,
    "from": "0xa04577e56a63000b7e2a4c690cb0418cc3f203e709b4d78ffdd2f25ac24f5e67",
    "to": "0xa0da8cda8e423792022ad58bb165268801c56112dedb1199d22b14c96fe16013",
    "value": "0x00aa",
    "hash": "0x9e00812b6e9898e8d79d2e332bfd1ff8d61e1f9c1dcb48a6eed3c84c3542640c",
    "gasPrice": "0x2540be400",
    "timestamp": 1568266790
  },
  "id": "1",
  "jsonrpc": "2.0"
}

With valid beacon hash:

sergiu@aion-XPS-8930:~/repos/aion$ curl -sX POST --data '{"jsonrpc":"2.0", "id":"1", "method": "eth_sendTransaction", "params":[ { "from":"0xa04577e56a63000b7e2a4c690cb0418cc3f203e709b4d78ffdd2f25ac24f5e67", "to":"0xa0da8cda8e423792022ad58bb165268801c56112dedb1199d22b14c96fe16013", "value":"0xaa", "gasPrice": "0x2540be400", "beaconHash": "0x597d47b2513390109adb6d594daea3d81c8e20ab0f764529127fcd15b749481c" } ] }' localhost:8545 | jq .
{
  "result": "0xa883493b54126e51ac080c10bb42ce1ed1031d708b2ae77af14e8e5ea4ac3626",
  "id": "1",
  "jsonrpc": "2.0"
}
sergiu@aion-XPS-8930:~/repos/aion$ curl -X POST --data '{"jsonrpc":"2.0", "id":"1", "method": "eth_getTransactionByHash", "params":[ "0xa883493b54126e51ac080c10bb42ce1ed1031d708b2ae77af14e8e5ea4ac3626" ] }' localhost:8545 | jq . 
{
  "result": {
    "nrgPrice": "0x2540be400",
    "blockHash": "0xe8ffbd80be2dca9315082522cde09c8d37bd379d5e03a07060d4c7be7346d546",
    "nrg": 90000,
    "transactionIndex": 0,
    "nonce": 1,
    "input": "0x",
    "blockNumber": "0x29",
    "gas": 90000,
    "from": "0xa04577e56a63000b7e2a4c690cb0418cc3f203e709b4d78ffdd2f25ac24f5e67",
    "to": "0xa0da8cda8e423792022ad58bb165268801c56112dedb1199d22b14c96fe16013",
    "value": "0x00aa",
    "hash": "0xa883493b54126e51ac080c10bb42ce1ed1031d708b2ae77af14e8e5ea4ac3626",
    "gasPrice": "0x2540be400",
    "timestamp": 1568266900
  },
  "id": "1",
  "jsonrpc": "2.0"
}

@aion-kelvin aion-kelvin self-assigned this Sep 12, 2019
@aion-kelvin aion-kelvin force-pushed the master.aip010.3 branch 5 times, most recently from 47ceae7 to c5c44bd Compare September 16, 2019 21:16
@aion-kelvin aion-kelvin force-pushed the master.aip010.3 branch 2 times, most recently from 6b9b8c2 to 67e9ecc Compare September 23, 2019 18:04
@aion-kelvin
Copy link
Contributor Author

merged

@AionJayT AionJayT deleted the master.aip010.3 branch October 1, 2019 15:49
@AionJayT AionJayT restored the master.aip010.3 branch October 1, 2019 15:49
@AionJayT AionJayT deleted the master.aip010.3 branch October 24, 2019 21:08
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.

1 participant