owned this note changed 6 years ago
Linked with GitHub

Goshimmer study note

System envronment

  • Hardware
    • IBM System x3550 M4 Server -[7914IA4]-
  • Software
    • No LSB modules are available.
    • Distributor ID: Ubuntu
    • Description: Ubuntu 18.04.2 LTS
    • Release: 18.04
    • Codename: bionic

Preparation

  • Go 1.12

Git Repository

Installation

  • Clone goshimmer repository
    • git clone https://github.com/iotaledger/goshimmer
    • cd goshimmer/
  • Build your executable
    • go build -o shimmer
  • Run
    • ./shimmer -node-disable-plugins statusscreen -node-enable-plugins "dashboard"

Ports:

tcp        0      0 0.0.0.0:14626           0.0.0.0:*               LISTEN      6093/shimmer        
tcp        0      0 0.0.0.0:14666           0.0.0.0:*               LISTEN      6093/shimmer        
tcp6       0      0 :::8080                 :::*                    LISTEN      6093/shimmer        
tcp6       0      0 :::8081                 :::*                    LISTEN      6093/shimmer    

Output:

Dashboard

Systemd

[Unit]
Description=Goshimmer FullNode
After=network-online.target

[Service]
WorkingDirectory=/{hide}/goshimmer
EnvironmentFile=-/{hide}
ExecStart=/{hide}/shimmer -node-disable-plugins statusscreen
KillMode=process
Type=simple
User={hide}
Group={hide}
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier={hide}

[Install]
WantedBy=multi-user.target

SPAM

Architecture

main.go

func main() {
	node.Run(
		cli.PLUGIN,
		autopeering.PLUGIN,
		gossip.PLUGIN,
		gossip_on_solidification.PLUGIN,
		tangle.PLUGIN,
		bundleprocessor.PLUGIN,
		analysis.PLUGIN,
		gracefulshutdown.PLUGIN,
		tipselection.PLUGIN,
		zeromq.PLUGIN,
		dashboard.PLUGIN,
		metrics.PLUGIN,

		statusscreen.PLUGIN,
		statusscreen_tps.PLUGIN,

		webapi.PLUGIN,
		webapi_gtta.PLUGIN,
		webapi_spammer.PLUGIN,
	)
}

在 [node] package , 有兩處要注意

  1. node.go
func Run(plugins ...*Plugin) *Node {
	node := New(plugins...)
	node.Run()

	return node
}

執行順序是 Run -> New -> configure -> 每個插件的 run 函數

configure會初始化全部插件的初始化

另外無法理解 node.Run() , node的結構似乎沒有run函數

  1. plugin.go
// Creates a new plugin with the given name, default status and callbacks.
// The last specified callback is the mandatory run callback, while all other callbacks are configure callbacks.
func NewPlugin(name string, status int, callback Callback, callbacks ...Callback) *Plugin {
	plugin := &Plugin{
		Name:   name,
		Status: status,
		Events: pluginEvents{
			Configure: events.NewEvent(pluginCaller),
			Run:       events.NewEvent(pluginCaller),
		},
	}

	// make the plugin known to the parameters
	parameter.AddPlugin(name, status)

	if len(callbacks) >= 1 {
		plugin.Events.Configure.Attach(events.NewClosure(callback))
		for _, callback = range callbacks[:len(callbacks)-1] {
			plugin.Events.Configure.Attach(events.NewClosure(callback))
		}

		plugin.Events.Run.Attach(events.NewClosure(callbacks[len(callbacks)-1]))
	} else {
		plugin.Events.Run.Attach(events.NewClosure(callback))
	}

	return plugin
}

每個packages或plugin , 都會有plugin.go

裡面都有 configure 與 run 函數 , configure用來初始化packages或plugin ; run用來註冊event對應的callback函數 , 或對 daemon 的backgroundWorker 註冊 callback函數

並透過NewPlugin在main.go去執行configure與run , configure先 , run後(Main.go 的 PLUGIN是個變數 , 在 plugin.go 中由NewPlugin賦值)

從以上可以得知 , 要trace某個package和plugin , 先去看對應目錄下的plugin.go

Autopeering

Work Flow:

func configure(plugin *node.Plugin) {
	saltmanager.Configure(plugin)
	instances.Configure(plugin)
	server.Configure(plugin)
	protocol.Configure(plugin)
	peerstorage.Configure(plugin)

	daemon.Events.Shutdown.Attach(events.NewClosure(func() {
		server.Shutdown(plugin)
	}))

	configureLogging(plugin)
}

func run(plugin *node.Plugin) {
	instances.Run(plugin)
	server.Run(plugin)
	protocol.Run(plugin)
}

Neighbors:

According the chapter 4.2 Choosing neighbors of coordecide whitepaper, neighbor can be divided into Chosen neighbors and Accepted Neighbors the definition as below:

Autopeering structure

Issues:

  • Gossip duration

    • jkrvivian 3:56 PM: 不然我 spam 一下,看你會不會收到
    • jkrvivian 3:58 PM: 開始!
    • Maybe some problem in the distance calculate
    • I should add vivian as EntryNode
  • Private Tangle

    • Deploy A, B node
    • Remove IF EntryNode from A, B
    • A, B add neighbors to each other
    • SPAM from A
    • A, B sould be a private network and DB storage

Tools

Reference

Select a repo