feat(p2p): no tips store in the p2p client#12395
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
63c9281 to
bc0c510
Compare
9e603da to
3190e47
Compare
2d6e4e9 to
e64590b
Compare
6008722 to
adfec1f
Compare
adfec1f to
a75a866
Compare
LHerskind
left a comment
There was a problem hiding this comment.
Looks good. Tiny comment around the epochs to avoid a potential race condition.
| return EthAddress.fromString(payloadAddress); | ||
| } | ||
|
|
||
| public handleBlockStreamEvent(event: L2BlockSourceEvent): Promise<void> { |
| } | ||
|
|
||
| const [localProvenEpochNumber, localProvenBlockNumber] = await Promise.all([ | ||
| this.store.getProvenL2EpochNumber(), |
There was a problem hiding this comment.
As in #12380 might be better if these depends on each other, and not be pulled as there could be a race condition. e.g., given the block number we should be able to get the slot number and then the epoch number.
There was a problem hiding this comment.
epoch can be inferred from block, gotcha
There was a problem hiding this comment.
epoch number is entirely not required, here, opening pr to remove
alexghr
left a comment
There was a problem hiding this comment.
Just a question on synching really, otherwise the code looks good and lot simpler than before!
With these changes do we really don't have to ask the P2P client if it's synched up the latest block? 🤔
| public stop() { | ||
| this.log.debug('Stopping Slasher client...'); | ||
| this.l2BlockSource.removeListener(L2BlockSourceEvents.L2PruneDetected, this.handlePruneL2Blocks.bind(this)); | ||
| this.l2BlockSource.removeListener(L2BlockSourceEvents.ChainPruned, this.handlePruneL2Blocks.bind(this)); |
There was a problem hiding this comment.
I realise this isn't new code (in this PR) but this bind will create a new function instance and won't remove the original.
|
|
||
| await advanceToProvenBlock(5); | ||
| advanceToProvenBlock(5); | ||
| await sleep(100); // wait for the event to be emitted and handled |
There was a problem hiding this comment.
I guess this is needed because advanceToProvenBlock is no longer async? Slightly worried this might flake in the future, but probably fine for now 😁
| // Store references to the wrapper functions for later removal | ||
| this.eventHandlers = { | ||
| handleChainPruned, | ||
| handleBlocksAdded, | ||
| handleChainProven, | ||
| }; |
| private async startServiceIfSynched() { | ||
| if ( | ||
| this.currentState === P2PClientState.SYNCHING && | ||
| (await this.getSyncedLatestBlockNum()) >= this.latestBlockNumberAtStart && | ||
| (await this.getSyncedProvenBlockNum()) >= this.provenBlockNumberAtStart | ||
| ) { | ||
| this.log.debug(`Synched to blocks at start`); | ||
| this.setCurrentState(P2PClientState.RUNNING); | ||
| if (this.syncResolve !== undefined) { | ||
| this.syncResolve(); | ||
| await this.p2pService.start(); | ||
| } | ||
| } |
There was a problem hiding this comment.
Is this not needed anymore? My understanding was that this function would block the node from 'starting' until all of its components had synched.
Is there a risk that after a restart a node would have components at different heights because they synched at different speeds from the archiver?
There was a problem hiding this comment.
You're completely correct, myself and lasse have just discussed this. I'm currently bringing this logic back!
| ] as const); | ||
|
|
||
| const [worldState, l2BlockSource, p2p, l1ToL2MessageSource] = syncedBlocks; | ||
| const [worldState, l2BlockSource, l1ToL2MessageSource] = syncedBlocks; |
There was a problem hiding this comment.
I think we should still ask the P2P node if it's synched up the latest block otherwise the sequencer could start building a block before the P2P client had a chance to react to the BlocksAdded event.
There was a problem hiding this comment.
This happened in the ci 👍
There was a problem hiding this comment.
This is exactly what happened in the failing prover test!
ba1798f to
1c82e22
Compare
|
stale |


Overview
Migrates the p2p client to use the archiver's event emitter that was created in the pr above in this stack.
This removes usage of the L2BlockStream from the p2p client for dealing with state changes, and instead uses events to deal with these situations