-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (129 loc) · 7.02 KB
/
Copy pathMakefile
File metadata and controls
145 lines (129 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Makefile for attsim GossipSub Shadow simulation
.PHONY: all build build-topology-gen generate-topology generate-config run-sim test plot clean help check-deps
# Default parameters
NODE_COUNT ?= 10
MESH_NODE_COUNT ?= 6
MESH_ATTESTER_COUNT ?= 2
NON_MESH_ATTESTER_COUNT ?= 2
TOPOLOGY_TYPE ?= random-regular
PEER_COUNT ?= 4
NON_MESH_NODE_PEER_COUNT ?= 4
BRANCHING ?= 2
PROGRESS ?= false
LOG_LEVEL ?= info
# Paths
TOPOLOGY_GEN_DIR = topology/gen
GOSSIPSUB_DIR = gossipsub
TOPOLOGY_FILE = topology.json
SIMCONFIG_FILE = simconfig.yaml
PLOT_DIR = updated-plots
PLOT_OUTPUT_FILE = output.png
# Check dependencies
check-deps:
@echo "Checking dependencies..."
@which shadow > /dev/null || (echo "Error: Shadow simulator not found. Install from https://shadow.github.io/" && exit 1)
@which uv > /dev/null || (echo "Error: uv not found" && exit 1)
@echo "Dependencies OK"
# Build the topology generator
build-topology-gen:
@echo "Building topology generator..."
cd $(TOPOLOGY_GEN_DIR) && go build -o topology-gen
@test -f $(TOPOLOGY_GEN_DIR)/topology-gen || (echo "Topology generator build failed" && exit 1)
@echo "Topology generator built"
# Generate topology file
generate-topology: build-topology-gen
@echo "Generating $(TOPOLOGY_TYPE) topology with $(NODE_COUNT) nodes..."
$(TOPOLOGY_GEN_DIR)/topology-gen -type $(TOPOLOGY_TYPE) -nodes $(NODE_COUNT) -degree $(PEER_COUNT) -non-mesh-node-degree $(NON_MESH_NODE_PEER_COUNT) -branching $(BRANCHING) -mesh-nodes $(MESH_NODE_COUNT) -mesh-attester-count $(MESH_ATTESTER_COUNT) -non-mesh-attester-count $(NON_MESH_ATTESTER_COUNT) -output $(TOPOLOGY_FILE) --simconfig-file $(SIMCONFIG_FILE)
@test -f $(TOPOLOGY_FILE) || (echo "Topology generation failed" && exit 1)
@echo "Topology generated: $(TOPOLOGY_FILE)"
# Build the gossipsub simulation binary
build: check-deps
@echo "Building GossipSub simulation binary..."
cd $(GOSSIPSUB_DIR) && go build -o gossipsub
@test -f $(GOSSIPSUB_DIR)/gossipsub || (echo "Build failed" && exit 1)
@echo "Build successful"
# Generate network graph and Shadow configuration
generate-config: build generate-topology
@echo "Generating Shadow network configuration for $(NODE_COUNT) nodes with $(MESH_NODE_COUNT) mesh nodes, $(MESH_ATTESTER_COUNT) mesh attesters nodes, $(NON_MESH_ATTESTER_COUNT) non mesh attesters nodes..."
uv run network_graph.py $(NODE_COUNT) $(TOPOLOGY_FILE) $(SIMCONFIG_FILE)
@test -f shadow-gossipsub.yaml && test -f graph.gml || (echo "Config generation failed" && exit 1)
@echo "Configuration generated"
generate-config-only:
@echo "Generating Shadow network configuration for $(NODE_COUNT) nodes with $(MESH_NODE_COUNT) mesh nodes, $(MESH_ATTESTER_COUNT) mesh attesters nodes, $(NON_MESH_ATTESTER_COUNT) non mesh attesters nodes..."
uv run network_graph.py $(NODE_COUNT) $(TOPOLOGY_FILE) $(SIMCONFIG_FILE)
@test -f shadow-gossipsub.yaml && test -f graph.gml || (echo "Config generation failed" && exit 1)
@echo "Configuration generated"
# Run the complete Shadow simulation
run-shadow: build
@echo "Starting GossipSub Shadow simulation"
@rm -rf shadow.data/
shadow --progress $(PROGRESS) shadow-gossipsub.yaml
@echo "GossipSub simulation completed"
# Test simulation results
test:
@echo "Testing GossipSub simulation results..."
uv run test_results.py $(NODE_COUNT) $(TOPOLOGY_FILE)
# Plot message propagation
plot:
@echo "Plotting message propagation..."
@mkdir -p $(PLOT_DIR)
uv run plot_propagation.py $(NODE_COUNT) --topology-file $(TOPOLOGY_FILE) --peer-count $(PEER_COUNT) --non-mesh-node-peer-count $(NON_MESH_NODE_PEER_COUNT) --simconfig-file $(SIMCONFIG_FILE) -o $(PLOT_DIR)/$(PLOT_OUTPUT_FILE)
@test -f $(PLOT_DIR)/$(PLOT_OUTPUT_FILE) && echo "Plot generated: $(PLOT_DIR)/$(PLOT_OUTPUT_FILE)" || echo "Plot generation failed"
run-sim: run-shadow test plot
# Clean build artifacts and simulation results
clean:
@echo "Cleaning up..."
rm -f $(GOSSIPSUB_DIR)/gossipsub
rm -f $(TOPOLOGY_FILE)
rm -f shadow-gossipsub.yaml
rm -f graph.gml
rm -f message_propagation.png
rm -rf shadow.data/
rm -f $(TOPOLOGY_GEN_DIR)/topology-gen
@echo "Cleanup completed"
# Complete workflow: build, run, test, and plot
all: build generate-config run-sim test plot
# Help target
help:
@echo "attsim GossipSub Shadow Simulation"
@echo "==================================="
@echo ""
@echo "Targets:"
@echo " check-deps - Check required dependencies"
@echo " build-topology-gen - Build the topology generator"
@echo " generate-topology - Generate network topology file"
@echo " build - Build the GossipSub simulation binary"
@echo " generate-config - Generate Shadow configuration"
@echo " run-sim - Run complete Shadow simulation"
@echo " test - Test simulation results"
@echo " plot - Plot message propagation over time"
@echo " all - Run simulation, test, and plot (default)"
@echo " clean - Clean up build artifacts and results"
@echo " help - Show this help message"
@echo ""
@echo "Configuration variables:"
@echo " NODE_COUNT - Number of nodes (default: $(NODE_COUNT))"
@echo " MESH_NODE_COUNT - Number of mesh nodes (default: $(MESH_NODE_COUNT))"
@echo " MESH_ATTESTER_COUNT - Number of mesh attesters nodes (default: $(MESH_ATTESTER_COUNT))"
@echo " NON_MESH_ATTESTER_COUNT - Number of non mesh attesters nodes (default: $(NON_MESH_ATTESTER_COUNT))"
@echo " MSG_SIZE - Message size in bytes (default: $(MSG_SIZE))"
@echo " TOPOLOGY_TYPE - Topology type: mesh, tree, random-regular (default: $(TOPOLOGY_TYPE))"
@echo " PEER_COUNT - Peer count for random-regular (default: $(PEER_COUNT))"
@echo " BRANCHING - Branching factor for tree (default: $(BRANCHING))"
@echo " PROGRESS - Show Shadow progress bar (default: $(PROGRESS))"
@echo " LOG_LEVEL - Log level (default: $(LOG_LEVEL))"
@echo " BATCH_INTERVAL - BLS batch interval in milliseconds (default: $(BATCH_INTERVAL))"
@echo " BATCH_VERIFIER_TIME - BLS batch verifier time in microseconds (default: $(BATCH_VERIFIER_TIME))"
@echo ""
@echo "Examples:"
@echo " make all # Run simulation, test, and plot (random-regular)"
@echo " make run-sim NODE_COUNT=20 MSG_SIZE=512 # Custom parameters"
@echo " make run-sim NODE_COUNT=20 NODES_TO_PUBLISH=5 # 20 nodes, only 5 publish"
@echo " make run-sim NODE_COUNT=20 NODES_TO_PUBLISH=5 NODES_TO_SUBSCRIBE=15 # 5 publishers, 15 subscribers"
@echo " make run-sim TOPOLOGY_TYPE=mesh NODE_COUNT=10 # Mesh topology"
@echo " make run-sim TOPOLOGY_TYPE=tree NODE_COUNT=31 BRANCHING=2 # Tree topology"
@echo " make run-sim TOPOLOGY_TYPE=random-regular PEER_COUNT=6 # Random-regular with 6 peers"
@echo " make run-sim PROGRESS=true # Run with progress bar"
@echo " make run-sim BATCH_INTERVAL=2 BATCH_VERIFIER_TIME=2000 # Custom batch parameters"
@echo " make test # Test existing simulation results"
@echo " make plot NODE_COUNT=10 # Plot message propagation"