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

feat(rpc): add scroll_* rollup APIs #548

Merged
merged 8 commits into from
Nov 9, 2023
Merged

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented Oct 31, 2023

1. Purpose or design rationale of this PR

The following APIs are added:

scroll_syncStatus (with `--rollup.verify` enabled)
scroll_estimateL1DataFee

"finalized" tag in APIs related to "get block" or "get header" (only nodes with --rollup.verify) e.g.,

eth_call
eth_createAccessList
eth_getBalance
eth_estimateGas
eth_getHeaderByNumber
eth_getBlockTransactionCountByNumber
eth_getCode
eth_getProof
eth_getStorageAt
eth_getTransactionByBlockNumberAndIndex
eth_getTransactionCount
eth_getUncleByBlockNumberAndIndex
eth_getUncleCountByBlockNumber
trace_block
debug_traceBlockByNumber

notion doc: https://www.notion.so/scrollzkp/scroll_-rollup-APIs-2299f3461fd044d7a1f8623fd87ec3aa

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change

@colinlyguo colinlyguo added the feature New feature or request label Oct 31, 2023
@colinlyguo colinlyguo self-assigned this Oct 31, 2023
eth/api.go Outdated Show resolved Hide resolved
@colinlyguo
Copy link
Member Author

colinlyguo commented Oct 31, 2023

some testing examples:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"scroll_syncStatus","params":[],"id":1}' http://localhost:8545/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   221  100   156  100    65  49476  20615 --:--:-- --:--:-- --:--:--  215k
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "l2BlockSyncHeight": 435497,
    "l1RollupSyncHeight": 18468384,
    "l1MessageSyncHeight": 18468384,
    "l2FinalizedBlockHeight": 434382
  }
}
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getHeaderByNumber","params":["finalized"],"id":2}' -H "Content-Type: application/json" http://localhost:8545/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1660  100  1578  100    82   463k  24661 --:--:-- --:--:-- --:--:-- 1621k
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "difficulty": "0x2",
    "extraData": "0xd883050001846765746888676f312e31392e31856c696e757800000000000000895b306ffac50ae0ad6c68390d0fa614f8256360a98888af62dd4d781735260b7a20c27680762572d1d206dbee67490accf1e7467c29cc0987eaf38c486b9b9e01",
    "gasLimit": "0x989680",
    "gasUsed": "0xc75ed",
    "hash": "0x95cfc0a11e4a1c346958d7fc16fc7ffe7c5868331537a47e3cfca3e9984179ae",
    "logsBloom": "0x0020000000020000000010000000000000000200100200000400000184000400000000082200000400040000400000000000000000040002000000400024000000008000084000000000408810000000400000000004000400020000802000000000000002000200000200200000080008000004214001000000041000200000004200040808000100200000a000000800000021000018000000000000000000020000100000000000000000202000000000000000000004000000080200000000000802210800040000080020001000000000001001000080000000000064000010000000000000000000000010000010000000001000401100000000000040",
    "miner": "0x0000000000000000000000000000000000000000",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "number": "0x6a0ce",
    "parentHash": "0x8650dc6a8387315f4ab7c5a49026afc394bfd895a8b51b38c907fd33ff1b0beb",
    "receiptsRoot": "0x2dbc7f2a54e6df82ddcc2b0ff3f44ec8df112a44161ecbb0fbd905c43791e723",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x293",
    "stateRoot": "0x051538acce68d64dedaf57d7c1179132c2ae7c2d9d8a1f0a65e816111450c718",
    "timestamp": "0x654098ae",
    "totalDifficulty": "0xd419d",
    "transactionsRoot": "0x79f7584b797be57a4f840a958480280af436910e4b58073150a2dcef6fbff8d1"
  }
}
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["finalized",false],"id":1}' -H "Content-Type: application/json" http://localhost:8545/ | jq

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2315    0  2228  100    87   617k  24694 --:--:-- --:--:-- --:--:-- 2260k
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "difficulty": "0x2",
    "extraData": "0xd883050001846765746888676f312e31392e31856c696e75780000000000000071fafed5d04d7b25c75aaa24e3157f764908490d276b479ad1bba2ef8637b0d1437c01ad18218223eb233ee19817ab8d05c5e185aefb92ecdad35349974d86cf01",
    "gasLimit": "0x989680",
    "gasUsed": "0xac4dc",
    "hash": "0xba5af4bc263734e092a67664a321694e0cf86adc0058707f829238f60c3ba335",
    "logsBloom": "0x002008000002401000000010000124000000000000000010102000000000000208000000000000000044000000000000000100080000000000000000002800000000000000000000020008088000022000000000000000200000000000000000000000000204000000000c00c0400800000240042000000000008110000000000000000000000010001001000080000000001040000000410004004000000010020000000000000000080001000000000000000400400000020000400000000802008002000000000200000401400000000400000020010000000400000020001010000100000208040000000000440004000000100080000004000088010040",
    "miner": "0x0000000000000000000000000000000000000000",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "number": "0x6959d",
    "parentHash": "0xa8cfdae3a9234adac54e06bc1cad5bed96f032b94f6a1ecbfdd6b9d1c20d1ca1",
    "receiptsRoot": "0x4e4c1a43890bebee69ebed03aa8c6f8ed9028edad794e9a6eb347795d8ce317c",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0xc5f",
    "stateRoot": "0x0d9e3b03a3932eb1be0f3273b0e4972e744cc3e1809f6ef704457b7f4da3e04b",
    "timestamp": "0x65407719",
    "totalDifficulty": "0xd2b3b",
    "transactions": [
      "0x3726c054bed73c90f13a672dbd5e45c7b3e3f3c2d9f3e0defc210bf10087cb13",
      "0x4b897b3047d52d96b48cf5f87248cc7d5a5c23dcfe8fa221d0973f7763fffe36",
      "0x46435aa7ebf50930bb33f2e7f0b9b23486b55f60e7a1f5f33f6f8191485081c0",
      "0x6466f1d50d0f02fba1600d8d4691d39f0bcb445fee2971f641fe7d2d6a31b1e1",
      "0x33020a250620eb924b0d129a9e69c5f7efc1ad399b5baec5a3d649dc1a7c0c08",
      "0xa9c78a44f5eee60b80686fb60e7cf92d2a7963df96cbd088da47ae31c6ae6db3",
      "0x288820ec74ee28842412695a9ff00192a13b21c5775335c7748351db86aab126",
      "0x927a6c1c72a60b1eb8ee11b5abdc363affad424bd871cfdbfd458fa3d5a5fa1d",
      "0xf13caa3b07c3bc8cc71e445d5d5a8ac6b8fb287e89709de5b6e7e27903fa512a"
    ],
    "transactionsRoot": "0x3a578feb5a45e82a8dd110eb358aaa0b66b15f0a04e1b061835482bbba4fe23d",
    "uncles": []
  }
}
curl -X POST -H "Content-Type: application/json" --data '{"method":"scroll_estimateL1DataFee","params":[{"from":"0x8888889C9818892B700e27F316cc3E41e17fBeb9","to":"0x8888889C9818892B700e27F316cc3E41e17fBeb9"}],"id":1,"jsonrpc":"2.0"}' http://localhost:8545/ | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   226  100    51  100   175  12570  43135 --:--:-- --:--:-- --:--:--  220k
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x440a4c7b345c"
}

eth/api.go Outdated Show resolved Hide resolved
Thegaram
Thegaram previously approved these changes Nov 8, 2023
@Thegaram Thegaram merged commit 1bf2628 into develop Nov 9, 2023
5 checks passed
@Thegaram Thegaram deleted the feat-add-rollup-apis branch November 9, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants