From 6274adf7c09e9904d86583f033505f10ba6bb6df Mon Sep 17 00:00:00 2001 From: Edmond-Honglei-Cong Date: Thu, 28 Nov 2019 22:44:09 +0800 Subject: [PATCH] update command line name --- cmd/account_cmd.go | 6 +- cmd/asset_cmd.go | 118 ++------------------------ cmd/config.go | 5 +- cmd/contract_cmd.go | 10 +-- cmd/import_cmd.go | 4 +- cmd/info_cmd.go | 2 +- cmd/sig_tx_cmd.go | 4 +- cmd/tx_cmd.go | 6 +- cmd/usage.go | 9 +- cmd/utils/flags.go | 10 +-- cmd/utils/ont.go | 2 +- cmd/utils/rpc.go | 33 +++---- common/config/config.go | 16 ++-- common/password/password.go | 32 +++---- common/password/password_windows.go | 32 +++---- core/genesis/genesis.go | 12 +-- core/utils/transaction_builder.go | 2 +- docker/Dockerfile | 10 +-- go.sum | 3 + main.go | 12 +-- smartcontract/service/neovm/config.go | 34 ++++---- smartcontract/test/verifysig_test.go | 2 +- 22 files changed, 134 insertions(+), 230 deletions(-) diff --git a/cmd/account_cmd.go b/cmd/account_cmd.go index 989b9934..7f731f40 100644 --- a/cmd/account_cmd.go +++ b/cmd/account_cmd.go @@ -43,7 +43,7 @@ var ( Usage: "Manage accounts", ArgsUsage: "[arguments...]", Description: `Wallet management commands can be used to add, view, modify, delete, import account, and so on. -You can use ./Ontology account --help command to view help information of wallet management command.`, +You can use ./DNA account --help command to view help information of wallet management command.`, Subcommands: []cli.Command{ { Action: accountCreate, @@ -61,8 +61,8 @@ You can use ./Ontology account --help command to view help information of wallet utils.WalletFileFlag, }, Description: ` Add a new account to wallet. - Ontology support three type of key: ecdsa, sm2 and ed25519, and support 224、256、384、521 bits length of key in ecdsa, but only support 256 bits length of key in sm2 and ed25519. - Ontology support multiple signature scheme. + DNA support three type of key: ecdsa, sm2 and ed25519, and support 224、256、384、521 bits length of key in ecdsa, but only support 256 bits length of key in sm2 and ed25519. + DNA support multiple signature scheme. For ECDSA support SHA224withECDSA、SHA256withECDSA、SHA384withECDSA、SHA512withEdDSA、SHA3-224withECDSA、SHA3-256withECDSA、SHA3-384withECDSA、SHA3-512withECDSA、RIPEMD160withECDSA; For SM2 support SM3withSM2, and for SHA512withEdDSA. ------------------------------------------------- diff --git a/cmd/asset_cmd.go b/cmd/asset_cmd.go index 09ac1c12..092f0683 100644 --- a/cmd/asset_cmd.go +++ b/cmd/asset_cmd.go @@ -23,14 +23,14 @@ package cmd import ( "fmt" + "strconv" + "strings" + "github.com/DNAProject/DNA/account" cmdcom "github.com/DNAProject/DNA/cmd/common" "github.com/DNAProject/DNA/cmd/utils" "github.com/DNAProject/DNA/common/config" - nutils "github.com/DNAProject/DNA/smartcontract/service/native/utils" "github.com/urfave/cli" - "strconv" - "strings" ) var AssetCommand = cli.Command{ @@ -112,28 +112,6 @@ var AssetCommand = cli.Command{ utils.WalletFileFlag, }, }, - { - Action: unboundOng, - Name: "unboundong", - Usage: "Show the balance of unbound ONG", - ArgsUsage: "", - Flags: []cli.Flag{ - utils.RPCPortFlag, - utils.WalletFileFlag, - }, - }, - { - Action: withdrawOng, - Name: "withdrawong", - Usage: "Withdraw ONG", - ArgsUsage: "", - Flags: []cli.Flag{ - utils.RPCPortFlag, - utils.TransactionGasPriceFlag, - utils.TransactionGasLimitFlag, - utils.WalletFileFlag, - }, - }, }, } @@ -220,7 +198,7 @@ func transfer(ctx *cli.Context) error { PrintInfoMsg(" Amount:%s", amountStr) PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } @@ -362,7 +340,7 @@ func approve(ctx *cli.Context) error { PrintInfoMsg(" Amount:%s", amountStr) PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } @@ -460,90 +438,6 @@ func transferFrom(ctx *cli.Context) error { PrintInfoMsg(" Amount:%s", amountStr) PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) - return nil -} - -func unboundOng(ctx *cli.Context) error { - SetRpcPort(ctx) - if ctx.NArg() < 1 { - PrintErrorMsg("Missing account argument.") - cli.ShowSubcommandHelp(ctx) - return nil - } - addrArg := ctx.Args().First() - accAddr, err := cmdcom.ParseAddress(addrArg, ctx) - if err != nil { - return err - } - fromAddr := nutils.OntContractAddress.ToBase58() - balanceStr, err := utils.GetAllowance("ong", fromAddr, accAddr) - if err != nil { - return err - } - balance, err := strconv.ParseUint(balanceStr, 10, 64) - if err != nil { - return err - } - balanceStr = utils.FormatOng(balance) - PrintInfoMsg("Unbound ONG:") - PrintInfoMsg(" Account:%s", accAddr) - PrintInfoMsg(" ONG:%s", balanceStr) - return nil -} - -func withdrawOng(ctx *cli.Context) error { - SetRpcPort(ctx) - if ctx.NArg() < 1 { - PrintErrorMsg("Missing account argument.") - cli.ShowSubcommandHelp(ctx) - return nil - } - addrArg := ctx.Args().First() - accAddr, err := cmdcom.ParseAddress(addrArg, ctx) - if err != nil { - return err - } - fromAddr := nutils.OntContractAddress.ToBase58() - balance, err := utils.GetAllowance("ong", fromAddr, accAddr) - if err != nil { - return err - } - - amount, err := strconv.ParseUint(balance, 10, 64) - if err != nil { - return err - } - if amount <= 0 { - return fmt.Errorf("haven't unbound ong\n") - } - - var signer *account.Account - signer, err = cmdcom.GetAccount(ctx, accAddr) - if err != nil { - return err - } - - gasPrice := ctx.Uint64(utils.TransactionGasPriceFlag.Name) - gasLimit := ctx.Uint64(utils.TransactionGasLimitFlag.Name) - networkId, err := utils.GetNetworkId() - if err != nil { - return err - } - if networkId == config.NETWORK_ID_SOLO_NET { - gasPrice = 0 - } - - txHash, err := utils.TransferFrom(gasPrice, gasLimit, signer, "ong", accAddr, fromAddr, accAddr, amount) - if err != nil { - return err - } - - PrintInfoMsg("Withdraw ONG:") - PrintInfoMsg(" Account:%s", accAddr) - PrintInfoMsg(" Amount:%s", utils.FormatOng(amount)) - PrintInfoMsg(" TxHash:%s", txHash) - PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } diff --git a/cmd/config.go b/cmd/config.go index aa023583..cf27c8d2 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -23,6 +23,7 @@ package cmd import ( "fmt" + "github.com/DNAProject/DNA/cmd/utils" "github.com/DNAProject/DNA/common" "github.com/DNAProject/DNA/common/config" @@ -31,7 +32,7 @@ import ( "github.com/urfave/cli" ) -func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error) { +func SetBlockchainConfig(ctx *cli.Context) (*config.BlockchainConfig, error) { cfg := config.DefConfig err := setGenesis(ctx, cfg) if err != nil { @@ -67,7 +68,7 @@ func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error) { return cfg, nil } -func setGenesis(ctx *cli.Context, cfg *config.OntologyConfig) error { +func setGenesis(ctx *cli.Context, cfg *config.BlockchainConfig) error { netWorkId := ctx.Int(utils.GetFlagName(utils.NetworkIdFlag)) switch netWorkId { case config.NETWORK_ID_MAIN_NET: diff --git a/cmd/contract_cmd.go b/cmd/contract_cmd.go index 3b9ffcb6..eeecaa1b 100644 --- a/cmd/contract_cmd.go +++ b/cmd/contract_cmd.go @@ -47,7 +47,7 @@ var ( { Action: deployContract, Name: "deploy", - Usage: "Deploy a smart contract to ontology", + Usage: "Deploy a smart contract to blockchain", ArgsUsage: " ", Flags: []cli.Flag{ utils.RPCPortFlag, @@ -69,7 +69,7 @@ var ( Action: invokeContract, Name: "invoke", Usage: "Invoke smart contract", - ArgsUsage: `Ontology contract support bytearray(need encode to hex string), string, integer, boolean parameter type. + ArgsUsage: `Smart contract supports bytearray(need encode to hex string), string, integer, boolean parameter type. Parameter Contract parameters separate with comma ',' to split params. and must add type prefix to params. @@ -189,7 +189,7 @@ func deployContract(ctx *cli.Context) error { PrintInfoMsg(" Contract Address:%s", address.ToHexString()) PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } @@ -281,7 +281,7 @@ func invokeCodeContract(ctx *cli.Context) error { PrintInfoMsg("TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } @@ -380,6 +380,6 @@ func invokeContract(ctx *cli.Context) error { PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTips:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } diff --git a/cmd/import_cmd.go b/cmd/import_cmd.go index 5f1859af..7d4f5a0d 100644 --- a/cmd/import_cmd.go +++ b/cmd/import_cmd.go @@ -57,9 +57,9 @@ var ImportCommand = cli.Command{ func importBlocks(ctx *cli.Context) error { log.InitLog(log.InfoLog) - cfg, err := SetOntologyConfig(ctx) + cfg, err := SetBlockchainConfig(ctx) if err != nil { - PrintErrorMsg("SetOntologyConfig error:%s", err) + PrintErrorMsg("SetBlockchainConfig error:%s", err) cli.ShowSubcommandHelp(ctx) return nil } diff --git a/cmd/info_cmd.go b/cmd/info_cmd.go index 9b8b8271..c7db4e1d 100644 --- a/cmd/info_cmd.go +++ b/cmd/info_cmd.go @@ -77,7 +77,7 @@ var InfoCommand = cli.Command{ }, }, Description: `Query information command can query information such as blocks, transactions, and transaction executions. -You can use the ./Ontology info block --help command to view help information.`, +You can use the ./DNA info block --help command to view help information.`, } var ShowTxCommand = cli.Command{ diff --git a/cmd/sig_tx_cmd.go b/cmd/sig_tx_cmd.go index 09b5d02c..fb656de1 100644 --- a/cmd/sig_tx_cmd.go +++ b/cmd/sig_tx_cmd.go @@ -221,7 +221,7 @@ func multiSigToTx(ctx *cli.Context) error { PrintInfoMsg("Send transaction success.") PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) } return nil } @@ -292,7 +292,7 @@ func sigToTx(ctx *cli.Context) error { PrintInfoMsg("Send transaction success.") PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) } return nil } diff --git a/cmd/tx_cmd.go b/cmd/tx_cmd.go index c6a9947d..d946ea4e 100644 --- a/cmd/tx_cmd.go +++ b/cmd/tx_cmd.go @@ -34,8 +34,8 @@ import ( var SendTxCommand = cli.Command{ Name: "sendtx", - Usage: "Send raw transaction to Ontology", - Description: "Send raw transaction to Ontology.", + Usage: "Send raw transaction to blockchain", + Description: "Send raw transaction to blockchain.", ArgsUsage: "", Action: sendTx, Flags: []cli.Flag{ @@ -74,7 +74,7 @@ func sendTx(ctx *cli.Context) error { PrintInfoMsg("Send transaction success.") PrintInfoMsg(" TxHash:%s", txHash) PrintInfoMsg("\nTip:") - PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash) + PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash) return nil } diff --git a/cmd/usage.go b/cmd/usage.go index d5e857c9..48e0ad29 100644 --- a/cmd/usage.go +++ b/cmd/usage.go @@ -25,12 +25,13 @@ import ( "encoding/json" "flag" "fmt" - "github.com/DNAProject/DNA/cmd/utils" - "github.com/urfave/cli" "io" "sort" "strings" "text/template" + + "github.com/DNAProject/DNA/cmd/utils" + "github.com/urfave/cli" ) // AppHelpTemplate is the test template for the default, global app help topic. @@ -38,7 +39,7 @@ var ( AppHelpTemplate = `NAME: {{.App.Name}} - {{.App.Usage}} - Ontology CLI is an Ontology node command line Client for starting and managing Ontology nodes, + Blockchain CLI is an blockchain node command line Client for starting and managing blockchain nodes, managing user wallets, sending transactions, deploying and invoking contract, and so on. USAGE: @@ -98,7 +99,7 @@ type flagGroup struct { var AppHelpFlagGroups = []flagGroup{ { - Name: "ONTOLOGY", + Name: "BLOCKCHAIN", Flags: []cli.Flag{ utils.ConfigFlag, utils.LogLevelFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a3207896..c2da90b6 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -37,7 +37,7 @@ const ( ) var ( - //Ontology setting + //Blockchain setting ConfigFlag = cli.StringFlag{ Name: "config", Usage: "Genesis block config ``. If doesn't specifies, use main net config as default.", @@ -120,7 +120,7 @@ var ( } NetworkIdFlag = cli.UintFlag{ Name: "networkid", - Usage: "Network id ``. 1=ontology main net, 2=polaris test net, 3=testmode, and other for custom network", + Usage: "Network id ``", Value: config.NETWORK_ID_MAIN_NET, } NodePortFlag = cli.UintFlag{ @@ -199,11 +199,11 @@ var ( AccountPassFlag = cli.StringFlag{ Name: "password,p", Hidden: true, - Usage: "Account `` when Ontology node starts.", + Usage: "Account `` when blockchain node starts.", } AccountAddressFlag = cli.StringFlag{ Name: "account,a", - Usage: "Account `
` when the Ontology node starts. If not specific, using default account instead", + Usage: "Account `
` when the blockchain node starts. If not specific, using default account instead", } AccountDefaultFlag = cli.BoolFlag{ Name: "default,d", @@ -401,7 +401,7 @@ var ( } SendTxFlag = cli.BoolFlag{ Name: "send,s", - Usage: "Send raw transaction to Ontology", + Usage: "Send raw transaction to blockchain", } ForceSendTxFlag = cli.BoolFlag{ Name: "force,f", diff --git a/cmd/utils/ont.go b/cmd/utils/ont.go index 5c2ffac1..7b6f7f81 100644 --- a/cmd/utils/ont.go +++ b/cmd/utils/ont.go @@ -438,7 +438,7 @@ func Sign(data []byte, signer *account.Account) ([]byte, error) { return sigData, nil } -//SendRawTransaction send a transaction to ontology network, and return hash of the transaction +// SendRawTransaction send a transaction to blockchain network, and return hash of the transaction func SendRawTransaction(tx *types.Transaction) (string, error) { txData := hex.EncodeToString(common.SerializeToBytes(tx)) return SendRawTransactionData(txData) diff --git a/cmd/utils/rpc.go b/cmd/utils/rpc.go index f79bf556..a07ab45d 100644 --- a/cmd/utils/rpc.go +++ b/cmd/utils/rpc.go @@ -24,36 +24,37 @@ package utils import ( "encoding/json" "fmt" - "github.com/DNAProject/DNA/common/config" - rpcerr "github.com/DNAProject/DNA/http/base/error" "io/ioutil" "net/http" "strings" + + "github.com/DNAProject/DNA/common/config" + rpcerr "github.com/DNAProject/DNA/http/base/error" ) //JsonRpc version const JSON_RPC_VERSION = "2.0" const ( - ERROR_INVALID_PARAMS = rpcerr.INVALID_PARAMS - ERROR_ONTOLOGY_COMMON = 10000 - ERROR_ONTOLOGY_SUCCESS = 0 + ERROR_INVALID_PARAMS = rpcerr.INVALID_PARAMS + ERROR_RPC_COMMON = 10000 + ERROR_RPC_SUCCESS = 0 ) -type OntologyError struct { +type RpcError struct { ErrorCode int64 Error error } -func NewOntologyError(err error, errCode ...int64) *OntologyError { - ontErr := &OntologyError{Error: err} +func NewRpcError(err error, errCode ...int64) *RpcError { + ontErr := &RpcError{Error: err} if len(errCode) > 0 { ontErr.ErrorCode = errCode[0] } else { - ontErr.ErrorCode = ERROR_ONTOLOGY_COMMON + ontErr.ErrorCode = ERROR_RPC_COMMON } if err == nil { - ontErr.ErrorCode = ERROR_ONTOLOGY_SUCCESS + ontErr.ErrorCode = ERROR_RPC_SUCCESS } return ontErr } @@ -73,7 +74,7 @@ type JsonRpcResponse struct { Result json.RawMessage `json:"result"` } -func sendRpcRequest(method string, params []interface{}) ([]byte, *OntologyError) { +func sendRpcRequest(method string, params []interface{}) ([]byte, *RpcError) { rpcReq := &JsonRpcRequest{ Version: JSON_RPC_VERSION, Id: "cli", @@ -82,27 +83,27 @@ func sendRpcRequest(method string, params []interface{}) ([]byte, *OntologyError } data, err := json.Marshal(rpcReq) if err != nil { - return nil, NewOntologyError(fmt.Errorf("JsonRpcRequest json.Marshal error:%s", err)) + return nil, NewRpcError(fmt.Errorf("JsonRpcRequest json.Marshal error:%s", err)) } addr := fmt.Sprintf("http://localhost:%d", config.DefConfig.Rpc.HttpJsonPort) resp, err := http.Post(addr, "application/json", strings.NewReader(string(data))) if err != nil { - return nil, NewOntologyError(err) + return nil, NewRpcError(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - return nil, NewOntologyError(fmt.Errorf("read rpc response body error:%s", err)) + return nil, NewRpcError(fmt.Errorf("read rpc response body error:%s", err)) } rpcRsp := &JsonRpcResponse{} err = json.Unmarshal(body, rpcRsp) if err != nil { - return nil, NewOntologyError(fmt.Errorf("json.Unmarshal JsonRpcResponse:%s error:%s", body, err)) + return nil, NewRpcError(fmt.Errorf("json.Unmarshal JsonRpcResponse:%s error:%s", body, err)) } if rpcRsp.Error != 0 { - return nil, NewOntologyError(fmt.Errorf("\n %s ", string(body)), rpcRsp.Error) + return nil, NewRpcError(fmt.Errorf("\n %s ", string(body)), rpcRsp.Error) } return rpcRsp.Result, nil } diff --git a/common/config/config.go b/common/config/config.go index 5894cb9b..a902464c 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -87,7 +87,7 @@ const ( NETWORK_ID_MAIN_NET = 1 NETWORK_ID_POLARIS_NET = 2 NETWORK_ID_SOLO_NET = 3 - NETWORK_NAME_MAIN_NET = "ontology" + NETWORK_NAME_MAIN_NET = "mainnet" NETWORK_NAME_POLARIS_NET = "polaris" NETWORK_NAME_SOLO_NET = "testmode" ) @@ -272,7 +272,7 @@ var MainNetConfig = &GenesisConfig{ SOLO: &SOLOConfig{}, } -var DefConfig = NewOntologyConfig() +var DefConfig = NewBlockchainConfig() type GenesisConfig struct { SeedList []string @@ -541,7 +541,7 @@ type WebSocketConfig struct { HttpKeyPath string } -type OntologyConfig struct { +type BlockchainConfig struct { Genesis *GenesisConfig Common *CommonConfig Consensus *ConsensusConfig @@ -551,8 +551,8 @@ type OntologyConfig struct { Ws *WebSocketConfig } -func NewOntologyConfig() *OntologyConfig { - return &OntologyConfig{ +func NewBlockchainConfig() *BlockchainConfig { + return &BlockchainConfig{ Genesis: MainNetConfig, Common: &CommonConfig{ LogLevel: DEFAULT_LOG_LEVEL, @@ -598,7 +598,7 @@ func NewOntologyConfig() *OntologyConfig { } } -func (this *OntologyConfig) GetBookkeepers() ([]keypair.PublicKey, error) { +func (this *BlockchainConfig) GetBookkeepers() ([]keypair.PublicKey, error) { var bookKeepers []string switch this.Genesis.ConsensusType { case CONSENSUS_TYPE_VBFT: @@ -626,7 +626,7 @@ func (this *OntologyConfig) GetBookkeepers() ([]keypair.PublicKey, error) { return pubKeys, nil } -func (this *OntologyConfig) GetDefaultNetworkId() (uint32, error) { +func (this *BlockchainConfig) GetDefaultNetworkId() (uint32, error) { defaultNetworkId, err := this.getDefNetworkIDFromGenesisConfig(this.Genesis) if err != nil { return 0, err @@ -648,7 +648,7 @@ func (this *OntologyConfig) GetDefaultNetworkId() (uint32, error) { return defaultNetworkId, nil } -func (this *OntologyConfig) getDefNetworkIDFromGenesisConfig(genCfg *GenesisConfig) (uint32, error) { +func (this *BlockchainConfig) getDefNetworkIDFromGenesisConfig(genCfg *GenesisConfig) (uint32, error) { var configData []byte var err error switch this.Genesis.ConsensusType { diff --git a/common/password/password.go b/common/password/password.go index 74fa41db..f3362d77 100644 --- a/common/password/password.go +++ b/common/password/password.go @@ -1,21 +1,23 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright 2019 DNA Dev team // -// Copyright (C) 2018 The ontology Authors -// This file is part of The ontology library. -// -// The ontology is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The ontology is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with The ontology. If not, see . +/* + * Copyright (C) 2018 The ontology Authors + * This file is part of The ontology library. + * + * The ontology is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The ontology is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with The ontology. If not, see . + */ // +build !windows diff --git a/common/password/password_windows.go b/common/password/password_windows.go index 44ea84b9..bb57bc6f 100644 --- a/common/password/password_windows.go +++ b/common/password/password_windows.go @@ -1,21 +1,23 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright 2019 DNA Dev team // -// Copyright (C) 2018 The ontology Authors -// This file is part of The ontology library. -// -// The ontology is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The ontology is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with The ontology. If not, see . +/* + * Copyright (C) 2018 The ontology Authors + * This file is part of The ontology library. + * + * The ontology is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The ontology is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with The ontology. If not, see . + */ // +build windows diff --git a/core/genesis/genesis.go b/core/genesis/genesis.go index 21c65851..4fb227a0 100644 --- a/core/genesis/genesis.go +++ b/core/genesis/genesis.go @@ -126,7 +126,7 @@ func BuildGenesisBlock(defaultBookkeeper []keypair.PublicKey, genesisConfig *con func newGoverningToken() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.OntContractAddress[:], "ONT", "1.0", - "Ontology Team", "contact@ont.io", "Ontology Network ONT Token", payload.NEOVM_TYPE) + "DNA Dev Team", "contact@ont.io", "Blockchain Network ONT Token", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") } @@ -139,7 +139,7 @@ func newGoverningToken() *types.Transaction { func newUtilityToken() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.OngContractAddress[:], "ONG", "1.0", - "Ontology Team", "contact@ont.io", "Ontology Network ONG Token", payload.NEOVM_TYPE) + "DNA Dev Team", "contact@onchain.com", "Blockchain Network Gas", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") } @@ -152,7 +152,7 @@ func newUtilityToken() *types.Transaction { func newParamContract() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.ParamContractAddress[:], - "ParamConfig", "1.0", "Ontology Team", "contact@ont.io", + "ParamConfig", "1.0", "DNA Dev Team", "contact@onchain.com", "Chain Global Environment Variables Manager ", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") @@ -166,7 +166,7 @@ func newParamContract() *types.Transaction { func newGovConfigTx() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.GovernanceContractAddress[:], "CONFIG", "1.0", - "Ontology Team", "contact@ont.io", "Ontology Network Consensus Config", payload.NEOVM_TYPE) + "DNA Dev Team", "contact@ont.io", "Blockchain Network Consensus Config", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") } @@ -179,7 +179,7 @@ func newGovConfigTx() *types.Transaction { func deployAuthContract() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.AuthContractAddress[:], "AuthContract", "1.0", - "Ontology Team", "contact@ont.io", "Ontology Network Authorization Contract", payload.NEOVM_TYPE) + "DNA Dev Team", "contact@ont.io", "Blockchain Network Authorization Contract", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") } @@ -192,7 +192,7 @@ func deployAuthContract() *types.Transaction { func deployOntIDContract() *types.Transaction { mutable, err := utils.NewDeployTransaction(nutils.OntIDContractAddress[:], "OID", "1.0", - "Ontology Team", "contact@ont.io", "Ontology Network ONT ID", payload.NEOVM_TYPE) + "DNA Dev Team", "contact@ont.io", "Blockchain Network ONT ID", payload.NEOVM_TYPE) if err != nil { panic("[NewDeployTransaction] construct genesis governing token transaction error ") } diff --git a/core/utils/transaction_builder.go b/core/utils/transaction_builder.go index 7a68b5ec..7c3b048d 100644 --- a/core/utils/transaction_builder.go +++ b/core/utils/transaction_builder.go @@ -36,7 +36,7 @@ import ( vm "github.com/DNAProject/DNA/vm/neovm" ) -const NATIVE_INVOKE_NAME = "Ontology.Native.Invoke" // copy from smartcontract/service/neovm/config.go to avoid cycle dependences +const NATIVE_INVOKE_NAME = "System.Native.Invoke" // copy from smartcontract/service/neovm/config.go to avoid cycle dependences // NewDeployTransaction returns a deploy Transaction func NewDeployTransaction(code []byte, name, version, author, email, desp string, vmType payload.VmType) (*types.MutableTransaction, error) { diff --git a/docker/Dockerfile b/docker/Dockerfile index 3f94ca85..dc209805 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,9 +1,9 @@ FROM tianon/ubuntu-core:14.04 -ENV ONTOLOGY_PATH /var/ontology -RUN mkdir -p $ONTOLOGY_PATH -COPY ontology $ONTOLOGY_PATH +ENV BLOCKCHAIN_PATH /var/blockchain +RUN mkdir -p $BLOCKCHAIN_PATH +COPY DNA $BLOCKCHAIN_PATH EXPOSE 20334 20335 20336 20337 20338 20339 -WORKDIR $ONTOLOGY_PATH -ENTRYPOINT ["./ontology"] +WORKDIR $BLOCKCHAIN_PATH +ENTRYPOINT ["./DNA"] diff --git a/go.sum b/go.sum index e5388d4b..d712d4e4 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1 github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= @@ -54,12 +55,14 @@ github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THr github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= diff --git a/main.go b/main.go index 16876685..9fc7a777 100644 --- a/main.go +++ b/main.go @@ -31,10 +31,6 @@ import ( "syscall" "time" - "github.com/ethereum/go-ethereum/common/fdlimit" - "github.com/ontio/ontology-crypto/keypair" - "github.com/ontio/ontology-eventbus/actor" - alog "github.com/ontio/ontology-eventbus/log" "github.com/DNAProject/DNA/account" "github.com/DNAProject/DNA/cmd" cmdcom "github.com/DNAProject/DNA/cmd/common" @@ -61,6 +57,10 @@ import ( "github.com/DNAProject/DNA/txnpool/proc" "github.com/DNAProject/DNA/validator/stateful" "github.com/DNAProject/DNA/validator/stateless" + "github.com/ethereum/go-ethereum/common/fdlimit" + "github.com/ontio/ontology-crypto/keypair" + "github.com/ontio/ontology-eventbus/actor" + alog "github.com/ontio/ontology-eventbus/log" "github.com/urfave/cli" ) @@ -212,9 +212,9 @@ func initLog(ctx *cli.Context) { } } -func initConfig(ctx *cli.Context) (*config.OntologyConfig, error) { +func initConfig(ctx *cli.Context) (*config.BlockchainConfig, error) { //init ontology config from cli - cfg, err := cmd.SetOntologyConfig(ctx) + cfg, err := cmd.SetBlockchainConfig(ctx) if err != nil { return nil, err } diff --git a/smartcontract/service/neovm/config.go b/smartcontract/service/neovm/config.go index 06591284..c23b3b7d 100644 --- a/smartcontract/service/neovm/config.go +++ b/smartcontract/service/neovm/config.go @@ -59,8 +59,8 @@ var ( VM_STEP_LIMIT int = 400000 // API Name - ATTRIBUTE_GETUSAGE_NAME = "Ontology.Attribute.GetUsage" - ATTRIBUTE_GETDATA_NAME = "Ontology.Attribute.GetData" + ATTRIBUTE_GETUSAGE_NAME = "System.Attribute.GetUsage" + ATTRIBUTE_GETDATA_NAME = "System.Attribute.GetData" BLOCK_GETTRANSACTIONCOUNT_NAME = "System.Block.GetTransactionCount" BLOCK_GETTRANSACTIONS_NAME = "System.Block.GetTransactions" @@ -74,22 +74,22 @@ var ( HEADER_GETINDEX_NAME = "System.Header.GetIndex" HEADER_GETHASH_NAME = "System.Header.GetHash" - HEADER_GETVERSION_NAME = "Ontology.Header.GetVersion" + HEADER_GETVERSION_NAME = "System.Header.GetVersion" HEADER_GETPREVHASH_NAME = "System.Header.GetPrevHash" HEADER_GETTIMESTAMP_NAME = "System.Header.GetTimestamp" - HEADER_GETCONSENSUSDATA_NAME = "Ontology.Header.GetConsensusData" - HEADER_GETNEXTCONSENSUS_NAME = "Ontology.Header.GetNextConsensus" - HEADER_GETMERKLEROOT_NAME = "Ontology.Header.GetMerkleRoot" + HEADER_GETCONSENSUSDATA_NAME = "System.Header.GetConsensusData" + HEADER_GETNEXTCONSENSUS_NAME = "System.Header.GetNextConsensus" + HEADER_GETMERKLEROOT_NAME = "System.Header.GetMerkleRoot" TRANSACTION_GETHASH_NAME = "System.Transaction.GetHash" - TRANSACTION_GETTYPE_NAME = "Ontology.Transaction.GetType" - TRANSACTION_GETATTRIBUTES_NAME = "Ontology.Transaction.GetAttributes" + TRANSACTION_GETTYPE_NAME = "System.Transaction.GetType" + TRANSACTION_GETATTRIBUTES_NAME = "System.Transaction.GetAttributes" - CONTRACT_CREATE_NAME = "Ontology.Contract.Create" - CONTRACT_MIGRATE_NAME = "Ontology.Contract.Migrate" + CONTRACT_CREATE_NAME = "System.Contract.Create" + CONTRACT_MIGRATE_NAME = "System.Contract.Migrate" CONTRACT_GETSTORAGECONTEXT_NAME = "System.Contract.GetStorageContext" CONTRACT_DESTROY_NAME = "System.Contract.Destroy" - CONTRACT_GETSCRIPT_NAME = "Ontology.Contract.GetScript" + CONTRACT_GETSCRIPT_NAME = "System.Contract.GetScript" STORAGE_GET_NAME = "System.Storage.Get" STORAGE_PUT_NAME = "System.Storage.Put" @@ -106,13 +106,13 @@ var ( RUNTIME_GETTRIGGER_NAME = "System.Runtime.GetTrigger" RUNTIME_SERIALIZE_NAME = "System.Runtime.Serialize" RUNTIME_DESERIALIZE_NAME = "System.Runtime.Deserialize" - RUNTIME_BASE58TOADDRESS_NAME = "Ontology.Runtime.Base58ToAddress" - RUNTIME_ADDRESSTOBASE58_NAME = "Ontology.Runtime.AddressToBase58" - RUNTIME_GETCURRENTBLOCKHASH_NAME = "Ontology.Runtime.GetCurrentBlockHash" - RUNTIME_VERIFYMUTISIG_NAME = "Ontology.Runtime.VerifyMutiSig" + RUNTIME_BASE58TOADDRESS_NAME = "System.Runtime.Base58ToAddress" + RUNTIME_ADDRESSTOBASE58_NAME = "System.Runtime.AddressToBase58" + RUNTIME_GETCURRENTBLOCKHASH_NAME = "System.Runtime.GetCurrentBlockHash" + RUNTIME_VERIFYMUTISIG_NAME = "System.Runtime.VerifyMutiSig" - NATIVE_INVOKE_NAME = "Ontology.Native.Invoke" - WASM_INVOKE_NAME = "Ontology.Wasm.InvokeWasm" + NATIVE_INVOKE_NAME = "System.Native.Invoke" + WASM_INVOKE_NAME = "System.Wasm.InvokeWasm" GETSCRIPTCONTAINER_NAME = "System.ExecutionEngine.GetScriptContainer" GETEXECUTINGSCRIPTHASH_NAME = "System.ExecutionEngine.GetExecutingScriptHash" diff --git a/smartcontract/test/verifysig_test.go b/smartcontract/test/verifysig_test.go index bdd0d307..997631e4 100644 --- a/smartcontract/test/verifysig_test.go +++ b/smartcontract/test/verifysig_test.go @@ -38,7 +38,7 @@ func TestVerifySig(t *testing.T) { /** # the code of source python. Cversion = '2.0.0' - from ontology.interop.Ontology.Runtime import VerifyMutiSig + from System.interop.System.Runtime import VerifyMutiSig def Main(data, pks_list, m, sig_list): return VerifyMutiSig(data, pks_list, m, sig_list)