allmende-sim: run 100 real nodes in one process and measure spread, churn and cost

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-18 21:31:43 +01:00
co-authored by Claude Sonnet 5.5
parent 93921c14e8
commit 85e8b6cbd5
3 changed files with 615 additions and 0 deletions
+7
View File
@@ -27,6 +27,7 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/discovery/mdns"
@@ -103,6 +104,9 @@ type Config struct {
AntiEntropyInterval time.Duration
Clock func() time.Time // default time.Now
Logger *slog.Logger
// Bandwidth, if set, counts the bytes this node sends and receives (the
// simulator uses it; a real node leaves it nil).
Bandwidth metrics.Reporter
}
// Node is a running participant.
@@ -199,6 +203,9 @@ func New(ctx context.Context, cfg Config) (*Node, error) {
}
opts = append(opts, libp2p.AddrsFactory(func([]ma.Multiaddr) []ma.Multiaddr { return announce }))
}
if cfg.Bandwidth != nil {
opts = append(opts, libp2p.BandwidthReporter(cfg.Bandwidth))
}
if cfg.Public {
opts = append(opts, libp2p.ForceReachabilityPublic(), libp2p.EnableRelayService(), libp2p.EnableNATService())
}