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

feat(daemon): multiplayer #2114

Merged
merged 20 commits into from
Mar 7, 2024
Merged

Conversation

kumavis
Copy link
Member

@kumavis kumavis commented Mar 3, 2024

  • adds NETS network directory which are automatically started on boot, used for generating network addresses, and attempting connections to peers.
  • adds a nodeIdentifier to formula identifiers that specifies where (what peer) a formula/value lives
  • adds an ownNodeIdentifier for identifying local formula/values
  • adds a peer store that stores the peers by nodeIdentifier
  • provideValueForFormulaIdentifier looks up non-local values via the formulaIdentifier's nodeIdentifier when peer is known
  • adds getPeerInfo, addPeerInfo for introducing peers
  • adds a gateway (used by network caplets) for exposing value requests from peers
  • peers are local formulas that expose the remote gateway via the matching network caplet

@kumavis kumavis force-pushed the kumavis-daemon-tcp-network-device2 branch from 0109bb0 to fc4c179 Compare March 3, 2024 22:37
@kumavis kumavis force-pushed the kumavis-daemon-tcp-network-device2 branch from fc4c179 to 375c3e9 Compare March 3, 2024 22:38
@kumavis kumavis changed the title feat(daemon): NameHubs expose listIdentifiers method feat(daemon): network directory Mar 3, 2024
@kumavis kumavis changed the title feat(daemon): network directory feat(daemon): multiplayer Mar 7, 2024
@kumavis kumavis force-pushed the kumavis-daemon-tcp-network-device2 branch from 8cec137 to f7e7f21 Compare March 7, 2024 20:19
@kumavis kumavis marked this pull request as ready for review March 7, 2024 20:26
Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

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

Only notes.

packages/daemon/src/directory.js Outdated Show resolved Hide resolved
const type = formulaIdentifier.slice(0, delimiterIndex);
const number = formulaIdentifier.slice(delimiterIndex + 1);
return { type, number };
const [type, number, location] = formulaIdentifier.split(':');
Copy link
Member

Choose a reason for hiding this comment

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

I’m guessing this eventually evolves to the endo://NODE/VALUE?type=TYPE subset of endo://NODE/VALUE?type=TYPE&subtype=&address=&address=

@@ -21,8 +21,10 @@ const { quote: q } = assert;
* @param {import('./types.js').DaemonCore['incarnateWebBundle']} args.incarnateWebBundle
* @param {import('./types.js').DaemonCore['incarnateHandle']} args.incarnateHandle
* @param {import('./types.js').DaemonCore['storeReaderRef']} args.storeReaderRef
* @param {import('./types.js').DaemonCore['getAllNetworkAddresses']} args.getAllNetworkAddresses
Copy link
Member

Choose a reason for hiding this comment

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

I’m fine abbreviating this to addresses

packages/daemon/src/host.js Outdated Show resolved Hide resolved
packages/daemon/src/host.js Show resolved Hide resolved
packages/daemon/src/host.js Show resolved Hide resolved
packages/daemon/src/host.js Outdated Show resolved Hide resolved
packages/daemon/src/host.js Outdated Show resolved Hide resolved
networksDirectoryFormulaIdentifier,
);
const peerInfo = {
location: ownLocation,
Copy link
Member

Choose a reason for hiding this comment

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

Location is going to become quickly ambiguous since we will have locations of varying specificity:

  • endo://node node location
  • endo://node/value value location
  • endo://node/value.type typed value location
  • endo://node/value.type?address=&address= value location (née offline capability) with connection hints
  • endo://node/value.blob-reader-base64/application/javascript?address=&address= MIME-typed downloadable blob location over base64 until CapTP maybe someday can do byte streams

This can perhaps just be peer implying “peer identifier” or “peer public key” someday

packages/daemon/src/pet-store.js Outdated Show resolved Hide resolved
packages/daemon/src/networks/loopback.js Outdated Show resolved Hide resolved
Comment on lines 91 to 102
// eslint-disable-next-line no-use-before-define
const ownLocation = getDerivedId(
'location',
rootEntropy,
cryptoPowers.makeSha512(),
);
// eslint-disable-next-line no-use-before-define
const peersFormulaNumber = getDerivedId(
'peers',
rootEntropy,
cryptoPowers.makeSha512(),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these derived as opposed to random?

If this is needed, the function should be renamed getDerivedNumber and we could move it to the top to get rid of the eslint-disable directives.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made a refactor that made sense at the time that separated endoCore generic methods from the configured Endo. this looked good at the time but now provideValueforFormulaIdentifier (and everything that uses it) rely on the configuration of the ownLocation. I made the smallest change here, but it invalidated the previous refactor.

Copy link
Contributor

Choose a reason for hiding this comment

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

So we can just use random numbers instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

after arm wrestling daemonCore a bit, yes

Copy link
Member Author

Choose a reason for hiding this comment

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

i recommend we do this after simplifying the daemon's provideWhateverFromFormulaWhatever code paths

packages/daemon/src/daemon.js Outdated Show resolved Hide resolved
@kumavis kumavis enabled auto-merge March 7, 2024 22:06
@kumavis kumavis merged commit 37b17ee into master Mar 7, 2024
14 checks passed
@kumavis kumavis deleted the kumavis-daemon-tcp-network-device2 branch March 7, 2024 22:07
@kumavis
Copy link
Member Author

kumavis commented Mar 7, 2024

🎉 🎉 🎉

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