Skip to content

Commit

Permalink
Merge pull request #27 from raventrov/platon-0.1.0
Browse files Browse the repository at this point in the history
Baleyworld_v0.4.0
  • Loading branch information
benbaley authored Jan 28, 2019
2 parents a047729 + 3381c13 commit 2d908d3
Show file tree
Hide file tree
Showing 512 changed files with 1,712 additions and 48,712 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ coverage.txt

go.sum

life/resolver/builtins/build
life/resolver/softfloat/*
life/resolver/builtins/build/

mpc.rlp

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

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

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

swarm:
build/env.sh go run build/ci.go install ./cmd/swarm
@echo "Done building."
Expand All @@ -40,6 +54,16 @@ all-with-mpc:
build/build_deps.sh
build/env.sh go run build/ci.go install -mpc on

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

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

android:
build/env.sh go run build/ci.go aar --local
@echo "Done building."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ Check the balance:

OK, it seems that the chain is running correctly

For more information, please visit our [wiki](https://github.com/PlatONnetwork/wiki/wiki)
For more information, please visit our [wiki](https://github.com/PlatONnetwork/wiki/wiki)
82 changes: 82 additions & 0 deletions build/build_snark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

DISTRO=""
Get_Dist_Name()
{
if grep -Eqii "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
DISTRO='CentOS'
PM='yum'
elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
DISTRO='RHEL'
PM='yum'
elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
DISTRO='Aliyun'
PM='yum'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
DISTRO='Fedora'
PM='yum'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='Debian'
PM='apt'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='Ubuntu'
PM='apt'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
DISTRO='Raspbian'
PM='apt'
else
DISTRO='unknow'
fi
# echo $DISTRO;
}
Get_Dist_Name
echo $DISTRO

if [ ! -f "build/build_snark.sh" ]; then
echo "$0 must be run from the root of the repository."
exit 2
fi

root=`pwd`
root=$root/life/resolver

if [ "`ls $root/vc`" = "" ]; then
git submodule add https://github.com/PlatONnetwork/libcsnark.git life/resolver/vc
fi

if [ "`ls $root/vc/build`" = "" ]; then
cd $root/vc
mkdir -p build
git submodule update --init --recursive
fi

if [ "`ls $root/libcsnark`" = "" ]; then
cd $root
mkdir -p libcsnark
fi

# Build vc
SF_BUILD=$root/vc/build
MAKE="make"
if [ `expr substr $(uname -s) 1 5` = "Linux" ]; then
if [ "$DISTRO" = "Ubuntu" ]; then
sudo apt-get install llvm-6.0-dev llvm-6.0 libclang-6.0-dev
sudo apt-get install libgmpxx4ldbl libgmp-dev libprocps4-dev
elif [ "$DISTRO" = "CentOS" ]; then
sudo yum install -y llvm clang gmp procps
else
echo "not support system $DISTRO"
fi
else
echo "not support system $(uname -s)"
exit 0
fi

cd $SF_BUILD
#$MAKE clean
cmake ../ -DMONTGOMERY_OUTPUT=OFF -DBINARY_OUTPUT=OFF
$MAKE
cp ./src/libcsnark.a ../../libcsnark/libcsnark.a
cp ./depends/libsnark/depends/libff/libff/libff.a ../../libcsnark/libff.a
cp ./depends/libsnark/libsnark/libsnark.a ../../libcsnark/libsnark.a

8 changes: 8 additions & 0 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ func doInstall(cmdline []string) {
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")
vc = flag.String("vc", "off", "Switch of vc , on for compiling VC, off for without compiling")
mv = flag.String("mv", "off", "Switch of mv , on for compilingMPC and VC, off for without compiling")
)
flag.CommandLine.Parse(cmdline)
env := build.Env()
Expand Down Expand Up @@ -252,6 +254,12 @@ func doInstall(cmdline []string) {
if *gcflags == "on" {
goinstall.Args = append(goinstall.Args, "-gcflags=-N -l")
}
if *vc == "on" {
goinstall.Args = append(goinstall.Args, "-tags=vcon")
}
if *mv == "on" {
goinstall.Args = append(goinstall.Args, "-tags=mpcon vcon")
}
goinstall.Args = append(goinstall.Args, packages...)
build.MustRun(goinstall)
return
Expand Down
3 changes: 3 additions & 0 deletions cmd/platon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
// pass on the rpc port to mpc pool conf.
cfg.Eth.MPCPool.LocalRpcPort = cfg.Node.HTTPPort

// pass on the rpc port to vc pool conf.
cfg.Eth.VCPool.LocalRpcPort = cfg.Node.HTTPPort

// load cbft config file.
if cbftConfig := cfg.Eth.LoadCbftConfig(cfg.Node); cbftConfig != nil {
cfg.Eth.CbftConfig = *cbftConfig
Expand Down
7 changes: 7 additions & 0 deletions cmd/platon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ var (
utils.MPCIceFileFlag,
utils.MPCActorFlag,
}
vcFlags = []cli.Flag{
utils.VCEnabledFlag,
utils.VCActorFlag,
utils.VCPasswordFlag,
}
)

func init() {
Expand Down Expand Up @@ -218,6 +223,8 @@ func init() {

// for mpc
app.Flags = append(app.Flags, mpcFlags...)
// for vc
app.Flags = append(app.Flags, vcFlags...)

app.Before = func(ctx *cli.Context) error {
runtime.GOMAXPROCS(runtime.NumCPU())
Expand Down
8 changes: 8 additions & 0 deletions cmd/platon/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,14 @@ var AppHelpFlagGroups = []flagGroup{
utils.MPCIceFileFlag,
},
},
{
Name: "VC COMPUTE",
Flags: []cli.Flag{
utils.VCEnabledFlag,
utils.VCActorFlag,
utils.VCPasswordFlag,
},
},
{
Name: "MISC",
},
Expand Down
39 changes: 33 additions & 6 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ var (
Value: eth.DefaultConfig.TxPool.GlobalQueue,
}
TxPoolGlobalTxCountFlag = cli.Uint64Flag{
Name: "txpool.globaltxcount",
Name: "txpool.globaltxcount",
Usage: "Maximum number of transactions for package",
Value: eth.DefaultConfig.TxPool.GlobalTxCount,
}
Expand Down Expand Up @@ -395,8 +395,6 @@ var (
Value: "",
}



VMEnableDebugFlag = cli.BoolFlag{
Name: "vmdebug",
Usage: "Record information useful for VM and contract debugging",
Expand Down Expand Up @@ -641,15 +639,29 @@ var (
Value: "",
}
MPCActorFlag = cli.StringFlag{
Name: "mpc.actor",
Name: "mpc.actor",
Usage: "The address of actor to exec mpc compute",
Value: "",
}
MPCEnabledFlag = cli.BoolFlag{
Name: "mpc",
Usage: "Enable mpc compute",
}
VCEnabledFlag = cli.BoolFlag{
Name: "vc",
Usage: "Enable vc compute",
}
VCActorFlag = cli.StringFlag{
Name: "vc.actor",
Usage: "The address of vc to exec set result",
Value: "",
}

VCPasswordFlag = cli.StringFlag{
Name: "vc.password",
Usage: "the pwd of unlock actor",
Value: "",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -909,7 +921,6 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
}
}


// MakePasswordList reads password lines from the file specified by the global --password flag.
func MakePasswordList(ctx *cli.Context) []string {
path := ctx.GlobalString(PasswordFileFlag.Name)
Expand Down Expand Up @@ -1108,6 +1119,21 @@ func setMpcPool(ctx *cli.Context, cfg *core.MPCPoolConfig) {
}
}

func setVcPool(ctx *cli.Context, cfg *core.VCPoolConfig) {
if ctx.GlobalIsSet(VCEnabledFlag.Name) {
cfg.VCEnable = ctx.GlobalBool(VCEnabledFlag.Name)
}
if ctx.GlobalIsSet(VCActorFlag.Name) {
cfg.VcActor = common.HexToAddress(ctx.GlobalString(VCActorFlag.Name))
fmt.Println("cfg.VcActor", cfg.VcActor)
}

if ctx.GlobalIsSet(VCPasswordFlag.Name) {
cfg.VcPassword = ctx.GlobalString(VCPasswordFlag.Name)
}

}

func setEthash(ctx *cli.Context, cfg *eth.Config) {
if ctx.GlobalIsSet(EthashCacheDirFlag.Name) {
cfg.Ethash.CacheDir = ctx.GlobalString(EthashCacheDirFlag.Name)
Expand Down Expand Up @@ -1192,6 +1218,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
setTxPool(ctx, &cfg.TxPool)
// for mpc compute
setMpcPool(ctx, &cfg.MPCPool)
setVcPool(ctx, &cfg.VCPool)
setEthash(ctx, cfg)

if ctx.GlobalIsSet(SyncModeFlag.Name) {
Expand Down Expand Up @@ -1453,7 +1480,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"*/ true,
Disabled:/*ctx.GlobalString(GCModeFlag.Name) == "archive"*/ true,
TrieNodeLimit: eth.DefaultConfig.TrieCache,
TrieTimeLimit: eth.DefaultConfig.TrieTimeout,
}
Expand Down
Loading

0 comments on commit 2d908d3

Please sign in to comment.