Skip to content

Commit

Permalink
Merge branch 'master' into master_add_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas7788 authored Apr 24, 2020
2 parents 6e7f75a + 14fae32 commit 84c1e4a
Show file tree
Hide file tree
Showing 267 changed files with 7,565 additions and 1,292 deletions.
19 changes: 19 additions & 0 deletions .travis.check-templog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
unset dirs files
dirs=$(go list -f {{.Dir}} ./... | grep -v /vendor/)
for d in ${dirs}
do
for f in ${d}/*.go
do
grep -q "log.Test" ${f} && files="${files} $f"
done
done

ret=0
for f in ${files}
do
echo "contains log.Test :$f"
ret=1
done

exit ${ret}
27 changes: 27 additions & 0 deletions .travis.deploy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -ex

VERSION=$(git describe --always --tags --long)
PLATFORM=""

if [[ ${TRAVIS_OS_NAME} == 'linux' ]]; then
PLATFORM="linux"
elif [[ ${TRAVIS_OS_NAME} == 'osx' ]]; then
PLATFORM="darwin"
else
PLATFORM="windows"
exit 1
fi

env GO111MODULE=on make ontology-${PLATFORM} tools-${PLATFORM}
mkdir tool-${PLATFORM}
cp ./tools/abi/* tool-${PLATFORM}
cp ./tools/sigsvr* tool-${PLATFORM}

zip -q -r tool-${PLATFORM}.zip tool-${PLATFORM};
rm -r tool-${PLATFORM};

set +x
echo "ontology-${PLATFORM}-amd64 |" $(md5sum ontology-${PLATFORM}-amd64|cut -d ' ' -f1)
echo "tool-${PLATFORM}.zip |" $(md5sum tool-${PLATFORM}.zip|cut -d ' ' -f1)

3 changes: 2 additions & 1 deletion .travis.gofmt.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# code from https://github.com/Seklfreak/Robyul2
which goimports || go get golang.org/x/tools/cmd/goimports
unset dirs files
dirs=$(go list -f {{.Dir}} ./... | grep -v /vendor/)
for d in $dirs
Expand All @@ -9,4 +10,4 @@ do
files="${files} $f"
done
done
diff <(gofmt -d $files) <(echo -n)
diff <(goimports -d $files) <(echo -n)
22 changes: 22 additions & 0 deletions .travis.script.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -ex

VERSION=$(git describe --always --tags --long)

if [ $TRAVIS_OS_NAME == 'linux' ]; then
echo "linux sys"
env GO111MODULE=on make all
env GO111MODULE=on go mod vendor
cd ./wasmtest && bash ./run-wasm-tests.sh && cd ../
bash ./.travis.check-license.sh
bash ./.travis.check-templog.sh
bash ./.travis.gofmt.sh
bash ./.travis.gotest.sh
elif [ $TRAVIS_OS_NAME == 'osx' ]; then
echo "osx sys"
env GO111MODULE=on make all
else
echo "win sys"
env GO111MODULE=on CGO_ENABLED=1 go build -ldflags "-X github.com/ontio/ontology/common/config.Version=${VERSION}" -o ontology-windows-amd64 main.go
env GO111MODULE=on go build -ldflags "-X github.com/ontio/ontology/common/config.Version=${VERSION}" -o sigsvr-windows-amd64 sigsvr.go
fi
23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ go_import_path: github.com/ontio/ontology

os:
- linux
- osx

go:
- 1.12.x

script:
- env GO111MODULE=on make all-cross
- env GO111MODULE=on go mod vendor
- cd ./wasmtest && bash ./run-wasm-tests.sh && cd ../
- bash ./.travis.check-license.sh
- bash ./.travis.gofmt.sh
- bash ./.travis.gotest.sh
- bash ./.travis.script.bash
- bash ./.travis.deploy.bash

deploy:
provider: releases
token: "${GITHUB_TOKEN}"
file_glob: true
file:
- ontology*
- tool-*.zip
skip_cleanup: true
overwrite: true
draft: true
on:
repo: ontio/ontology
tags: true
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ ABI=$(TOOLS)/abi
NATIVE_ABI_SCRIPT=./cmd/abi/native_abi_script

ontology: $(SRC_FILES)
$(GC) $(BUILD_NODE_PAR) -o ontology main.go
CGO_ENABLED=1 $(GC) $(BUILD_NODE_PAR) -o ontology main.go

sigsvr: $(SRC_FILES) abi
$(GC) $(BUILD_NODE_PAR) -o sigsvr sigsvr.go
$(GC) $(BUILD_NODE_PAR) -o sigsvr cmd-tools/sigsvr/sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr $(TOOLS)

Expand All @@ -33,28 +33,28 @@ all: ontology tools
ontology-cross: ontology-windows ontology-linux ontology-darwin

ontology-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-windows-amd64.exe main.go
GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-windows-amd64.exe main.go

ontology-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-linux-amd64 main.go
GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-linux-amd64 main.go

ontology-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-darwin-amd64 main.go
GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o ontology-darwin-amd64 main.go

tools-cross: tools-windows tools-linux tools-darwin

tools-windows: abi
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-windows-amd64.exe sigsvr.go
GOOS=windows GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-windows-amd64.exe cmd-tools/sigsvr/sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-windows-amd64.exe $(TOOLS)

tools-linux: abi
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-linux-amd64 sigsvr.go
GOOS=linux GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-linux-amd64 cmd-tools/sigsvr/sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-linux-amd64 $(TOOLS)

tools-darwin: abi
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-darwin-amd64 sigsvr.go
GOOS=darwin GOARCH=amd64 $(GC) $(BUILD_NODE_PAR) -o sigsvr-darwin-amd64 cmd-tools/sigsvr/sigsvr.go
@if [ ! -d $(TOOLS) ];then mkdir -p $(TOOLS) ;fi
@mv sigsvr-darwin-amd64 $(TOOLS)

Expand Down
114 changes: 29 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@ As a public blockchain project, Ontology is currently maintained by both the Ont

New features are still being rapidly developed, therefore the master branch may be unstable. Stable versions can be found in the [releases section](https://github.com/ontio/ontology/releases).

- [Features](#features)
- [Build Development Environment](#build-development-environment)
- [Download Ontology](#download-ontology)
- [Download Release](#download-release)
- [Build from Source Code](#build-from-source-code)
- [Run Ontology](#run-ontology)
- [MainNet Sync Node](#mainnet-sync-node)
- [TestNet Sync Node](#testnet-sync-node)
- [Local PrivateNet](#local-privatenet)
- [Run with Docker](#run-in-docker)
- [Examples](#examples)
- [ONT transfer sample](#ont-transfer-sample)
- [Query transfer status sample](#query-transfer-status-sample)
- [Query account balance sample](#query-account-balance-sample)
- [Contributions](#contributions)
- [License](#license)

## Features

- Scalable lightweight universal smart contracts
Expand All @@ -46,22 +29,23 @@ New features are still being rapidly developed, therefore the master branch may
- Quick block generation time (1-30 seconds)


## Build Development Environment
The requirements to build Ontology are:
## Install from Binaries
You can download a stable compiled version of the Ontology node software by either:

- Downloading the latest Ontology binary file with `curl https://dev.ont.io/ontology_install | sh`.
- Downloading a specific version from the [release section](https://github.com/ontio/ontology/releases).

## Build From Source

### Prerequisites

- [Golang](https://golang.org/doc/install) version 1.11 or later
- [Glide](https://glide.sh) (a third party package management tool for Golang)

## Download Ontology

### Download Release
You can download a stable compiled version of the Ontology node software by either:

- Downloading the latest Ontology binary file with `curl https://dev.ont.io/ontology_install | sh`.
- Downloading a specific version from the [release section](https://github.com/ontio/ontology/releases).
### Build

### Build from Source Code
Alternatively, you can build the Ontology application directly from the source code. Note that the code in the `master` branch may not be stable.
Note that the code in the `master` branch may not be stable.

1) Clone the Ontology repository into the appropriate `$GOPATH/src/github.com/ontio` directory:

Expand All @@ -76,21 +60,10 @@ $ go get github.com/ontio/ontology
2) Fetch the dependent third party packages with [Glide](https://glide.sh):

```
$ cd $GOPATH/src/github.com/ontio/ontology
$ glide install
```

3) If necessary, update the dependent third party packages with Glide:

```
$ cd $GOPATH/src/github.com/ontio/ontology
$ glide update
```

4) Build the source code with make:

```
$ make all
cd $GOPATH/src/github.com/ontio/ontology
glide install
glide update
make all
```

After building the source code successfully, you should see two executable programs:
Expand All @@ -106,41 +79,21 @@ The Ontology CLI can run nodes for the MainNet, TestNet and local PrivateNet. Ch

You can run an Ontology MainNet node built from the source code with:

``` shell
./ontology
```

To run it with a macOS release build:

``` shell
./ontology-darwin-amd64
```

To run it with a Windows release build:

``` shell
start ontology-windows-amd64.exe
```
```shell
./ontology # Linux
./ontology-darwin-amd64 # MacOS
start ontology-windows-amd64.exe # Windows
```

### TestNet Sync Node

You can run an Ontology TestNet node built from the source code with:

``` shell
./ontology --networkid 2
```

To run it with a macOS release build:

``` shell
./ontology-darwin-amd64 --networkid 2
```

To run it with a Windows release build:

``` shell
start ontology-windows-amd64.exe --networkid 2
```
```shell
./ontology --networkid 2 # Linux
./ontology-darwin-amd64 --networkid 2 # MacOS
start ontology-windows-amd64.exe --networkid 2 # Windows
```

### Local PrivateNet

Expand All @@ -152,8 +105,10 @@ The Ontology CLI allows you to run a local PrivateNet on your computer. Before y

To start the PrivateNet built from the source code with:

``` shell
./ontology --testmode
```shell
./ontology --testmode # Linux
./ontology-darwin-amd64 --testmode # MacOS
start ontology-windows-amd64.exe --testmode # Windows
```

Here's an example of the directory structure
Expand All @@ -165,17 +120,6 @@ $ tree
└── wallet.dat
```

To run it with a macOS release build:

``` shell
./ontology-darwin-amd64 --testmode
```

To run it with a Windows release build:

``` shell
start ontology-windows-amd64.exe --testmode
```

### Run with Docker

Expand Down
1 change: 0 additions & 1 deletion TODO

This file was deleted.

5 changes: 3 additions & 2 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
package account

import (
"github.com/ontio/ontology/core/types"
"github.com/stretchr/testify/assert"
"os"
"testing"

"github.com/ontio/ontology/core/types"
"github.com/stretchr/testify/assert"
)

func TestNewAccount(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions account/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ package account

import (
"fmt"
"os"
"testing"

"github.com/ontio/ontology-crypto/keypair"
s "github.com/ontio/ontology-crypto/signature"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

var (
Expand Down
8 changes: 3 additions & 5 deletions account/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"
"math/big"

base58 "github.com/itchyny/base58-go"
"github.com/itchyny/base58-go"
"github.com/ontio/ontology-crypto/keypair"
"github.com/ontio/ontology/core/types"
"golang.org/x/crypto/ripemd160"
Expand Down Expand Up @@ -89,10 +89,8 @@ func VerifyID(id string) bool {
data := buf[:pos]
check := buf[pos:]
sum := checksum(data)
if !bytes.Equal(sum, check) {
return false
}
return true

return bytes.Equal(sum, check)
}

func checksum(data []byte) []byte {
Expand Down
Loading

0 comments on commit 84c1e4a

Please sign in to comment.