Skip to content

[GH-846] Added --bootstrap-url parameter for simple initialization of archive node#847

Merged
Un1oR merged 2 commits intomainfrom
feature/GH-846-simple-archive-node-bootstrap
Apr 23, 2025
Merged

[GH-846] Added --bootstrap-url parameter for simple initialization of archive node#847
Un1oR merged 2 commits intomainfrom
feature/GH-846-simple-archive-node-bootstrap

Conversation

@Un1oR
Copy link
Copy Markdown
Contributor

@Un1oR Un1oR commented Apr 22, 2025

This is an alternative approach to the one proposed in #813.

Pros:

  • No hardcodes
  • No infrastructure lock-in, works fine locally, with or without relays

Caveats:

  • Establishing a connection using relays requires additional research, debugging and experimentation with EnableAutoNATv2 and EnableHolePunching in real or near real conditions. To avoid being blocked by this now, I've enabled the WithInfiniteLimits setting on relays, and WithAllowLimitedConn on nodes. This should work "cheap but surly".

@Un1oR Un1oR requested a review from dmtrskv April 22, 2025 20:52
@Un1oR Un1oR force-pushed the feature/GH-846-simple-archive-node-bootstrap branch from 9372c0d to aec9e75 Compare April 22, 2025 20:57
@Un1oR Un1oR changed the title [GH-846] Added bootstrap-url parameter for simple initialization of archive node [GH-846] Added --bootstrap-url parameter for simple initialization of archive node Apr 22, 2025
@Un1oR Un1oR changed the title [GH-846] Added --bootstrap-url parameter for simple initialization of archive node [GH-846] Added bootstrap-url parameter for simple initialization of archive node Apr 22, 2025
@Un1oR Un1oR changed the title [GH-846] Added bootstrap-url parameter for simple initialization of archive node [GH-846] Added --bootstrap-url parameter for simple initialization of archive node Apr 22, 2025
@Un1oR Un1oR force-pushed the feature/GH-846-simple-archive-node-bootstrap branch from aec9e75 to ddf6eb2 Compare April 22, 2025 21:03
@@ -0,0 +1,13 @@
package types
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not directly relevant to the PR.)

The package should've been called rpctypes so that one doesn't have to rename it all the time

(actually, I have the same thought about connection_manager which is contra at least two go conventions: no snake_case and a manager cannot be a package; the package should be what the manager manages; I suggest smth like connections there)

func (nb *nodeApiBuilder) WithLocalShardApiRw(shardId types.ShardId, txnpool txnpool.Pool) *nodeApiBuilder {
var localShardApi shardApiRw = newLocalShardApiRw(newLocalShardApiRo(shardId, nb.db), txnpool)
var bootstrapConfig *rpctypes.BootstrapConfig // = nil — not used in rw API methods
var localShardApi shardApiRw = newLocalShardApiRw(newLocalShardApiRo(shardId, nb.db, bootstrapConfig), txnpool)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not shardApiRw := newLocalShardApiRw(newLocalShardApiRo(shardId, nb.db, nil), txnpool)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answered in a neighboring comment. I want to see the interface type explicitly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To see the explicit interface type for what purpose?
(it's usually shown by an IDE btw)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a contract for the code below

shardId types.ShardId,
bootstrapConfig *rpctypes.BootstrapConfig,
) *nodeApiBuilder {
var localShardApi shardApiRo = newLocalShardApiRo(shardId, nb.db, bootstrapConfig)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's stick to :=

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this code was written by me earlier, just changing the formatting here. But I purposely used an explicit type statement for clarity and to express the intent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that var localShardApi shardApiRo = newLocalShardApiRo is more clear than localShardApi := newLocalShardApiRo
But up to you

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is that the "constructor" returns a pointer to the implementation (this may also be controversial, but so far I find it more practical). At the point of assignment, I emphasize that the code should not rely on the details of the implementation, but rather work with the interface.
Yes, this is probably really far-fetched, but I found it convenient.

}()
if err = initSyncers(ctx, res.syncers, cfg.AllowDbDrop); err != nil {
if err = initSyncers(
libp2pnetwork.WithAllowLimitedConn(ctx, "allow working through relay with traffic proxying"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be done on some lower level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ultimately we need to deal with establishing a direct connection, but as I wrote in the PR description, it's not the most trivial task. So such an obvious "plug" that the eye clings to seems to me preferable to a solution that will pretend to be good.

shardId types.ShardId,
bootstrapConfig *rpctypes.BootstrapConfig,
) *nodeApiBuilder {
var localShardApi shardApiRo = newLocalShardApiRo(shardId, nb.db, bootstrapConfig)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that var localShardApi shardApiRo = newLocalShardApiRo is more clear than localShardApi := newLocalShardApiRo
But up to you

func (nb *nodeApiBuilder) WithLocalShardApiRw(shardId types.ShardId, txnpool txnpool.Pool) *nodeApiBuilder {
var localShardApi shardApiRw = newLocalShardApiRw(newLocalShardApiRo(shardId, nb.db), txnpool)
var bootstrapConfig *rpctypes.BootstrapConfig // = nil — not used in rw API methods
var localShardApi shardApiRw = newLocalShardApiRw(newLocalShardApiRo(shardId, nb.db, bootstrapConfig), txnpool)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To see the explicit interface type for what purpose?
(it's usually shown by an IDE btw)

@Un1oR Un1oR force-pushed the feature/GH-846-simple-archive-node-bootstrap branch from 925dfee to c6e4e74 Compare April 23, 2025 21:22
@Un1oR Un1oR enabled auto-merge April 23, 2025 21:23
@Un1oR Un1oR added this pull request to the merge queue Apr 23, 2025
Merged via the queue into main with commit 098f6fc Apr 23, 2025
15 of 16 checks passed
@Un1oR Un1oR deleted the feature/GH-846-simple-archive-node-bootstrap branch April 23, 2025 21:48
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.

3 participants