Block Synchronization Contract

blksync.xsat

Actions

  • Initialize block bucket

  • Sharding of upload chunks

  • Delete block shards

  • Verify the validity of the block

Quickstart

# initbucket @synchronizer
$ cleos push action blksync.xsat initbucket '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "block_size": 2325617, "num_chunks": 11}' -p alice

# pushchunk @synchronizer
$ cleos push action blksync.xsat pushchunk '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "chunk_id": 0, "data": "<data>"}' -p alice

# delchunk @synchronizer
$ cleos push action blksync.xsat delchunk '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "chunk_id": 0}' -p alice

# delbucket @synchronizer
$ cleos push action blksync.xsat delbucket '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5"}' -p alice

# verify @synchronizer
$ cleos push action blksync.xsat verify '{"synchronizer": "alice", "height": 840000, "hash": "0000000000000000000320283a032748cef8227873ff4872689bf23f1cda83a5", "nonce": 1}' -p alice

Table Information

ENUM block_status

TABLE globalid

scope

blksync.xsat

params

  • {uint64_t} bucket_id - latest bucket_id

example

STRUCT verify_info_data

params

  • {name} miner - block miner account

  • {vector<string>} btc_miners - btc miner account

  • {checksum256} previous_block_hash - hash in internal byte order of the previous block’s header

  • {checksum256} work - block workload

  • {checksum256} witness_reserve_value - witness reserve value in the block

  • {std::optional<checksum256>} - witness commitment in the block

  • {bool} has_witness - whether any of the transactions in the block contains witness

  • {checksum256} header_merkle - the merkle root of the block

  • {std::vector<checksum256>} relay_header_merkle - check header merkle relay data

  • {std::vector<checksum256>} relay_witness_merkle - check witness merkle relay data

  • {uint64_t} num_transactions - the number of transactions in the block

  • {uint64_t} processed_position - the location of the block that has been resolved

  • {uint64_t} processed_transactions - the number of processed transactions

  • {uint32_t} timestamp - the block time in seconds since epoch (Jan 1 1970 GMT)

  • {uint32_t} bits - the bits

example

TABLE blockbuckets

scope validator

params

  • {uint64_t} bucket_id - primary key, bucket_id is the scope associated with block.bucket

  • {uint64_t} height - block height

  • {uint32_t} size -block size

  • {uint32_t} uploaded_size - the latest release id

  • {uint8_t} num_chunks - number of chunks

  • {uint8_t} uploaded_num_chunks - number of chunks that have been uploaded

  • {uint32_t} chunk_size - the size of each chunk

  • {vector<uint8_t>} chunk_ids - the uploaded chunk_id

  • {string} reason - reason for verification failure

  • {block_status} status - current block status

  • {time_point_sec} updated_at - updated at time

  • {std::optional<verify_info_data>} verify_info - @see struct verify_info_data

example

TABLE passedindexs

scope height

params

  • {uint64_t} id - primary key

  • {checksum256} hash - block hash

  • {checksum256} cumulative_work - the cumulative workload of the block

  • {uint64_t} bucket_id - bucket_id is used to obtain block data

  • {name} synchronizer - synchronizer account

  • {name} miner - miner account

  • {time_point_sec} created_at - created at time

example

TABLE blockminer

scope height

params

  • {uint64_t} id - primary key

  • {checksum256} hash - block hash

  • {name} miner - block miner account

  • {uint32_t} block_num - the block number that passed the first verification

example

TABLE block.chunk

scope bucket_id

params

  • {std::vector<char>} data - the block chunk for block

example

STRUCT verify_block_result

params

  • {string} status - verification status (uploading, upload_complete, verify_merkle, verify_parent_hash, waiting_miner_verification, verify_pass, verify_fail)

  • {string} reason - reason for verification failure

  • {checksum256} block_hash - block hash

example

ACTION consensus

  • authority: utxomng.xsat

Consensus completion processing logic

params

  • {uint64_t} height - block height

  • {name} synchronizer - synchronizer account

  • {uint64_t} bucket_id - bucket id

example

ACTION delchunks

  • authority: utxomng.xsat

Deletion of historical block data after parsing is completed

params

  • {uint64_t} bucket_id - bucket_id of block data to be deleted

example

ACTION initbucket

  • authority: synchronizer

Initialize the block information to be uploaded

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {uint32_t} size -block size

  • {uint8_t} num_chunks - number of chunks

  • {uint32_t} chunk_size - the size of each chunk

example

ACTION pushchunk

  • authority: synchronizer

Upload block shard data

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {uint8_t} chunk_id - chunk id

  • {std::vector<char>} data - block data to be uploaded

example

ACTION delchunk

  • authority: synchronizer

Delete block shard data

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {uint8_t} chunk_id - chunk id

example

ACTION delbucket

  • authority: synchronizer

Delete the entire block data

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

example

ACTION verify

  • authority: synchronizer

Verify block data

params

  • {name} synchronizer - synchronizer account

  • {uint64_t} height - block height

  • {checksum256} hash - block hash

  • {uint64_t} nonce - unique value for each call to prevent duplicate transactions

example

Last updated