Rollup data restore

All transaction data on the shard chain has full data visibility on the beacon chain, so anyone is able to restore the data on the shard chain without permission. The process of data restoration involves rebuilding the Genesis root node by getting records from the beacon chain based on the Genesis hash, and then restoring the state tree and all rollup transactions based on transaction.input. The details are as follows.

Restore the Genesis Root Node

All the operations of the sharded chain are stored in transaction.input on the base chain. We can get the record of Genesis hash to reconstruct the Genesis root node information by the eth_getTransactionByHash method, which is stored from the transaction.input.0 commitment field to extract the 6 smart contract addresses.

transaction.input=[
{
    _blocknumber: unit32
    _priority_operations: uint32
    _pending_onchain_operations_hash: bytes32
    _timestamp: unit256
    _state_hash: bytes32
    _commitment: bytes32
},
[{
    _encoded_root : bytes32
    _calldata: bytes (public_data)
    _timestamp: unit256
    _eth_witness: bytes
    _blocknumber: uint32
    _feeaccount: uint32
}]
]

transaction.input[0]._commitment = 6 * INPUT_DATA_ADDRESS_BYTES_WIDTH(32) + INPUT_DATA_ROOT_HASH_BYTES_WIDTH(32)

Restore Rollup Transaction Data

The calldata field of transaction.input.1 contains the original compressed data of all blocks of the shard chain, which can restore all transaction data.

transaction.input[1]._calldata = tx_type | chips * chip_bytes(10bytes)

DepositTx structure

tx_typechips

0x01

6

account_idtokenamountto

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 25 bytes

25 ~ 45 bytes

TransferToNewAddrTx & TransferToNewAddrNFTTx structure

tx_typechips

0x02

6

from_idtokenamounttoto_idfee

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 14 bytes

14 ~ 34 bytes

34 ~ 38 bytes

38 ~ 40 bytes

WithdrawTx structure

tx_typechips

0x03

6

account_idtokenamountfeeto

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 13 bytes

25 ~ 27 bytes

27 ~ 47 bytes

TransferTx & TransferNFTTx structure

tx_typechips

0x05

2

account_idtokentoamountfee

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 13 bytes

13 ~ 18 bytes

18 ~ 20 bytes

FullWithdrawTx & FullWithdrawNFTTx structure

tx_typechips

0x06

11

account_ideth_addresstokenamountcreator_addresscontent_hash

1 ~ 5 bytes

5 ~ 25 bytes

25 ~ 29 bytes

29 ~ 45 bytes

45 ~ 65 bytes

65 ~ 97 bytes

UpdatePublicKeyTx structure

tx_typechips

0x07

6

account_idnew_pk_hashaccountnoncefee_tokenfee

1 ~ 5 bytes

5 ~ 25 bytes

25 ~ 45 bytes

45 ~ 49 bytes

49 ~ 53 bytes

53 ~ 55 bytes

ForcedWithdrawTx structure

tx_typechips

0x08

6

initiator_account_idtarget_account_idtokenamountfeetarget

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 13 bytes

13 ~ 29 bytes

29 ~ 31 bytes

31 ~ 51 bytes

MintNFTTx structure

tx_typechips

0x09

5

creator_account_idrecipient_account_idcontent_hashfee_token_idfee

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 41 bytes

41 ~ 45 bytes

45 ~ 47 bytes

WithdrawNFTTx structure

tx_typechips

0x0a

10

account_idcreator_idcreator_addressserial_idcontent_hashtotokentoken_feefee

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 29 bytes

29 ~ 33 bytes

33 ~ 65 bytes

65 ~ 85 bytes

85 ~ 89 bytes

89 ~ 93 bytes

93 ~ 95 bytes

SwapTx & SwapNFTTx structure

tx_typechips

0x0b

5

account_id_0recipient_id_0account_id_1recipient_id_1submitter_idtoken_0token_1fee_tokenamount_0amount_1feeswap_fee_0swap_fee_1nonce

1 ~ 5 bytes

5 ~ 9 bytes

9 ~ 13 bytes

13 ~ 17 bytes

17 ~ 21 bytes

21 ~ 25 bytes

25 ~ 29 bytes

29 ~ 33 byte

33 ~ 38 bytes

38 ~ 43 bytes

43 ~ 45 bytes

45~47 bytes

47 ~ 49 bytes

49 ~ 49 bytes

Last updated