Open srene opened 2 weeks ago
The changes introduce a robust peer-to-peer (P2P) block syncing mechanism in the block
and p2p
modules. This enhancement includes new methods for event subscriptions, block caching, and synchronization processes, coupled with improved logging and error handling. Substantial updates to the configuration files ensure seamless integration.
Files / Groups | Change Summary |
---|---|
block/block.go |
Added attemptCacheBlock function and updated applyBlock logic for block caching and height management. |
block/manager.go |
Introduced new event subscriptions, enhanced syncing logic for sequencers and full-nodes, and added new functions for block production and submission loops. |
block/manager_test.go |
Updated TestInitialState to use datastore.NewMapDatastore() for parameter setup. |
block/p2p.go |
Added functions for handling and synchronizing gossiped blocks, refreshing block sync advertisements, and gossiping blocks. |
block/produce.go |
Added a logging statement to ProduceBlockLoop to log the size of new blocks. |
block/retriever.go |
Commented out or removed specific logging statements in the syncToTargetHeight and ProcessNextDABatch methods. |
block/types.go |
Added new blocksyncBlock constant and updated CachedBlock struct to include a Source field. |
config/defaults.go , config/p2p.go |
Introduced BlockSyncRetryTime field in P2PConfig with a default value of 30 * time.Second . |
da/celestia/celestia.go , da/da.go , ... |
Refactored batch retrieval methods, changed Grpc constant order, and fixed a typo in a log message. |
go.mod |
Updated dependencies including github.com/google/uuid , github.com/hashicorp/golang-lru , and go.opentelemetry.io/otel . |
node/node.go |
Added datastore and leveldb imports, and updated NewNode function to initialize a datastore.Datastore instance. |
p2p/block_sync.go , p2p/block_sync_dag.go |
Introduced BlockSync and BlockSyncDagService structs with methods for managing block synchronization, DAG services, and IPLD block data handling. |
p2p/block_sync_test.go |
Added tests for block synchronization functionality in a P2P network environment. |
p2p/client.go |
Added methods for handling block advertisements, adding and retrieving blocks, and managing block synchronization. Modified NewClient function to include a store parameter. |
p2p/client_test.go |
Introduced a test for block advertisement and validation logic, and updated TestClientStartup to use datastore.NewMapDatastore() . |
p2p/events.go , p2p/validator.go |
Added EventNewBlockSyncBlock event and updated deserialization logic for gossiped blocks in the BlockValidator function. |
p2p/validator_test.go |
Renamed GossipedBlock to P2PBlock , affecting the creation of gossiped block instances in TestValidator_BlockValidator . |
testutil/p2p.go |
Updated StartTestNetwork function to take an additional datastore parameter. |
sequenceDiagram
participant Client
participant Manager
participant P2P Network
participant Data Layer
Client->>Manager: StartBlockSync
Manager->>P2P Network: AdvertiseBlock
P2P Network-->>Manager: NewBlockSyncBlockEvent
Manager->>Client: AddBlock(block)
Client-->>Data Layer: StoreBlock(block)
Client-->>P2P Network: GetBlockId
P2P Network-->>Manager: RequestBlock(blockId)
Manager->>Client: SyncBlock(blockId)
Client-->>Data Layer: RetrieveBlock(blockId)
Data Layer-->>Client: BlockData
Client-->>Manager: UpdateBlock(blockData)
Objective (Issue Number) | Addressed | Explanation |
---|---|---|
Implement robust P2P block syncing (#914) | ✅ | |
Include improved error handling (#914) | ✅ | |
Add and document necessary configurations (#914) | ✅ | |
Introduce comprehensive logging (#914) | ✅ | |
Test synchronization processes (#914) | ✅ |
In the network of blocks anew, P2P sync makes its debut, With caches and retries, it flows, Ensuring each block knows, The place where it belongs, Singing synchrony’s songs, A change both sure and true! 🌐
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Attention: Patch coverage is 55.55556%
with 168 lines
in your changes missing coverage. Please review.
Project coverage is 39.64%. Comparing base (
5a3478b
) to head (c27c7e6
). Report is 4 commits behind head on main.:exclamation: Current head c27c7e6 differs from pull request most recent head d6a174b
Please upload reports for the commit d6a174b to get more accurate results.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
PR Standards
This PR is aimed at providing a new feature to be able to sync from P2P, retrieving blocks from other peers using the P2P network, mainly using available libp2p and IPFS libraries.
ADR is defined here https://www.notion.so/ADR-x-Rollapp-block-sync-protocol-6ee48b232a6a45e09989d67f1a6c0297?pvs=4
--
PR naming convention: https://hackmd.io/@nZpxHZ0CT7O5ngTp0TP9mg/HJP_jrm7A
Close #914
<-- Briefly describe the content of this pull request -->
For Author:
godoc
commentsFor Reviewer:
After reviewer approval:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Tests