This PR is a refactoring of the XDM relayer, the change set is quite large so I didn't organize the change commit by commit but the logic after refactoring should be clear and easy to review.
The relayer works as follows:
For every imported consensus block
Skip if it is in major sync
Skip if the block is not the best block
Get the finalized_block as imported_block - confirmation_depth_k
The finalized_block won't be processed directly but instead the relayer will process finalized_block - 1 and finalized_block is used to generate the MMR proof of finalized_block - 1
Fetch and filter XDM in finalized_block - 1
The relayer will check against the current best block state to see if the XDM in finalized_block - 1 is already relayed
Construct XDM proof which consists of:
The MMR proof of finalized_block - 1
The message proof
If the src chain is a domain there is also a storage proof of the LastConfirmedDomainBlockReceipt
Gossip/submit the XDM to the network
A few notable logical changes:
The relayer of the consensus chain and the domain is merged into one worker
The relayer when encountering an error will not shut down the whole node but instead just print an error log, since it is not fatal
The is_state_available check is removed so the relayer just prints an error log if the state at finalized_block - 1 and LastConfirmedDomainBlock is not available
This PR is a refactoring of the XDM relayer, the change set is quite large so I didn't organize the change commit by commit but the logic after refactoring should be clear and easy to review.
The relayer works as follows:
finalized_block
asimported_block - confirmation_depth_k
finalized_block
won't be processed directly but instead the relayer will processfinalized_block - 1
andfinalized_block
is used to generate the MMR proof offinalized_block - 1
finalized_block - 1
finalized_block - 1
is already relayedfinalized_block - 1
LastConfirmedDomainBlockReceipt
A few notable logical changes:
is_state_available
check is removed so the relayer just prints an error log if the state atfinalized_block - 1
andLastConfirmedDomainBlock
is not availableCode contributor checklist: