Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1190 from Bytom/prod
Browse files Browse the repository at this point in the history
Prod
  • Loading branch information
Paladz authored Jul 26, 2018
2 parents fdd52d1 + 1832735 commit 9082510
Show file tree
Hide file tree
Showing 20 changed files with 1,089 additions and 478 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ endif
endif

PACKAGES := $(shell go list ./... | grep -v '/vendor/' | grep -v '/crypto/ed25519/chainkd' | grep -v '/mining/tensority')
PACKAGES += 'github.com/bytom/mining/tensority/go_algorithm'

BUILD_FLAGS := -ldflags "-X github.com/bytom/version.GitCommit=`git rev-parse HEAD`"

MINER_BINARY32 := miner-$(GOOS)_386
Expand Down Expand Up @@ -39,12 +41,12 @@ all: test target release-all

bytomd:
@echo "Building bytomd to cmd/bytomd/bytomd"
@CGO_ENABLED=0 go build $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go
@go build $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go

bytomd-simd:
@echo "Building SIMD version bytomd to cmd/bytomd/bytomd"
@cd mining/tensority/cgo_algorithm/lib/ && make
@CGO_ENABLED=1 go build $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go
@go build -tags="simd" $(BUILD_FLAGS) -o cmd/bytomd/bytomd cmd/bytomd/main.go

bytomcli:
@echo "Building bytomcli to cmd/bytomcli/bytomcli"
Expand Down Expand Up @@ -111,14 +113,14 @@ target/$(MINER_BINARY64):

test:
@echo "====> Running go test"
@CGO_ENABLED=0 go test -tags "network" $(PACKAGES)
@go test -tags "network" $(PACKAGES)

benchmark:
@CGO_ENABLED=0 go test -bench $(PACKAGES)
@go test -bench $(PACKAGES)

functional-tests:
@CGO_ENABLED=0 go test -v -timeout=5m -tags=functional ./test
@go test -v -timeout=5m -tags="functional" ./test

ci: test functional-tests

.PHONY: all target release-all clean test benchmark
.PHONY: all target release-all clean test benchmark
410 changes: 36 additions & 374 deletions README.md

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions api/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/bytom/consensus"
"github.com/bytom/crypto/ed25519/chainkd"
chainjson "github.com/bytom/encoding/json"
"github.com/bytom/errors"
"github.com/bytom/protocol/bc"
"github.com/bytom/protocol/bc/types"
)
Expand Down Expand Up @@ -285,29 +286,46 @@ type AccountPubkey struct {

// POST /list-pubkeys
func (a *API) listPubKeys(ctx context.Context, ins struct {
AccountID string `json:"account_id"`
AccountID string `json:"account_id"`
AccountAlias string `json:"account_alias"`
PublicKey string `json:"public_key"`
}) Response {
account, err := a.wallet.AccountMgr.FindByID(ins.AccountID)
var err error
account := &account.Account{}
if ins.AccountAlias != "" {
account, err = a.wallet.AccountMgr.FindByAlias(ins.AccountAlias)
} else {
account, err = a.wallet.AccountMgr.FindByID(ins.AccountID)
}

if err != nil {
return NewErrorResponse(err)
}

pubKeyInfos := []PubKeyInfo{}
idx := a.wallet.AccountMgr.GetContractIndex(ins.AccountID)
idx := a.wallet.AccountMgr.GetContractIndex(account.ID)
for i := uint64(1); i <= idx; i++ {
rawPath := signers.Path(account.Signer, signers.AccountKeySpace, i)
derivedXPub := account.XPubs[0].Derive(rawPath)
pubkey := derivedXPub.PublicKey()

if ins.PublicKey != "" && ins.PublicKey != hex.EncodeToString(pubkey) {
continue
}

var path []chainjson.HexBytes
for _, p := range rawPath {
path = append(path, chainjson.HexBytes(p))
}

pubKeyInfos = append([]PubKeyInfo{{
pubKeyInfos = append(pubKeyInfos, PubKeyInfo{
Pubkey: hex.EncodeToString(pubkey),
Path: path,
}}, pubKeyInfos...)
})
}

if len(pubKeyInfos) == 0 {
return NewErrorResponse(errors.New("Not found publickey for the account"))
}

return NewSuccessResponse(&AccountPubkey{
Expand Down
23 changes: 18 additions & 5 deletions cmd/bytomcli/commands/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"os"
"strings"

"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
Expand All @@ -14,7 +15,7 @@ func init() {
createAccountCmd.PersistentFlags().IntVarP(&accountQuorum, "quorom", "q", 1, "quorum must be greater than 0 and less than or equal to the number of signers")
createAccountCmd.PersistentFlags().StringVarP(&accountToken, "access", "a", "", "access token")

listAccountsCmd.PersistentFlags().StringVar(&accountID, "id", "", "ID of account")
listAccountsCmd.PersistentFlags().StringVar(&accountID, "id", "", "account ID")

listAddressesCmd.PersistentFlags().StringVar(&accountID, "id", "", "account ID")
listAddressesCmd.PersistentFlags().StringVar(&accountAlias, "alias", "", "account alias")
Expand Down Expand Up @@ -157,13 +158,25 @@ var validateAddressCmd = &cobra.Command{
}

var listPubKeysCmd = &cobra.Command{
Use: "list-pubkeys <accountID>",
Use: "list-pubkeys <accountInfo> [publicKey]",
Short: "list the account pubkeys",
Args: cobra.ExactArgs(1),
Args: cobra.RangeArgs(1, 2),
Run: func(cmd *cobra.Command, args []string) {
var ins = struct {
AccountID string `json:"account_id"`
}{AccountID: args[0]}
AccountID string `json:"account_id"`
AccountAlias string `json:"account_alias"`
PublicKey string `json:"public_key"`
}{}

if len(args[0]) == 13 && strings.HasPrefix(args[0], "0") {
ins.AccountID = args[0]
} else {
ins.AccountAlias = args[0]
}

if len(args) == 2 {
ins.PublicKey = args[1]
}

data, exitCode := util.ClientCall("/list-pubkeys", &ins)
if exitCode != util.Success {
Expand Down
2 changes: 2 additions & 0 deletions consensus/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ var MainNetParams = Params{
{20000, bc.NewHash([32]byte{0x7d, 0x38, 0x61, 0xf3, 0x2c, 0xc0, 0x03, 0x81, 0xbb, 0xcd, 0x9a, 0x37, 0x6f, 0x10, 0x5d, 0xfe, 0x6f, 0xfe, 0x2d, 0xa5, 0xea, 0x88, 0xa5, 0xe3, 0x42, 0xed, 0xa1, 0x17, 0x9b, 0xa8, 0x0b, 0x7c})},
{30000, bc.NewHash([32]byte{0x32, 0x36, 0x06, 0xd4, 0x27, 0x2e, 0x35, 0x24, 0x46, 0x26, 0x7b, 0xe0, 0xfa, 0x48, 0x10, 0xa4, 0x3b, 0xb2, 0x40, 0xf1, 0x09, 0x51, 0x5b, 0x22, 0x9f, 0xf3, 0xc3, 0x83, 0x28, 0xaa, 0x4a, 0x00})},
{40000, bc.NewHash([32]byte{0x7f, 0xe2, 0xde, 0x11, 0x21, 0xf3, 0xa9, 0xa0, 0xee, 0x60, 0x8d, 0x7d, 0x4b, 0xea, 0xcc, 0x33, 0xfe, 0x41, 0x25, 0xdc, 0x2f, 0x26, 0xc2, 0xf2, 0x9c, 0x07, 0x17, 0xf9, 0xe4, 0x4f, 0x9d, 0x46})},
{50000, bc.NewHash([32]byte{0x5e, 0xfb, 0xdf, 0xf5, 0x35, 0x38, 0xa6, 0x0b, 0x75, 0x32, 0x02, 0x61, 0x83, 0x54, 0x34, 0xff, 0x3e, 0x82, 0x2e, 0xf8, 0x64, 0xae, 0x2d, 0xc7, 0x6c, 0x9d, 0x5e, 0xbd, 0xa3, 0xd4, 0x50, 0xcf})},
{62000, bc.NewHash([32]byte{0xd7, 0x39, 0x8f, 0x23, 0x57, 0xf9, 0x4c, 0xa0, 0x28, 0xa7, 0x00, 0x2b, 0x53, 0x9e, 0x51, 0x2d, 0x3e, 0xca, 0xc9, 0x22, 0x59, 0xfc, 0xd0, 0x3f, 0x67, 0x1a, 0x0a, 0xb1, 0x02, 0xbf, 0x2b, 0x03})},
},
}

Expand Down
4 changes: 2 additions & 2 deletions dashboard/dashboard.go

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions docs/release-notes/release-notes-1.0.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
Bytom version 1.0.4 is now available from:

https://github.com/Bytom/bytom/releases/tag/v1.0.4


Please report bugs using the issue tracker at github:

https://github.com/Bytom/bytom/issues

How to Upgrade
===============

If you are running an older version, shut it down. Wait until it has completely, then run the new version Bytom.
You can operate according to the user manual.[(Bytom User Manual)](https://bytom.io/wp-content/themes/freddo/images/wallet/BytomUsermanualV1.0_en.pdf)


1.0.4 changelog
================
Bytom Node

`PR #1104`
- Add block fast sync function.

`PR #1048`
- Sort actions by original list for function MergeSpendAction.

`PR #1081`
- Add API list-pubkeys.

`PR #1098`
- Add API wallet-info to acquire rescanning wallet schedule.

`PR #1112`
- Wallet support spends unconfirmed utxo.

`PR #1115`
- Add bytomd command line parameter `--log_level` to set log level.

`PR #1118`
- Add network access control api, include list-peers,connect-peer,disconnect-peer.

`PR #1124`
- Fix a security bug that might attack Bytom server.

`PR #1126`
- Optimize the gas estimation for the multi-signed transaction.

`PR #1130`
- Add tx_id and input_id to the decode-raw-transaction API response.

`PR #1133`
- Reorganize error codes and messages

`PR #1139`
- Fix p2p node discover table delete bug

`PR #1141`
- Delete unconfirmed transaction from the dashboard if it has been double spend

`PR #1142`
- Add simd support for tensority, including compilation option and command line flag (`--simd.enable`).

`PR #1149`
- Optimize wallet utxo select algorithm on build transaction.

Bytom Dashboard
`PR #1143`
- Update the password field to prevent browser remember password.
- Add the rescan Wallet button for the balances page.
- Restyled the backup & restore pages.
- Add the terminal pop up modal in the setting page.

`PR #1169`
- updated error message display in submitted form.

Equity Contract frontend:
`PR #1144`
- Add 8 contracts to the lock page.
- Render the static component in the unlock page.
- Setup and configured the equity project into production environment.
- Unlock page get data from contract program for dynamic rendering.
- Build actions based on different contract templates.

Credits
--------

Thanks to everyone who directly contributed to this release:
- Broadroad
- Colt-Z
- HAOYUatHZ
- langyu
- oysheng
- Paladz
- RockerFlower
- shanhuhai5739
- shenao78
- successli
- yahtoo
- zcc0721
- ZhitingLin

And everyone who helped test.
12 changes: 8 additions & 4 deletions equity/equity.go

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions mining/tensority/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions mining/tensority/cgo_algorithm/algorithm_simd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// +build cgo
// +build simd

package cgo_algorithm

// #cgo !darwin CFLAGS: -I.
// #cgo !darwin LDFLAGS: -L. -l:./lib/cSimdTs.o -lstdc++ -lgomp -lpthread
// #cgo darwin CFLAGS: -I. -I/usr/local/opt/llvm/include
// #cgo darwin LDFLAGS: -L. -l:./lib/cSimdTs.o -lstdc++ -lomp -L/usr/local/opt/llvm/lib
// #cgo darwin LDFLAGS: -L. -l./lib/cSimdTs.o -lstdc++ -lomp -L/usr/local/opt/llvm/lib
// #include "./lib/cSimdTs.h"
import "C"

Expand Down
2 changes: 1 addition & 1 deletion mining/tensority/cgo_algorithm/algorithm_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !cgo
// +build !simd

package cgo_algorithm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tensority
package go_algorithm

import (
"reflect"
Expand Down Expand Up @@ -237,13 +237,13 @@ var tests = []struct {
}

// Tests that tensority hash result is correct.
func TestAlgorithm(t *testing.T) {
func TestLegacyAlgorithm(t *testing.T) {
startT := time.Now()
for i, tt := range tests {
sT := time.Now()
bhhash := bc.NewHash(tt.blockHeader)
sdhash := bc.NewHash(tt.seed)
result := algorithm(&bhhash, &sdhash).Bytes()
result := LegacyAlgorithm(&bhhash, &sdhash).Bytes()
var resArr [32]byte
copy(resArr[:], result)
eT := time.Now()
Expand All @@ -263,26 +263,22 @@ func TestAlgorithm(t *testing.T) {
t.Log("Avg time:", time.Duration(int(endT.Sub(startT))/len(tests)))
}

func BenchmarkAlgorithm(b *testing.B) {
func BenchmarkLegacyAlgorithm(b *testing.B) {
bhhash := bc.NewHash(tests[0].blockHeader)
sdhash := bc.NewHash(tests[0].seed)
b.ResetTimer()
for i := 0; i < b.N; i++ {
algorithm(&bhhash, &sdhash)
LegacyAlgorithm(&bhhash, &sdhash)
}
}

func BenchmarkAlgorithmParallel(b *testing.B) {
func BenchmarkLegacyAlgorithmParallel(b *testing.B) {
bhhash := bc.NewHash(tests[0].blockHeader)
sdhash := bc.NewHash(tests[0].seed)
b.SetParallelism(runtime.NumCPU())
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
algorithm(&bhhash, &sdhash)
LegacyAlgorithm(&bhhash, &sdhash)
}
})
}

func init() {
UseSIMD = true
}
5 changes: 2 additions & 3 deletions netsync/block_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
log "github.com/sirupsen/logrus"
"gopkg.in/karalabe/cookiejar.v2/collections/prque"

"github.com/bytom/protocol"
"github.com/bytom/protocol/bc"
)

Expand All @@ -17,7 +16,7 @@ const (
// blockFetcher is responsible for accumulating block announcements from various peers
// and scheduling them for retrieval.
type blockFetcher struct {
chain *protocol.Chain
chain Chain
peers *peerSet

newBlockCh chan *blockMsg
Expand All @@ -26,7 +25,7 @@ type blockFetcher struct {
}

//NewBlockFetcher creates a block fetcher to retrieve blocks of the new mined.
func newBlockFetcher(chain *protocol.Chain, peers *peerSet) *blockFetcher {
func newBlockFetcher(chain Chain, peers *peerSet) *blockFetcher {
f := &blockFetcher{
chain: chain,
peers: peers,
Expand Down
Loading

0 comments on commit 9082510

Please sign in to comment.