Skip to content

Commit

Permalink
refactor: xuperchain = core + front + visual (xuperchain#624)
Browse files Browse the repository at this point in the history
* refactor: xuperchain = core + front + visual
* refactor the repo to make it able to contain more components, to support node management and visual interaction in the future
  - core - the core logic of blockchain system
  - front - CA policy, node management
  - visual - wallet & blockahin explorer
  • Loading branch information
fxsjy authored Jan 13, 2020
1 parent 2d66582 commit ade1ccb
Show file tree
Hide file tree
Showing 707 changed files with 875 additions and 873 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: |
diff -u <(echo -n) <(gofmt -d $(find . -type f -name '*.go' -not -path "./vendor/*"))
make && make test
cd ./test && bash ci_pipeline.sh
cd ./core/test && bash ci_pipeline.sh
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project specific files
plugins/
output/
xvm/compile/wabt/build/
core/plugins/
core/output/
core/xvm/compile/wabt/build/

# Compiled source
*.com
Expand All @@ -24,4 +24,4 @@ xvm/compile/wabt/build/
*.test

# idea
.idea
.idea
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: go
go_import_path: github.com/xuperchain/xuperunion
install: true
sudo: false

go:
Expand All @@ -15,7 +15,7 @@ matrix:
script:
- diff -u <(echo -n) <(gofmt -d $(find . -type f -name '*.go' -not -path "./vendor/*"))
- make && make test
- cd ./test && bash ci_pipeline.sh
- cd ./core/test && bash ci_pipeline.sh

cache:
directories:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ endif
all: build
export GO111MODULE=on
export GOFLAGS=-mod=vendor
XCHAIN_ROOT := ${PWD}
XCHAIN_ROOT := ${PWD}/core
export XCHAIN_ROOT
PATH := ${PWD}/xvm/compile/wabt/build:$(PATH)
PATH := ${PWD}/core/xvm/compile/wabt/build:$(PATH)

build:
PLATFORM=$(PLATFORM) ./build.sh

test:
go test -cover `go list ./... | egrep -v 'test'`
# test wasm sdk
GOOS=js GOARCH=wasm go build github.com/xuperchain/xuperunion/contractsdk/go/driver
cd xvm/spectest && go run main.go core
GOOS=js GOARCH=wasm go build github.com/xuperchain/xuperchain/core/contractsdk/go/driver
cd core/xvm/spectest && go run main.go core

clean:
rm -rf output
Expand Down
40 changes: 20 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ protoc -I contractsdk/pb contractsdk/pb/contract.proto \
!

# build wasm2c
make -C xvm/compile/wabt -j 4
cp xvm/compile/wabt/build/wasm2c ./
make -C core/xvm/compile/wabt -j 4
cp core/xvm/compile/wabt/build/wasm2c ./

# build framework and tools
function buildpkg() {
Expand All @@ -40,24 +40,24 @@ function buildpkg() {
go build -o $output -ldflags "-X main.buildVersion=$buildVersion -X main.buildDate=$buildDate -X main.commitHash=$commitHash" $pkg
}

buildpkg xchain-cli github.com/xuperchain/xuperunion/cmd/cli
buildpkg xchain github.com/xuperchain/xuperunion/cmd/xchain
buildpkg xc github.com/xuperchain/xuperunion/contractsdk/xc
go build -o xchain-httpgw gateway/http_gateway.go
go build -o dump_chain test/dump_chain.go
buildpkg xchain-cli github.com/xuperchain/xuperchain/core/cmd/cli
buildpkg xchain github.com/xuperchain/xuperchain/core/cmd/xchain
buildpkg xc github.com/xuperchain/xuperchain/core/contractsdk/xc
buildpkg xchain-httpgw github.com/xuperchain/xuperchain/core/gateway
buildpkg dump_chain github.com/xuperchain/xuperchain/core/test

# build plugins
echo "OS:"${PLATFORM}
echo "## Build Plugins..."
mkdir -p plugins/kv plugins/crypto plugins/consensus plugins/contract
go build --buildmode=plugin --tags multi -o plugins/kv/kv-ldb-multi.so.1.0.0 github.com/xuperchain/xuperunion/kv/kvdb/plugin-ldb
go build --buildmode=plugin --tags single -o plugins/kv/kv-ldb-single.so.1.0.0 github.com/xuperchain/xuperunion/kv/kvdb/plugin-ldb
go build --buildmode=plugin -o plugins/kv/kv-badger.so.1.0.0 github.com/xuperchain/xuperunion/kv/kvdb/plugin-badger
go build --buildmode=plugin -o plugins/crypto/crypto-default.so.1.0.0 github.com/xuperchain/xuperunion/crypto/client/xchain/plugin_impl
go build --buildmode=plugin -o plugins/crypto/crypto-schnorr.so.1.0.0 github.com/xuperchain/xuperunion/crypto/client/schnorr/plugin_impl
go build --buildmode=plugin -o plugins/consensus/consensus-pow.so.1.0.0 github.com/xuperchain/xuperunion/consensus/pow
go build --buildmode=plugin -o plugins/consensus/consensus-single.so.1.0.0 github.com/xuperchain/xuperunion/consensus/single
go build --buildmode=plugin -o plugins/consensus/consensus-tdpos.so.1.0.0 github.com/xuperchain/xuperunion/consensus/tdpos/main
mkdir -p core/plugins/kv core/plugins/crypto core/plugins/consensus core/plugins/contract
go build --buildmode=plugin --tags multi -o core/plugins/kv/kv-ldb-multi.so.1.0.0 github.com/xuperchain/xuperchain/core/kv/kvdb/plugin-ldb
go build --buildmode=plugin --tags single -o core/plugins/kv/kv-ldb-single.so.1.0.0 github.com/xuperchain/xuperchain/core/kv/kvdb/plugin-ldb
go build --buildmode=plugin -o core/plugins/kv/kv-badger.so.1.0.0 github.com/xuperchain/xuperchain/core/kv/kvdb/plugin-badger
go build --buildmode=plugin -o core/plugins/crypto/crypto-default.so.1.0.0 github.com/xuperchain/xuperchain/core/crypto/client/xchain/plugin_impl
go build --buildmode=plugin -o core/plugins/crypto/crypto-schnorr.so.1.0.0 github.com/xuperchain/xuperchain/core/crypto/client/schnorr/plugin_impl
go build --buildmode=plugin -o core/plugins/consensus/consensus-pow.so.1.0.0 github.com/xuperchain/xuperchain/core/consensus/pow
go build --buildmode=plugin -o core/plugins/consensus/consensus-single.so.1.0.0 github.com/xuperchain/xuperchain/core/consensus/single
go build --buildmode=plugin -o core/plugins/consensus/consensus-tdpos.so.1.0.0 github.com/xuperchain/xuperchain/core/consensus/tdpos/main

# build output dir
mkdir -p output
Expand All @@ -67,8 +67,8 @@ mv xchain-httpgw ${output_dir}
mv wasm2c ${output_dir}
mv dump_chain ${output_dir}
mv xc ${output_dir}
cp -rf plugins ${output_dir}
cp -rf data ${output_dir}
cp -rf conf ${output_dir}
cp -rf cmd/quick_shell/* ${output_dir}
cp -rf core/plugins ${output_dir}
cp -rf core/data ${output_dir}
cp -rf core/conf ${output_dir}
cp -rf core/cmd/quick_shell/* ${output_dir}
mkdir -p ${output_dir}/data/blockchain
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/pb"
)

// AccountBalanceCommand account balance command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/pb"
)

// AccountContractsCommand
Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/account_new.go → core/cmd/cli/account_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/permission/acl/utils"
"github.com/xuperchain/xuperunion/utxo"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/permission/acl/utils"
"github.com/xuperchain/xuperchain/core/utxo"
)

// AccountNewCommand new account struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/spf13/cobra"

crypto_client "github.com/xuperchain/xuperunion/crypto/client"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
)

// AccountNewkeysCommand create account addr
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/account_query.go → core/cmd/cli/account_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

// AccountQueryCommand query acl struct
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cmd/cli/acl_query.go → core/cmd/cli/acl_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

// ACLQueryCommand query acl struct
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/block.go → core/cmd/cli/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

// BlockCommand query block
Expand Down
10 changes: 5 additions & 5 deletions cmd/cli/cli.go → core/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

crypto_client "github.com/xuperchain/xuperunion/crypto/client"
crypto_base "github.com/xuperchain/xuperunion/crypto/client/base"
"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo/txhash"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
crypto_base "github.com/xuperchain/xuperchain/core/crypto/client/base"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo/txhash"
)

// CommandFunc 代表了一个子命令,用于往Cli注册子命令
Expand Down
12 changes: 6 additions & 6 deletions cmd/cli/comm_trans.go → core/cmd/cli/comm_trans.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (

"github.com/golang/protobuf/proto"

"github.com/xuperchain/xuperunion/contract"
crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo"
"github.com/xuperchain/xuperunion/utxo/txhash"
"github.com/xuperchain/xuperchain/core/contract"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo"
"github.com/xuperchain/xuperchain/core/utxo/txhash"
)

// CommTrans base method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

type GetComplianceCheckSignCommand struct {
Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/createchains.go → core/cmd/cli/createchains.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/common/config"
"github.com/xuperchain/xuperunion/common/log"
"github.com/xuperchain/xuperunion/contract/kernel"
"github.com/xuperchain/xuperchain/core/common/config"
"github.com/xuperchain/xuperchain/core/common/log"
"github.com/xuperchain/xuperchain/core/contract/kernel"
)

// CreateChainCommand create chain cmd
Expand Down
10 changes: 5 additions & 5 deletions cmd/cli/genModBlockDesc.go → core/cmd/cli/genModBlockDesc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/contract"
crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo/txhash"
"github.com/xuperchain/xuperchain/core/contract"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo/txhash"
)

// GenModBlockDescCommand modify blockchain data desc file only by regulatory address
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/pb"
)

// MultisigCheckCommand multisig check struct
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/multisig_gen.go → core/cmd/cli/multisig_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"os"

"github.com/spf13/cobra"
crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/utxo"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/utxo"
)

// MultisigGenCommand multisig generate struct
Expand Down
8 changes: 4 additions & 4 deletions cmd/cli/multisig_send.go → core/cmd/cli/multisig_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"

crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo/txhash"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo/txhash"
)

// MultisigSendCommand multisig send struct
Expand Down
6 changes: 3 additions & 3 deletions cmd/cli/multisig_sign.go → core/cmd/cli/multisig_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"

crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo/txhash"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo/txhash"
)

// MultisigSignCommand multisig sign struct
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperunion/utxo"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
"github.com/xuperchain/xuperchain/core/utxo"
)

// NativeActivateCommand native activate cmd
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cmd/cli/native_deploy.go → core/cmd/cli/native_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/golang/protobuf/proto"
"github.com/spf13/cobra"

crypto_client "github.com/xuperchain/xuperunion/crypto/client"
"github.com/xuperchain/xuperunion/crypto/hash"
"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
crypto_client "github.com/xuperchain/xuperchain/core/crypto/client"
"github.com/xuperchain/xuperchain/core/crypto/hash"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

// NativeDeployCommand native deploy cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/native_invoke.go → core/cmd/cli/native_invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/utxo"
"github.com/xuperchain/xuperchain/core/utxo"
)

// NativeInvokeCommand native invoke cmd
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cmd/cli/native_status.go → core/cmd/cli/native_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/golang/protobuf/jsonpb"
"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/global"
"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/global"
"github.com/xuperchain/xuperchain/core/pb"
)

// NativeStatusCommand native status cmd
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/cli/neturl_gen.go → core/cmd/cli/neturl_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/p2pv2"
"github.com/xuperchain/xuperchain/core/p2pv2"
)

// NetURLGenCommand neturl gen cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/neturl_get.go → core/cmd/cli/neturl_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/spf13/cobra"

"github.com/xuperchain/xuperunion/pb"
"github.com/xuperchain/xuperchain/core/pb"
)

// NetURLGetCommand get neturl cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/spf13/cobra"

p2pv2 "github.com/xuperchain/xuperunion/p2pv2"
p2pv2 "github.com/xuperchain/xuperchain/core/p2pv2"
)

// NetURLPreviewCommand preview neturl using given params
Expand Down
Loading

0 comments on commit ade1ccb

Please sign in to comment.