Skip to content
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

#307: Optimize p2p sync requests #312

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mvandeberg
Copy link
Member

Resolves #307

Brief description

Optimizes the sync requests to try not to request more blocks than needed.

Checklist

  • I have built this pull request locally
  • I have ran the unit tests locally
  • I have manually tested this pull request
  • I have reviewed my pull request
  • I have added any relevant tests

Demonstration

On a test node, I am running with gossip disabled:

p2p:
  listen: /ip4/0.0.0.0/tcp/8888                       # Multiaddress on which to listen
  peer:                                               # Peer seed nodes
    - /dns4/seed.koinos.io/tcp/8888/p2p/Qmd2bkf65yCKVZb2PG3FiRQWzrYgKf47zGBFuoU5qdebEY
    - /dns4/seed.koinosblocks.com/tcp/8888/p2p/QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze
      #- /dns4/seed-east.burnkoin.com/tcp/8888/p2p/QmYAC9nxqgVt2p8NvmxNFsoMpQS7c4zEBmsZndEBTRHNu4
      #  - /dns4/seed-west.burnkoin.com/tcp/8888/p2p/QmcwsnczsFRxgkyYtTWK4dq6tbE5tpE48jtHp7nKAvy22V
  # checkpoint:                                       # Checkpoints required in synced chain
  #  - BLOCK_HEIGHT:BLOCK_ID
  disable-gossip: true                              # Disables gossip, this is not recommended
  # force-gossip: true                                # Forces gossip to always be enabled, this is not recommended
  # seed: MY_SECRET_SEED_PHRASE                       # Seed string to generate a peer ID, this should only be used when configuring the node as a seed node

And the node still works

p2p:

p2p-1  | 2024-11-18 18:56:53.289338 (p2p.Koinos) [koinos-p2p/main.go:139] <info>: Koinos P2P v1.2.0 (7d620ddd)
p2p-1  | 2024-11-18 18:56:53.289775 (p2p.Koinos) [[email protected]/client.go:117] <info>: Connecting client to AMQP server amqp://guest:guest@amqp:5672/
p2p-1  | 2024-11-18 18:56:53.289881 (p2p.Koinos) [[email protected]/connection.go:85] <info>: Dialing AMQP server amqp://guest:guest@amqp:5672/
p2p-1  | 2024-11-18 18:56:53.300772 (p2p.Koinos) [[email protected]/client.go:136] <info>: Client connected
p2p-1  | 2024-11-18 18:56:53.300856 (p2p.Koinos) [koinos-p2p/main.go:202] <info>: Attempting to connect to block_store...
p2p-1  | 2024-11-18 18:56:53.303020 (p2p.Koinos) [koinos-p2p/main.go:208] <info>: Connected
p2p-1  | 2024-11-18 18:56:53.303120 (p2p.Koinos) [koinos-p2p/main.go:213] <info>: Attempting to connect to chain...
p2p-1  | 2024-11-18 18:56:53.304596 (p2p.Koinos) [koinos-p2p/main.go:219] <info>: Connected
p2p-1  | 2024-11-18 18:56:53.304644 (p2p.Koinos) [node/node.go:460] <info>: Using random seed: LgUcZhBB
p2p-1  | 2024-11-18 18:56:53.322266 (p2p.Koinos) [[email protected]/request_handler.go:100] <info>: Connecting request handler to AMQP server amqp://guest:guest@amqp:5672/
p2p-1  | 2024-11-18 18:56:53.322351 (p2p.Koinos) [[email protected]/connection.go:85] <info>: Dialing AMQP server amqp://guest:guest@amqp:5672/
p2p-1  | 2024-11-18 18:56:53.341961 (p2p.Koinos) [[email protected]/request_handler.go:132] <info>: Request handler connected
p2p-1  | 2024-11-18 18:56:53.343886 (p2p.Koinos) [p2p/gossip_toggle.go:54] <info>: Gossip always disabled
p2p-1  | 2024-11-18 18:56:53.343857 (p2p.Koinos) [koinos-p2p/main.go:233] <info>: Starting node at address: /ip4/127.0.0.1/tcp/8888/p2p/QmeFLwSma8xzCHTxQSpa7RCCySiDuD6suCX8sMfu9awN3w
p2p-1  | 2024-11-18 18:56:53.344007 (p2p.Koinos) [p2p/connection_manager.go:309] <info>: Attempting to connect to seed Qmd2bkf65yCKVZb2PG3FiRQWzrYgKf47zGBFuoU5qdebEY
p2p-1  | 2024-11-18 18:56:53.603328 (p2p.Koinos) [p2p/connection_manager.go:309] <info>: Attempting to connect to seed QmUNURuZxSu5wLnmBNJdwGtwjLmV5JxGhu4uNSAS8ZNcze

chain:

chain-1  | 2024-11-18 18:56:53.821853 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810727, ID: 0x1220af611604510c5bdb95324d5d7c64887806807cc973895e011c3dd0001540e231 (0 transactions)
chain-1  | 2024-11-18 18:57:04.031839 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810728, ID: 0x12209df52a8728abc9529d57a38117ffedc550c263ce010a9674e82d6541d9c0952b (0 transactions)
chain-1  | 2024-11-18 18:57:04.070309 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810729, ID: 0x12202095adbee58aba1b1aef091240419507b91007024628f9b4ab87c7058007ace3 (0 transactions)
chain-1  | 2024-11-18 18:57:04.108335 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810730, ID: 0x12207dcc5879443254d9f874da3531c393f044cb59e7b33da6f269bc0d4610e7b341 (0 transactions)
chain-1  | 2024-11-18 18:57:04.146975 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810731, ID: 0x1220d181132433e7629472b0ce92e1a609e1e57206f6064b11624c69e703552ea302 (0 transactions)
chain-1  | 2024-11-18 18:57:14.353858 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810732, ID: 0x12203010b5f8e755da969858844d6d329e7a13c25fe5d5b17ae5227c36881d5e6676 (0 transactions)
chain-1  | 2024-11-18 18:57:14.392639 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810733, ID: 0x1220d48589039e6bccd4253c600c5d5e4edffa429f00477a3fd85f44b56137216c94 (0 transactions)
chain-1  | 2024-11-18 18:57:14.435634 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810734, ID: 0x1220a575371106401c319172a91d13cb872769223ba8f80631988ebff04641fb45fa (0 transactions)
chain-1  | 2024-11-18 18:57:14.475677 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810735, ID: 0x1220b15057d0b2878d0deef45b751c33e586b7b031bdfb9add81ba6f47cd9cbf726e (0 transactions)
chain-1  | 2024-11-18 18:57:14.516178 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810736, ID: 0x122098a7015db67dca1155664244754dfeaa650576acd22e8834f2ebeb9807b0cdc3 (0 transactions)
chain-1  | 2024-11-18 18:57:14.554610 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810737, ID: 0x12208a7c8358642bcb8938d45ba857d2d80080c889d2e0ae2e9dcd63a3b92ef54737 (0 transactions)
chain-1  | 2024-11-18 18:57:24.764291 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810738, ID: 0x1220ea09e6c5791e8420a6623736cbb1fa79dd1e4e2c212b0069c5a5be77f61081c8 (0 transactions)
chain-1  | 2024-11-18 18:57:24.805338 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810739, ID: 0x1220ae59cb2b56c5c41638987df0dddb30551897a0d37ef6b40b2b015097ecba32d8 (0 transactions)
chain-1  | 2024-11-18 18:57:35.027218 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810740, ID: 0x1220d72d9ac0ec12fb57e6065ac7f60a307bd525b925b371cfea94f101a72df6c296 (0 transactions)
chain-1  | 2024-11-18 18:57:35.066579 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810741, ID: 0x1220e4cd85597fadfcb5016fa282e3d7872940eb84fbfa287ee05dd20f0bb45d7316 (0 transactions)
chain-1  | 2024-11-18 18:57:45.274294 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810742, ID: 0x12204a41c7849bcf79e25aa5f71a804daf15085df3e2e769224d86e13aab4cdcc331 (0 transactions)
chain-1  | 2024-11-18 18:57:55.480834 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810743, ID: 0x1220d5b4987833661a693966ce09858c41c7b4a9d4b7756c6b1fd513a65df1345626 (0 transactions)
chain-1  | 2024-11-18 18:57:55.519836 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810744, ID: 0x122024c340157bf6348fa1e368a4aab75ec7039e478a3163973f59f5af89377741ce (0 transactions)
chain-1  | 2024-11-18 18:57:55.557927 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810745, ID: 0x12204467a97558cc1704d510b4a2c92a38b287d89825953786a3d1f8867e53886e06 (0 transactions)
chain-1  | 2024-11-18 18:57:55.599050 (chain.Koinos) [controller.cpp:434] <info>: Block applied - Height: 20810746, ID: 0x12200c147500a240d89e3c8243fed5c64960eea8610ac8145a1bcbb3ebd8b4cf54da (0 transactions)

@mvandeberg mvandeberg requested a review from sgerbino November 18, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Sync optimization
1 participant