-
Notifications
You must be signed in to change notification settings - Fork 0
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
New synchronisation mechanism #40
Comments
sequenceDiagram
autonumber
participant Arweave Network
participant Syncer
participant DB
participant Sequencer
participant Forwarder
loop For every CURRENT_HEIGHT
Note over Syncer: SYNCER_FINISHED_HEIGHT = <br/> CURRENT_HEIGHT - <br/> CONFIRMATION_BLOCKS
Syncer->>Arweave Network: Download block for height <br/> SYNCER_FINISHED_HEIGHT
activate Syncer
Syncer->>DB: Save interactions with <br/> sortKey1 = SYNCER_FINISHED_HEIGHT + <br/> READY_BLOCKS
Syncer->>DB: Save SYNCER_FINISHED_HEIGHT
deactivate Syncer
end
loop For every SYNCER_FINISHED_HEIGHT
activate Sequencer
Sequencer->>DB: Get SYNCER_FINISHED_HEIGHT
Note over Sequencer: SEQUENCER_CURRENT_HEIGHT = <br/> SYNCER_FINISHED_HEIGHT <br/> + CONFIRMATION_BLOCKS
Sequencer->>DB: Save SEQUENCER_CURRENT_HEIGHT
Note over Sequencer: Use updated <br/> SEQUENCER_CURRENT_HEIGHT <br/> for generating sortKey
deactivate Sequencer
end
loop For every SEQUENCER_CURRENT_HEIGHT
activate Forwarder
Forwarder ->> DB: Get interactions <br/> already stored by Syncer
Forwarder ->> DB: Get interactions <br/> added by Sequencer
Note over Forwarder: Forward to Redis
deactivate Forwarder
end
|
My dumb questions/comments:
|
One thing missing in the above specs is setting the 'previous sort key' (a.k.a. |
L1 transactions are sent to the Redis only after the right SEQUENCER_CURRENT_HEIGHT is reached.
|
lastSort key is set in Forwarder and specified per contract, only for L1. Sequencer handles lastSortKey for L2 |
also - after the last call - no one really knows what is the point of |
Current implementation
Currently, the sequencer generates transactions with a sortKey set for the current network height.
https://github.com/warp-contracts/gateway/blob/main/src/gateway/router/routes/sequencerRoute.ts#L76
The new Syncer waits a specified number of blocks to synchronize L1 transactions (to ensure they are properly confirmed and not from a fork).
Problem
There is a risk with how Sequencer is generating sortKeys. For example:
Because the second part of the sortKey for sequencer transactions is always greater than those from L1, there is a risk that transactions from the sequencer at block height 100 will be processed (e.g. by DRE) before Syncer adds its transactions at that block height. This could cause the transactions from the Syncer to be effectively unused for evaluating state (because the client will have already calculated transactions for newer sortKeys - those from the sequencer).
Solution
Parameters
Block height used for SortKey generation
Syncer
It saves the block height it last synchronized (SYNCER_FINISHED_HEIGHT) in the database.
Syncer saves interactions with block height =
SYNCER_FINISHED_HEIGHT + READY_BLOCKS
.For example:
should have a block height of 100.
Sequencer
Sequencer assigns sortKeys using block height:
Sequencer doesn't know what is the current block height of Arweave network
Sequencer doesn't send interactions to Redis anymore.
Introduce Forwarder
Forwarder is a new component connected to the database and the Redis master node, it is responsible for:
Forwarder gets interactions that are already bundled
Implementation details:
Block height in interaciton table
Block height used in sortKey vs block key seen by the contract
Gateway
Gateway needs to use SEQUENCER_CURRENT_HEIGHT when returning interactions. Only interactions with sortKeys generated with block height smaller than SEQUENCER_CURRENT_HEIGHT can be returned.
TODO (remove)
Additional SortKey
We should generate two sortKeys:
Data in the interaction column should reflect the block for which we are generating the sortKey (problem: what about double generation of sortKeys - do we save two interactions? that's a lot of data...).
The text was updated successfully, but these errors were encountered: