Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make empty block deterministic #1287

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,13 @@ all-cross: ontology-cross tools-cross abi
format:
$(GOFMT) -w main.go

docker/payload: docker/build/bin/ontology docker/Dockerfile
@echo "Building ontology payload"
@mkdir -p $@
@cp docker/Dockerfile $@
@cp docker/build/bin/ontology $@
@touch $@

docker/build/bin/%: Makefile
@echo "Building ontology in docker"
@mkdir -p docker/build/bin docker/build/pkg
@$(DRUN) --rm \
-v $(abspath docker/build/bin):/go/bin \
-v $(abspath docker/build/pkg):/go/pkg \
-v $(GOPATH)/src:/go/src \
-w /go/src/github.com/ontio/ontology \
golang:1.9.5-stretch \
$(GC) $(BUILD_NODE_PAR) -o docker/build/bin/ontology main.go
@touch $@

docker: Makefile docker/payload docker/Dockerfile
docker: Makefile
@echo "Building ontology docker"
@$(DBUILD) -t $(DOCKER_NS)/ontology docker/payload
@docker tag $(DOCKER_NS)/ontology $(DOCKER_NS)/ontology:$(DOCKER_TAG)
@$(DBUILD) --no-cache -t $(DOCKER_NS)/ontology:$(DOCKER_TAG) - < docker/Dockerfile
@touch $@

clean:
rm -rf *.8 *.o *.out *.6 *exe coverage
rm -rf ontology ontology-* tools docker/payload docker/build
rm -rf ontology ontology-* tools

54 changes: 24 additions & 30 deletions cmd/abi/native_abi_script/governance.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,29 @@
],
"returnType":"Bool"
},
{
"name":"setFeePercentage",
"parameters":
[
{
"name":"PeerPubkey",
"type":"String"
},
{
"name":"Address",
"type":"Address"
},
{
"name":"PeerCost",
"type":"Int"
},
{
"name":"StakeCost",
"type":"Int"
}
],
"returnType":"Bool"
},
{
"name":"withdrawFee",
"parameters":
Expand Down Expand Up @@ -556,38 +579,9 @@
}
],
"returnType":"Bool"
},
{
"name":"getPeerPool",
"parameters":
[
],
"returnType":"ByteArray"
},
{
"name":"getPeerInfo",
"parameters":
[
{
"name":"PeerPublicKey",
"type":"String"
}
],
"returnType":"ByteArray"
},
{
"name":"getPeerPoolByAddress",
"parameters":
[
{
"name":"Address",
"type":"Address"
}
],
"returnType":"ByteArray"
}
],
"events":
[
]
}
}
12 changes: 3 additions & 9 deletions cmd/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var schemeMap = map[string]schemeInfo{
// wait for user to choose options
func chooseKeyType(reader *bufio.Reader) string {
common.PrintNotice("key type")
for true {
for {
tmp, _ := reader.ReadString('\n')
tmp = strings.TrimSpace(tmp)
_, ok := keyTypeMap[tmp]
Expand All @@ -123,7 +123,7 @@ func chooseKeyType(reader *bufio.Reader) string {
}
func chooseScheme(reader *bufio.Reader) string {
common.PrintNotice("signature-scheme")
for true {
for {
tmp, _ := reader.ReadString('\n')
tmp = strings.TrimSpace(tmp)

Expand All @@ -139,7 +139,7 @@ func chooseScheme(reader *bufio.Reader) string {
}
func chooseCurve(reader *bufio.Reader) string {
common.PrintNotice("curve")
for true {
for {
tmp, _ := reader.ReadString('\n')
tmp = strings.TrimSpace(tmp)
_, ok := curveMap[tmp]
Expand Down Expand Up @@ -217,15 +217,12 @@ func checkCurve(ctx *cli.Context, reader *bufio.Reader, t *string) string {
} else {
c = chooseCurve(reader)
}
break
case "sm2":
fmt.Println("Use curve sm2p256v1 with key length of 256 bits.")
c = "SM2P256V1"
break
case "ed25519":
fmt.Println("Use curve 25519 with key length of 256 bits.")
c = "ED25519"
break
default:
return ""
}
Expand All @@ -247,15 +244,12 @@ func checkScheme(ctx *cli.Context, reader *bufio.Reader, t *string) string {
} else {
sch = chooseScheme(reader)
}
break
case "sm2":
fmt.Println("Use SM3withSM2 as the signature scheme.")
sch = "SM3withSM2"
break
case "ed25519":
fmt.Println("Use SHA512withEdDSA as the signature scheme.")
sch = "SHA512withEdDSA"
break
default:
return ""
}
Expand Down
3 changes: 0 additions & 3 deletions cmd/common/notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Select a signature algorithm from the following:
3 Ed25519

[default is 1]: `)
break

case "curve":
fmt.Printf(`
Expand All @@ -46,7 +45,6 @@ Select a curve from the following:
4 | P-521 | 521

This determines the length of the private key [default is 2]: `)
break

case "signature-scheme":
fmt.Printf(`
Expand All @@ -63,7 +61,6 @@ Select a signature scheme from the following:
9 RIPEMD160withECDSA

This can be changed later [default is 2]: `)
break

default:
}
Expand Down
8 changes: 8 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error) {
setP2PNodeConfig(ctx, cfg.P2PNode)
setRpcConfig(ctx, cfg.Rpc)
setRestfulConfig(ctx, cfg.Restful)
setGraphQLConfig(ctx, cfg.GraphQL)
setWebSocketConfig(ctx, cfg.Ws)
if cfg.Genesis.ConsensusType == config.CONSENSUS_TYPE_SOLO {
cfg.Ws.EnableHttpWs = true
cfg.Restful.EnableHttpRestful = true
cfg.GraphQL.EnableGraphQL = true
cfg.Consensus.EnableConsensus = true
cfg.P2PNode.NetworkId = config.NETWORK_ID_SOLO_NET
cfg.P2PNode.NetworkName = config.GetNetworkName(cfg.P2PNode.NetworkId)
Expand Down Expand Up @@ -187,6 +189,12 @@ func setRestfulConfig(ctx *cli.Context, cfg *config.RestfulConfig) {
cfg.HttpMaxConnections = ctx.Uint(utils.GetFlagName(utils.RestfulMaxConnsFlag))
}

func setGraphQLConfig(ctx *cli.Context, cfg *config.GraphQLConfig) {
cfg.EnableGraphQL = ctx.Bool(utils.GetFlagName(utils.GraphQLEnableFlag))
cfg.GraphQLPort = ctx.Uint(utils.GetFlagName(utils.GraphQLPortFlag))
cfg.MaxConnections = ctx.Uint(utils.GetFlagName(utils.GraphQLMaxConnsFlag))
}

func setWebSocketConfig(ctx *cli.Context, cfg *config.WebSocketConfig) {
cfg.EnableHttpWs = ctx.Bool(utils.GetFlagName(utils.WsEnabledFlag))
cfg.HttpWsPort = ctx.Uint(utils.GetFlagName(utils.WsPortFlag))
Expand Down
2 changes: 1 addition & 1 deletion cmd/contract_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func deployContract(ctx *cli.Context) error {
gasPrice = 0
}

cversion := fmt.Sprintf("%s", version)
cversion := version

if ctx.IsSet(utils.GetFlagName(utils.ContractPrepareDeployFlag)) {
preResult, err := utils.PrepareDeployContract(vmtype, code, name, cversion, author, email, desc)
Expand Down
6 changes: 6 additions & 0 deletions cmd/sig_tx_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func genMultiSigAddress(ctx *cli.Context) error {
continue
}
data, err := hex.DecodeString(pk)
if err != nil {
return err
}
pubKey, err := keypair.DeserializePublicKey(data)
if err != nil {
return fmt.Errorf("invalid pub key:%s", pk)
Expand Down Expand Up @@ -141,6 +144,9 @@ func multiSigToTx(ctx *cli.Context) error {
continue
}
data, err := hex.DecodeString(pk)
if err != nil {
return err
}
pubKey, err := keypair.DeserializePublicKey(data)
if err != nil {
return fmt.Errorf("invalid pub key:%s", pk)
Expand Down
15 changes: 7 additions & 8 deletions cmd/tx_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ func transferTx(ctx *cli.Context) error {
switch strings.ToLower(asset) {
case "ont":
amount = utils.ParseOnt(amountStr)
amountStr = utils.FormatOnt(amount)
// amountStr = utils.FormatOnt(amount)
case "ong":
amount = utils.ParseOng(amountStr)
amountStr = utils.FormatOng(amount)
// amountStr = utils.FormatOng(amount)
default:
return fmt.Errorf("unsupport asset:%s", asset)
}
Expand Down Expand Up @@ -277,10 +277,10 @@ func approveTx(ctx *cli.Context) error {
switch strings.ToLower(asset) {
case "ont":
amount = utils.ParseOnt(amountStr)
amountStr = utils.FormatOnt(amount)
// amountStr = utils.FormatOnt(amount)
case "ong":
amount = utils.ParseOng(amountStr)
amountStr = utils.FormatOng(amount)
// amountStr = utils.FormatOng(amount)
default:
return fmt.Errorf("unsupport asset:%s", asset)
}
Expand Down Expand Up @@ -363,10 +363,9 @@ func transferFromTx(ctx *cli.Context) error {
switch strings.ToLower(asset) {
case "ont":
amount = utils.ParseOnt(amountStr)
amountStr = utils.FormatOnt(amount)
case "ong":
amount = utils.ParseOng(amountStr)
amountStr = utils.FormatOng(amount)
// amountStr = utils.FormatOng(amount)
default:
return fmt.Errorf("unsupport asset:%s", asset)
}
Expand Down Expand Up @@ -425,13 +424,13 @@ func withdrawONGTx(ctx *cli.Context) error {
if amount <= 0 {
return fmt.Errorf("haven't unbound ong")
}
amountStr = utils.FormatOng(amount)
// amountStr = utils.FormatOng(amount)
} else {
amount = utils.ParseOng(amountStr)
if amount <= 0 {
return fmt.Errorf("haven't unbound ong")
}
amountStr = utils.FormatOng(amount)
// amountStr = utils.FormatOng(amount)
}

var payer common.Address
Expand Down
8 changes: 8 additions & 0 deletions cmd/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ var AppHelpFlagGroups = []flagGroup{
utils.RestfulMaxConnsFlag,
},
},
{
Name: "GRAPHQL",
Flags: []cli.Flag{
utils.GraphQLEnableFlag,
utils.GraphQLPortFlag,
utils.GraphQLMaxConnsFlag,
},
},
{
Name: "WEB SOCKET",
Flags: []cli.Flag{
Expand Down
20 changes: 17 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ var (
Usage: "Block data storage `<path>`",
Value: config.DEFAULT_DATA_DIR,
}

//Consensus setting
EnableConsensusFlag = cli.BoolFlag{
Name: "enable-consensus",
Expand All @@ -103,7 +102,6 @@ var (
Usage: "Min gas price `<value>` of transaction to be accepted by tx pool.",
Value: config.DEFAULT_GAS_PRICE,
}

//Test Mode setting
EnableTestModeFlag = cli.BoolFlag{
Name: "testmode",
Expand Down Expand Up @@ -199,7 +197,23 @@ var (
RestfulMaxConnsFlag = cli.UintFlag{
Name: "restmaxconns",
Usage: "Restful server maximum connections `<number>`",
Value: config.DEFAULT_REST_MAX_CONN,
Value: config.DEFAULT_HTTP_MAX_CONN,
}

//GraphQL setting
GraphQLEnableFlag = cli.BoolFlag{
Name: "graphql",
Usage: "Enable graphql api server",
}
GraphQLPortFlag = cli.UintFlag{
Name: "graphql-port",
Usage: "GraphQL server listening port `<number>`",
Value: config.DEFAULT_GRAPHQL_PORT,
}
GraphQLMaxConnsFlag = cli.UintFlag{
Name: "graphql-max-connection",
Usage: "GraphQL server maximum connections `<number>`",
Value: config.DEFAULT_HTTP_MAX_CONN,
}

//Account setting
Expand Down
Loading