Skip to content

Commit

Permalink
Merge pull request #22 from raventrov/platon-0.1.0
Browse files Browse the repository at this point in the history
PlatON Baleyworld v0.3.0
  • Loading branch information
benbaley authored Jan 18, 2019
2 parents 78f9266 + a3504fd commit a047729
Show file tree
Hide file tree
Showing 151 changed files with 8,223 additions and 4,429 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ coverage.txt
go.sum

life/resolver/builtins/build
life/resolver/softfloat/*
life/resolver/softfloat/*
mpc.rlp

consensus/cbft/data/
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ platon:
@echo "Done building."
@echo "Run \"$(GOBIN)/platon\" to launch platon."

platon-with-mpc:
build/build_deps.sh
build/env.sh go run build/ci.go install -mpc on ./cmd/platon
@echo "Done building platon with mpc."
@echo "Run \"$(GOBIN)/platon\" to launch platon."

swarm:
build/env.sh go run build/ci.go install ./cmd/swarm
@echo "Done building."
Expand All @@ -26,6 +32,14 @@ all:
build/build_deps.sh
build/env.sh go run build/ci.go install

all-debug:
build/build_deps.sh
build/env.sh go run build/ci.go install -gcflags on

all-with-mpc:
build/build_deps.sh
build/env.sh go run build/ci.go install -mpc on

android:
build/env.sh go run build/ci.go aar --local
@echo "Done building."
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ or, to build the full suite of utilities:

make all

If you want to Building platon with MPC function, run

make platon-with-mpc

or:

make all-with-mpc

## Executables

The project comes with several executables found in the `cmd` directory.
Expand Down
12 changes: 10 additions & 2 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ func main() {
func doInstall(cmdline []string) {
// ./cmd/platon
var (
arch = flag.String("arch", "", "Architecture to cross build for")
cc = flag.String("cc", "", "C compiler to cross build with")
arch = flag.String("arch", "", "Architecture to cross build for")
cc = flag.String("cc", "", "C compiler to cross build with")
mpc = flag.String("mpc", "off", "Switch of mpc , on for compiling MPC, off for without compiling")
gcflags = flag.String("gcflags", "", "Turn off compiler code optimization and function inlining")
)
flag.CommandLine.Parse(cmdline)
env := build.Env()
Expand Down Expand Up @@ -244,6 +246,12 @@ func doInstall(cmdline []string) {
if *arch == "" || *arch == runtime.GOARCH {
goinstall := goTool("install", buildFlags(env)...)
goinstall.Args = append(goinstall.Args, "-v")
if *mpc == "on" {
goinstall.Args = append(goinstall.Args, "-tags=mpcon")
}
if *gcflags == "on" {
goinstall.Args = append(goinstall.Args, "-gcflags=-N -l")
}
goinstall.Args = append(goinstall.Args, packages...)
build.MustRun(goinstall)
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/ctool/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"gas": "0x999999",
"gasPrice": "0x8250de00",
"from":"0x60ceca9c1290ee56b98d4e160ef0453f7c40d219"
}
}
4 changes: 2 additions & 2 deletions cmd/ctool/core/contractcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ func DeployContract(abiFilePath string, codeFilePath string) error {

fmt.Printf("\ntrasaction hash: %s\n", resp.Result)

//根据result获取交易receipt
// Get transaction receipt according to result
ch := make(chan string, 1)
go GetTransactionReceipt(resp.Result, ch)

//获取receipt
// Getting receipt
select {
case address := <-ch:
fmt.Printf("contract address: %s\n", address)
Expand Down
1 change: 0 additions & 1 deletion cmd/ctool/core/transactioncmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func getTxReceiptCmd(c *cli.Context) {

func GetTxReceipt(txHash string) (Receipt, error) {
var receipt = Receipt{}
//根据result获取交易receipt
res, _ := Send([]string{txHash}, "eth_getTransactionReceipt")
e := json.Unmarshal([]byte(res), &receipt)
if e != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/ctool/core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func parseFuncFromAbi(fileName string, funcName string) (*FuncDesc, error) {
}

/**
通过解析abi查找所调用方法
Find the method called by parsing abi
*/
func GetFuncNameAndParams(f string) (string, []string) {
funcName := string(f[0:strings.Index(f, "(")])
Expand All @@ -170,19 +170,19 @@ func GetFuncNameAndParams(f string) (string, []string) {
}

/**
自测方法,用于对参数加密
Self-test method for encrypting parameters
*/
func encodeParam(abiPath string, funcName string, funcParams string) error {
//判断该方法是否存在
// Determine if the method exists
abiFunc, err := parseFuncFromAbi(abiPath, funcName)
if err != nil {
return err
}

//解析调用的方法 参数
// Parsing the method of the call
funcName, inputParams := GetFuncNameAndParams(funcParams)

//判断参数是否正确
// Determine if the parameters are correct
if len(abiFunc.Inputs) != len(inputParams) {
return fmt.Errorf("incorrect number of parameters ,request=%d,get=%d\n", len(abiFunc.Inputs), len(inputParams))
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/ctool/core/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func TestHttpPostDeploy(t *testing.T) {
}
fmt.Printf("trasaction hash: %s\n", resp.Result)

//根据result获取交易receipt
// Get transaction receipt according to result
ch := make(chan string, 1)
go GetTransactionReceipt(resp.Result, ch)

//然后,我们把timeout这个channel利用起来
// Then, we use the timeout channel
select {
case address := <-ch:
fmt.Printf("contract address:%s\n", address)
Expand Down Expand Up @@ -208,4 +208,4 @@ func TestCCC(t *testing.T) {
fmt.Println(b[24:])
fmt.Print(common.Int64ToBytes(int64(1231)))

}
}
2 changes: 1 addition & 1 deletion cmd/platon/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func initGenesis(ctx *cli.Context) error {
}
// Open an initialise both full and light databases
stack := makeFullNode(ctx)
for _, name := range []string{"chaindata", "lightchaindata"} {
for _, name := range []string{"chaindata"} {
chaindb, err := stack.OpenDatabase(name, 0, 0)
if err != nil {
utils.Fatalf("Failed to open database: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions cmd/platon/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func TestConsoleWelcome(t *testing.T) {

// Verify the actual welcome message to the required template
geth.Expect(`
Welcome to the Platon JavaScript console!
Welcome to the PlatON JavaScript console!
instance: Platon/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
instance: platon/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Etherbase}}
at block: 0 ({{niltime}})
datadir: {{.Datadir}}
Expand Down Expand Up @@ -144,7 +144,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
attach.Expect(`
Welcome to the PlatON JavaScript console!
instance: PlatON/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
instance: platon/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{etherbase}}
at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}}
Expand Down
6 changes: 4 additions & 2 deletions cmd/platon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var (
// Git SHA1 commit hash of the release (set via linker flags)
gitCommit = ""
// The app that holds all commands and flags.
app = utils.NewApp(gitCommit, "the go-platon command line interface")
app = utils.NewApp(gitCommit, "the platon-go command line interface")
// flags that configure the node
nodeFlags = []cli.Flag{
utils.IdentityFlag,
Expand Down Expand Up @@ -82,6 +82,7 @@ var (
utils.TxPoolGlobalSlotsFlag,
utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag,
utils.TxPoolGlobalTxCountFlag,
utils.TxPoolLifetimeFlag,
utils.SyncModeFlag,
utils.GCModeFlag,
Expand All @@ -94,6 +95,7 @@ var (
utils.TrieCacheGenFlag,
utils.ListenPortFlag,
utils.MaxPeersFlag,
utils.MaxConsensusPeersFlag,
utils.MaxPendingPeersFlag,
utils.MiningEnabledFlag,
utils.MinerThreadsFlag,
Expand Down Expand Up @@ -176,7 +178,7 @@ func init() {
// Initialize the CLI app and start Geth
app.Action = geth
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2013-2018 The go-ethereum Authors"
app.Copyright = "Copyright 2019 The PlatON-Go Authors"
app.Commands = []cli.Command{
// See chaincmd.go:
initCommand,
Expand Down
4 changes: 2 additions & 2 deletions cmd/platon/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
var AppHelpTemplate = `NAME:
{{.App.Name}} - {{.App.Usage}}
Copyright 2013-2018 The go-ethereum Authors
Copyright 2019 The PlatON-Go Authors
USAGE:
{{.App.HelpName}} [options]{{if .App.Commands}} command [command options]{{end}} {{if .App.ArgsUsage}}{{.App.ArgsUsage}}{{else}}[arguments...]{{end}}
Expand Down Expand Up @@ -124,6 +124,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.TxPoolGlobalSlotsFlag,
utils.TxPoolAccountQueueFlag,
utils.TxPoolGlobalQueueFlag,
utils.TxPoolGlobalTxCountFlag,
utils.TxPoolLifetimeFlag,
},
},
Expand Down Expand Up @@ -255,7 +256,6 @@ var AppHelpFlagGroups = []flagGroup{
{
Name: "MISC",
},

}

// byCategory sorts an array of flagGroup by Name in the order
Expand Down
50 changes: 25 additions & 25 deletions cmd/puppeth/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,31 +323,31 @@ func (w *wizard) readNodeURL() *discover.Node {
}
}

func (w *wizard) readNodeID() discover.NodeID {
for {
// Read the url from the user
fmt.Printf("> 0x")
text, err := w.in.ReadString('\n')
if err != nil {
log.Crit("Failed to read user input", "err", err)
}
if text = strings.TrimSpace(text); text == "" {
return discover.NodeID{0}
}

// Make sure it looks ok and return it if so
if len(text) < 128 {
log.Error("Invalid url length, please retry")
continue
}
node,err := discover.BytesID(common.Hex2Bytes(text))
if err != nil {
log.Error("Node ID invalid", "NodeID", text, "err", err)
}

return node
}
}
//func (w *wizard) readNodeID() discover.NodeID {
// for {
// // Read the url from the user
// fmt.Printf("> 0x")
// text, err := w.in.ReadString('\n')
// if err != nil {
// log.Crit("Failed to read user input", "err", err)
// }
// if text = strings.TrimSpace(text); text == "" {
// return discover.NodeID{0}
// }
//
// // Make sure it looks ok and return it if so
// if len(text) < 128 {
// log.Error("Invalid url length, please retry")
// continue
// }
// node,err := discover.BytesID(common.Hex2Bytes(text))
// if err != nil {
// log.Error("Node ID invalid", "NodeID", text, "err", err)
// }
//
// return node
// }
//}

// readPrivate reads a single line from stdin, parse and convert
// it to an Ethereum ecdsa private key.
Expand Down
2 changes: 1 addition & 1 deletion cmd/swarm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ var app = utils.NewApp(gitCommit, "Ethereum Swarm")
func init() {
app.Action = bzzd
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2013-2016 The go-ethereum Authors"
app.Copyright = "Copyright 2019 The PlatON-Go Authors"
app.Commands = []cli.Command{
{
Action: version,
Expand Down
22 changes: 19 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ var (
Usage: "Maximum number of non-executable transaction slots for all accounts",
Value: eth.DefaultConfig.TxPool.GlobalQueue,
}
TxPoolGlobalTxCountFlag = cli.Uint64Flag{
Name: "txpool.globaltxcount",
Usage: "Maximum number of transactions for package",
Value: eth.DefaultConfig.TxPool.GlobalTxCount,
}
TxPoolLifetimeFlag = cli.DurationFlag{
Name: "txpool.lifetime",
Usage: "Maximum amount of time non-executable transaction are queued",
Expand Down Expand Up @@ -484,7 +489,12 @@ var (
MaxPeersFlag = cli.IntFlag{
Name: "maxpeers",
Usage: "Maximum number of network peers (network disabled if set to 0)",
Value: 25,
Value: 50,
}
MaxConsensusPeersFlag = cli.IntFlag{
Name: "maxconsensuspeers",
Usage: "Maximum number of network consensus peers (network disabled if set to 0)",
Value: 75,
}
MaxPendingPeersFlag = cli.IntFlag{
Name: "maxpendpeers",
Expand Down Expand Up @@ -929,6 +939,9 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
lightServer := ctx.GlobalInt(LightServFlag.Name) != 0
lightPeers := ctx.GlobalInt(LightPeersFlag.Name)

if ctx.GlobalIsSet(MaxConsensusPeersFlag.Name) {
cfg.MaxConsensusPeers = ctx.GlobalInt(MaxConsensusPeersFlag.Name)
}
if ctx.GlobalIsSet(MaxPeersFlag.Name) {
cfg.MaxPeers = ctx.GlobalInt(MaxPeersFlag.Name)
if lightServer && !ctx.GlobalIsSet(LightPeersFlag.Name) {
Expand Down Expand Up @@ -1062,6 +1075,9 @@ func setTxPool(ctx *cli.Context, cfg *core.TxPoolConfig) {
if ctx.GlobalIsSet(TxPoolGlobalQueueFlag.Name) {
cfg.GlobalQueue = ctx.GlobalUint64(TxPoolGlobalQueueFlag.Name)
}
if ctx.GlobalIsSet(TxPoolGlobalTxCountFlag.Name) {
cfg.GlobalTxCount = ctx.GlobalUint64(TxPoolGlobalTxCountFlag.Name)
}
if ctx.GlobalIsSet(TxPoolLifetimeFlag.Name) {
cfg.Lifetime = ctx.GlobalDuration(TxPoolLifetimeFlag.Name)
}
Expand Down Expand Up @@ -1199,7 +1215,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if gcmode := ctx.GlobalString(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" {
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
}
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == "archive"
cfg.NoPruning = /*ctx.GlobalString(GCModeFlag.Name) == "archive"*/ true

if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
cfg.TrieCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
Expand Down Expand Up @@ -1437,7 +1453,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name)
}
cache := &core.CacheConfig{
Disabled: ctx.GlobalString(GCModeFlag.Name) == "archive",
Disabled: /*ctx.GlobalString(GCModeFlag.Name) == "archive"*/ true,
TrieNodeLimit: eth.DefaultConfig.TrieCache,
TrieTimeLimit: eth.DefaultConfig.TrieTimeout,
}
Expand Down
Loading

0 comments on commit a047729

Please sign in to comment.