### Install go-metrics using go get Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Command to install the go-metrics library using the Go package management tool. ```sh go get github.com/rcrowley/go-metrics ``` -------------------------------- ### Run Ping-Pong Simulation Server (Go) Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/p2p/simulations/examples/README.md Starts the simulation server for the ping-pong example. It logs the adapter being used and the address the server is starting on. This is typically run in one terminal. ```go go run ping-pong.go ``` ```go go run ping-pong.go --adapter exec ``` -------------------------------- ### Install StatHat Go Client Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Command to install the StatHat Go client, which is a dependency for StatHat support in go-metrics. ```sh go get github.com/stathat/go ``` -------------------------------- ### Start Ping-Pong Simulation Nodes (Shell) Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/p2p/simulations/examples/README.md Starts and connects the nodes for the ping-pong simulation. This script creates a specified number of nodes and connects them to each other. It logs the creation and connection process. ```bash ./ping-pong.sh ``` -------------------------------- ### Start go-u2u Fakenet Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Starts the go-u2u fakenet with a specified number of genesis validators (N). This script is used for setting up the private testing network. ```sh N=3 ./start.sh ``` -------------------------------- ### Run go-u2u Node with Docker Compose Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/join-mainnet/README.md Starts the go-u2u node in detached mode using Docker Compose. Ensure Docker Compose is installed and configured. ```Shell docker compose up -d ``` -------------------------------- ### Start Development Prometheus Monitoring Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This script starts the Prometheus container in development mode for monitoring U2U services. It requires navigating to the 'development' directory before execution. ```shell cd development ./prometheus-on.sh ``` -------------------------------- ### Start Grafana, Cadvisor, NodeReporter with Docker Compose Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This command uses Docker Compose to launch multiple services, including Grafana, Cadvisor, and NodeReporter, for tracking and reporting analytics. Ensure the docker-compose.yaml file is correctly configured. ```shell docker compose up ``` -------------------------------- ### Install abigen Go Tool Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/integrationtests/contracts/README.md Installs the abigen tool, which is used for generating Go bindings from smart contracts. This command ensures you have the latest version of the tool. ```Go go install github.com/unicornultrafoundation/go-u2u/cmd/abigen@latest ``` -------------------------------- ### Start Testnet Prometheus Monitoring Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This script starts a Prometheus container for collecting metrics from running testnet nodes. It's necessary to have the testnet nodes running prior to executing this command. Use './prometheus-off.sh' to stop the monitoring. ```shell cd testnet ./prometheus-on.sh ``` -------------------------------- ### Run Go-u2u Demo Scripts Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md These bash scripts are used to manage the Go-u2u demo environment. They allow you to start, stop, and clean the chain data for testing purposes. ```bash cd demo/ ./start.sh # start the u2u processes ``` ```bash ./stop.sh # stop the demo ``` ```bash ./clean.sh # erase the chain data ``` -------------------------------- ### Build go-u2u Docker Image Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/join-mainnet/README.md Builds the Docker image for the go-u2u project. Specify the network (e.g., 'mainnet') as a parameter. This command is executed from the go-u2u directory. ```Shell cd /go-u2u make NET=mainnet u2u-image ``` -------------------------------- ### Build go-u2u Executable Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md This command builds the 'u2u' executable for the go-u2u project. It requires Go (version 1.14+) and a C compiler to be installed. ```shell make u2u ``` -------------------------------- ### Exposing Metrics via Expvars in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Demonstrates how to expose all registered metrics along with standard expvars under the /debug/metrics endpoint using the exp package. ```go import "github.com/rcrowley/go-metrics/exp" exp.Exp(metrics.DefaultRegistry) ``` -------------------------------- ### Emitting Metrics to StatHat in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Provides an example of how to periodically emit metrics to StatHat using the stathat client. ```go import "github.com/rcrowley/go-metrics/stathat" go stathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com") ``` -------------------------------- ### Start Devnet Prometheus Monitoring Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This script initiates a Prometheus container to collect metrics from running devnet nodes. Ensure the devnet nodes are active before running this script. The monitoring can be stopped using a corresponding 'prometheus-off.sh' script. ```shell cd devnet ./prometheus-on.sh ``` -------------------------------- ### Import log15 Package in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/log/README.md Demonstrates how to import the log15 package into a Go project for logging functionalities. This is the initial step to start using the library. ```Go import log "github.com/inconshreveable/log15" ``` -------------------------------- ### Emitting Metrics to Graphite in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Provides an example of how to periodically emit all metrics to Graphite using the go-metrics-graphite client. ```go import "github.com/cyberdelia/go-metrics-graphite" addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003") go graphite.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr) ``` -------------------------------- ### Prometheus Configuration Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This YAML file contains the configuration settings for Prometheus, defining the endpoints for monitoring. ```yaml prometheus.yml ``` -------------------------------- ### Get Node Balance Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Retrieves the balance of an account on a go-u2u node using the JavaScript console. This is useful for verifying account balances before and after transactions. ```js u2u.getBalance(u2u.accounts[0]); ``` -------------------------------- ### Emitting Metrics to Librato in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Shows how to periodically emit metrics to Librato using the go-metrics-librato client, including configuration for API token, source, and percentiles. ```go import "github.com/mihasya/go-metrics-librato" go librato.Librato(metrics.DefaultRegistry, 10e9, // interval "example@example.com", // account owner email address "token", // Librato API token "hostname", // source []float64{0.95}, // percentiles to send time.Millisecond, // time unit ) ``` -------------------------------- ### Get Transaction Receipt Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Retrieves the receipt of a transaction on the go-u2u network using its unique hash. This allows checking the block number in which the transaction was included. ```sh u2u.getTransactionReceipt("0x68a7c1daeee7e7ab5aedf0d0dba337dbf79ce0988387cf6d63ea73b98193adfd").blockNumber ``` -------------------------------- ### Logging Metrics to Syslog in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Shows how to periodically log metrics in a more parseable format to syslog using the Syslog function. ```go w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics") go metrics.Syslog(metrics.DefaultRegistry, 60e9, w) ``` -------------------------------- ### Run Go-U2U Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/testnet/README.md Starts the Go-U2U node in detached mode using Docker Compose. This command assumes the configuration in 'docker-compose.yml' has been completed. ```bash docker compose up -d ``` -------------------------------- ### Launch Fakenet with 1 Validator Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md This command launches the fakenet with a single validator, effectively functioning as a Proof-of-Authority (PoA) blockchain. It's a simple setup for basic private testing. ```shell $ u2u --fakenet 1/1 ``` -------------------------------- ### Run go-u2u Node with Docker Compose Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/mainnet/README.md Starts the go-u2u node services in detached mode using Docker Compose. This assumes the docker-compose.yml file has been correctly configured. ```bash docker compose up -d ``` -------------------------------- ### Monitor go-u2u Node Logs Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/join-mainnet/README.md Displays the last 10 lines of logs for the running 'u2u' Docker container in follow mode. This is useful for monitoring the node's activity and debugging. ```Shell docker logs -f --tail 10 u2u ``` -------------------------------- ### Grafana Datasource Configuration Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This YAML file specifies the data source configuration for Grafana, enabling it to analyze and store data. ```yaml datasource.yml ``` -------------------------------- ### Thread-Safe Metric Registration in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Shows how to use GetOrRegister for thread-safe registration of metrics, ensuring that a metric is only registered once even if called concurrently. ```go t := metrics.GetOrRegisterTimer("account.create.latency", nil) t.Time(func() {}) t.Update(47) ``` -------------------------------- ### Logging Metrics to Standard Error in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Demonstrates how to periodically log all registered metrics in a human-readable format to standard error using the Log function. ```go go metrics.Log(metrics.DefaultRegistry, 5 * time.Second, log.New(os.Stderr, "metrics: ", log.Lmicroseconds)) ``` -------------------------------- ### Create and Update Metrics in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Demonstrates how to create, register, and update different types of metrics including Counter, Gauge, Histogram, Meter, and Timer. It also shows how to use a FunctionalGauge and different sample types for Histograms. ```go c := metrics.NewCounter() metrics.Register("foo", c) c.Inc(47) g := metrics.NewGauge() metrics.Register("bar", g) g.Update(47) r := NewRegistry() g := metrics.NewRegisteredFunctionalGauge("cache-evictions", r, func() int64 { return cache.getEvictionsCount() }) s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028) h := metrics.NewHistogram(s) metrics.Register("baz", h) h.Update(47) m := metrics.NewMeter() metrics.Register("quux", m) m.Mark(47) t := metrics.NewTimer() metrics.Register("bang", t) t.Time(func() {}) t.Update(47) ``` -------------------------------- ### Go Fuzzer Output Example Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/FUZZING.md This snippet displays the typical output from a Go fuzzing process, showing metrics like the number of workers, corpus size, crashers found, and execution rate. This information is crucial for monitoring the fuzzing progress and identifying potential issues. ```log 2020/12/30 22:50:51 workers: 0, corpus: 1 (3s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 3s 2020/12/30 22:50:54 workers: 0, corpus: 1 (6s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 6s 2020/12/30 22:50:57 workers: 3, corpus: 1 (9s ago), crashers: 0, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 9s 2020/12/30 22:51:00 workers: 3, corpus: 1 (12s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 12s 2020/12/30 22:51:03 workers: 3, corpus: 1 (15s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 15s 2020/12/30 22:51:06 workers: 3, corpus: 1 (18s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 18s 2020/12/30 22:51:09 workers: 3, corpus: 1 (21s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 21s 2020/12/30 22:51:12 workers: 3, corpus: 1 (24s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 24s 2020/12/30 22:51:15 workers: 3, corpus: 1 (27s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 27s 2020/12/30 22:51:18 workers: 3, corpus: 1 (30s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 30s 2020/12/30 22:51:21 workers: 3, corpus: 1 (33s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 33s 2020/12/30 22:51:24 workers: 3, corpus: 1 (36s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 36s 2020/12/30 22:51:27 workers: 3, corpus: 1 (39s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 39s 2020/12/30 22:51:30 workers: 3, corpus: 1 (42s ago), crashers: 1, restarts: 1/0, execs: 0 (0/sec), cover: 0, uptime: 42s ``` -------------------------------- ### Attach to go-u2u Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Attaches a JavaScript console to a running go-u2u node. This allows interaction with the node for tasks like checking balances or sending transactions. ```sh go run ../cmd/u2u attach http://localhost:4000 ``` -------------------------------- ### Emitting Metrics to InfluxDB in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Demonstrates how to periodically emit metrics to InfluxDB using the go-metrics-influxdb client. Note that client libraries are being moved out of the core library. ```go import "github.com/vrischmann/go-metrics-influxdb" go influxdb.InfluxDB(metrics.DefaultRegistry, 10e9, "127.0.0.1:8086", "database-name", "username", "password" ) ``` -------------------------------- ### InfluxDB Reporter Configuration (Go) Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/influxdb/README.md Configures and starts the InfluxDB reporter for the go-metrics library. It takes the metrics registry, reporting interval, InfluxDB URL, database name, username, and password as arguments. ```go import "github.com/vrischmann/go-metrics-influxdb" go influxdb.InfluxDB( metrics.DefaultRegistry, // metrics registry time.Second * 10, // interval "http://localhost:8086", // the InfluxDB url "mydb", // your InfluxDB database "myuser", // your InfluxDB user "mypassword", // your InfluxDB password ) ``` -------------------------------- ### Build libsecp256k1 using Autotools Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/crypto/secp256k1/libsecp256k1/README.md This snippet outlines the standard build process for the libsecp256k1 library using autotools. It includes generating the build scripts, configuring the build, compiling the library, running tests, and optionally installing it. ```Shell ./autogen.sh ./configure make ./tests sudo make install # optional ``` -------------------------------- ### Check Balances After Transaction Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Checks the balances of accounts on different go-u2u nodes after a transaction has been processed and included in a block. This verifies the successful transfer of funds. ```sh go run ../cmd/u2u attach --exec "u2u.getBalance(u2u.accounts[0])" http://localhost:4000 go run ../cmd/u2u attach --exec "u2u.getBalance(u2u.accounts[0])" http://localhost:4001 ``` -------------------------------- ### Send Transaction Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Sends a transaction from one account to another on the go-u2u network using the JavaScript console. It includes the sender, receiver, value, and a callback function to handle the transaction hash. ```js u2u.sendTransaction( {from: u2u.accounts[0], to: "0x39F2b8b6B7c772A218fB1a1c438e375047f72d88", value: "1000000000000000000"}, function(err, transactionHash) { if (!err) console.log(transactionHash + " success"); }); ``` -------------------------------- ### Get Node Address Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/demo/README.md Retrieves the address of an account on a specific go-u2u node using the JavaScript console. This is needed to specify the recipient of a transaction. ```sh go run ../cmd/u2u attach --exec "u2u.accounts[0]" http://localhost:4001 ``` -------------------------------- ### Basic Logging with Key/Value Context in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/log/README.md Shows how to create a logger with initial context and log messages with additional key/value pairs. This illustrates the core structured logging capability of log15. ```Go srvlog := log.New("module", "app/server") // all log messages can have key/value contextsrvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate) ``` -------------------------------- ### Launch go-u2u Testnet Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Launches a 'u2u' node for a testnet by specifying the testnet's genesis file. ```shell $ u2u --genesis /path/to/testnet.g ``` -------------------------------- ### Build Go-U2U Docker Image Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/testnet/README.md Builds the Docker image for the Go-U2U project for a specified network (e.g., testnet). This command requires navigating to the project directory first. ```bash cd /go-u2u make NET=testnet u2u-image ``` -------------------------------- ### Go-u2u p2psim CLI Commands Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/p2p/simulations/README.md Details the commands available for the `p2psim` command-line client, which interacts with the HTTP API. It covers simulation control, node management, event handling, and RPC calls. ```bash p2psim show p2psim events [--current] [--filter=FILTER] p2psim snapshot p2psim load p2psim node create [--name=NAME] [--services=SERVICES] [--key=KEY] p2psim node list p2psim node show p2psim node start p2psim node stop p2psim node connect p2psim node disconnect p2psim node rpc [] [--subscribe] ``` -------------------------------- ### Stop Devnet Prometheus Monitoring Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This script stops the Prometheus container that is collecting metrics from devnet nodes. ```shell cd devnet ./prometheus-off.sh ``` -------------------------------- ### Create New Account for Testnet Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Creates a new account for a 'u2u' testnet node using the specified data directory. ```shell $ u2u --datadir /path/to/datadir account new ``` -------------------------------- ### Stop Testnet Prometheus Monitoring Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/docker/README.MD This script stops the Prometheus container responsible for collecting metrics from testnet nodes. ```shell cd testnet ./prometheus-off.sh ``` -------------------------------- ### Registering Services in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/p2p/simulations/README.md Demonstrates how to register service initializers for nodes in the simulation framework. Service initializers are functions that create node services and must be registered in an init() hook using adapters.RegisterServices. ```Go func init() { adapters.RegisterServices(adapters.Services{ "service1": initService1, "service2": initService2, }) } ``` -------------------------------- ### Launch Fakenet with Multiple Validators Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md This command sequence allows you to launch a fakenet with multiple validators. You need to run the command for each validator, specifying its unique ID and the total number of validators. ```shell $ u2u --fakenet 1/5 # first node, use 2/5 for second node ``` -------------------------------- ### Build go-u2u Docker Image Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/mainnet/README.md Builds the Docker image for the go-u2u project for a specified network (e.g., mainnet). This command requires navigating to the project directory. ```bash cd /go-u2u make NET=mainnet u2u-image ``` -------------------------------- ### Launch Testnet Node with Custom Data Directory Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Launches a 'u2u' testnet node using a specific genesis file and a dedicated data directory to avoid conflicts with other network instances. ```shell $ u2u --genesis /path/to/testnet.g --datadir /path/to/datadir ``` -------------------------------- ### Run go-u2u Unit Tests Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Executes all unit tests for the go-u2u client using the Go testing tool. This helps verify the integrity and correctness of the codebase. ```shell go test ./... ``` -------------------------------- ### Flexible Logging Configuration in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/log/README.md Illustrates how to configure log15 with multiple handlers, including outputting to standard error with logfmt format and to a file with JSON format, while filtering by log level. This showcases the flexibility of the Handler interface. ```Go // flexible configurationsrvlog.SetHandler(log.MultiHandler( log.StreamHandler(os.Stderr, log.LogfmtFormat()), log.LvlFilterHandler( log.LvlError, log.Must.FileHandler("errors.json", log.JSONFormat())))) ``` -------------------------------- ### View go-u2u Node Logs Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/mainnet/README.md Displays the logs for the running go-u2u node container. It follows the logs in real-time and shows the last 10 lines by default. ```bash docker logs -f --tail 10 u2u ``` -------------------------------- ### Unregistering Metrics in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/metrics/README.md Illustrates how to unregister metrics to prevent memory leaks, especially for short-lived meters and timers. Calling Unregister implicitly calls Stop() on the metric. ```go // Will call Stop() on the Meter to allow for garbage collection metrics.Unregister("quux") // Or similarly for a Timer that embeds a Meter metrics.Unregister("bang") ``` -------------------------------- ### Configure go-u2u with TOML File Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Configures the 'u2u' node by specifying a TOML configuration file instead of using command-line flags. ```shell $ u2u --config /path/to/your_config.toml ``` -------------------------------- ### Dump go-u2u Configuration Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Exports the current 'u2u' configuration to a file, which can be useful for creating custom configuration files. ```shell $ u2u --your-favourite-flags dumpconfig ``` -------------------------------- ### Configure Go-U2U Node via Docker Compose Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/testnet/README.md Configuration steps for running the Go-U2U node using Docker Compose. This involves updating the password file and modifying the 'docker-compose.yml' file with specific validator details and bootnodes. ```yaml Update password wallet in "/etc/password" Go to /go-u2u/deployment/testnet Update config in docker-compose.yml: validator.id validator.pubkey bootnodes ``` -------------------------------- ### Launch go-u2u Validator Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Launches a 'u2u' validator node, requiring specific flags for the validator ID and public key. It will prompt for a password to decrypt the private key. ```shell $ u2u --nousb --validator.id YOUR_ID --validator.pubkey 0xYOUR_PUBKEY ``` -------------------------------- ### Run Go P2P Protocol Fuzzer Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/FUZZING.md This command initiates a fuzzing process for a peer-to-peer protocol written in Go. It is designed to identify vulnerabilities by testing complex input parsing. The process generates a 'gossip-fuzz.zip' file in the 'fuzzing/' directory upon successful execution. ```bash make fuzz ``` -------------------------------- ### Launch go-u2u Readonly Node Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/README.md Launches a read-only (non-validator) 'u2u' node for a specified network using a genesis file. ```shell $ u2u --genesis file.g ``` -------------------------------- ### Type-Safe Logging with log.Ctx in Go Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/log/README.md Shows how to use `log.Ctx` for type-safe logging, providing a more robust alternative to the varargs style for passing context information to loggers and log messages. ```Go srvlog := log.New(log.Ctx{"module": "app/server"})srvlog.Warn("abnormal conn rate", log.Ctx{"rate": curRate, "low": lowRate, "high": highRate}) ``` -------------------------------- ### Go-u2u HTTP API Endpoints Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/p2p/simulations/README.md Lists the available HTTP API endpoints for controlling the simulation network. These endpoints allow for starting/stopping nodes, managing connections, streaming events, and taking snapshots. ```bash GET / Get network information POST /start Start all nodes in the network POST /stop Stop all nodes in the network GET /events Stream network events GET /snapshot Take a network snapshot POST /snapshot Load a network snapshot POST /nodes Create a node GET /nodes Get all nodes in the network GET /nodes/:nodeid Get node information POST /nodes/:nodeid/start Start a node POST /nodes/:nodeid/stop Stop a node POST /nodes/:nodeid/conn/:peerid Connect two nodes DELETE /nodes/:nodeid/conn/:peerid Disconnect two nodes GET /nodes/:nodeid/rpc Make RPC requests to a node via WebSocket ``` -------------------------------- ### Configure go-u2u Docker Compose Source: https://github.com/unicornultrafoundation/go-u2u/blob/master/deployment/mainnet/README.md Provides configuration details for the go-u2u node, including updating the wallet password in '/etc/password' and modifying parameters like validator ID, public key, and bootnodes in the 'docker-compose.yml' file. ```yaml Update password wallet in "/etc/password" Go to /go-u2u/deployment/mainnet Update config in docker-compose.yml: validator.id validator.pubkey bootnodes ```