Skip to content

different set of worker block for one master block on v3 and v2 API #1544

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

Open
IpankajI opened this issue Mar 4, 2025 · 4 comments
Open

Comments

@IpankajI
Copy link

IpankajI commented Mar 4, 2025

Hi,

I was using v2 API to get shard for one master block but this v2 API is missing few shards.

v2 curl-

curl --location 'https://testnet.toncenter.com/api/v2/jsonRPC' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "id": 1,
    "jsonrpc": "2.0",
    "method": "shards",
    "params": {
        "seqno": 28727425
    }
}
'

response

{
    "ok": true,
    "result": {
        "@type": "blocks.shards",
        "shards": [
            {
                "@type": "ton.blockIdExt",
                "workchain": 0,
                "shard": "2305843009213693952",
                "seqno": 30542574,
                "root_hash": "wxdX3TJprn+Zlfv5MnWiZE73Ir32RKmWvp9VDujMr40=",
                "file_hash": "lDMeQ1H2dTt5TRmHojJUfVv2zJvyj4W/tSwAQgQSQh0="
            },
            {
                "@type": "ton.blockIdExt",
                "workchain": 0,
                "shard": "6917529027641081856",
                "seqno": 30539770,
                "root_hash": "WiuVagIZaGRAC7N4gSl1KGs2D7+hMtcuYF1W9w8gayI=",
                "file_hash": "jhKbG7sqspAZDob5vPcLIEx2G4ueoHWCW0tWvKZ53vY="
            },
            {
                "@type": "ton.blockIdExt",
                "workchain": 0,
                "shard": "-6917529027641081856",
                "seqno": 30536994,
                "root_hash": "/KI3fEqZZ/55Mm1H8D/Xq/6pqRQtw2GS1GCMC59hgzQ=",
                "file_hash": "hpDDVKoxCYNTmLjTRj8JpR5cFaVIIpnjVj49IRlXF5E="
            },
            {
                "@type": "ton.blockIdExt",
                "workchain": 0,
                "shard": "-2305843009213693952",
                "seqno": 30501264,
                "root_hash": "XvU4Lggls656Ppzs7gxoj7cheKWTE/O6lCPfmyy13Ug=",
                "file_hash": "GfYgBPbZ6cU0vlS/0SCT4XhkrK9CpTw56P5/9BXdqAM="
            }
        ],
        "@extra": "1741082157.319137:11:0.7580206777109749"
    },
    "id": "1",
    "jsonrpc": "2.0"
}

v3 curl-

curl --location 'https://testnet.toncenter.com/api/v3/masterchainBlockShards?seqno=28727425&limit=10&offset=0' \
--header 'accept: application/json'

response

{
    "blocks": [
        {
            "workchain": -1,
            "shard": "8000000000000000",
            "seqno": 28727425,
            "root_hash": "0V1l6JE6PTsXBZtoKkAg43TjblAhO7/bTIDStpZSRK0=",
            "file_hash": "whPAwPQcDK30HnRbA+6RnKUTLC1tXSftHSR7hoCGFfQ=",
            "global_id": -3,
            "version": 0,
            "after_merge": false,
            "before_split": false,
            "after_split": false,
            "want_merge": true,
            "want_split": false,
            "key_block": false,
            "vert_seqno_incr": false,
            "flags": 1,
            "gen_utime": "1741057984",
            "start_lt": "31992561000000",
            "end_lt": "31992561000004",
            "validator_list_hash_short": 720661494,
            "gen_catchain_seqno": 372919,
            "min_ref_mc_seqno": 28727421,
            "prev_key_block_seqno": 28724965,
            "vert_seqno": 0,
            "master_ref_seqno": 0,
            "rand_seed": "LVp2kKW5ZWOtsUUYzE/2tSuhytwX4XdbZNPKeuRgl/A=",
            "created_by": "8jlYt0xgDEtTVnWNxe/bwLY9QmSzvgEQHhcj0xAEtlM=",
            "tx_count": 3,
            "masterchain_block_ref": {
                "workchain": -1,
                "shard": "8000000000000000",
                "seqno": 28727425
            },
            "prev_blocks": [
                {
                    "workchain": -1,
                    "shard": "8000000000000000",
                    "seqno": 28727424
                }
            ]
        },
        {
            "workchain": 0,
            "shard": "A000000000000000",
            "seqno": 30536993,
            "root_hash": "8JBC5RmTw6jEKQKUf+syTfscQXqSHfnjtiG8HF8OIbE=",
            "file_hash": "qRDnUjQ9vsIto8gKx30TIOqBIwsmSFBulP4PrsAPbfg=",
            "global_id": -3,
            "version": 0,
            "after_merge": false,
            "before_split": false,
            "after_split": false,
            "want_merge": true,
            "want_split": false,
            "key_block": false,
            "vert_seqno_incr": false,
            "flags": 1,
            "gen_utime": "1741057979",
            "start_lt": "31992559000000",
            "end_lt": "31992559000015",
            "validator_list_hash_short": -1713911687,
            "gen_catchain_seqno": 373494,
            "min_ref_mc_seqno": 28727422,
            "prev_key_block_seqno": 28724965,
            "vert_seqno": 0,
            "master_ref_seqno": 28727422,
            "rand_seed": "avFsBwuLfBo09Y6DWe7kkJsA8wQep+iNq5+gsbYNNHs=",
            "created_by": "Oi9byfgbI0AwZNZ5TQElz1lFF5/wFhIbfnM3KC7xoZc=",
            "tx_count": 8,
            "masterchain_block_ref": {
                "workchain": -1,
                "shard": "8000000000000000",
                "seqno": 28727425
            },
            "prev_blocks": [
                {
                    "workchain": 0,
                    "shard": "A000000000000000",
                    "seqno": 30536992
                }
            ]
        },
        {
            "workchain": 0,
            "shard": "A000000000000000",
            "seqno": 30536994,
            "root_hash": "/KI3fEqZZ/55Mm1H8D/Xq/6pqRQtw2GS1GCMC59hgzQ=",
            "file_hash": "hpDDVKoxCYNTmLjTRj8JpR5cFaVIIpnjVj49IRlXF5E=",
            "global_id": -3,
            "version": 0,
            "after_merge": false,
            "before_split": false,
            "after_split": false,
            "want_merge": true,
            "want_split": false,
            "key_block": false,
            "vert_seqno_incr": false,
            "flags": 1,
            "gen_utime": "1741057982",
            "start_lt": "31992560000000",
            "end_lt": "31992560000001",
            "validator_list_hash_short": -1713911687,
            "gen_catchain_seqno": 373494,
            "min_ref_mc_seqno": 28727422,
            "prev_key_block_seqno": 28724965,
            "vert_seqno": 0,
            "master_ref_seqno": 28727422,
            "rand_seed": "ucyIa+YPWDJ1PkpPJIA+zvixzisMGbeEUAM8n6Mm580=",
            "created_by": "geBNDs8MckTbvita1JC2UhzNA77t//1oHLTWREfoz88=",
            "tx_count": 0,
            "masterchain_block_ref": {
                "workchain": -1,
                "shard": "8000000000000000",
                "seqno": 28727425
            },
            "prev_blocks": [
                {
                    "workchain": 0,
                    "shard": "A000000000000000",
                    "seqno": 30536993
                }
            ]
        },
        {
            "workchain": 0,
            "shard": "6000000000000000",
            "seqno": 30539770,
            "root_hash": "WiuVagIZaGRAC7N4gSl1KGs2D7+hMtcuYF1W9w8gayI=",
            "file_hash": "jhKbG7sqspAZDob5vPcLIEx2G4ueoHWCW0tWvKZ53vY=",
            "global_id": -3,
            "version": 0,
            "after_merge": false,
            "before_split": false,
            "after_split": false,
            "want_merge": true,
            "want_split": false,
            "key_block": false,
            "vert_seqno_incr": false,
            "flags": 1,
            "gen_utime": "1741057980",
            "start_lt": "31992559000000",
            "end_lt": "31992559000001",
            "validator_list_hash_short": -1476051248,
            "gen_catchain_seqno": 373504,
            "min_ref_mc_seqno": 28727422,
            "prev_key_block_seqno": 28724965,
            "vert_seqno": 0,
            "master_ref_seqno": 28727422,
            "rand_seed": "uQeC2rPagCwU8oNeSnxJ4coUEX43hbF3BS4105dYAiM=",
            "created_by": "cZT/+BI85lFo9ePSr+qYb/1iLfLsTY3CX2zYHwAO0cs=",
            "tx_count": 0,
            "masterchain_block_ref": {
                "workchain": -1,
                "shard": "8000000000000000",
                "seqno": 28727425
            },
            "prev_blocks": [
                {
                    "workchain": 0,
                    "shard": "6000000000000000",
                    "seqno": 30539769
                }
            ]
        }
    ]
}

following shard from v3 is not available on v2.

            "workchain": 0,
            "shard": "A000000000000000",
            "seqno": 30536993,

Please let me know if there is any way I can find above shard through v2 API or I am missing anything

@saravadeanil
Copy link

+1

1 similar comment
@KBA07
Copy link

KBA07 commented Mar 4, 2025

+1

@arec1b0
Copy link

arec1b0 commented Mar 19, 2025

+1

@dungeon-master-666
Copy link
Member

dungeon-master-666 commented Apr 1, 2025

The analogue of the v2/shards method is v3/masterchainBlockShardState. It returns the latest block of each shard masterchain block X knows of.

The v3/masterchainBlockShards method, on the other hand, returns all shard blocks that were created after masterchain block X-1 and committed to masterchain block X.
If a shard did not produce a new block during this interval, it will be absent from the response (unlike v2/shards and v3/masterchainBlockShardState, which will still include it with the latest known block).
If a shard produced multiple blocks, all of them will be included in the response (whereas v2/shards and v3/masterchainBlockShardState include only the latest block for each shard).
This method is helpful if you are scanning blocks and don't want to miss those shard blocks that were produced in between masterchain blocks.

Example

Image

For seqno 102:

  • v2/shards returns blocks 202, 222, 224. v3/masterchainBlockShardState returns the same set plus 102 since it also returns requested masterchain block.
  • v3/masterchainBlockShards returns 102, 201, 202, 222, 223, 224.

For seqno 101:

  • v2/shards returns blocks 200, 221, 222. v3/masterchainBlockShardState returns 101, 200, 221, 222
  • v3/masterchainBlockShards returns 101, 221, 222.

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

No branches or pull requests

6 participants
@IpankajI @KBA07 @dungeon-master-666 @saravadeanil @arec1b0 and others