diff --git a/Makefile b/Makefile index 1ca7d0758..d5a8d7028 100644 --- a/Makefile +++ b/Makefile @@ -50,4 +50,5 @@ gen_client: go generate rpc/core_client/*.go revision: - -echo `git rev-parse --verify HEAD` >> $(TMROOT)/revisions + -echo `git rev-parse --verify HEAD` > $(TMROOT)/revision + -echo `git rev-parse --verify HEAD` >> $(TMROOT)/revision_history diff --git a/config/tendermint/config.go b/config/tendermint/config.go index d58942f1b..167eeec5a 100644 --- a/config/tendermint/config.go +++ b/config/tendermint/config.go @@ -54,6 +54,9 @@ func GetConfig(rootDir string) cfg.Config { if mapConfig.IsSet("chain_id") { Exit("Cannot set 'chain_id' via config.toml") } + if mapConfig.IsSet("revision_file") { + Exit("Cannot set 'revision_file' via config.toml. It must match what's in the Makefile") + } mapConfig.SetDefault("chain_id", "tendermint_testnet_11.b") mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json") mapConfig.SetDefault("moniker", "anonymous") @@ -65,9 +68,12 @@ func GetConfig(rootDir string) cfg.Config { mapConfig.SetDefault("priv_validator_file", rootDir+"/priv_validator.json") mapConfig.SetDefault("db_backend", "leveldb") mapConfig.SetDefault("db_dir", rootDir+"/data") + mapConfig.SetDefault("vm_log", true) mapConfig.SetDefault("log_level", "info") mapConfig.SetDefault("rpc_laddr", "0.0.0.0:46657") - mapConfig.SetDefault("revisions_file", rootDir+"/revisions") + mapConfig.SetDefault("prof_laddr", "") + mapConfig.SetDefault("revision_file", rootDir+"/revision") + mapConfig.SetDefault("local_routing", false) return mapConfig } diff --git a/config/tendermint_test/config.go b/config/tendermint_test/config.go index f0857a770..79a42e495 100644 --- a/config/tendermint_test/config.go +++ b/config/tendermint_test/config.go @@ -70,8 +70,11 @@ func GetConfig(rootDir string) cfg.Config { mapConfig.SetDefault("db_backend", "memdb") mapConfig.SetDefault("db_dir", rootDir+"/data") mapConfig.SetDefault("log_level", "debug") + mapConfig.SetDefault("vm_log", true) mapConfig.SetDefault("rpc_laddr", "0.0.0.0:36657") - mapConfig.SetDefault("revisions_file", rootDir+"/revisions") + mapConfig.SetDefault("prof_laddr", "") + mapConfig.SetDefault("revision_file", rootDir+"/revision") + mapConfig.SetDefault("local_routing", false) return mapConfig } diff --git a/node/node.go b/node/node.go index 99594a33f..8e39b7697 100644 --- a/node/node.go +++ b/node/node.go @@ -24,6 +24,7 @@ import ( sm "github.com/tendermint/tendermint/state" stypes "github.com/tendermint/tendermint/state/types" "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/vm" "github.com/tendermint/tendermint/wire" ) @@ -127,6 +128,17 @@ func NewNode() *Node { // they should all satisfy events.Eventable SetFireable(eventSwitch, pexReactor, bcReactor, mempoolReactor, consensusReactor) + // run the profile server + profileHost := config.GetString("prof_laddr") + if profileHost != "" { + go func() { + log.Warn("Profile server", "error", http.ListenAndServe(profileHost, nil)) + }() + } + + // set vm log level + vm.SetDebug(config.GetBool("vm_log")) + return &Node{ sw: sw, evsw: eventSwitch, @@ -256,7 +268,7 @@ func makeNodeInfo(sw *p2p.Switch, privKey acm.PrivKeyEd25519) *types.NodeInfo { } // include git hash in the nodeInfo if available - if rev, err := ReadFile(config.GetString("revisions_file")); err == nil { + if rev, err := ReadFile(config.GetString("revision_file")); err == nil { nodeInfo.Version.Revision = string(rev) } diff --git a/p2p/netaddress.go b/p2p/netaddress.go index 0730ab942..f6567e059 100644 --- a/p2p/netaddress.go +++ b/p2p/netaddress.go @@ -110,6 +110,10 @@ func (na *NetAddress) DialTimeout(timeout time.Duration) (net.Conn, error) { } func (na *NetAddress) Routable() bool { + if config.GetBool("local_routing") { + return na.Valid() + } + // TODO(oga) bitcoind doesn't include RFC3849 here, but should we? return na.Valid() && !(na.RFC1918() || na.RFC3927() || na.RFC4862() || na.RFC4193() || na.RFC4843() || na.Local()) diff --git a/vm/vm.go b/vm/vm.go index 49dfca5fc..ac10882ec 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -36,15 +36,20 @@ func (err ErrPermission) Error() string { return fmt.Sprintf("Contract does not have permission to %s", err.typ) } -type Debug bool - const ( - dataStackCapacity = 1024 - callStackCapacity = 100 // TODO ensure usage. - memoryCapacity = 1024 * 1024 // 1 MB - dbg Debug = true + dataStackCapacity = 1024 + callStackCapacity = 100 // TODO ensure usage. + memoryCapacity = 1024 * 1024 // 1 MB ) +type Debug bool + +var dbg Debug + +func SetDebug(d bool) { + dbg = Debug(d) +} + func (d Debug) Printf(s string, a ...interface{}) { if d { fmt.Printf(s, a...)