From 1f571425131534ad58fc69a6391aec40773ce32a Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 18:22:33 +0900 Subject: [PATCH 01/27] Update strings, variables *klay* --- accounts/abi/bind/template.go | 22 ++-- accounts/keystore/keystore_plain_test.go | 2 +- accounts/keystore/keystore_test.go | 2 +- accounts/url_test.go | 38 +++---- api/api_ethereum.go | 20 ++-- api/api_private_account_test.go | 2 +- api/api_public_transaction_pool_test.go | 2 +- blockchain/bench_test.go | 2 +- cmd/abigen/main.go | 8 +- cmd/homi/common/utils.go | 2 +- cmd/utils/flags.go | 4 +- cmd/utils/nodecmd/accountcmd.go | 4 +- cmd/utils/nodecmd/accountcmd_test.go | 104 +++++++++--------- cmd/utils/nodecmd/consolecmd_test.go | 52 ++++----- cmd/utils/nodecmd/flags_test.go | 18 +-- cmd/utils/nodecmd/genesis_test.go | 10 +- cmd/utils/nodecmd/migrationcmd.go | 2 +- cmd/utils/nodecmd/run_test.go | 12 +- cmd/utils/nodecmd/snapshot.go | 6 +- networks/rpc/http_datadog.go | 6 +- node/config.go | 2 +- node/sc/subbridge_test.go | 2 +- storage/database/child_chain_data_test.go | 14 ++- storage/database/database_test.go | 4 +- storage/database/dynamodb_test.go | 2 +- .../database/leveldb_bench_multidisks_test.go | 2 +- .../database/leveldb_bench_options_test.go | 2 +- storage/database/rocksdb_database_test.go | 2 +- tests/db_write_and_read_test.go | 2 +- tests/hard_fork_test.go | 2 +- tests/kip103_test.go | 2 +- tests/klay_blockchain_test.go | 2 +- tests/testutil_blockchain_test.go | 2 +- tests/tx_gas_calculation_test.go | 8 +- 34 files changed, 184 insertions(+), 182 deletions(-) diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index 1da4718ca7..a01011ee2b 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -159,7 +159,7 @@ var ( // Deprecated: Use {{.Type}}MetaData.Bin instead. var {{.Type}}Bin = {{.Type}}MetaData.Bin - // Deploy{{.Type}} deploys a new Klaytn contract, binding an instance of {{.Type}} to it. + // Deploy{{.Type}} deploys a new Kaia contract, binding an instance of {{.Type}} to it. func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type $structs}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) { parsed, err := {{.Type}}MetaData.GetAbi() if err != nil { @@ -180,29 +180,29 @@ var ( } {{end}} - // {{.Type}} is an auto generated Go binding around a Klaytn contract. + // {{.Type}} is an auto generated Go binding around a Kaia contract. type {{.Type}} struct { {{.Type}}Caller // Read-only binding to the contract {{.Type}}Transactor // Write-only binding to the contract {{.Type}}Filterer // Log filterer for contract events } - // {{.Type}}Caller is an auto generated read-only Go binding around a Klaytn contract. + // {{.Type}}Caller is an auto generated read-only Go binding around a Kaia contract. type {{.Type}}Caller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } - // {{.Type}}Transactor is an auto generated write-only Go binding around a Klaytn contract. + // {{.Type}}Transactor is an auto generated write-only Go binding around a Kaia contract. type {{.Type}}Transactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } - // {{.Type}}Filterer is an auto generated log filtering Go binding around a Klaytn contract events. + // {{.Type}}Filterer is an auto generated log filtering Go binding around a Kaia contract events. type {{.Type}}Filterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } - // {{.Type}}Session is an auto generated Go binding around a Klaytn contract, + // {{.Type}}Session is an auto generated Go binding around a Kaia contract, // with pre-set call and transact options. type {{.Type}}Session struct { Contract *{{.Type}} // Generic contract binding to set the session for @@ -210,31 +210,31 @@ var ( TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } - // {{.Type}}CallerSession is an auto generated read-only Go binding around a Klaytn contract, + // {{.Type}}CallerSession is an auto generated read-only Go binding around a Kaia contract, // with pre-set call options. type {{.Type}}CallerSession struct { Contract *{{.Type}}Caller // Generic contract caller binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session } - // {{.Type}}TransactorSession is an auto generated write-only Go binding around a Klaytn contract, + // {{.Type}}TransactorSession is an auto generated write-only Go binding around a Kaia contract, // with pre-set transact options. type {{.Type}}TransactorSession struct { Contract *{{.Type}}Transactor // Generic contract transactor binding to set the session for TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } - // {{.Type}}Raw is an auto generated low-level Go binding around a Klaytn contract. + // {{.Type}}Raw is an auto generated low-level Go binding around a Kaia contract. type {{.Type}}Raw struct { Contract *{{.Type}} // Generic contract binding to access the raw methods on } - // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around a Klaytn contract. + // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around a Kaia contract. type {{.Type}}CallerRaw struct { Contract *{{.Type}}Caller // Generic read-only contract binding to access the raw methods on } - // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around a Klaytn contract. + // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around a Kaia contract. type {{.Type}}TransactorRaw struct { Contract *{{.Type}}Transactor // Generic write-only contract binding to access the raw methods on } diff --git a/accounts/keystore/keystore_plain_test.go b/accounts/keystore/keystore_plain_test.go index b04c4ea219..38e81dee8d 100644 --- a/accounts/keystore/keystore_plain_test.go +++ b/accounts/keystore/keystore_plain_test.go @@ -35,7 +35,7 @@ import ( ) func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) { - d, err := os.MkdirTemp("", "klay-keystore-test") + d, err := os.MkdirTemp("", "kaia-test-keystore-") if err != nil { t.Fatal(err) } diff --git a/accounts/keystore/keystore_test.go b/accounts/keystore/keystore_test.go index 87198acba2..e0263bf8cc 100644 --- a/accounts/keystore/keystore_test.go +++ b/accounts/keystore/keystore_test.go @@ -468,7 +468,7 @@ func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) { } func tmpKeyStore(t *testing.T, encrypted bool) (string, *KeyStore) { - d, err := os.MkdirTemp("", "klay-keystore-test") + d, err := os.MkdirTemp("", "kaia-test-keystore-") if err != nil { t.Fatal(err) } diff --git a/accounts/url_test.go b/accounts/url_test.go index ceb56cfd68..14da84a708 100644 --- a/accounts/url_test.go +++ b/accounts/url_test.go @@ -21,56 +21,56 @@ import ( ) func TestURLParsing(t *testing.T) { - url, err := parseURL("https://klaytn.com") + url, err := parseURL("https://kaia.com") if err != nil { t.Errorf("unexpected error: %v", err) } if url.Scheme != "https" { t.Errorf("expected: %v, got: %v", "https", url.Scheme) } - if url.Path != "klaytn.com" { - t.Errorf("expected: %v, got: %v", "klaytn.com", url.Path) + if url.Path != "kaia.com" { + t.Errorf("expected: %v, got: %v", "kaia.com", url.Path) } - _, err = parseURL("klaytn.com") + _, err = parseURL("kaia.com") if err == nil { t.Error("expected err, got: nil") } } func TestURLString(t *testing.T) { - url := URL{Scheme: "https", Path: "klaytn.com"} - if url.String() != "https://klaytn.com" { - t.Errorf("expected: %v, got: %v", "https://klaytn.com", url.String()) + url := URL{Scheme: "https", Path: "kaia.com"} + if url.String() != "https://kaia.com" { + t.Errorf("expected: %v, got: %v", "https://kaia.com", url.String()) } - url = URL{Scheme: "", Path: "klaytn.com"} - if url.String() != "klaytn.com" { - t.Errorf("expected: %v, got: %v", "klaytn.com", url.String()) + url = URL{Scheme: "", Path: "kaia.com"} + if url.String() != "kaia.com" { + t.Errorf("expected: %v, got: %v", "kaia.com", url.String()) } } func TestURLMarshalJSON(t *testing.T) { - url := URL{Scheme: "https", Path: "klaytn.com"} + url := URL{Scheme: "https", Path: "kaia.com"} json, err := url.MarshalJSON() if err != nil { t.Errorf("unexpcted error: %v", err) } - if string(json) != "\"https://klaytn.com\"" { - t.Errorf("expected: %v, got: %v", "\"https://klaytn.com\"", string(json)) + if string(json) != "\"https://kaia.com\"" { + t.Errorf("expected: %v, got: %v", "\"https://kaia.com\"", string(json)) } } func TestURLUnmarshalJSON(t *testing.T) { url := &URL{} - err := url.UnmarshalJSON([]byte("\"https://klaytn.com\"")) + err := url.UnmarshalJSON([]byte("\"https://kaia.com\"")) if err != nil { t.Errorf("unexpcted error: %v", err) } if url.Scheme != "https" { t.Errorf("expected: %v, got: %v", "https", url.Scheme) } - if url.Path != "klaytn.com" { + if url.Path != "kaia.com" { t.Errorf("expected: %v, got: %v", "https", url.Path) } } @@ -81,10 +81,10 @@ func TestURLComparison(t *testing.T) { urlB URL expect int }{ - {URL{"https", "klaytn.com"}, URL{"https", "klaytn.com"}, 0}, - {URL{"http", "klaytn.com"}, URL{"https", "klaytn.com"}, -1}, - {URL{"https", "klaytn.com/a"}, URL{"https", "klaytn.com"}, 1}, - {URL{"https", "abc.org"}, URL{"https", "klaytn.com"}, -1}, + {URL{"https", "kaia.com"}, URL{"https", "kaia.com"}, 0}, + {URL{"http", "kaia.com"}, URL{"https", "kaia.com"}, -1}, + {URL{"https", "kaia.com/a"}, URL{"https", "kaia.com"}, 1}, + {URL{"https", "abc.org"}, URL{"https", "kaia.com"}, -1}, } for i, tt := range tests { diff --git a/api/api_ethereum.go b/api/api_ethereum.go index d76c6fb107..df523ee521 100644 --- a/api/api_ethereum.go +++ b/api/api_ethereum.go @@ -518,7 +518,7 @@ func (api *EthereumAPI) GetProof(ctx context.Context, address common.Address, st // * When blockNr is -2 the pending chain head is returned. func (api *EthereumAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error) { // In Ethereum, err is always nil because the backend of Ethereum always return nil. - klaytnHeader, err := api.publicBlockChainAPI.b.HeaderByNumber(ctx, number) + header, err := api.publicBlockChainAPI.b.HeaderByNumber(ctx, number) if err != nil { if strings.Contains(err.Error(), "does not exist") { return nil, nil @@ -526,7 +526,7 @@ func (api *EthereumAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockN return nil, err } inclMiner := number != rpc.PendingBlockNumber - response, err := api.rpcMarshalHeader(klaytnHeader, inclMiner) + response, err := api.rpcMarshalHeader(header, inclMiner) if err != nil { return nil, err } @@ -542,9 +542,9 @@ func (api *EthereumAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockN // GetHeaderByHash returns the requested header by hash. func (api *EthereumAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) map[string]interface{} { // In Ethereum, err is always nil because the backend of Ethereum always return nil. - klaytnHeader, _ := api.publicBlockChainAPI.b.HeaderByHash(ctx, hash) - if klaytnHeader != nil { - response, err := api.rpcMarshalHeader(klaytnHeader, true) + header, _ := api.publicBlockChainAPI.b.HeaderByHash(ctx, hash) + if header != nil { + response, err := api.rpcMarshalHeader(header, true) if err != nil { return nil } @@ -561,7 +561,7 @@ func (api *EthereumAPI) GetHeaderByHash(ctx context.Context, hash common.Hash) m func (api *EthereumAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { // Kaia backend returns error when there is no matched block but // Ethereum returns it as nil without error, so we should return is as nil when there is no matched block. - klaytnBlock, err := api.publicBlockChainAPI.b.BlockByNumber(ctx, number) + block, err := api.publicBlockChainAPI.b.BlockByNumber(ctx, number) if err != nil { if strings.Contains(err.Error(), "does not exist") { return nil, nil @@ -571,7 +571,7 @@ func (api *EthereumAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNu inclMiner := number != rpc.PendingBlockNumber inclTx := true - response, err := api.rpcMarshalBlock(klaytnBlock, inclMiner, inclTx, fullTx) + response, err := api.rpcMarshalBlock(block, inclMiner, inclTx, fullTx) if err == nil && number == rpc.PendingBlockNumber { // Pending blocks need to nil out a few fields for _, field := range []string{"hash", "nonce", "miner"} { @@ -586,14 +586,14 @@ func (api *EthereumAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNu func (api *EthereumAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) { // Kaia backend returns error when there is no matched block but // Ethereum returns it as nil without error, so we should return is as nil when there is no matched block. - klaytnBlock, err := api.publicBlockChainAPI.b.BlockByHash(ctx, hash) + block, err := api.publicBlockChainAPI.b.BlockByHash(ctx, hash) if err != nil { if strings.Contains(err.Error(), "does not exist") { return nil, nil } return nil, err } - return api.rpcMarshalBlock(klaytnBlock, true, true, fullTx) + return api.rpcMarshalBlock(block, true, true, fullTx) } // GetUncleByBlockNumberAndIndex returns nil because there is no uncle block in Kaia. @@ -1516,7 +1516,7 @@ func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error { feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.KLAY))) feeFloat, _ := feeEth.Float64() if feeFloat > cap { - return fmt.Errorf("tx fee (%.2f klay) exceeds the configured cap (%.2f klay)", feeFloat, cap) + return fmt.Errorf("tx fee (%.2f KAIA) exceeds the configured cap (%.2f KAIA)", feeFloat, cap) } return nil } diff --git a/api/api_private_account_test.go b/api/api_private_account_test.go index 83be611807..381e323115 100644 --- a/api/api_private_account_test.go +++ b/api/api_private_account_test.go @@ -34,7 +34,7 @@ func TestPrivateAccountAPI_ImportRawKey(t *testing.T) { // To get JSON files use below. // keydir := filepath.Join(".", "keystore") - keydir, err := os.MkdirTemp("", "klay-test") + keydir, err := os.MkdirTemp("", "kaia-test-api-") require.NoError(t, err) defer os.RemoveAll(keydir) diff --git a/api/api_public_transaction_pool_test.go b/api/api_public_transaction_pool_test.go index 0e353ac9dd..27be41eb64 100644 --- a/api/api_public_transaction_pool_test.go +++ b/api/api_public_transaction_pool_test.go @@ -71,7 +71,7 @@ func TestTxTypeSupport(t *testing.T) { chainConf := params.ChainConfig{ChainID: big.NewInt(1)} // generate a keystore and active accounts - dir, err := os.MkdirTemp("", "klay-keystore-test") + dir, err := os.MkdirTemp("", "kaia-test-tx-") if err != nil { t.Fatal(err) } diff --git a/blockchain/bench_test.go b/blockchain/bench_test.go index 17b9eba70c..ffc0486ee5 100644 --- a/blockchain/bench_test.go +++ b/blockchain/bench_test.go @@ -359,7 +359,7 @@ func benchReadChain(b *testing.B, full bool, databaseType database.DBType, count // genTempDirForDB returns temp dir for database func genTempDirForDB(b *testing.B) string { - dir, err := os.MkdirTemp("", "klay-blockchain-bench") + dir, err := os.MkdirTemp("", "kaia-test-bench-blockchain-") if err != nil { b.Fatalf("cannot create temporary directory: %v", err) } diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go index a9cfad56f1..3346e0e216 100644 --- a/cmd/abigen/main.go +++ b/cmd/abigen/main.go @@ -58,11 +58,11 @@ var ( // Flags needed by abigen abiFlag = &cli.StringFlag{ Name: "abi", - Usage: "Path to the Klaytn contract ABI json to bind, - for STDIN", + Usage: "Path to the Kaia contract ABI json to bind, - for STDIN", } binFlag = &cli.StringFlag{ Name: "bin", - Usage: "Path to the Klaytn contract bytecode (generate deploy method)", + Usage: "Path to the Kaia contract bytecode (generate deploy method)", } binruntimeFlag = &cli.StringFlag{ Name: "binruntime", @@ -78,7 +78,7 @@ var ( } solFlag = &cli.StringFlag{ Name: "sol", - Usage: "Path to the Klaytn contract Solidity source to build and bind", + Usage: "Path to the Kaia contract Solidity source to build and bind", } solcFlag = &cli.StringFlag{ Name: "solc", @@ -109,7 +109,7 @@ var ( ) func init() { - app = utils.NewApp(gitCommit, "klaytn checkpoint helper tool") + app = utils.NewApp(gitCommit, "Kaia checkpoint helper tool") app.Flags = []cli.Flag{ abiFlag, binFlag, diff --git a/cmd/homi/common/utils.go b/cmd/homi/common/utils.go index a443e5309d..41697019eb 100644 --- a/cmd/homi/common/utils.go +++ b/cmd/homi/common/utils.go @@ -39,7 +39,7 @@ import ( const ( defaultLocalDir = "/tmp/kdata" - clientIdentifier = "klay" + clientIdentifier = "kaia" ) var logger = log.NewModuleLogger(log.CMDIstanbul) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index babdbbc944..780d62e3c9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -844,7 +844,7 @@ var ( } RPCGlobalEthTxFeeCapFlag = &cli.Float64Flag{ Name: "rpc.ethtxfeecap", - Usage: "Sets a cap on transaction fee (=gasLimit*gasPrice) (in klay) in eth_signTransaction (0 = no cap)", + Usage: "Sets a cap on transaction fee (=gasLimit*gasPrice) (in KAIA) in eth_signTransaction (0 = no cap)", Aliases: []string{"http-rpc.eth-tx-feecap"}, EnvVars: []string{"KLAYTN_RPC_ETHTXFEECAP"}, Category: "API AND CONSOLE", @@ -1830,7 +1830,7 @@ var ( } DstDynamoDBTableNameFlag = &cli.StringFlag{ Name: "db.dst.dynamo.tablename", - Usage: "Specifies DynamoDB table name. This is mandatory to use dynamoDB. (Set dbtype to use DynamoDBS3). If dstDB is singleDB, tableName should be in form of 'PREFIX-TABLENAME'.(e.g. 'klaytn-misc', 'klaytn-statetrie')", + Usage: "Specifies DynamoDB table name. This is mandatory to use dynamoDB. (Set dbtype to use DynamoDBS3). If dstDB is singleDB, tableName should be in form of 'PREFIX-TABLENAME'.(e.g. 'kaia-misc', 'kaia-statetrie')", Aliases: []string{"migration.dst.db.dynamo.table-name"}, EnvVars: []string{"KLAYTN_DB_DST_DYNAMO_TABLENAME"}, Category: "DATABASE MIGRATION", diff --git a/cmd/utils/nodecmd/accountcmd.go b/cmd/utils/nodecmd/accountcmd.go index 3031c81fb5..6325e120fc 100644 --- a/cmd/utils/nodecmd/accountcmd.go +++ b/cmd/utils/nodecmd/accountcmd.go @@ -61,7 +61,7 @@ Note that exporting your key in unencrypted format is NOT supported. Keys are stored under /keystore. It is safe to transfer the entire directory or the individual keys therein -between klay nodes by simply copying. +between Kaia nodes by simply copying. Make sure you backup your keys regularly.`, Before: beforeAccountCmd, @@ -148,7 +148,7 @@ You must remember this passphrase to unlock your account in the future. For non-interactive use the passphrase can be specified with the --password flag: -Note, as you can directly copy your encrypted accounts to another klay instance, +Note, as you can directly copy your encrypted accounts to another Kaia instance, this import mechanism is not needed when you transfer an account between nodes. `, diff --git a/cmd/utils/nodecmd/accountcmd_test.go b/cmd/utils/nodecmd/accountcmd_test.go index 3399104152..a3de8108bc 100644 --- a/cmd/utils/nodecmd/accountcmd_test.go +++ b/cmd/utils/nodecmd/accountcmd_test.go @@ -50,22 +50,22 @@ func tmpDatadirWithKeystore(t *testing.T) string { } func TestAccountListEmpty(t *testing.T) { - klay := runKlay(t, "klay-test", "account", "list") - klay.ExpectExit() + kaia := runKaia(t, "kaia-test", "account", "list") + kaia.ExpectExit() } func TestAccountList(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", "account", "list", "--datadir", datadir) - defer klay.ExpectExit() + kaia := runKaia(t, "kaia-test", "account", "list", "--datadir", datadir) + defer kaia.ExpectExit() if runtime.GOOS == "windows" { - klay.Expect(` + kaia.Expect(` Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}\keystore\UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}\keystore\aaa Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\keystore\zzz `) } else { - klay.Expect(` + kaia.Expect(` Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}/keystore/aaa Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/keystore/zzz @@ -74,21 +74,21 @@ Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/k } func TestAccountNew(t *testing.T) { - klay := runKlay(t, "klay-test", "account", "new", "--lightkdf") - defer klay.ExpectExit() - klay.Expect(` + kaia := runKaia(t, "kaia-test", "account", "new", "--lightkdf") + defer kaia.ExpectExit() + kaia.Expect(` Your new account is locked with a password. Please give a password. Do not forget this password. !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "foobar"}} Repeat passphrase: {{.InputLine "foobar"}} `) - klay.ExpectRegexp(`Address: \{[0-9a-f]{40}\}\n`) + kaia.ExpectRegexp(`Address: \{[0-9a-f]{40}\}\n`) } func TestAccountNewBadRepeat(t *testing.T) { - klay := runKlay(t, "klay-test", "account", "new", "--lightkdf") - defer klay.ExpectExit() - klay.Expect(` + kaia := runKaia(t, "kaia-test", "account", "new", "--lightkdf") + defer kaia.ExpectExit() + kaia.Expect(` Your new account is locked with a password. Please give a password. Do not forget this password. !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "something"}} @@ -99,11 +99,11 @@ Fatal: Passphrases do not match func TestAccountUpdate(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", "account", "update", + kaia := runKaia(t, "kaia-test", "account", "update", "--datadir", datadir, "--lightkdf", "f466859ead1932d743d622cb74fc058882e8648a") - defer klay.ExpectExit() - klay.Expect(` + defer kaia.ExpectExit() + kaia.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "foobar"}} @@ -115,23 +115,23 @@ Repeat passphrase: {{.InputLine "foobar2"}} func TestUnlockFlag(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "js", "testdata/empty.js") - klay.Expect(` + kaia.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "foobar"}} `) - klay.ExpectExit() + kaia.ExpectExit() wantMessages := []string{ "Unlocked account", "0xf466859eAD1932D743d622CB74FC058882E8648A", } for _, m := range wantMessages { - if !strings.Contains(klay.StderrText(), m) { + if !strings.Contains(kaia.StderrText(), m) { t.Errorf("stderr text does not contain %q", m) } } @@ -139,11 +139,11 @@ Passphrase: {{.InputLine "foobar"}} func TestUnlockFlagWrongPassword(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--unlock", "f466859ead1932d743d622cb74fc058882e8648a") - defer klay.ExpectExit() - klay.Expect(` + defer kaia.ExpectExit() + kaia.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "wrong1"}} @@ -158,18 +158,18 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could // https://github.com/ethereum/go-ethereum/issues/1785 func TestUnlockFlagMultiIndex(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--unlock", "0,2", "js", "testdata/empty.js") - klay.Expect(` + kaia.Expect(` Unlocking account 0 | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "foobar"}} Unlocking account 2 | Attempt 1/3 Passphrase: {{.InputLine "foobar"}} `) - klay.ExpectExit() + kaia.ExpectExit() wantMessages := []string{ "Unlocked account", @@ -177,7 +177,7 @@ Passphrase: {{.InputLine "foobar"}} "0x289d485D9771714CCe91D3393D764E1311907ACc", } for _, m := range wantMessages { - if !strings.Contains(klay.StderrText(), m) { + if !strings.Contains(kaia.StderrText(), m) { t.Errorf("stderr text does not contain %q", m) } } @@ -185,11 +185,11 @@ Passphrase: {{.InputLine "foobar"}} func TestUnlockFlagPasswordFile(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--password", "testdata/passwords.txt", "--unlock", "0,2", "js", "testdata/empty.js") - klay.ExpectExit() + kaia.ExpectExit() wantMessages := []string{ "Unlocked account", @@ -197,7 +197,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) { "0x289d485D9771714CCe91D3393D764E1311907ACc", } for _, m := range wantMessages { - if !strings.Contains(klay.StderrText(), m) { + if !strings.Contains(kaia.StderrText(), m) { t.Errorf("stderr text does not contain %q", m) } } @@ -205,29 +205,29 @@ func TestUnlockFlagPasswordFile(t *testing.T) { func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) { datadir := tmpDatadirWithKeystore(t) - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--password", "testdata/wrong-passwords.txt", "--unlock", "0,2") - defer klay.ExpectExit() - klay.Expect(` + defer kaia.ExpectExit() + kaia.Expect(` Fatal: Failed to unlock account 0 (could not decrypt key with given passphrase) `) } func TestUnlockFlagAmbiguous(t *testing.T) { store := filepath.Join("..", "..", "..", "accounts", "keystore", "testdata", "dupes") - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--keystore", store, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "js", "testdata/empty.js") - defer klay.ExpectExit() + defer kaia.ExpectExit() // Helper for the expect template, returns absolute keystore path. - klay.SetTemplateFunc("keypath", func(file string) string { + kaia.SetTemplateFunc("keypath", func(file string) string { abs, _ := filepath.Abs(filepath.Join(store, file)) return abs }) - klay.Expect(` + kaia.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "foobar"}} @@ -239,14 +239,14 @@ Your passphrase unlocked keystore://{{keypath "1"}} In order to avoid this warning, you need to remove the following duplicate key files: keystore://{{keypath "2"}} `) - klay.ExpectExit() + kaia.ExpectExit() wantMessages := []string{ "Unlocked account", "0xf466859eAD1932D743d622CB74FC058882E8648A", } for _, m := range wantMessages { - if !strings.Contains(klay.StderrText(), m) { + if !strings.Contains(kaia.StderrText(), m) { t.Errorf("stderr text does not contain %q", m) } } @@ -254,17 +254,17 @@ In order to avoid this warning, you need to remove the following duplicate key f func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) { store := filepath.Join("..", "..", "..", "accounts", "keystore", "testdata", "dupes") - klay := runKlay(t, "klay-test", + kaia := runKaia(t, "kaia-test", "--keystore", store, "--nat", "none", "--nodiscover", "--maxconnections", "0", "--port", "0", "--unlock", "f466859ead1932d743d622cb74fc058882e8648a") - defer klay.ExpectExit() + defer kaia.ExpectExit() // Helper for the expect template, returns absolute keystore path. - klay.SetTemplateFunc("keypath", func(file string) string { + kaia.SetTemplateFunc("keypath", func(file string) string { abs, _ := filepath.Abs(filepath.Join(store, file)) return abs }) - klay.Expect(` + kaia.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. Passphrase: {{.InputLine "wrong"}} @@ -274,7 +274,7 @@ Multiple key files exist for address f466859ead1932d743d622cb74fc058882e8648a: Testing your passphrase against all of them... Fatal: None of the listed files could be unlocked. `) - klay.ExpectExit() + kaia.ExpectExit() } func TestBlsInfo(t *testing.T) { @@ -301,12 +301,12 @@ func TestBlsInfo(t *testing.T) { // Save nodekey before node starts assert.Nil(t, os.MkdirAll(filepath.Join(datadir, "klay"), 0o700)) assert.Nil(t, os.WriteFile(nodekeyPath, []byte(nodekeyHex), 0o400)) - server := runKlay(t, "klay-test", "--datadir", datadir, + server := runKaia(t, "kaia-test", "--datadir", datadir, "--netrestrict", "127.0.0.1/32", "--port", "0", "--verbosity", "2") time.Sleep(5 * time.Second) // Simple way to wait for the RPC endpoint to open os.Remove(outputPath) // delete before test, because otherwise the "already exists" error occurs - client := runKlay(t, "klay-test", "account", "bls-info", "--datadir", datadir) + client := runKaia(t, "kaia-test", "account", "bls-info", "--datadir", datadir) client.ExpectRegexp(expectPrint) content, err := os.ReadFile(outputPath) @@ -334,9 +334,9 @@ func TestBlsImport(t *testing.T) { defer os.RemoveAll(datadir) t.Logf("datadir: %s", datadir) - klay := runKlay(t, "klay-test", "account", "bls-import", "--datadir", datadir, + kaia := runKaia(t, "kaia-test", "account", "bls-import", "--datadir", datadir, "--bls-nodekeystore", keystorePath, "--password", passwordPath) - klay.ExpectRegexp(expectPrint) + kaia.ExpectRegexp(expectPrint) content, err := os.ReadFile(outputPath) assert.Nil(t, err) @@ -369,10 +369,10 @@ func TestBlsExport(t *testing.T) { assert.Nil(t, os.WriteFile(blsnodekeyPath, []byte(blsnodekeyHex), 0o400)) os.Remove(outputPath) // delete before test, because otherwise the "already exists" error occurs - klay := runKlay(t, "klay-test", "account", "bls-export", "--datadir", datadir) - klay.InputLine("1234") // Enter password - klay.InputLine("1234") // Confirm password - klay.ExpectRegexp(expectPrint) + kaia := runKaia(t, "kaia-test", "account", "bls-export", "--datadir", datadir) + kaia.InputLine("1234") // Enter password + kaia.InputLine("1234") // Confirm password + kaia.ExpectRegexp(expectPrint) content, err := os.ReadFile(outputPath) assert.Nil(t, err) diff --git a/cmd/utils/nodecmd/consolecmd_test.go b/cmd/utils/nodecmd/consolecmd_test.go index 60c9240b5a..e7d817f2d5 100644 --- a/cmd/utils/nodecmd/consolecmd_test.go +++ b/cmd/utils/nodecmd/consolecmd_test.go @@ -43,21 +43,21 @@ const ( // then terminated by closing the input stream. func TestConsoleWelcome(t *testing.T) { // Start a Kaia console, make sure it's cleaned up and terminate the console - klay := runKlay(t, - "klay-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", + kaia := runKaia(t, + "kaia-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "console") // Gather all the infos the welcome message needs to contain - klay.SetTemplateFunc("goos", func() string { return runtime.GOOS }) - klay.SetTemplateFunc("goarch", func() string { return runtime.GOARCH }) - klay.SetTemplateFunc("gover", runtime.Version) + kaia.SetTemplateFunc("goos", func() string { return runtime.GOOS }) + kaia.SetTemplateFunc("goarch", func() string { return runtime.GOARCH }) + kaia.SetTemplateFunc("gover", runtime.Version) // TODO: Fix as in testAttachWelcome() - klay.SetTemplateFunc("klayver", func() string { return params.VersionWithCommit("") }) - klay.SetTemplateFunc("apis", func() string { return ipcAPIs }) - klay.SetTemplateFunc("datadir", func() string { return klay.Datadir }) + kaia.SetTemplateFunc("klayver", func() string { return params.VersionWithCommit("") }) + kaia.SetTemplateFunc("apis", func() string { return ipcAPIs }) + kaia.SetTemplateFunc("datadir", func() string { return kaia.Datadir }) // Verify the actual welcome message to the required template - klay.Expect(` + kaia.Expect(` Welcome to the Klaytn JavaScript console! instance: Klaytn/{{klayver}}/{{goos}}-{{goarch}}/{{gover}} @@ -66,7 +66,7 @@ Welcome to the Klaytn JavaScript console! > {{.InputLine "exit"}} `) - klay.ExpectExit() + kaia.ExpectExit() } // Tests that a console can be attached to a running node via various means. @@ -82,46 +82,46 @@ func TestIPCAttachWelcome(t *testing.T) { } // Note: we need --shh because testAttachWelcome checks for default // list of ipc modules and shh is included there. - klay := runKlay(t, - "klay-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--ipcpath", ipc) + kaia := runKaia(t, + "kaia-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--ipcpath", ipc) waitForEndpoint(t, ipc, 10*time.Second) - testAttachWelcome(t, klay, "ipc:"+ipc, ipcAPIs) + testAttachWelcome(t, kaia, "ipc:"+ipc, ipcAPIs) - klay.Interrupt() - klay.Kill() + kaia.Interrupt() + kaia.Kill() } func TestHTTPAttachWelcome(t *testing.T) { port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P - klay := runKlay(t, - "klay-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--rpc", "--rpcport", port) + kaia := runKaia(t, + "kaia-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--rpc", "--rpcport", port) endpoint := "http://127.0.0.1:" + port waitForEndpoint(t, endpoint, 10*time.Second) - testAttachWelcome(t, klay, endpoint, httpAPIs) + testAttachWelcome(t, kaia, endpoint, httpAPIs) - klay.Interrupt() - klay.Kill() + kaia.Interrupt() + kaia.Kill() } func TestWSAttachWelcome(t *testing.T) { port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P - klay := runKlay(t, - "klay-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--ws", "--wsport", port) + kaia := runKaia(t, + "kaia-test", "--port", "0", "--maxconnections", "0", "--nodiscover", "--nat", "none", "--ws", "--wsport", port) endpoint := "ws://127.0.0.1:" + port waitForEndpoint(t, endpoint, 10*time.Second) - testAttachWelcome(t, klay, endpoint, httpAPIs) + testAttachWelcome(t, kaia, endpoint, httpAPIs) - klay.Interrupt() - klay.Kill() + kaia.Interrupt() + kaia.Kill() } func testAttachWelcome(t *testing.T, klay *testklay, endpoint, apis string) { // Attach to a running Kaia node and terminate immediately - attach := runKlay(t, "klay-test", "attach", endpoint) + attach := runKaia(t, "kaia-test", "attach", endpoint) defer attach.ExpectExit() attach.CloseStdin() diff --git a/cmd/utils/nodecmd/flags_test.go b/cmd/utils/nodecmd/flags_test.go index fd64747f9f..969fade067 100644 --- a/cmd/utils/nodecmd/flags_test.go +++ b/cmd/utils/nodecmd/flags_test.go @@ -780,10 +780,10 @@ func testFlags(t *testing.T, flag string, value string, idx int) { t.Fatalf("test %d: failed to write genesis file: %v", idx, err) } - runKlay(t, "klay-test-flag", "--verbosity", "0", "--datadir", datadir, "init", json).WaitExit() + runKaia(t, "kaia-test-flag", "--verbosity", "0", "--datadir", datadir, "init", json).WaitExit() - klay := runKlay(t, "klay-test-flag", "--datadir", datadir, flag, value) - klay.ExpectExit() + kaia := runKaia(t, "kaia-test-flag", "--datadir", datadir, flag, value) + kaia.ExpectExit() } func testWrongFlags(t *testing.T, flag string, value string, idx int, expectedError string) { @@ -795,10 +795,10 @@ func testWrongFlags(t *testing.T, flag string, value string, idx int, expectedEr t.Fatalf("test %d: failed to write genesis file: %v", idx, err) } - runKlay(t, "klay-test-flag", "--verbosity", "0", "--datadir", datadir, "init", json).WaitExit() + runKaia(t, "kaia-test-flag", "--verbosity", "0", "--datadir", datadir, "init", json).WaitExit() - klay := runKlay(t, "klay-test-flag", "--datadir", datadir, flag, value) - klay.ExpectRegexp(expectedError) + kaia := runKaia(t, "kaia-test-flag", "--datadir", datadir, flag, value) + kaia.ExpectRegexp(expectedError) } func TestFlags(t *testing.T) { @@ -811,17 +811,17 @@ func TestFlags(t *testing.T) { for idx, fwv := range flagsWithValues { switch fwv.flagType { case FlagTypeBoolean: - t.Run("klay-test-flag"+fwv.flag, func(t *testing.T) { + t.Run("kaia-test-flag"+fwv.flag, func(t *testing.T) { testFlags(t, fwv.flag, "", idx) }) case FlagTypeArgument: for _, item := range fwv.values { - t.Run("klay-test-flag"+fwv.flag+"-"+item, func(t *testing.T) { + t.Run("kaia-test-flag"+fwv.flag+"-"+item, func(t *testing.T) { testFlags(t, fwv.flag, item, idx) }) } for idx2, wrongItem := range fwv.wrongValues { - t.Run("klay-test-flag"+fwv.flag+"-"+wrongItem, func(t *testing.T) { + t.Run("kaia-test-flag"+fwv.flag+"-"+wrongItem, func(t *testing.T) { testWrongFlags(t, fwv.flag, wrongItem, idx, expectedError[fwv.errors[idx2]]) }) } diff --git a/cmd/utils/nodecmd/genesis_test.go b/cmd/utils/nodecmd/genesis_test.go index 1dc34f9d7c..f32a6304bd 100644 --- a/cmd/utils/nodecmd/genesis_test.go +++ b/cmd/utils/nodecmd/genesis_test.go @@ -172,19 +172,19 @@ func TestCustomGenesis(t *testing.T) { if err := os.WriteFile(json, []byte(tt.genesis), 0o600); err != nil { t.Fatalf("test %d: failed to write genesis file: %v", i, err) } - runKlay(t, "klay-test", "--datadir", datadir, "--verbosity", "0", "init", json).WaitExit() + runKaia(t, "kaia-test", "--datadir", datadir, "--verbosity", "0", "init", json).WaitExit() // Query the custom genesis block if len(tt.query) != len(tt.result) { t.Errorf("Test cases are wrong, #query: %v, #result, %v", len(tt.query), len(tt.result)) } for idx, query := range tt.query { - klay := runKlay(t, - "klay-test", "--datadir", datadir, "--maxconnections", "0", "--port", "0", + kaia := runKaia(t, + "kaia-test", "--datadir", datadir, "--maxconnections", "0", "--port", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--ntp.disable", "--exec", query, "--verbosity", "0", "console") - klay.ExpectRegexp(tt.result[idx]) - klay.ExpectExit() + kaia.ExpectRegexp(tt.result[idx]) + kaia.ExpectExit() } } } diff --git a/cmd/utils/nodecmd/migrationcmd.go b/cmd/utils/nodecmd/migrationcmd.go index c283a8ebc6..c57db778ae 100644 --- a/cmd/utils/nodecmd/migrationcmd.go +++ b/cmd/utils/nodecmd/migrationcmd.go @@ -54,7 +54,7 @@ Even if db dir names are changed in srcDB, the original db dir names are used in (e.g. use 'statetrie' instead of 'statetrie_migrated_xxxxx') If dst db is singleDB, you should set dst.datadir or db.dst.dynamo.tablename to the original db dir name. -(e.g. Data dir : 'chaindata/klay/statetrie', Dynamo table name : 'klaytn-statetrie') +(e.g. Data dir : 'chaindata/kaia/statetrie', Dynamo table name : 'kaia-statetrie') Note: This feature is only provided when srcDB is single LevelDB.`, }, diff --git a/cmd/utils/nodecmd/run_test.go b/cmd/utils/nodecmd/run_test.go index 64a887137d..b01cf1d2ab 100644 --- a/cmd/utils/nodecmd/run_test.go +++ b/cmd/utils/nodecmd/run_test.go @@ -40,7 +40,7 @@ import ( ) func tmpdir(t *testing.T) string { - dir, err := os.MkdirTemp("", "klay-test") + dir, err := os.MkdirTemp("", "kaia-test-") if err != nil { t.Fatal(err) } @@ -57,7 +57,7 @@ type testklay struct { var ( // The app that holds all commands and flags. - app = utils.NewApp(GetGitCommit(), "the Klaytn command line interface") + app = utils.NewApp(GetGitCommit(), "the Kaia command line interface") // flags that configure the node nodeFlags = utils.CommonNodeFlags @@ -110,15 +110,15 @@ func init() { return nil } - // Run the app if we've been exec'd as "klay-test" in runKlay. - reexec.Register("klay-test", func() { + // Run the app if we've been exec'd as "kaia-test" in runKaia. + reexec.Register("kaia-test", func() { if err := app.Run(os.Args); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } os.Exit(0) }) - reexec.Register("klay-test-flag", func() { + reexec.Register("kaia-test-flag", func() { app.Action = RunTestKlaytnNode if err := app.Run(os.Args); err != nil { fmt.Fprintln(os.Stderr, err) @@ -138,7 +138,7 @@ func TestMain(m *testing.M) { // spawns Kaia with the given command line args. If the args don't set --datadir, the // child g gets a temporary data directory. -func runKlay(t *testing.T, name string, args ...string) *testklay { +func runKaia(t *testing.T, name string, args ...string) *testklay { tt := &testklay{} tt.TestCmd = utils.NewTestCmd(t, tt) for i, arg := range args { diff --git a/cmd/utils/nodecmd/snapshot.go b/cmd/utils/nodecmd/snapshot.go index 91784f65a7..4e98adf52d 100644 --- a/cmd/utils/nodecmd/snapshot.go +++ b/cmd/utils/nodecmd/snapshot.go @@ -48,7 +48,7 @@ var SnapshotCommand = &cli.Command{ Action: utils.MigrateFlags(verifyState), Flags: utils.SnapshotFlags, Description: ` -klay snapshot verify-state +Kaia snapshot verify-state will traverse the whole accounts and storages set based on the specified snapshot and recalculate the root hash of state for verification. In other words, this command does the snapshot to trie conversion. @@ -61,7 +61,7 @@ In other words, this command does the snapshot to trie conversion. Action: utils.MigrateFlags(traceTrie), Flags: utils.SnapshotFlags, Description: ` -klaytn statedb trace-trie +Kaia statedb trace-trie trace all account and storage nodes to find missing data during the migration process. Start tracing from the state root of the last block, @@ -75,7 +75,7 @@ reading all nodes and logging the missing nodes. Action: utils.MigrateFlags(iterateTrie), Flags: utils.SnapshotFlags, Description: ` -klaytn statedb iterate-triedb +Kaia statedb iterate-triedb Count the number of nodes in the state-trie db. `, }, diff --git a/networks/rpc/http_datadog.go b/networks/rpc/http_datadog.go index d56ac3514f..4bd878b6b7 100644 --- a/networks/rpc/http_datadog.go +++ b/networks/rpc/http_datadog.go @@ -47,10 +47,10 @@ func newDatadogTracer() *DatadogTracer { } service := os.Getenv("DD_SERVICE") - klaytnResponse := false + response := false if v := os.Getenv("DD_KLAYTN_RPC_RESPONSE"); v != "" { var err error - klaytnResponse, err = strconv.ParseBool(v) + response, err = strconv.ParseBool(v) if err != nil { return nil } @@ -59,7 +59,7 @@ func newDatadogTracer() *DatadogTracer { tracer.Start() logger.Info("Datadog APM trace is enabled", "serviceName", service) - return &DatadogTracer{tags, service, klaytnResponse} + return &DatadogTracer{tags, service, response} } func newDatadogHTTPHandler(ddTracer *DatadogTracer, handler http.Handler) http.Handler { diff --git a/node/config.go b/node/config.go index 3196634517..b506b148a6 100644 --- a/node/config.go +++ b/node/config.go @@ -283,7 +283,7 @@ func DefaultGRPCEndpoint() string { // NodeName returns the devp2p node identifier. func (c *Config) NodeName() string { name := c.name() - // Backwards compatibility: previous versions used title-cased "Kaia", keep that. + // Backwards compatibility: previous versions used title-cased "Klaytn", keep that. if name == "klay" || name == "klay-testnet" { name = "Klaytn" } diff --git a/node/sc/subbridge_test.go b/node/sc/subbridge_test.go index f43370fe92..83aa7b6da3 100644 --- a/node/sc/subbridge_test.go +++ b/node/sc/subbridge_test.go @@ -36,7 +36,7 @@ import ( // testNewSubBridge returns a test SubBridge. func testNewSubBridge(t *testing.T) *SubBridge { - tempDir, err := os.MkdirTemp(os.TempDir(), "klaytn-test-sb-") + tempDir, err := os.MkdirTemp(os.TempDir(), "kaia-test-sb-") if err != nil { t.Fatal(err) } diff --git a/storage/database/child_chain_data_test.go b/storage/database/child_chain_data_test.go index 9049fc3036..1253982679 100644 --- a/storage/database/child_chain_data_test.go +++ b/storage/database/child_chain_data_test.go @@ -26,8 +26,10 @@ import ( "github.com/stretchr/testify/assert" ) +const testDirPat = "kaia-test-child-chain-data-" + func TestChildChainData_ReadAndWrite_ChildChainTxHash(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } @@ -57,7 +59,7 @@ func TestChildChainData_ReadAndWrite_ChildChainTxHash(t *testing.T) { } func TestLastIndexedBlockData_ReadAndWrite_AnchoredBlockNumber(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } @@ -83,7 +85,7 @@ func TestLastIndexedBlockData_ReadAndWrite_AnchoredBlockNumber(t *testing.T) { } func TestChildChainData_ReadAndWrite_AnchoredBlockNumber(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } @@ -109,7 +111,7 @@ func TestChildChainData_ReadAndWrite_AnchoredBlockNumber(t *testing.T) { } func TestChildChainData_ReadAndWrite_ReceiptFromParentChain(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } @@ -141,7 +143,7 @@ func TestChildChainData_ReadAndWrite_ReceiptFromParentChain(t *testing.T) { } func TestChildChainData_ReadAndWrite_ValueTransferTxHash(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } @@ -171,7 +173,7 @@ func TestChildChainData_ReadAndWrite_ValueTransferTxHash(t *testing.T) { } func TestChildChainData_ReadAndWrite_OperatorFeePayer(t *testing.T) { - dir, err := os.MkdirTemp("", "klaytn-test-child-chain-data") + dir, err := os.MkdirTemp("", testDirPat) if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } diff --git a/storage/database/database_test.go b/storage/database/database_test.go index 950cadf9fb..dafebf4db9 100644 --- a/storage/database/database_test.go +++ b/storage/database/database_test.go @@ -38,7 +38,7 @@ import ( ) func newTestLDB() (Database, func(), string) { - dirName, err := os.MkdirTemp(os.TempDir(), "klay_leveldb_test_") + dirName, err := os.MkdirTemp(os.TempDir(), "kaia-test-leveldb-") if err != nil { panic("failed to create test file: " + err.Error()) } @@ -54,7 +54,7 @@ func newTestLDB() (Database, func(), string) { } func newTestBadgerDB() (Database, func(), string) { - dirName, err := os.MkdirTemp(os.TempDir(), "klay_badgerdb_test_") + dirName, err := os.MkdirTemp(os.TempDir(), "kaia-test-badgerdb-") if err != nil { panic("failed to create test file: " + err.Error()) } diff --git a/storage/database/dynamodb_test.go b/storage/database/dynamodb_test.go index 2f54675587..9b698cb81d 100644 --- a/storage/database/dynamodb_test.go +++ b/storage/database/dynamodb_test.go @@ -45,7 +45,7 @@ func GetTestDynamoConfig() *DynamoDBConfig { Region: "us-east-1", Endpoint: "http://localhost:4566", S3Endpoint: "http://localhost:4566", - TableName: "klaytn-default" + strconv.Itoa(time.Now().Nanosecond()), + TableName: "kaia-default" + strconv.Itoa(time.Now().Nanosecond()), IsProvisioned: false, ReadCapacityUnits: 10000, WriteCapacityUnits: 10000, diff --git a/storage/database/leveldb_bench_multidisks_test.go b/storage/database/leveldb_bench_multidisks_test.go index b84b5fbdb1..45f4882c70 100644 --- a/storage/database/leveldb_bench_multidisks_test.go +++ b/storage/database/leveldb_bench_multidisks_test.go @@ -43,7 +43,7 @@ func genDirForMDPTest(b *testing.B, numDisks, numShards int) []string { dirs := make([]string, numShards, numShards) for i := 0; i < numShards; i++ { diskNum := i % numDisks - dir, err := os.MkdirTemp(diskPaths[diskNum], "klaytn-db-bench-mdp") + dir, err := os.MkdirTemp(diskPaths[diskNum], "kaia-test-db-bench-mdp-") if err != nil { b.Fatalf("cannot create temporary directory: %v", err) } diff --git a/storage/database/leveldb_bench_options_test.go b/storage/database/leveldb_bench_options_test.go index 8a08e30a8b..2b8ac98202 100644 --- a/storage/database/leveldb_bench_options_test.go +++ b/storage/database/leveldb_bench_options_test.go @@ -29,7 +29,7 @@ import ( ) func genTempDirForTestDB(b *testing.B) string { - dir, err := os.MkdirTemp("", "klaytn-db-bench") + dir, err := os.MkdirTemp("", "kaia-test-db-bench-") if err != nil { b.Fatalf("cannot create temporary directory: %v", err) } diff --git a/storage/database/rocksdb_database_test.go b/storage/database/rocksdb_database_test.go index f55cd193fe..87a733cf6c 100644 --- a/storage/database/rocksdb_database_test.go +++ b/storage/database/rocksdb_database_test.go @@ -29,7 +29,7 @@ func init() { } func newTestRocksDB() (Database, func(), string) { - dirName, err := os.MkdirTemp(os.TempDir(), "klay_rocksdb_test_") + dirName, err := os.MkdirTemp(os.TempDir(), "kaia-test-rocksdb-") if err != nil { panic("failed to create test file: " + err.Error()) } diff --git a/tests/db_write_and_read_test.go b/tests/db_write_and_read_test.go index 86fcbfe99b..b90c0150e7 100644 --- a/tests/db_write_and_read_test.go +++ b/tests/db_write_and_read_test.go @@ -51,7 +51,7 @@ var testEntries = []testEntry{ // Sometimes 3) and 4) are omitted if such operation is not possible due to some reasons. func TestDBManager_WriteAndRead_Functional(t *testing.T) { for _, entry := range testEntries { - tempDir, err := os.MkdirTemp("", "klaytn-db-manager-test") + tempDir, err := os.MkdirTemp("", "kaia-test-db-manager-") if err != nil { t.Fatalf("cannot create temporary directory: %v", err) } diff --git a/tests/hard_fork_test.go b/tests/hard_fork_test.go index 02383d8ff2..43daabdbec 100644 --- a/tests/hard_fork_test.go +++ b/tests/hard_fork_test.go @@ -152,7 +152,7 @@ func genBlocks(t *testing.T) { Type string account TestAccount }{ - {"KlaytnLegacy", genKlaytnLegacyAccount(t)}, + {"KlaytnLegacy", genKaiaLegacyAccount(t)}, {"Public", genPublicAccount(t)}, {"MultiSig", genMultiSigAccount(t)}, {"RoleBasedWithPublic", genRoleBasedWithPublicAccount(t)}, diff --git a/tests/kip103_test.go b/tests/kip103_test.go index 913dc56855..312ebe6da7 100644 --- a/tests/kip103_test.go +++ b/tests/kip103_test.go @@ -71,7 +71,7 @@ func TestRebalanceTreasury_EOA(t *testing.T) { t.Log("Total Newbie amount: ", totalNewbieAlloc) for i := 0; i < numNewbie; i++ { - newbieAccs[i] = genKlaytnLegacyAccount(t) + newbieAccs[i] = genKaiaLegacyAccount(t) newbieAllocs[i] = new(big.Int).Div(totalNewbieAlloc, big.NewInt(2)) totalNewbieAlloc.Sub(totalNewbieAlloc, newbieAllocs[i]) diff --git a/tests/klay_blockchain_test.go b/tests/klay_blockchain_test.go index e3c8bf7a05..41dfb7b793 100644 --- a/tests/klay_blockchain_test.go +++ b/tests/klay_blockchain_test.go @@ -91,7 +91,7 @@ func TestSimpleBlockchain(t *testing.T) { func newBlockchain(t *testing.T, config *params.ChainConfig, genesis *blockchain.Genesis) (*node.Node, *cn.CN, *TestAccountType, *big.Int, string) { t.Log("Create a new blockchain") // Prepare workspace - workspace, err := os.MkdirTemp("", "klaytn-test-state") + workspace, err := os.MkdirTemp("", "kaia-test-state-") if err != nil { t.Fatalf("failed to create temporary keystore: %v", err) } diff --git a/tests/testutil_blockchain_test.go b/tests/testutil_blockchain_test.go index e5375996aa..34cd633aea 100644 --- a/tests/testutil_blockchain_test.go +++ b/tests/testutil_blockchain_test.go @@ -157,7 +157,7 @@ func (ctx *blockchainTestContext) setGenesis(alloc blockchain.GenesisAlloc) { } func (ctx *blockchainTestContext) setWorkspace() { - workspace, _ := os.MkdirTemp("", "klaytn-test-state") + workspace, _ := os.MkdirTemp("", "kaia-test-state-") ctx.workspace = workspace } diff --git a/tests/tx_gas_calculation_test.go b/tests/tx_gas_calculation_test.go index 827187d8a1..90e381f66f 100644 --- a/tests/tx_gas_calculation_test.go +++ b/tests/tx_gas_calculation_test.go @@ -89,7 +89,7 @@ func TestGasCalculation(t *testing.T) { Type string account TestAccount }{ - {"KlaytnLegacy", genKlaytnLegacyAccount(t)}, + {"KlaytnLegacy", genKaiaLegacyAccount(t)}, {"Public", genPublicAccount(t)}, {"MultiSig", genMultiSigAccount(t)}, {"RoleBasedWithPublic", genRoleBasedWithPublicAccount(t)}, @@ -891,12 +891,12 @@ func genMapForChainDataAnchoring(from TestAccount, gasPrice *big.Int, txType typ return values, intrinsic + gasPayload } -func genKlaytnLegacyAccount(t *testing.T) TestAccount { +func genKaiaLegacyAccount(t *testing.T) TestAccount { // For KlaytnLegacy - klaytnLegacy, err := createAnonymousAccount(getRandomPrivateKeyString(t)) + kaiaLegacy, err := createAnonymousAccount(getRandomPrivateKeyString(t)) assert.Equal(t, nil, err) - return klaytnLegacy + return kaiaLegacy } func genPublicAccount(t *testing.T) TestAccount { From c1222f6cd68885117f704a075b49b04b0b009ed7 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 19:53:37 +0900 Subject: [PATCH 02/27] Update strings, variables *Klay* and *KLAY* --- api/api_ethereum.go | 32 +++++++++++++------------- api/api_ethereum_test.go | 2 +- api/api_public_blockchain.go | 2 +- api/api_public_klay.go | 28 +++++++++++------------ api/backend.go | 6 ++--- cmd/homi/setup/cmd.go | 12 +++++----- cmd/homi/setup/flags.go | 10 ++++---- cmd/homi/setup/klaytn_config.go | 12 +++++----- cmd/kbn/main.go | 6 ++--- cmd/kcn/main.go | 6 ++--- cmd/ken/main.go | 6 ++--- cmd/kgen/main.go | 6 ++--- cmd/kpn/main.go | 6 ++--- cmd/kscn/main.go | 6 ++--- cmd/ksen/main.go | 6 ++--- cmd/kspn/main.go | 6 ++--- cmd/utils/flags.go | 8 +++---- cmd/utils/nodecmd/consolecmd_test.go | 4 ++-- cmd/utils/nodecmd/defaultcmd.go | 10 ++++---- cmd/utils/nodecmd/run_test.go | 2 +- console/console.go | 2 +- governance/api.go | 20 ++++++++-------- governance/api_test.go | 4 ++-- node/api.go | 14 ++++++------ node/cn/api.go | 12 +++++----- node/cn/backend.go | 8 +++---- node/node.go | 4 ++-- node/sc/bridge_manager_test.go | 34 ++++++++++++++-------------- node/sc/mainbridge_test.go | 2 +- tests/tx_gas_calculation_test.go | 8 +++---- 30 files changed, 142 insertions(+), 142 deletions(-) diff --git a/api/api_ethereum.go b/api/api_ethereum.go index df523ee521..85d29bc10a 100644 --- a/api/api_ethereum.go +++ b/api/api_ethereum.go @@ -65,9 +65,9 @@ var ( // TODO-Kaia: Removed unused variable type EthereumAPI struct { publicFilterAPI *filters.PublicFilterAPI - governanceKlayAPI *governance.GovernanceKlayAPI + governanceKaiaAPI *governance.GovernanceKaiaAPI - publicKlayAPI *PublicKlayAPI + publicKaiaAPI *PublicKaiaAPI publicBlockChainAPI *PublicBlockChainAPI publicTransactionPoolAPI *PublicTransactionPoolAPI publicAccountAPI *PublicAccountAPI @@ -87,14 +87,14 @@ func (api *EthereumAPI) SetPublicFilterAPI(publicFilterAPI *filters.PublicFilter api.publicFilterAPI = publicFilterAPI } -// SetGovernanceKlayAPI sets governanceKlayAPI -func (api *EthereumAPI) SetGovernanceKlayAPI(governanceKlayAPI *governance.GovernanceKlayAPI) { - api.governanceKlayAPI = governanceKlayAPI +// SetGovernanceKaiaAPI sets governanceKaiaAPI +func (api *EthereumAPI) SetGovernanceKaiaAPI(governanceKaiaAPI *governance.GovernanceKaiaAPI) { + api.governanceKaiaAPI = governanceKaiaAPI } -// SetPublicKlayAPI sets publicKlayAPI -func (api *EthereumAPI) SetPublicKlayAPI(publicKlayAPI *PublicKlayAPI) { - api.publicKlayAPI = publicKlayAPI +// SetPublicKaiaAPI sets publicKaiaAPI +func (api *EthereumAPI) SetPublicKaiaAPI(publicKaiaAPI *PublicKaiaAPI) { + api.publicKaiaAPI = publicKaiaAPI } // SetPublicBlockChainAPI sets publicBlockChainAPI @@ -304,20 +304,20 @@ func (api *EthereumAPI) GetFilterChanges(id rpc.ID) (interface{}, error) { // GasPrice returns a suggestion for a gas price. func (api *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { - return api.publicKlayAPI.GasPrice(ctx) + return api.publicKaiaAPI.GasPrice(ctx) } func (api *EthereumAPI) UpperBoundGasPrice(ctx context.Context) *hexutil.Big { - return (*hexutil.Big)(api.publicKlayAPI.UpperBoundGasPrice(ctx)) + return (*hexutil.Big)(api.publicKaiaAPI.UpperBoundGasPrice(ctx)) } func (api *EthereumAPI) LowerBoundGasPrice(ctx context.Context) *hexutil.Big { - return (*hexutil.Big)(api.publicKlayAPI.LowerBoundGasPrice(ctx)) + return (*hexutil.Big)(api.publicKaiaAPI.LowerBoundGasPrice(ctx)) } // MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions. func (api *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error) { - return api.publicKlayAPI.MaxPriorityFeePerGas(ctx) + return api.publicKaiaAPI.MaxPriorityFeePerGas(ctx) } // DecimalOrHex unmarshals a non-negative decimal or hex parameter into a uint64. @@ -342,7 +342,7 @@ func (dh *DecimalOrHex) UnmarshalJSON(data []byte) error { } func (api *EthereumAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error) { - return api.publicKlayAPI.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles) + return api.publicKaiaAPI.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles) } // Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not @@ -353,7 +353,7 @@ func (api *EthereumAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, // - pulledStates: number of state entries processed until now // - knownStates: number of known state entries that still need to be pulled func (api *EthereumAPI) Syncing() (interface{}, error) { - return api.publicKlayAPI.Syncing() + return api.publicKaiaAPI.Syncing() } // ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config. @@ -1303,7 +1303,7 @@ func (api *EthereumAPI) rpcMarshalHeader(head *types.Header, inclMiner bool) (ma var proposer common.Address var err error - b := api.publicKlayAPI.b + b := api.publicKaiaAPI.b if head.Number.Sign() != 0 && inclMiner { proposer, err = b.Engine().Author(head) if err != nil { @@ -1549,7 +1549,7 @@ func doCreateAccessList(ctx context.Context, b Backend, args EthTransactionArgs, // CreateAccessList creates an EIP-2930 type AccessList for the given transaction. // Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state. func (api *EthereumAPI) CreateAccessList(ctx context.Context, args EthTransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (interface{}, error) { - return doCreateAccessList(ctx, api.publicKlayAPI.b, args, blockNrOrHash) + return doCreateAccessList(ctx, api.publicKaiaAPI.b, args, blockNrOrHash) } // AccessList creates an access list for the given transaction. diff --git a/api/api_ethereum_test.go b/api/api_ethereum_test.go index 9dde3f2621..1d708a9142 100644 --- a/api/api_ethereum_test.go +++ b/api/api_ethereum_test.go @@ -990,7 +990,7 @@ func testInitForEthApi(t *testing.T) (*gomock.Controller, *mock_api.MockBackend, api := EthereumAPI{ publicTransactionPoolAPI: NewPublicTransactionPoolAPI(mockBackend, new(AddrLocker)), - publicKlayAPI: NewPublicKlayAPI(mockBackend), + publicKaiaAPI: NewPublicKaiaAPI(mockBackend), publicBlockChainAPI: NewPublicBlockChainAPI(mockBackend), } return mockCtrl, mockBackend, api diff --git a/api/api_public_blockchain.go b/api/api_public_blockchain.go index 9e69fae316..aa9f73fd42 100644 --- a/api/api_public_blockchain.go +++ b/api/api_public_blockchain.go @@ -151,7 +151,7 @@ func (s *PublicBlockChainAPI) GetAccount(ctx context.Context, address common.Add return serAcc, state.Error() } -func (s *PublicKlayAPI) ForkStatus(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error) { +func (s *PublicKaiaAPI) ForkStatus(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error) { block, err := s.b.BlockByNumber(ctx, number) if err != nil { return nil, err diff --git a/api/api_public_klay.go b/api/api_public_klay.go index 7400225917..29aa06af28 100644 --- a/api/api_public_klay.go +++ b/api/api_public_klay.go @@ -31,38 +31,38 @@ import ( "github.com/klaytn/klaytn/rlp" ) -// PublicKlayAPI provides an API to access Kaia related information. +// PublicKaiaAPI provides an API to access Kaia related information. // It offers only methods that operate on public data that is freely available to anyone. -type PublicKlayAPI struct { +type PublicKaiaAPI struct { b Backend } -// NewPublicKlayAPI creates a new Kaia protocol API. -func NewPublicKlayAPI(b Backend) *PublicKlayAPI { - return &PublicKlayAPI{b} +// NewPublicKaiaAPI creates a new Kaia protocol API. +func NewPublicKaiaAPI(b Backend) *PublicKaiaAPI { + return &PublicKaiaAPI{b} } // GasPrice returns a suggestion for a gas price (baseFee * 2). -func (s *PublicKlayAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { +func (s *PublicKaiaAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { price, err := s.b.SuggestPrice(ctx) return (*hexutil.Big)(price), err } -func (s *PublicKlayAPI) UpperBoundGasPrice(ctx context.Context) *hexutil.Big { +func (s *PublicKaiaAPI) UpperBoundGasPrice(ctx context.Context) *hexutil.Big { return (*hexutil.Big)(s.b.UpperBoundGasPrice(ctx)) } -func (s *PublicKlayAPI) LowerBoundGasPrice(ctx context.Context) *hexutil.Big { +func (s *PublicKaiaAPI) LowerBoundGasPrice(ctx context.Context) *hexutil.Big { return (*hexutil.Big)(s.b.LowerBoundGasPrice(ctx)) } // ProtocolVersion returns the current Kaia protocol version this node supports. -func (s *PublicKlayAPI) ProtocolVersion() hexutil.Uint { +func (s *PublicKaiaAPI) ProtocolVersion() hexutil.Uint { return hexutil.Uint(s.b.ProtocolVersion()) } // MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions. -func (s *PublicKlayAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error) { +func (s *PublicKaiaAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error) { price, err := s.b.SuggestTipCap(ctx) return (*hexutil.Big)(price), err } @@ -75,7 +75,7 @@ type FeeHistoryResult struct { } // FeeHistory returns data relevant for fee estimation based on the specified range of blocks. -func (s *PublicKlayAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error) { +func (s *PublicKaiaAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error) { oldest, reward, baseFee, gasUsed, err := s.b.FeeHistory(ctx, int(blockCount), lastBlock, rewardPercentiles) if err != nil { return nil, err @@ -109,7 +109,7 @@ func (s *PublicKlayAPI) FeeHistory(ctx context.Context, blockCount DecimalOrHex, // - highestBlock: block number of the highest block header this node has received from peers // - pulledStates: number of state entries processed until now // - knownStates: number of known state entries that still need to be pulled -func (s *PublicKlayAPI) Syncing() (interface{}, error) { +func (s *PublicKaiaAPI) Syncing() (interface{}, error) { progress := s.b.Progress() // Return not syncing if the synchronisation already completed @@ -127,7 +127,7 @@ func (s *PublicKlayAPI) Syncing() (interface{}, error) { } // EncodeAccountKey gets an account key of JSON format and returns RLP encoded bytes of the key. -func (s *PublicKlayAPI) EncodeAccountKey(accKey accountkey.AccountKeyJSON) (hexutil.Bytes, error) { +func (s *PublicKaiaAPI) EncodeAccountKey(accKey accountkey.AccountKeyJSON) (hexutil.Bytes, error) { if accKey.KeyType == nil { return nil, errors.New("key type is not specified") } @@ -152,7 +152,7 @@ func (s *PublicKlayAPI) EncodeAccountKey(accKey accountkey.AccountKeyJSON) (hexu } // DecodeAccountKey gets an RLP encoded bytes of an account key and returns the decoded account key. -func (s *PublicKlayAPI) DecodeAccountKey(encodedAccKey hexutil.Bytes) (*accountkey.AccountKeySerializer, error) { +func (s *PublicKaiaAPI) DecodeAccountKey(encodedAccKey hexutil.Bytes) (*accountkey.AccountKeySerializer, error) { dec := accountkey.NewAccountKeySerializer() if err := rlp.DecodeBytes(encodedAccKey, &dec); err != nil { return nil, err diff --git a/api/backend.go b/api/backend.go index fc8b9bf9df..4b61eae0ec 100644 --- a/api/backend.go +++ b/api/backend.go @@ -104,12 +104,12 @@ func GetAPIs(apiBackend Backend, disableUnsafeDebug bool) ([]rpc.API, *EthereumA ethAPI := NewEthereumAPI() - publicKlayAPI := NewPublicKlayAPI(apiBackend) + publicKaiaAPI := NewPublicKaiaAPI(apiBackend) publicBlockChainAPI := NewPublicBlockChainAPI(apiBackend) publicTransactionPoolAPI := NewPublicTransactionPoolAPI(apiBackend, nonceLock) publicAccountAPI := NewPublicAccountAPI(apiBackend.AccountManager()) - ethAPI.SetPublicKlayAPI(publicKlayAPI) + ethAPI.SetPublicKaiaAPI(publicKaiaAPI) ethAPI.SetPublicBlockChainAPI(publicBlockChainAPI) ethAPI.SetPublicTransactionPoolAPI(publicTransactionPoolAPI) ethAPI.SetPublicAccountAPI(publicAccountAPI) @@ -118,7 +118,7 @@ func GetAPIs(apiBackend Backend, disableUnsafeDebug bool) ([]rpc.API, *EthereumA { Namespace: "klay", Version: "1.0", - Service: publicKlayAPI, + Service: publicKaiaAPI, Public: true, }, { Namespace: "klay", diff --git a/cmd/homi/setup/cmd.go b/cmd/homi/setup/cmd.go index 5b3c57847e..fb367a36fb 100644 --- a/cmd/homi/setup/cmd.go +++ b/cmd/homi/setup/cmd.go @@ -142,14 +142,14 @@ var HomiFlags = []cli.Flag{ var SetupCommand = &cli.Command{ Name: "setup", - Usage: "Generate klaytn CN's init files", + Usage: "Generate Kaia CN's init files", Description: `This tool helps generate: * Genesis Block (genesis.json) * Static nodes for all CNs(Consensus Node) * CN details * Docker-compose - for Klaytn Consensus Node. + for Kaia Consensus Node. Args : type : [local | remote | deploy | docker (default)] @@ -872,9 +872,9 @@ func Gen(ctx *cli.Context) error { downLoadGrafanaJson() case TypeDeploy: writeCNInfoKey(cnNum, nodeAddrs, nodeKeys, privKeys, genesisJsonBytes) - writeKlayConfig(ctx.Int(networkIdFlag.Name), ctx.Int(rpcPortFlag.Name), ctx.Int(wsPortFlag.Name), ctx.Int(p2pPortFlag.Name), + writeKaiaConfig(ctx.Int(networkIdFlag.Name), ctx.Int(rpcPortFlag.Name), ctx.Int(wsPortFlag.Name), ctx.Int(p2pPortFlag.Name), ctx.String(dataDirFlag.Name), ctx.String(logDirFlag.Name), "CN") - writeKlayConfig(ctx.Int(networkIdFlag.Name), ctx.Int(rpcPortFlag.Name), ctx.Int(wsPortFlag.Name), ctx.Int(p2pPortFlag.Name), + writeKaiaConfig(ctx.Int(networkIdFlag.Name), ctx.Int(rpcPortFlag.Name), ctx.Int(wsPortFlag.Name), ctx.Int(p2pPortFlag.Name), ctx.String(dataDirFlag.Name), ctx.String(logDirFlag.Name), "PN") writePNInfoKey(ctx.Int(numOfPNsFlag.Name)) writePrometheusConfig(cnNum, ctx.Int(numOfPNsFlag.Name)) @@ -933,8 +933,8 @@ func writePNInfoKey(num int) { } } -func writeKlayConfig(networkId int, rpcPort int, wsPort int, p2pPort int, dataDir string, logDir string, nodeType string) { - kConfig := NewKlaytnConfig(networkId, rpcPort, wsPort, p2pPort, dataDir, logDir, "/var/run/klay", nodeType) +func writeKaiaConfig(networkId int, rpcPort int, wsPort int, p2pPort int, dataDir string, logDir string, nodeType string) { + kConfig := NewKaiaConfig(networkId, rpcPort, wsPort, p2pPort, dataDir, logDir, "/var/run/klay", nodeType) WriteFile([]byte(kConfig.String()), strings.ToLower(nodeType), "klay.conf") } diff --git a/cmd/homi/setup/flags.go b/cmd/homi/setup/flags.go index fe9d5602aa..4b7887ce6d 100644 --- a/cmd/homi/setup/flags.go +++ b/cmd/homi/setup/flags.go @@ -285,35 +285,35 @@ var ( rpcPortFlag = &cli.IntFlag{ Name: "rpc-port", - Usage: "klay.conf - Klaytn node's rpc port [default: 8551] ", + Usage: "klay.conf - Kaia node's rpc port [default: 8551] ", Value: 8551, Aliases: []string{"deploy.rpc-port"}, } wsPortFlag = &cli.IntFlag{ Name: "ws-port", - Usage: "klay.conf - Klaytn node's ws port [default: 8552]", + Usage: "klay.conf - Kaia node's ws port [default: 8552]", Value: 8552, Aliases: []string{"deploy.ws-port"}, } p2pPortFlag = &cli.IntFlag{ Name: "p2p-port", - Usage: "klay.conf - Klaytn node's p2p port [default: 32323]", + Usage: "klay.conf - Kaia node's p2p port [default: 32323]", Value: 32323, Aliases: []string{"deploy.p2p-port"}, } dataDirFlag = &cli.StringFlag{ Name: "data-dir", - Usage: "klay.conf - Klaytn node's data directory path [default : /var/klay/data]", + Usage: "klay.conf - Kaia node's data directory path [default : /var/klay/data]", Value: "/var/klay/data", Aliases: []string{"deploy.data-dir"}, } logDirFlag = &cli.StringFlag{ Name: "log-dir", - Usage: "klay.conf - Klaytn node's log directory path [default : /var/klay/log]", + Usage: "klay.conf - Kaia node's log directory path [default : /var/klay/log]", Value: "/var/klay/log", Aliases: []string{"deploy.log-dir"}, } diff --git a/cmd/homi/setup/klaytn_config.go b/cmd/homi/setup/klaytn_config.go index a24756e5d6..2fd7592e76 100644 --- a/cmd/homi/setup/klaytn_config.go +++ b/cmd/homi/setup/klaytn_config.go @@ -22,7 +22,7 @@ import ( "text/template" ) -type KlaytnConfig struct { +type KaiaConfig struct { NetworkId int RPCPort int WSPort int @@ -33,8 +33,8 @@ type KlaytnConfig struct { NodeType string } -func NewKlaytnConfig(networkId int, rpcPort int, wsPort int, p2pPort int, dataDir string, logDir string, runDir string, nodeType string) *KlaytnConfig { - kConf := &KlaytnConfig{ +func NewKaiaConfig(networkId int, rpcPort int, wsPort int, p2pPort int, dataDir string, logDir string, runDir string, nodeType string) *KaiaConfig { + kConf := &KaiaConfig{ NetworkId: networkId, RPCPort: rpcPort, WSPort: wsPort, @@ -47,8 +47,8 @@ func NewKlaytnConfig(networkId int, rpcPort int, wsPort int, p2pPort int, dataDi return kConf } -func (k KlaytnConfig) String() string { - tmpl, err := template.New("KlaytnConfig").Parse(kTemplate) +func (k KaiaConfig) String() string { + tmpl, err := template.New("KaiaConfig").Parse(kTemplate) if err != nil { fmt.Printf("Failed to parse template, %v", err) return "" @@ -64,7 +64,7 @@ func (k KlaytnConfig) String() string { return res.String() } -var kTemplate = `# Configuration file for the klay service. +var kTemplate = `# Configuration file for the Kaia service. NETWORK_ID={{ .NetworkId }} diff --git a/cmd/kbn/main.go b/cmd/kbn/main.go index afb8de83ae..ebdb296bb1 100644 --- a/cmd/kbn/main.go +++ b/cmd/kbn/main.go @@ -128,7 +128,7 @@ func bootnode(ctx *cli.Context) error { realaddr := conn.LocalAddr().(*net.UDPAddr) if bcfg.natm != nil { if !realaddr.IP.IsLoopback() { - go nat.Map(bcfg.natm, nil, "udp", realaddr.Port, realaddr.Port, "Klaytn node discovery") + go nat.Map(bcfg.natm, nil, "udp", realaddr.Port, realaddr.Port, "Kaia node discovery") } // TODO: react to external IP changes over time. if ext, err := bcfg.natm.ExternalIP(); err == nil { @@ -188,9 +188,9 @@ func startNode(node *Node) error { func main() { // TODO-Kaia: remove `help` command - app := utils.NewApp("", "the Klaytn's bootnode command line interface") + app := utils.NewApp("", "the Kaia's bootnode command line interface") app.Name = "kbn" - app.Copyright = "Copyright 2018 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.UsageText = app.Name + " [global options] [commands]" app.Flags = append(app.Flags, utils.BNAppFlags()...) app.Commands = []*cli.Command{ diff --git a/cmd/kcn/main.go b/cmd/kcn/main.go index 06f4b4c04d..3510f08303 100644 --- a/cmd/kcn/main.go +++ b/cmd/kcn/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKCN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Consensus Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia Consensus Node") ) func init() { // Initialize the CLI app and start kcn - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/ken/main.go b/cmd/ken/main.go index 53e898777c..d1daa299e2 100644 --- a/cmd/ken/main.go +++ b/cmd/ken/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKEN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Endpoint Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia Endpoint Node") ) func init() { // Initialize the CLI app and start ken - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/kgen/main.go b/cmd/kgen/main.go index 7bf453f64f..72bb5ecb86 100644 --- a/cmd/kgen/main.go +++ b/cmd/kgen/main.go @@ -48,7 +48,7 @@ var ( logger = log.NewModuleLogger(log.CMDKGEN) fileFlag = &cli.BoolFlag{ Name: "file", - Usage: `Generate a nodekey and a Klaytn node information as files`, + Usage: `Generate a nodekey and a Kaia node information as files`, } portFlag = &cli.IntFlag{ Name: "port", @@ -70,8 +70,8 @@ func init() { func main() { app := cli.NewApp() app.Name = "kgen" - app.Usage = "The command line interface to generate nodekey information for Klaytn" - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Usage = "The command line interface to generate nodekey information for Kaia" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Action = genNodeKey app.Flags = []cli.Flag{ fileFlag, diff --git a/cmd/kpn/main.go b/cmd/kpn/main.go index df6d5bf97f..e361ee1e26 100644 --- a/cmd/kpn/main.go +++ b/cmd/kpn/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKPN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Proxy Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia Proxy Node") ) func init() { // Initialize the CLI app and start kpn - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/kscn/main.go b/cmd/kscn/main.go index 7470885a0a..9744fc14ee 100644 --- a/cmd/kscn/main.go +++ b/cmd/kscn/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKSCN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn ServiceChain Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia ServiceChain Node") ) func init() { // Initialize the CLI app and start kcn - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/ksen/main.go b/cmd/ksen/main.go index 2a08b2ef4a..367e063f5b 100644 --- a/cmd/ksen/main.go +++ b/cmd/ksen/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKSEN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Endpoint Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia Endpoint Node") ) func init() { // Initialize the CLI app and start ksen - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/kspn/main.go b/cmd/kspn/main.go index baa9fa9bf1..4796a922ba 100644 --- a/cmd/kspn/main.go +++ b/cmd/kspn/main.go @@ -37,14 +37,14 @@ var ( logger = log.NewModuleLogger(log.CMDKSPN) // The app that holds all commands and flags. - app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Klaytn Proxy Node") + app = utils.NewApp(nodecmd.GetGitCommit(), "The command line interface for Kaia Proxy Node") ) func init() { // Initialize the CLI app and start kspn - app.Action = nodecmd.RunKlaytnNode + app.Action = nodecmd.RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See utils/nodecmd/chaincmd.go: nodecmd.InitCommand, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 780d62e3c9..3fa318f655 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -87,7 +87,7 @@ var ( } NetworkTypeFlag = &cli.StringFlag{ Name: "networktype", - Usage: "Klaytn network type (main-net (mn), service chain-net (scn))", + Usage: "Kaia network type (main-net (mn), service chain-net (scn))", Value: "mn", Aliases: []string{}, EnvVars: []string{"KLAYTN_NETWORKTYPE"}, @@ -1080,7 +1080,7 @@ var ( // Network Settings NodeTypeFlag = &cli.StringFlag{ Name: "nodetype", - Usage: "Klaytn node type (consensus node (cn), proxy node (pn), endpoint node (en))", + Usage: "Kaia node type (consensus node (cn), proxy node (pn), endpoint node (en))", Value: "en", Aliases: []string{}, EnvVars: []string{"KLAYTN_NODETYPE"}, @@ -1216,7 +1216,7 @@ var ( CypressFlag = &cli.BoolFlag{ Name: "cypress", - Usage: "Pre-configured Klaytn Cypress network", + Usage: "Pre-configured Kaia Cypress network", Aliases: []string{"p2p.cypress"}, EnvVars: []string{"KLAYTN_CYPRESS"}, Category: "NETWORK", @@ -1224,7 +1224,7 @@ var ( // Baobab bootnodes setting BaobabFlag = &cli.BoolFlag{ Name: "baobab", - Usage: "Pre-configured Klaytn baobab network", + Usage: "Pre-configured Kaia baobab network", Aliases: []string{"p2p.baobab"}, EnvVars: []string{"KLAYTN_BAOBAB"}, Category: "NETWORK", diff --git a/cmd/utils/nodecmd/consolecmd_test.go b/cmd/utils/nodecmd/consolecmd_test.go index e7d817f2d5..553037d93c 100644 --- a/cmd/utils/nodecmd/consolecmd_test.go +++ b/cmd/utils/nodecmd/consolecmd_test.go @@ -58,7 +58,7 @@ func TestConsoleWelcome(t *testing.T) { // Verify the actual welcome message to the required template kaia.Expect(` -Welcome to the Klaytn JavaScript console! +Welcome to the Kaia JavaScript console! instance: Klaytn/{{klayver}}/{{goos}}-{{goarch}}/{{gover}} datadir: {{datadir}} @@ -139,7 +139,7 @@ func testAttachWelcome(t *testing.T, klay *testklay, endpoint, apis string) { // Verify the actual welcome message to the required template attach.Expect(` -Welcome to the Klaytn JavaScript console! +Welcome to the Kaia JavaScript console! instance: Klaytn/{{klayver}}/{{goos}}-{{goarch}}/{{gover}}{{if ipc}} datadir: {{datadir}}{{end}} diff --git a/cmd/utils/nodecmd/defaultcmd.go b/cmd/utils/nodecmd/defaultcmd.go index 7048816b40..b400a15c27 100644 --- a/cmd/utils/nodecmd/defaultcmd.go +++ b/cmd/utils/nodecmd/defaultcmd.go @@ -40,10 +40,10 @@ import ( "github.com/urfave/cli/v2/altsrc" ) -// runKlaytnNode is the main entry point into the system if no special subcommand is ran. +// runKaiaNode is the main entry point into the system if no special subcommand is ran. // It creates a default node based on the command line arguments and runs it in // blocking mode, waiting for it to be shut down. -func RunKlaytnNode(ctx *cli.Context) error { +func RunKaiaNode(ctx *cli.Context) error { fullNode := MakeFullNode(ctx) startNode(ctx, fullNode) fullNode.Wait() @@ -133,7 +133,7 @@ func startNode(ctx *cli.Context, stack *node.Node) { if utils.NetworkTypeFlag.Value == utils.SCNNetworkType && utils.ServiceChainConsensusFlag.Value == "clique" { logger.Crit("using clique consensus type is not allowed anymore!") } else { - startKlaytnAuxiliaryService(ctx, stack) + startKaiaAuxiliaryService(ctx, stack) } // Unlock any account specifically requested @@ -148,10 +148,10 @@ func startNode(ctx *cli.Context, stack *node.Node) { } } -func startKlaytnAuxiliaryService(ctx *cli.Context, stack *node.Node) { +func startKaiaAuxiliaryService(ctx *cli.Context, stack *node.Node) { var cn *cn.CN if err := stack.Service(&cn); err != nil { - log.Fatalf("Klaytn service not running: %v", err) + log.Fatalf("Kaia service not running: %v", err) } // TODO-Kaia-NodeCmd disable accept tx before finishing sync. diff --git a/cmd/utils/nodecmd/run_test.go b/cmd/utils/nodecmd/run_test.go index b01cf1d2ab..c4958d53bd 100644 --- a/cmd/utils/nodecmd/run_test.go +++ b/cmd/utils/nodecmd/run_test.go @@ -67,7 +67,7 @@ var ( func init() { // Initialize the CLI app and start Kaia - app.Action = RunKlaytnNode + app.Action = RunKaiaNode app.HideVersion = true // we have a command to print the version app.Copyright = "Copyright 2018-2023 The klaytn Authors" app.Commands = []*cli.Command{ diff --git a/console/console.go b/console/console.go index 30ad33e54b..cec5e474cd 100644 --- a/console/console.go +++ b/console/console.go @@ -318,7 +318,7 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str // console's available modules. func (c *Console) Welcome() { // Print some generic Kaia metadata - fmt.Fprintf(c.printer, "Welcome to the Klaytn JavaScript console!\n\n") + fmt.Fprintf(c.printer, "Welcome to the Kaia JavaScript console!\n\n") c.jsre.Run(` console.log("instance: " + web3.version.node); console.log(" datadir: " + admin.datadir); diff --git a/governance/api.go b/governance/api.go index 701e5e7a01..2b589f9d89 100644 --- a/governance/api.go +++ b/governance/api.go @@ -45,13 +45,13 @@ func NewGovernanceAPI(gov Engine) *GovernanceAPI { return &GovernanceAPI{governance: gov} } -type GovernanceKlayAPI struct { +type GovernanceKaiaAPI struct { governance Engine chain blockChain } -func NewGovernanceKlayAPI(gov Engine, chain blockChain) *GovernanceKlayAPI { - return &GovernanceKlayAPI{governance: gov, chain: chain} +func NewGovernanceKaiaAPI(gov Engine, chain blockChain) *GovernanceKaiaAPI { + return &GovernanceKaiaAPI{governance: gov, chain: chain} } var ( @@ -65,24 +65,24 @@ var ( errInvalidUpperBound = errors.New("upperboundbasefee cannot be set lower than lowerboundbasefee") ) -func (api *GovernanceKlayAPI) GetChainConfig(num *rpc.BlockNumber) *params.ChainConfig { +func (api *GovernanceKaiaAPI) GetChainConfig(num *rpc.BlockNumber) *params.ChainConfig { return getChainConfig(api.governance, num) } -func (api *GovernanceKlayAPI) GetStakingInfo(num *rpc.BlockNumber) (*reward.StakingInfo, error) { +func (api *GovernanceKaiaAPI) GetStakingInfo(num *rpc.BlockNumber) (*reward.StakingInfo, error) { return getStakingInfo(api.governance, num) } -func (api *GovernanceKlayAPI) GetParams(num *rpc.BlockNumber) (map[string]interface{}, error) { +func (api *GovernanceKaiaAPI) GetParams(num *rpc.BlockNumber) (map[string]interface{}, error) { return getParams(api.governance, num) } -func (api *GovernanceKlayAPI) NodeAddress() common.Address { +func (api *GovernanceKaiaAPI) NodeAddress() common.Address { return api.governance.NodeAddress() } // GetRewards returns detailed information of the block reward at a given block number. -func (api *GovernanceKlayAPI) GetRewards(num *rpc.BlockNumber) (*reward.RewardSpec, error) { +func (api *GovernanceKaiaAPI) GetRewards(num *rpc.BlockNumber) (*reward.RewardSpec, error) { blockNumber := uint64(0) if num == nil || *num == rpc.LatestBlockNumber { blockNumber = api.chain.CurrentBlock().NumberU64() @@ -129,7 +129,7 @@ type AccumulatedRewards struct { // GetRewardsAccumulated returns accumulated rewards data in the block range of [first, last]. func (api *GovernanceAPI) GetRewardsAccumulated(first rpc.BlockNumber, last rpc.BlockNumber) (*AccumulatedRewards, error) { blockchain := api.governance.BlockChain() - govKlayAPI := NewGovernanceKlayAPI(api.governance, blockchain) + govKaiaAPI := NewGovernanceKaiaAPI(api.governance, blockchain) currentBlock := blockchain.CurrentBlock().NumberU64() @@ -172,7 +172,7 @@ func (api *GovernanceAPI) GetRewardsAccumulated(first rpc.BlockNumber, last rpc. // the minimum digit of request is period to avoid current access to an accArray item for num := range reqCh { bn := rpc.BlockNumber(num) - blockReward, err := govKlayAPI.GetRewards(&bn) + blockReward, err := govKaiaAPI.GetRewards(&bn) if err != nil { errCh <- err wg.Done() diff --git a/governance/api_test.go b/governance/api_test.go index 89b4bbb0a4..beeb97c6f2 100644 --- a/governance/api_test.go +++ b/governance/api_test.go @@ -141,12 +141,12 @@ func TestGetRewards(t *testing.T) { e.headerGov.WriteGovernance(uint64(o.num), gset, override) } - govKlayApi := NewGovernanceKlayAPI(e, bc) + govKaiaApi := NewGovernanceKaiaAPI(e, bc) for num := 1; num <= tc.length; num++ { bc.SetBlockNum(uint64(num)) - rewardSpec, err := govKlayApi.GetRewards(&latestNum) + rewardSpec, err := govKaiaApi.GetRewards(&latestNum) assert.Nil(t, err) minted := new(big.Int).SetUint64(tc.expected[num]) diff --git a/node/api.go b/node/api.go index bd9bf223fe..836086f4a8 100644 --- a/node/api.go +++ b/node/api.go @@ -460,23 +460,23 @@ func (api *PublicDebugAPI) Metrics(raw bool) (map[string]interface{}, error) { return counters, nil } -// PublicKlayAPI offers helper utils -type PublicKlayAPI struct { +// PublicKaiaAPI offers helper utils +type PublicKaiaAPI struct { stack *Node } -// NewPublicKlayAPI creates a new Web3Service instance -func NewPublicKlayAPI(stack *Node) *PublicKlayAPI { - return &PublicKlayAPI{stack} +// NewPublicKaiaAPI creates a new Web3Service instance +func NewPublicKaiaAPI(stack *Node) *PublicKaiaAPI { + return &PublicKaiaAPI{stack} } // ClientVersion returns the node name -func (s *PublicKlayAPI) ClientVersion() string { +func (s *PublicKaiaAPI) ClientVersion() string { return s.stack.Server().Name() } // Sha3 applies the Kaia sha3 implementation on the input. // It assumes the input is hex encoded. -func (s *PublicKlayAPI) Sha3(input hexutil.Bytes) hexutil.Bytes { +func (s *PublicKaiaAPI) Sha3(input hexutil.Bytes) hexutil.Bytes { return crypto.Keccak256(input) } diff --git a/node/cn/api.go b/node/cn/api.go index 49329e677a..c999651e58 100644 --- a/node/cn/api.go +++ b/node/cn/api.go @@ -43,19 +43,19 @@ import ( "github.com/klaytn/klaytn/work" ) -// PublicKlayAPI provides an API to access Kaia CN-related +// PublicKaiaAPI provides an API to access Kaia CN-related // information. -type PublicKlayAPI struct { +type PublicKaiaAPI struct { cn *CN } -// NewPublicKlayAPI creates a new Kaia protocol API for full nodes. -func NewPublicKlayAPI(e *CN) *PublicKlayAPI { - return &PublicKlayAPI{e} +// NewPublicKaiaAPI creates a new Kaia protocol API for full nodes. +func NewPublicKaiaAPI(e *CN) *PublicKaiaAPI { + return &PublicKaiaAPI{e} } // Rewardbase is the address that consensus rewards will be send to -func (api *PublicKlayAPI) Rewardbase() (common.Address, error) { +func (api *PublicKaiaAPI) Rewardbase() (common.Address, error) { return api.cn.Rewardbase() } diff --git a/node/cn/backend.go b/node/cn/backend.go index e3b209370f..72a3814e82 100644 --- a/node/cn/backend.go +++ b/node/cn/backend.go @@ -521,13 +521,13 @@ func (s *CN) APIs() []rpc.API { apis = append(apis, s.engine.APIs(s.BlockChain())...) publicFilterAPI := filters.NewPublicFilterAPI(s.APIBackend, false) - governanceKlayAPI := governance.NewGovernanceKlayAPI(s.governance, s.blockchain) + governanceKaiaAPI := governance.NewGovernanceKaiaAPI(s.governance, s.blockchain) governanceAPI := governance.NewGovernanceAPI(s.governance) publicDownloaderAPI := downloader.NewPublicDownloaderAPI(s.protocolManager.Downloader(), s.eventMux) privateDownloaderAPI := downloader.NewPrivateDownloaderAPI(s.protocolManager.Downloader()) ethAPI.SetPublicFilterAPI(publicFilterAPI) - ethAPI.SetGovernanceKlayAPI(governanceKlayAPI) + ethAPI.SetGovernanceKaiaAPI(governanceKaiaAPI) ethAPI.SetGovernanceAPI(governanceAPI) // Append all the local APIs and return @@ -535,7 +535,7 @@ func (s *CN) APIs() []rpc.API { { Namespace: "klay", Version: "1.0", - Service: NewPublicKlayAPI(s), + Service: NewPublicKaiaAPI(s), Public: true, }, { Namespace: "klay", @@ -589,7 +589,7 @@ func (s *CN) APIs() []rpc.API { }, { Namespace: "klay", Version: "1.0", - Service: governanceKlayAPI, + Service: governanceKaiaAPI, Public: true, }, { Namespace: "eth", diff --git a/node/node.go b/node/node.go index 4674d71d34..ce9ec1b433 100644 --- a/node/node.go +++ b/node/node.go @@ -739,12 +739,12 @@ func (n *Node) apis() []rpc.API { // "web3" namespace will be deprecated soon. The same APIs in "web3" are available in "klay" namespace. Namespace: "web3", Version: "1.0", - Service: NewPublicKlayAPI(n), + Service: NewPublicKaiaAPI(n), Public: true, }, { Namespace: "klay", Version: "1.0", - Service: NewPublicKlayAPI(n), + Service: NewPublicKaiaAPI(n), Public: true, }, { Namespace: "debug", diff --git a/node/sc/bridge_manager_test.go b/node/sc/bridge_manager_test.go index ebfa3fdde6..c7fbae962b 100644 --- a/node/sc/bridge_manager_test.go +++ b/node/sc/bridge_manager_test.go @@ -223,16 +223,16 @@ func TestBridgeManager(t *testing.T) { assert.Equal(t, cNftAddr, nftAddr) balance, _ := sim.BalanceAt(context.Background(), pAuth.From, nil) - t.Logf("auth(%v) KLAY balance : %v\n", pAuth.From.String(), balance) + t.Logf("auth(%v) KAIA balance : %v\n", pAuth.From.String(), balance) balance, _ = sim.BalanceAt(context.Background(), cAuth.From, nil) - t.Logf("auth2(%v) KLAY balance : %v\n", cAuth.From.String(), balance) + t.Logf("auth2(%v) KAIA balance : %v\n", cAuth.From.String(), balance) balance, _ = sim.BalanceAt(context.Background(), alice.From, nil) - t.Logf("auth3(%v) KLAY balance : %v\n", alice.From.String(), balance) + t.Logf("auth3(%v) KAIA balance : %v\n", alice.From.String(), balance) balance, _ = sim.BalanceAt(context.Background(), bob.From, nil) - t.Logf("auth4(%v) KLAY balance : %v\n", bob.From.String(), balance) + t.Logf("auth4(%v) KAIA balance : %v\n", bob.From.String(), balance) // 4. Subscribe Bridge Contract bridgeManager.SubscribeEvent(addr) @@ -574,7 +574,7 @@ func TestBridgeManagerWithFee(t *testing.T) { bridgeManager, err := NewBridgeManager(sc) testToken := int64(100000) - testKLAY := int64(100000) + testKAIA := int64(100000) KLAYFee := int64(500) ERC20Fee := int64(500) @@ -651,10 +651,10 @@ func TestBridgeManagerWithFee(t *testing.T) { assert.Equal(t, cTokenAddr, tokenAddr) balance, _ := sim.BalanceAt(context.Background(), Alice.From, nil) - t.Logf("Alice(%v) KLAY balance : %v\n", Alice.From.String(), balance) + t.Logf("Alice(%v) KAIA balance : %v\n", Alice.From.String(), balance) balance, _ = sim.BalanceAt(context.Background(), Bob.From, nil) - t.Logf("Bob(%v) KLAY balance : %v\n", Bob.From.String(), balance) + t.Logf("Bob(%v) KAIA balance : %v\n", Bob.From.String(), balance) // 4. Subscribe Bridge Contract bridgeManager.SubscribeEvent(pBridgeAddr) @@ -823,7 +823,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-1. Request KAIA transfer from Alice to Bob with same feeLimit with fee { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKLAY + KLAYFee), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKLAY), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + KLAYFee), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) if err != nil { log.Fatalf("Failed to RequestKLAYTransfer: %v", err) } @@ -836,7 +836,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-2. Request KAIA transfer from Alice to Bob with zero feeLimit { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKLAY), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKLAY), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) assert.Equal(t, nil, err) sim.Commit() // block @@ -846,7 +846,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-3. Request KAIA transfer from Alice to Bob with insufficient feeLimit { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKLAY + (KLAYFee - 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKLAY), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KLAYFee - 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) assert.Equal(t, nil, err) sim.Commit() // block @@ -856,7 +856,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-4. Request KAIA transfer from Alice to Bob with enough feeLimit { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKLAY + (KLAYFee + 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKLAY), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KLAYFee + 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) assert.Equal(t, nil, err) sim.Commit() // block @@ -868,7 +868,7 @@ func TestBridgeManagerWithFee(t *testing.T) { { nonce, _ := sim.PendingNonceAt(context.Background(), Alice.From) gasPrice, _ := sim.SuggestGasPrice(context.Background()) - unsignedTx := types.NewTransaction(nonce, pBridgeAddr, big.NewInt(testKLAY+KLAYFee), testGasLimit, gasPrice, []byte{}) + unsignedTx := types.NewTransaction(nonce, pBridgeAddr, big.NewInt(testKAIA+KLAYFee), testGasLimit, gasPrice, []byte{}) chainID, _ := sim.ChainID(context.Background()) tx, err = types.SignTx(unsignedTx, types.LatestSignerForChainID(chainID), AliceKey) @@ -904,15 +904,15 @@ func TestBridgeManagerWithFee(t *testing.T) { // 11. Check KAIA balance { balance, _ = sim.BalanceAt(context.Background(), Alice.From, nil) - t.Log("Alice KLAY balance :", balance) - assert.Equal(t, initialValue-(testKLAY+KLAYFee)*2-KLAYFee, balance.Int64()) + t.Log("Alice KAIA balance :", balance) + assert.Equal(t, initialValue-(testKAIA+KLAYFee)*2-KLAYFee, balance.Int64()) balance, _ = sim.BalanceAt(context.Background(), Bob.From, nil) - t.Log("Bob KLAY balance :", balance) - assert.Equal(t, big.NewInt(testKLAY*2).String(), balance.String()) + t.Log("Bob KAIA balance :", balance) + assert.Equal(t, big.NewInt(testKAIA*2).String(), balance.String()) balance, _ = sim.BalanceAt(context.Background(), receiver.From, nil) - t.Log("receiver KLAY balance :", balance) + t.Log("receiver KAIA balance :", balance) assert.Equal(t, KLAYFee*3, balance.Int64()) } diff --git a/node/sc/mainbridge_test.go b/node/sc/mainbridge_test.go index 29a0d7ff03..574f93a7c9 100644 --- a/node/sc/mainbridge_test.go +++ b/node/sc/mainbridge_test.go @@ -151,7 +151,7 @@ func TestMainBridge_basic(t *testing.T) { { Namespace: "klay", Version: "1.0", - Service: api.NewPublicKlayAPI(&cn.CNAPIBackend{}), + Service: api.NewPublicKaiaAPI(&cn.CNAPIBackend{}), Public: true, }, } diff --git a/tests/tx_gas_calculation_test.go b/tests/tx_gas_calculation_test.go index 90e381f66f..aee9b4ee28 100644 --- a/tests/tx_gas_calculation_test.go +++ b/tests/tx_gas_calculation_test.go @@ -89,7 +89,7 @@ func TestGasCalculation(t *testing.T) { Type string account TestAccount }{ - {"KlaytnLegacy", genKaiaLegacyAccount(t)}, + {"KaiaLegacy", genKaiaLegacyAccount(t)}, {"Public", genPublicAccount(t)}, {"MultiSig", genMultiSigAccount(t)}, {"RoleBasedWithPublic", genRoleBasedWithPublicAccount(t)}, @@ -242,8 +242,8 @@ func TestGasCalculation(t *testing.T) { toAccount := reservoir senderRole := accountkey.RoleTransaction - // LegacyTransaction can be used only by the KlaytnAccount with AccountKeyLegacy. - if sender.Type != "KlaytnLegacy" && (strings.Contains(f.Name, "Legacy") || strings.Contains(f.Name, "Access") || strings.Contains(f.Name, "Dynamic")) { + // LegacyTransaction can be used only by the KaiaAccount with AccountKeyLegacy. + if sender.Type != "KaiaLegacy" && (strings.Contains(f.Name, "Legacy") || strings.Contains(f.Name, "Access") || strings.Contains(f.Name, "Dynamic")) { continue } @@ -892,7 +892,7 @@ func genMapForChainDataAnchoring(from TestAccount, gasPrice *big.Int, txType typ } func genKaiaLegacyAccount(t *testing.T) TestAccount { - // For KlaytnLegacy + // For KaiaLegacy kaiaLegacy, err := createAnonymousAccount(getRandomPrivateKeyString(t)) assert.Equal(t, nil, err) From 56d3e590b470414ff3e0efb87f28a441d0daacdd Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 20:00:58 +0900 Subject: [PATCH 03/27] Change params/denomination --- api/api_ethereum.go | 2 +- api/api_ethereum_test.go | 8 +- blockchain/blockchain_test.go | 4 +- blockchain/system/kip113_test.go | 4 +- blockchain/system/rebalance_test.go | 2 +- blockchain/system/registry_test.go | 4 +- blockchain/tx_pool_test.go | 6 +- .../testing/reward/KlaytnReward_test.go | 2 +- governance/contract_test.go | 2 +- node/cn/tracers/api_test.go | 10 +-- node/sc/bridge_manager_test.go | 78 +++++++++---------- node/sc/bridge_test.go | 24 +++--- node/sc/multi_bridge_test.go | 4 +- node/sc/vt_recovery_test.go | 6 +- params/denomination.go | 12 +-- reward/staking_info.go | 2 +- tests/account_keytype_test.go | 22 +++--- tests/gov_contract_test.go | 2 +- tests/hard_fork_test.go | 4 +- tests/kip103_test.go | 2 +- tests/klay_blockchain_test.go | 2 +- tests/klay_scenario_test.go | 8 +- tests/klay_test_blockchain_test.go | 2 +- tests/pregenerated_data_generation_test.go | 2 +- tests/role_based_account_test.go | 16 ++-- tests/rpc_output_test.go | 4 +- tests/testutil_blockchain_test.go | 4 +- tests/tx_gas_calculation_test.go | 4 +- tests/tx_validation_test.go | 2 +- tests/validate_sender_test.go | 4 +- 30 files changed, 124 insertions(+), 124 deletions(-) diff --git a/api/api_ethereum.go b/api/api_ethereum.go index 85d29bc10a..2dcd9b9519 100644 --- a/api/api_ethereum.go +++ b/api/api_ethereum.go @@ -1513,7 +1513,7 @@ func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error { if cap == 0 { return nil } - feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.KLAY))) + feeEth := new(big.Float).Quo(new(big.Float).SetInt(new(big.Int).Mul(gasPrice, new(big.Int).SetUint64(gas))), new(big.Float).SetInt(big.NewInt(params.KAIA))) feeFloat, _ := feeEth.Float64() if feeFloat > cap { return fmt.Errorf("tx fee (%.2f KAIA) exceeds the configured cap (%.2f KAIA)", feeFloat, cap) diff --git a/api/api_ethereum_test.go b/api/api_ethereum_test.go index 1d708a9142..f4428b8b42 100644 --- a/api/api_ethereum_test.go +++ b/api/api_ethereum_test.go @@ -2452,7 +2452,7 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate account2 = common.HexToAddress("0xbbbb") account3 = common.HexToAddress("0xcccc") gspec = &blockchain.Genesis{Alloc: blockchain.GenesisAlloc{ - account1: {Balance: big.NewInt(params.KLAY * 2)}, + account1: {Balance: big.NewInt(params.KAIA * 2)}, account2: {Balance: common.Big0}, account3: {Balance: common.Big0, Code: hexutil.MustDecode(codeRevertHello)}, }, Config: chainConfig} @@ -2465,9 +2465,9 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate chain = &testChainContext{header: header} // tx arguments - KLAY = hexutil.Big(*big.NewInt(params.KLAY)) - mKLAY = hexutil.Big(*big.NewInt(params.KLAY / 1000)) - KLAY2_1 = hexutil.Big(*big.NewInt(params.KLAY*2 + 1)) + KLAY = hexutil.Big(*big.NewInt(params.KAIA)) + mKLAY = hexutil.Big(*big.NewInt(params.KAIA / 1000)) + KLAY2_1 = hexutil.Big(*big.NewInt(params.KAIA*2 + 1)) gas1000 = hexutil.Uint64(1000) gas40000 = hexutil.Uint64(40000) baddata = hexutil.Bytes(hexutil.MustDecode("0xdeadbeef")) diff --git a/blockchain/blockchain_test.go b/blockchain/blockchain_test.go index 1e41480fc0..3fae0df1ee 100644 --- a/blockchain/blockchain_test.go +++ b/blockchain/blockchain_test.go @@ -1423,7 +1423,7 @@ func TestAccessListTx(t *testing.T) { gspec = &Genesis{ Config: config, Alloc: GenesisAlloc{ - senderAddr: {Balance: big.NewInt(params.KLAY)}, + senderAddr: {Balance: big.NewInt(params.KAIA)}, contractAddr: { // SLOAD 0x00 and 0x01 Code: []byte{ byte(vm.PC), @@ -1499,7 +1499,7 @@ func TestEIP3651(t *testing.T) { key2, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a") addr1 = crypto.PubkeyToAddress(key1.PublicKey) addr2 = crypto.PubkeyToAddress(key2.PublicKey) - funds = new(big.Int).Mul(common.Big1, big.NewInt(params.KLAY)) + funds = new(big.Int).Mul(common.Big1, big.NewInt(params.KAIA)) gspec = &Genesis{ Config: params.CypressChainConfig.Copy(), Alloc: GenesisAlloc{ diff --git a/blockchain/system/kip113_test.go b/blockchain/system/kip113_test.go index 55e1a69d69..aa5de230ab 100644 --- a/blockchain/system/kip113_test.go +++ b/blockchain/system/kip113_test.go @@ -27,7 +27,7 @@ func TestReadKip113(t *testing.T) { alloc = blockchain.GenesisAlloc{ sender.From: { - Balance: big.NewInt(params.KLAY), + Balance: big.NewInt(params.KAIA), }, } backend = backends.NewSimulatedBackend(alloc) @@ -87,7 +87,7 @@ func TestAllocKip113(t *testing.T) { alloc = blockchain.GenesisAlloc{ sender.From: { - Balance: big.NewInt(params.KLAY), + Balance: big.NewInt(params.KAIA), }, } backend = backends.NewSimulatedBackend(alloc) diff --git a/blockchain/system/rebalance_test.go b/blockchain/system/rebalance_test.go index 7d5c7d08e2..70b65dd8e2 100644 --- a/blockchain/system/rebalance_test.go +++ b/blockchain/system/rebalance_test.go @@ -71,7 +71,7 @@ func rebalanceTreasury(t *testing.T, sender *bind.TransactOpts, config *params.C } alloc = blockchain.GenesisAlloc{ - senderAddr: {Balance: big.NewInt(params.KLAY)}, + senderAddr: {Balance: big.NewInt(params.KAIA)}, rebalanceAddress: {Code: rebalanceCode, Balance: common.Big0}, zeroeds[0].addr: {Balance: zeroeds[0].balance}, zeroeds[1].addr: {Balance: zeroeds[1].balance}, diff --git a/blockchain/system/registry_test.go b/blockchain/system/registry_test.go index e52baea967..a2046af1c5 100644 --- a/blockchain/system/registry_test.go +++ b/blockchain/system/registry_test.go @@ -23,7 +23,7 @@ func TestReadRegistry(t *testing.T) { alloc = blockchain.GenesisAlloc{ sender.From: { - Balance: big.NewInt(params.KLAY), + Balance: big.NewInt(params.KAIA), }, RegistryAddr: { Code: RegistryMockCode, @@ -74,7 +74,7 @@ func TestAllocRegistry(t *testing.T) { alloc = blockchain.GenesisAlloc{ sender.From: { - Balance: big.NewInt(params.KLAY), + Balance: big.NewInt(params.KAIA), }, RegistryAddr: { Code: RegistryMockCode, diff --git a/blockchain/tx_pool_test.go b/blockchain/tx_pool_test.go index 53e95b7286..271cea3d4f 100644 --- a/blockchain/tx_pool_test.go +++ b/blockchain/tx_pool_test.go @@ -281,7 +281,7 @@ func (c *testChain) State() (*state.StateDB, error) { c.statedb, _ = state.New(common.Hash{}, state.NewDatabase(database.NewMemoryDBManager()), nil, nil) // simulate that the new head block included tx0 and tx1 c.statedb.SetNonce(c.address, 2) - c.statedb.SetBalance(c.address, new(big.Int).SetUint64(params.KLAY)) + c.statedb.SetBalance(c.address, new(big.Int).SetUint64(params.KAIA)) *c.trigger = false } return stdb, nil @@ -301,7 +301,7 @@ func TestStateChangeDuringTransactionPoolReset(t *testing.T) { ) // setup pool with 2 transaction in it - statedb.SetBalance(address, new(big.Int).SetUint64(params.KLAY)) + statedb.SetBalance(address, new(big.Int).SetUint64(params.KAIA)) blockchain := &testChain{&testBlockChain{statedb, 1000000000, new(event.Feed)}, address, &trigger} tx0 := transaction(0, 100000, key) @@ -367,7 +367,7 @@ func TestHomesteadTransaction(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "0x4c8D290a1B368ac4728d83a9e8321fC3af2b39b1", from.String()) - testAddBalance(pool, from, new(big.Int).Mul(big.NewInt(10), big.NewInt(params.KLAY))) + testAddBalance(pool, from, new(big.Int).Mul(big.NewInt(10), big.NewInt(params.KAIA))) err = pool.AddRemote(tx) assert.NoError(t, err) } diff --git a/contracts/contracts/testing/reward/KlaytnReward_test.go b/contracts/contracts/testing/reward/KlaytnReward_test.go index 03ab76bbad..316c5f6586 100644 --- a/contracts/contracts/testing/reward/KlaytnReward_test.go +++ b/contracts/contracts/testing/reward/KlaytnReward_test.go @@ -38,7 +38,7 @@ func TestSmartContract(t *testing.T) { key2, _ := crypto.GenerateKey() auth2 := bind.NewKeyedTransactor(key2) - initialValue := big.NewInt(params.KLAY) + initialValue := big.NewInt(params.KAIA) withdrawValue := big.NewInt(500000000) alloc := blockchain.GenesisAlloc{auth.From: {Balance: initialValue}, auth2.From: {Balance: initialValue}} diff --git a/governance/contract_test.go b/governance/contract_test.go index 969a29a0eb..7e03661331 100644 --- a/governance/contract_test.go +++ b/governance/contract_test.go @@ -42,7 +42,7 @@ func prepareSimulatedContract(t *testing.T) ([]*bind.TransactOpts, *backends.Sim account := bind.NewKeyedTransactor(key) account.GasLimit = 10000000 accounts = append(accounts, account) - alloc[account.From] = blockchain.GenesisAccount{Balance: big.NewInt(params.KLAY)} + alloc[account.From] = blockchain.GenesisAccount{Balance: big.NewInt(params.KAIA)} } config := ¶ms.ChainConfig{} config.SetDefaults() diff --git a/node/cn/tracers/api_test.go b/node/cn/tracers/api_test.go index 555d9d8058..4486f13a6d 100644 --- a/node/cn/tracers/api_test.go +++ b/node/cn/tracers/api_test.go @@ -299,8 +299,8 @@ func TestTraceTransaction(t *testing.T) { // Initialize test accounts accounts := newAccounts(2) genesis := &blockchain.Genesis{Alloc: blockchain.GenesisAlloc{ - accounts[0].addr: {Balance: big.NewInt(params.KLAY)}, - accounts[1].addr: {Balance: big.NewInt(params.KLAY)}, + accounts[0].addr: {Balance: big.NewInt(params.KAIA)}, + accounts[1].addr: {Balance: big.NewInt(params.KAIA)}, }} target := common.Hash{} signer := types.LatestSignerForChainID(params.TestChainConfig.ChainID) @@ -332,9 +332,9 @@ func TestTraceBlock(t *testing.T) { // Initialize test accounts accounts := newAccounts(3) genesis := &blockchain.Genesis{Alloc: blockchain.GenesisAlloc{ - accounts[0].addr: {Balance: big.NewInt(params.KLAY)}, - accounts[1].addr: {Balance: big.NewInt(params.KLAY)}, - accounts[2].addr: {Balance: big.NewInt(params.KLAY)}, + accounts[0].addr: {Balance: big.NewInt(params.KAIA)}, + accounts[1].addr: {Balance: big.NewInt(params.KAIA)}, + accounts[2].addr: {Balance: big.NewInt(params.KAIA)}, }} genBlocks := 10 signer := types.LatestSignerForChainID(params.TestChainConfig.ChainID) diff --git a/node/sc/bridge_manager_test.go b/node/sc/bridge_manager_test.go index c7fbae962b..4d13cbec48 100644 --- a/node/sc/bridge_manager_test.go +++ b/node/sc/bridge_manager_test.go @@ -150,9 +150,9 @@ func TestBridgeManager(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - alice.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + alice.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -379,9 +379,9 @@ func TestBridgeManagerERC721_notSupportURI(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - alice.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + alice.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -951,11 +951,11 @@ func TestBasicJournal(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, - auth2.From: {Balance: big.NewInt(params.KLAY)}, - auth4.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, + auth2.From: {Balance: big.NewInt(params.KAIA)}, + auth4.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1032,11 +1032,11 @@ func TestMethodRestoreBridges(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, - auth2.From: {Balance: big.NewInt(params.KLAY)}, - auth4.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, + auth2.From: {Balance: big.NewInt(params.KAIA)}, + auth4.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1257,11 +1257,11 @@ func TestErrorDuplicatedSetBridgeInfo(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, - auth2.From: {Balance: big.NewInt(params.KLAY)}, - auth4.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, + auth2.From: {Balance: big.NewInt(params.KAIA)}, + auth4.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1324,11 +1324,11 @@ func TestScenarioSubUnsub(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, - auth2.From: {Balance: big.NewInt(params.KLAY)}, - auth4.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, + auth2.From: {Balance: big.NewInt(params.KAIA)}, + auth4.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1430,11 +1430,11 @@ func TestErrorDupSubscription(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, - auth2.From: {Balance: big.NewInt(params.KLAY)}, - auth4.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, + auth2.From: {Balance: big.NewInt(params.KAIA)}, + auth4.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -2022,10 +2022,10 @@ func TestBridgeAliasAPIs(t *testing.T) { bacc.cAccount.chainID = big.NewInt(0) alloc := blockchain.GenesisAlloc{ - alice.From: {Balance: big.NewInt(params.KLAY)}, - bob.From: {Balance: big.NewInt(params.KLAY)}, - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + alice.From: {Balance: big.NewInt(params.KAIA)}, + bob.From: {Balance: big.NewInt(params.KAIA)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -2487,8 +2487,8 @@ func TestBridgeAddressType(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -2677,8 +2677,8 @@ func TestGetBridgeContractBalance(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - bacc.pAccount.address: {Balance: big.NewInt(params.KLAY)}, - bacc.cAccount.address: {Balance: big.NewInt(params.KLAY)}, + bacc.pAccount.address: {Balance: big.NewInt(params.KAIA)}, + bacc.cAccount.address: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() diff --git a/node/sc/bridge_test.go b/node/sc/bridge_test.go index ca07c8b60c..6e1d295410 100644 --- a/node/sc/bridge_test.go +++ b/node/sc/bridge_test.go @@ -132,7 +132,7 @@ func TestBridgeDeployWithKLAY(t *testing.T) { bridgeAccountKey, _ := crypto.GenerateKey() bridgeAccount := bind.NewKeyedTransactor(bridgeAccountKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -167,7 +167,7 @@ func TestBridgeRequestValueTransferNonce(t *testing.T) { testAccKey, _ := crypto.GenerateKey() testAcc := bind.NewKeyedTransactor(testAccKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -233,7 +233,7 @@ func TestBridgeHandleValueTransferNonceAndBlockNumber(t *testing.T) { testAccKey, _ := crypto.GenerateKey() testAcc := bind.NewKeyedTransactor(testAccKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -326,7 +326,7 @@ func TestBridgePublicVariables(t *testing.T) { bridgeAccountKey, _ := crypto.GenerateKey() bridgeAccount := bind.NewKeyedTransactor(bridgeAccountKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -395,7 +395,7 @@ func TestExtendedBridgeAndCallbackERC20(t *testing.T) { bobKey, _ := crypto.GenerateKey() bobAcc := bind.NewKeyedTransactor(bobKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -541,7 +541,7 @@ func TestExtendedBridgeAndCallbackERC721(t *testing.T) { bobKey, _ := crypto.GenerateKey() bobAcc := bind.NewKeyedTransactor(bobKey) - alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{bridgeAccount.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) defer backend.Close() @@ -710,7 +710,7 @@ func generateBridgeTokenTestEnv(t *testing.T) *bridgeTokenTestENV { tester := bind.NewKeyedTransactor(testKey) tester.GasLimit = DefaultBridgeTxGasLimit - alloc := blockchain.GenesisAlloc{operator.From: {Balance: big.NewInt(params.KLAY)}, tester.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{operator.From: {Balance: big.NewInt(params.KAIA)}, tester.From: {Balance: big.NewInt(params.KAIA)}} backend := backends.NewSimulatedBackend(alloc) // Deploy Bridge @@ -1166,8 +1166,8 @@ func TestBridgeRequestHandleGasUsed(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - alice.From: {Balance: big.NewInt(params.KLAY)}, - auth.From: {Balance: big.NewInt(params.KLAY)}, + alice.From: {Balance: big.NewInt(params.KAIA)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1267,8 +1267,8 @@ func TestBridgeMaxOperatorHandleTxGasUsed(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - alice.From: {Balance: big.NewInt(params.KLAY)}, - auth.From: {Balance: big.NewInt(params.KLAY)}, + alice.From: {Balance: big.NewInt(params.KAIA)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() @@ -1350,7 +1350,7 @@ func TestBridgeThresholdLimit(t *testing.T) { // Create Simulated backend alloc := blockchain.GenesisAlloc{ - auth.From: {Balance: big.NewInt(params.KLAY)}, + auth.From: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) defer sim.Close() diff --git a/node/sc/multi_bridge_test.go b/node/sc/multi_bridge_test.go index 2ac9f12488..941661896a 100644 --- a/node/sc/multi_bridge_test.go +++ b/node/sc/multi_bridge_test.go @@ -55,7 +55,7 @@ func prepareMultiBridgeTest(t *testing.T) *bridgeTestInfo { accKey, _ := crypto.GenerateKey() acc := bind.NewKeyedTransactor(accKey) - alloc := blockchain.GenesisAlloc{acc.From: {Balance: big.NewInt(params.KLAY)}} + alloc := blockchain.GenesisAlloc{acc.From: {Balance: big.NewInt(params.KAIA)}} sim := backends.NewSimulatedBackend(alloc) chargeAmount := big.NewInt(10000000) @@ -77,7 +77,7 @@ func prepareMultiBridgeEventTest(t *testing.T) *multiBridgeTestInfo { for i := 0; i < maxAccounts; i++ { accKey, _ := crypto.GenerateKey() res.accounts[i] = bind.NewKeyedTransactor(accKey) - accountMap[res.accounts[i].From] = blockchain.GenesisAccount{Balance: big.NewInt(params.KLAY)} + accountMap[res.accounts[i].From] = blockchain.GenesisAccount{Balance: big.NewInt(params.KAIA)} } res.sim = backends.NewSimulatedBackend(accountMap) diff --git a/node/sc/vt_recovery_test.go b/node/sc/vt_recovery_test.go index cc9f299e7b..5de9dd17d6 100644 --- a/node/sc/vt_recovery_test.go +++ b/node/sc/vt_recovery_test.go @@ -660,9 +660,9 @@ func prepare(t *testing.T, vtcallback func(*testInfo)) *testInfo { // Alloc genesis and create a simulator. alloc := blockchain.GenesisAlloc{ - cAcc.From: {Balance: big.NewInt(params.KLAY)}, - pAcc.From: {Balance: big.NewInt(params.KLAY)}, - aliceAuth.From: {Balance: big.NewInt(params.KLAY)}, + cAcc.From: {Balance: big.NewInt(params.KAIA)}, + pAcc.From: {Balance: big.NewInt(params.KAIA)}, + aliceAuth.From: {Balance: big.NewInt(params.KAIA)}, } sim := backends.NewSimulatedBackend(alloc) diff --git a/params/denomination.go b/params/denomination.go index 891b01538c..4f25626261 100644 --- a/params/denomination.go +++ b/params/denomination.go @@ -30,10 +30,10 @@ const ( Mpeb = 1e6 // same Gpeb = 1e9 // same Ston = 1e9 // official notation 'ston' - UKLAY = 1e12 // official notation 'uKLAY' - MiliKLAY = 1e15 // official notation 'mKLAY' - KLAY = 1e18 // same - KKLAY = 1e21 // official notation 'kKLAY' - MKLAY = 1e24 // same - GKLAY = 1e27 // same + UKAIA = 1e12 // official notation 'uKAIA' + MiliKAIA = 1e15 // official notation 'mKAIA' + KAIA = 1e18 // same + KKAIA = 1e21 // official notation 'kKAIA' + MKAIA = 1e24 // same + GKAIA = 1e27 // same ) diff --git a/reward/staking_info.go b/reward/staking_info.go index b22500b246..286e7e14c1 100644 --- a/reward/staking_info.go +++ b/reward/staking_info.go @@ -213,7 +213,7 @@ func newStakingInfo(bc blockChain, helper governanceHelper, blockNum uint64, nod // Get balance of stakingAddrs stakingAmounts := make([]uint64, len(stakingAddrs)) for i, stakingAddr := range stakingAddrs { - tempStakingAmount := big.NewInt(0).Div(statedb.GetBalance(stakingAddr), big.NewInt(0).SetUint64(params.KLAY)) + tempStakingAmount := big.NewInt(0).Div(statedb.GetBalance(stakingAddr), big.NewInt(0).SetUint64(params.KAIA)) if tempStakingAmount.Cmp(maxStakingLimitBigInt) > 0 { tempStakingAmount.SetUint64(maxStakingLimit) } diff --git a/tests/account_keytype_test.go b/tests/account_keytype_test.go index 85e651cd09..b2f0738f9b 100644 --- a/tests/account_keytype_test.go +++ b/tests/account_keytype_test.go @@ -516,7 +516,7 @@ func TestDefaultTxsWithDefaultAccountKey(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.GetNonce(), sender.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -668,7 +668,7 @@ func TestAccountUpdateMultiSigKeyMaxKey(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -782,7 +782,7 @@ func TestAccountUpdateMultiSigKeyBigThreshold(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -893,7 +893,7 @@ func TestAccountUpdateMultiSigKeyDupPrvKeys(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1009,7 +1009,7 @@ func TestAccountUpdateMultiSigKeyWeightOverflow(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1108,7 +1108,7 @@ func TestAccountUpdateRoleBasedKeyInvalidNumKey(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1253,7 +1253,7 @@ func TestAccountUpdateRoleBasedKeyInvalidTypeKey(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1523,7 +1523,7 @@ func TestAccountUpdateRoleBasedKey(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1710,7 +1710,7 @@ func TestAccountUpdateRoleBasedKeyNested(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1884,7 +1884,7 @@ func TestRoleBasedKeySendTx(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, roleBased.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -2089,7 +2089,7 @@ func TestRoleBasedKeyFeeDelegation(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, roleBased.Addr, amount, gasLimit, gasPrice, []byte{}) diff --git a/tests/gov_contract_test.go b/tests/gov_contract_test.go index bfde4c334b..f4d8f64889 100644 --- a/tests/gov_contract_test.go +++ b/tests/gov_contract_test.go @@ -53,7 +53,7 @@ func TestGovernance_Engines(t *testing.T) { config.Istanbul.Epoch = 2 config.Istanbul.SubGroupSize = 1 config.Istanbul.ProposerPolicy = uint64(istanbul.RoundRobin) - config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KLAY)) + config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KAIA)) config.Governance.Reward.Kip82Ratio = params.DefaultKip82Ratio config.Governance.GovParamContract = common.Address{} diff --git a/tests/hard_fork_test.go b/tests/hard_fork_test.go index 43daabdbec..16a06abdb3 100644 --- a/tests/hard_fork_test.go +++ b/tests/hard_fork_test.go @@ -201,7 +201,7 @@ func genBlocks(t *testing.T) { var txs types.Transactions // Preparing step. Send KAIA to LegacyAccount. { - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.GetNonce(), accountTypes[0].account.GetAddr(), amount, gasLimit, gasPrice, []byte{}) @@ -222,7 +222,7 @@ func genBlocks(t *testing.T) { accountTypes[i].account.SetAddr(anon.Addr) { - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.GetNonce(), accountTypes[i].account.GetAddr(), amount, gasLimit, gasPrice, []byte{}) diff --git a/tests/kip103_test.go b/tests/kip103_test.go index 312ebe6da7..b1935579a6 100644 --- a/tests/kip103_test.go +++ b/tests/kip103_test.go @@ -27,7 +27,7 @@ func TestRebalanceTreasury_EOA(t *testing.T) { config.KoreCompatibleBlock = big.NewInt(0) config.Istanbul.SubGroupSize = 1 config.Istanbul.ProposerPolicy = uint64(istanbul.RoundRobin) - config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KLAY)) + config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KAIA)) // make a blockchain node fullNode, node, validator, _, workspace := newBlockchain(t, config, nil) diff --git a/tests/klay_blockchain_test.go b/tests/klay_blockchain_test.go index 41dfb7b793..7653f1d4dd 100644 --- a/tests/klay_blockchain_test.go +++ b/tests/klay_blockchain_test.go @@ -173,7 +173,7 @@ func newKlaytnNode(t *testing.T, dir string, validator *TestAccountType, config genesis.Config = params.CypressChainConfig.Copy() genesis.Config.Istanbul.SubGroupSize = 1 genesis.Config.Istanbul.ProposerPolicy = uint64(istanbul.RoundRobin) - genesis.Config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KLAY)) + genesis.Config.Governance.Reward.MintingAmount = new(big.Int).Mul(big.NewInt(9000000000000000000), big.NewInt(params.KAIA)) } else { genesis.Config = config } diff --git a/tests/klay_scenario_test.go b/tests/klay_scenario_test.go index 1b325aa122..4b2bfedb80 100644 --- a/tests/klay_scenario_test.go +++ b/tests/klay_scenario_test.go @@ -1083,7 +1083,7 @@ func TestAccountUpdate(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).SetUint64(params.KLAY) + amount := new(big.Int).SetUint64(params.KAIA) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1279,7 +1279,7 @@ func TestFeeDelegatedAccountUpdate(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1409,7 +1409,7 @@ func TestFeeDelegatedAccountUpdateWithRatio(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -1552,7 +1552,7 @@ func TestMultisigScenario(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, anon.Addr, amount, gasLimit, gasPrice, []byte{}) diff --git a/tests/klay_test_blockchain_test.go b/tests/klay_test_blockchain_test.go index 77f08fc07b..3d9a641f5f 100644 --- a/tests/klay_test_blockchain_test.go +++ b/tests/klay_test_blockchain_test.go @@ -473,7 +473,7 @@ func initBlockChain(db database.DBManager, cacheConfig *blockchain.CacheConfig, alloc := make(blockchain.GenesisAlloc) for _, a := range coinbaseAddrs { - alloc[*a] = blockchain.GenesisAccount{Balance: new(big.Int).Mul(big.NewInt(1e16), big.NewInt(params.KLAY))} + alloc[*a] = blockchain.GenesisAccount{Balance: new(big.Int).Mul(big.NewInt(1e16), big.NewInt(params.KAIA))} } genesis.Alloc = alloc diff --git a/tests/pregenerated_data_generation_test.go b/tests/pregenerated_data_generation_test.go index 406d42fdc8..5d4a7c25b4 100644 --- a/tests/pregenerated_data_generation_test.go +++ b/tests/pregenerated_data_generation_test.go @@ -99,7 +99,7 @@ func makeTxsWithNonceMap(isGenerate bool, nonceMap map[common.Address]uint64, fr var transferValue *big.Int if isGenerate { - transferValue = new(big.Int).Mul(big.NewInt(1e4), big.NewInt(params.KLAY)) + transferValue = new(big.Int).Mul(big.NewInt(1e4), big.NewInt(params.KAIA)) } else { transferValue = new(big.Int).Mul(big.NewInt(1e3), big.NewInt(params.Peb)) } diff --git a/tests/role_based_account_test.go b/tests/role_based_account_test.go index 10b1ae74d2..b709cd08c2 100644 --- a/tests/role_based_account_test.go +++ b/tests/role_based_account_test.go @@ -116,7 +116,7 @@ func TestRoleBasedAccount(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, colin.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -327,7 +327,7 @@ func TestAccountUpdateRoleBasedNil(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -482,7 +482,7 @@ func TestAccountUpdateRoleBasedLegacy(t *testing.T) { // 2. Test RoleTransfer of the RoleBasedKey { - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -573,7 +573,7 @@ func TestAccountUpdateRoleBasedLegacy(t *testing.T) { // 5. Test RoleTransfer of the RoleBasedKey with invalid signature { - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -595,7 +595,7 @@ func TestAccountUpdateRoleBasedLegacy(t *testing.T) { // 6. Test RoleTransfer of the RoleBasedKey with invalid number of signatures { - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -667,7 +667,7 @@ func TestAccountUpdateRoleBasedWrongLength(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -792,7 +792,7 @@ func TestAccountUpdateRoleBasedTransition(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -976,7 +976,7 @@ func TestAccountUpdateToRoleBasedToPub(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, diff --git a/tests/rpc_output_test.go b/tests/rpc_output_test.go index c646952d36..25ed53bd0a 100644 --- a/tests/rpc_output_test.go +++ b/tests/rpc_output_test.go @@ -146,7 +146,7 @@ func BenchmarkRPCOutput(t *testing.B) { // TxTypeValueTransfer { - amount := new(big.Int).Mul(big.NewInt(10000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(10000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, @@ -168,7 +168,7 @@ func BenchmarkRPCOutput(t *testing.B) { // TxTypeFeeDelegatedValueTransfer { - amount := new(big.Int).Mul(big.NewInt(10000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(10000), new(big.Int).SetUint64(params.KAIA)) values := map[types.TxValueKeyType]interface{}{ types.TxValueKeyNonce: reservoir.Nonce, types.TxValueKeyFrom: reservoir.Addr, diff --git a/tests/testutil_blockchain_test.go b/tests/testutil_blockchain_test.go index 34cd633aea..c31ab9b132 100644 --- a/tests/testutil_blockchain_test.go +++ b/tests/testutil_blockchain_test.go @@ -65,7 +65,7 @@ var blockchainTestChainConfig = ¶ms.ChainConfig{ Governance: ¶ms.GovernanceConfig{ GovernanceMode: "none", Reward: ¶ms.RewardConfig{ - MintingAmount: big.NewInt(params.KLAY * 6.4), + MintingAmount: big.NewInt(params.KAIA * 6.4), Ratio: "100/0/0", Kip82Ratio: "20/80", UseGiniCoeff: false, @@ -140,7 +140,7 @@ func (ctx *blockchainTestContext) setGenesis(alloc blockchain.GenesisAlloc) { vanity := make([]byte, types.IstanbulExtraVanity) // Genesis Alloc from overrides.alloc + rich accountAddrs - richBalance := new(big.Int).Mul(big.NewInt(params.KLAY), big.NewInt(10_000_000)) + richBalance := new(big.Int).Mul(big.NewInt(params.KAIA), big.NewInt(10_000_000)) for _, addr := range ctx.accountAddrs { account := alloc[addr] account.Balance = richBalance diff --git a/tests/tx_gas_calculation_test.go b/tests/tx_gas_calculation_test.go index aee9b4ee28..4a431d8dfd 100644 --- a/tests/tx_gas_calculation_test.go +++ b/tests/tx_gas_calculation_test.go @@ -135,7 +135,7 @@ func TestGasCalculation(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.GetNonce(), accountTypes[0].account.GetAddr(), amount, gasLimit, gasPrice, []byte{}) @@ -158,7 +158,7 @@ func TestGasCalculation(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.GetNonce(), anon.Addr, amount, gasLimit, gasPrice, []byte{}) diff --git a/tests/tx_validation_test.go b/tests/tx_validation_test.go index 8ef6307a25..9ad5b3f7f1 100644 --- a/tests/tx_validation_test.go +++ b/tests/tx_validation_test.go @@ -1998,7 +1998,7 @@ func TestValidationPoolResetAfterFeePayerKeyChange(t *testing.T) { types.TxValueKeyNonce: reservoir.GetNonce(), types.TxValueKeyFrom: reservoir.GetAddr(), types.TxValueKeyTo: feePayer.Addr, - types.TxValueKeyAmount: new(big.Int).Mul(big.NewInt(params.KLAY), big.NewInt(100000)), + types.TxValueKeyAmount: new(big.Int).Mul(big.NewInt(params.KAIA), big.NewInt(100000)), types.TxValueKeyGasLimit: gasLimit, types.TxValueKeyGasPrice: big.NewInt(25 * params.Ston), } diff --git a/tests/validate_sender_test.go b/tests/validate_sender_test.go index 34d0e0c0fa..9c987c7c25 100644 --- a/tests/validate_sender_test.go +++ b/tests/validate_sender_test.go @@ -104,7 +104,7 @@ func TestValidateSenderContract(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, multisig.Addr, amount, gasLimit, gasPrice, []byte{}) @@ -147,7 +147,7 @@ func TestValidateSenderContract(t *testing.T) { { var txs types.Transactions - amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KLAY)) + amount := new(big.Int).Mul(big.NewInt(3000), new(big.Int).SetUint64(params.KAIA)) tx := types.NewTransaction(reservoir.Nonce, multisig2.Addr, amount, gasLimit, gasPrice, []byte{}) From 2c95efa3c5626e70732233b0ae5a751b14696406 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 20:26:59 +0900 Subject: [PATCH 04/27] Chage denomination in console --- console/jsre/deps/web3.js | 84 +++++++++++++++++++-------------------- console/web3ext/doc.go | 3 +- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/console/jsre/deps/web3.js b/console/jsre/deps/web3.js index 18dae444bf..871c0d2a8b 100644 --- a/console/jsre/deps/web3.js +++ b/console/jsre/deps/web3.js @@ -1787,17 +1787,17 @@ var KLAY_UNITS = [ 'Mpeb', 'Gpeb', 'ston', - 'uKLAY', - 'mKLAY', - 'KLAY', - 'kKLAY', - 'MKLAY', - 'GKLAY', - 'TKLAY', - 'PKLAY', - 'EKLAY', - 'ZKLAY', - 'YKLAY', + 'uKAIA', + 'mKAIA', + 'KAIA', + 'kKAIA', + 'MKAIA', + 'GKAIA', + 'TKAIA', + 'PKAIA', + 'EKAIA', + 'ZKAIA', + 'YKAIA', ]; module.exports = { @@ -1899,13 +1899,13 @@ var unitMap = { 'Mpeb': '1000000', 'Gpeb': '1000000000', 'ston': '1000000000', - 'uKLAY': '1000000000000', - 'mKLAY': '1000000000000000', - 'KLAY': '1000000000000000000', - 'kKLAY': '1000000000000000000000', - 'MKLAY': '1000000000000000000000000', - 'GKLAY': '1000000000000000000000000000', - 'TKLAY': '1000000000000000000000000000000' + 'uKAIA': '1000000000000', + 'mKAIA': '1000000000000000', + 'KAIA': '1000000000000000000', + 'kKAIA': '1000000000000000000000', + 'MKAIA': '1000000000000000000000000', + 'GKAIA': '1000000000000000000000000000', + 'TKAIA': '1000000000000000000000000000000' }; var unitEthToKlayMap = { @@ -1924,18 +1924,18 @@ var unitEthToKlayMap = { 'shannon': 'Gpeb', 'nanoether': 'Gpeb', 'nano': 'Gpeb', - 'szabo': 'uKLAY', - 'microether': 'uKLAY', - 'micro': 'uKLAY', - 'finney': 'mKLAY', - 'milliether': 'mKLAY', - 'milli': 'mKLAY', - 'ether': 'KLAY', - 'kether': 'kKLAY', - 'grand': 'kKLAY', - 'mether': 'MKLAY', - 'gether': 'GKLAY', - 'tether': 'TKLAY' + 'szabo': 'uKAIA', + 'microether': 'uKAIA', + 'micro': 'uKAIA', + 'finney': 'mKAIA', + 'milliether': 'mKAIA', + 'milli': 'mKAIA', + 'ether': 'KAIA', + 'kether': 'kKAIA', + 'grand': 'kKAIA', + 'mether': 'MKAIA', + 'gether': 'GKAIA', + 'tether': 'TKAIA' }; /** @@ -2229,13 +2229,13 @@ var fromWei = function(number, unit) { * - kpeb * - Mpeb * - Gpeb - * - uKLAY - * - mKLAY + * - uKAIA + * - mKAIA * - KLAY - * - kKLAY - * - MKLAY - * - GKLAY - * - TKLAY + * - kKAIA + * - MKAIA + * - GKAIA + * - TKAIA * * @method fromPeb * @param {Number|String} number can be a number, number string or a HEX of a decimal @@ -2285,13 +2285,13 @@ var toWei = function(number, unit) { * - kpeb * - Mpeb * - Gpeb - * - uKLAY - * - mKLAY + * - uKAIA + * - mKAIA * - KLAY - * - kKLAY - * - MKLAY - * - GKLAY - * - TKLAY + * - kKAIA + * - MKAIA + * - GKAIA + * - TKAIA * * @method toPeb * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal diff --git a/console/web3ext/doc.go b/console/web3ext/doc.go index 4dc7e9ebe7..ce913a591c 100644 --- a/console/web3ext/doc.go +++ b/console/web3ext/doc.go @@ -25,9 +25,10 @@ web3ext defines `Modules` which defines APIs for each category. This `Modules` i # API Categories -APIs are categorized as follows. If you want to know more detail, please refer to https://docs.klaytn.com/bapp/json-rpc +APIs are categorized as follows. If you want to know more detail, please refer to https://docs.kaia.io/docs/references/ - admin - debug + - kaia - klay - miner - net From d93f70ccc5705c8db4a3549675bc0f863ab89658 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 20:27:09 +0900 Subject: [PATCH 05/27] Change docs url --- blockchain/types/account/doc.go | 2 +- blockchain/types/accountkey/doc.go | 2 +- blockchain/vm/contracts.go | 2 +- blockchain/vm/doc.go | 2 +- build/rpm/main.go | 14 +++++++------- consensus/istanbul/validator/doc.go | 2 +- governance/doc.go | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/blockchain/types/account/doc.go b/blockchain/types/account/doc.go index 6d91c1f2f4..153f628f42 100644 --- a/blockchain/types/account/doc.go +++ b/blockchain/types/account/doc.go @@ -44,6 +44,6 @@ Account related functions and variables are defined in the files listed below. - smart_contract_account.go : SmartContractAccount containing an AccountCommon is defined. For more information on Account, please refer to the document below. -https://docs.klaytn.com/klaytn/design/accounts#klaytn-accounts +https://docs.kaia.io/docs/learn/accounts/#klaytn-accounts- */ package account diff --git a/blockchain/types/accountkey/doc.go b/blockchain/types/accountkey/doc.go index d227552818..145f61f922 100644 --- a/blockchain/types/accountkey/doc.go +++ b/blockchain/types/accountkey/doc.go @@ -44,6 +44,6 @@ AccountKey related functions and variables are defined in the files listed below - public_key.go : PublicKeySerializable is defined for serialization of public key. For more information on AccountKey, please see the document below. -https://docs.klaytn.com/klaytn/design/accounts#account-key +https://docs.kaia.io/docs/learn/accounts/#account-key- */ package accountkey diff --git a/blockchain/vm/contracts.go b/blockchain/vm/contracts.go index 89199e7f70..9c05309005 100644 --- a/blockchain/vm/contracts.go +++ b/blockchain/vm/contracts.go @@ -55,7 +55,7 @@ var ( // requires a deterministic gas count based on the input size of the Run method of the // contract. // If you want more information about Kaia's precompiled contracts, -// please refer https://docs.klaytn.com/smart-contract/precompiled-contracts +// please refer https://docs.kaia.io/docs/learn/computation/precompiled-contracts/ type PrecompiledContract interface { // GetRequiredGasAndComputationCost returns the gas and computation cost // required to execute the precompiled contract. diff --git a/blockchain/vm/doc.go b/blockchain/vm/doc.go index 8f33085250..85e95914f6 100644 --- a/blockchain/vm/doc.go +++ b/blockchain/vm/doc.go @@ -25,6 +25,6 @@ The vm package implements one EVM, a byte code VM. The Byte Code VM loops over a set of bytes and executes them according to the set of rules defined in the Ethereum yellow paper. As well as the original functionality of the EVM, this package implemented additional pre-compiled contracts to support the native features of Kaia. -For more information about pre-compiled contracts, see KlaytnDocs (https://docs.klaytn.com/smart-contract/precompiled-contracts). +For more information about pre-compiled contracts, see KlaytnDocs (https://docs.kaia.io/docs/learn/computation/precompiled-contracts/). */ package vm diff --git a/build/rpm/main.go b/build/rpm/main.go index 0d693a480a..2e4bf2d220 100644 --- a/build/rpm/main.go +++ b/build/rpm/main.go @@ -33,37 +33,37 @@ var BINARY_TYPE = map[string]NodeInfo{ CN: { "kcnd", "Klaytn consensus node daemon", - "kcnd is a daemon for Klaytn consensus node (kcn). For more information, please refer to https://docs.klaytn.com.", + "kcnd is a daemon for Klaytn consensus node (kcn). For more information, please refer to https://docs.kaia.io.", }, PN: { "kpnd", "Klaytn proxy node daemon", - "kpnd is a daemon for Klaytn proxy node (kpn). For more information, please refer to https://docs.klaytn.com.", + "kpnd is a daemon for Klaytn proxy node (kpn). For more information, please refer to https://docs.kaia.io.", }, EN: { "kend", "Klaytn endpoint node daemon", - "kend is a daemon for Klaytn endpoint node (ken). For more information, please refer to https://docs.klaytn.com.", + "kend is a daemon for Klaytn endpoint node (ken). For more information, please refer to https://docs.kaia.io.", }, SCN: { "kscnd", "Klaytn servicechain consensus node daemon", - "kscnd is a daemon for Klaytn servicechain consensus node (kscn). For more information, please refer to https://docs.klaytn.com.", + "kscnd is a daemon for Klaytn servicechain consensus node (kscn). For more information, please refer to https://docs.kaia.io.", }, SPN: { "kspnd", "Klaytn servicechain proxy node daemon", - "kspnd is a daemon for Klaytn servicechain proxy node (kspn). For more information, please refer to https://docs.klaytn.com.", + "kspnd is a daemon for Klaytn servicechain proxy node (kspn). For more information, please refer to https://docs.kaia.io.", }, SEN: { "ksend", "Klaytn servicechain endpoint node daemon", - "ksend is a daemon for Klaytn servicechain endpoint node (ksen). For more information, please refer to https://docs.klaytn.com.", + "ksend is a daemon for Klaytn servicechain endpoint node (ksen). For more information, please refer to https://docs.kaia.io.", }, BN: { "kbnd", "Klaytn boot node daemon", - "kbnd is a daemon for Klaytn boot node (kbn). For more information, please refer to https://docs.klaytn.com.", + "kbnd is a daemon for Klaytn boot node (kbn). For more information, please refer to https://docs.kaia.io.", }, HOMI: { "homi", diff --git a/consensus/istanbul/validator/doc.go b/consensus/istanbul/validator/doc.go index 332afbea7a..1958113833 100644 --- a/consensus/istanbul/validator/doc.go +++ b/consensus/istanbul/validator/doc.go @@ -39,7 +39,7 @@ A validator selected as a block proposer will have a chance to make a block. Kaia implements `Validator` and `ValidatorSet` interface for Kaia consensus. Klaytn reflects the ratio of staking amounts to the probability of selecting a proposer. This is called weightedRandom policy. -Detailed information can be found in https://docs.klaytn.com/klaytn/token_economy#klaytn-governance-council-reward. +Detailed information can be found in https://docs.kaia.io/docs/learn/token-economy/#klaytn-governance-council-reward-mechanism-. Implementation structures are weightedValidator and weightedCouncil in weighted.go file. # Files diff --git a/governance/doc.go b/governance/doc.go index 5f61f0fc51..bf6d84cf51 100644 --- a/governance/doc.go +++ b/governance/doc.go @@ -17,7 +17,7 @@ /* Package governance contains functions and variables used for voting and reflecting vote results in Kaia. In Kaia, various settings such as the amount of KAIA minted as a block reward can be changed by using governance vote. -These votes can be casted by nodes of Governance Council and detailed introduction can be found at https://docs.klaytn.com/klaytn/design/governance +These votes can be casted by nodes of Governance Council and detailed introduction can be found at https://docs.kaia.io/docs/learn/governance # How to cast a vote @@ -45,7 +45,7 @@ Following keys can be handled as of 7/20/2019. Governance package contains a governance struct which stores current system configurations and voting status. If a vote passed, the governance struct is updated to provide new information to related packages and users. -The API documentation can be found at https://docs.klaytn.com/bapp/json-rpc/api-references/governance +The API documentation can be found at https://docs.kaia.io/docs/references/json-rpc/governance/chain-config/ When a CN (consensus node which is managed by CCO) proposes a block, it writes its vote on the block header and other nodes parse the header and handle it. This process is handled by snapshot.go in the consensus engine and processed by functions in handler.go From 5bd45dce3ef1507660bed1cb95cca3901cfea690 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 21:29:05 +0900 Subject: [PATCH 06/27] Update accounts --- accounts/abi/bind/backend.go | 12 ++++---- accounts/abi/bind/backends/blockchain.go | 12 ++++---- accounts/abi/bind/backends/blockchain_test.go | 28 ++++++++--------- accounts/abi/bind/backends/simulated.go | 18 +++++------ accounts/abi/bind/backends/simulated_test.go | 30 +++++++++---------- accounts/abi/bind/base.go | 10 +++---- accounts/abi/bind/base_test.go | 6 ++-- accounts/abi/bind/template.go | 6 ++-- accounts/accounts.go | 4 +-- accounts/keystore/account_cache_test.go | 4 +-- accounts/keystore/keystore_wallet.go | 4 +-- 11 files changed, 67 insertions(+), 67 deletions(-) diff --git a/accounts/abi/bind/backend.go b/accounts/abi/bind/backend.go index 6af997ee37..cf6bf1c72f 100644 --- a/accounts/abi/bind/backend.go +++ b/accounts/abi/bind/backend.go @@ -25,7 +25,7 @@ import ( "errors" "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" ) @@ -53,7 +53,7 @@ type ContractCaller interface { CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error) // ContractCall executes a Kaia contract call with the specified data as the // input. - CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) + CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) } // PendingContractCaller defines methods to perform contract calls on the pending state. @@ -63,7 +63,7 @@ type PendingContractCaller interface { // PendingCodeAt returns the code of the given account in the pending state. PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error) // PendingCallContract executes a Kaia contract call against the pending state. - PendingCallContract(ctx context.Context, call klaytn.CallMsg) ([]byte, error) + PendingCallContract(ctx context.Context, call kaia.CallMsg) ([]byte, error) } // ContractTransactor defines the methods needed to allow operating with contract @@ -83,7 +83,7 @@ type ContractTransactor interface { // There is no guarantee that this is the true gas limit requirement as other // transactions may be added or removed by miners, but it should provide a basis // for setting a reasonable default. - EstimateGas(ctx context.Context, call klaytn.CallMsg) (gas uint64, err error) + EstimateGas(ctx context.Context, call kaia.CallMsg) (gas uint64, err error) // SendTransaction injects the transaction into the pending pool for execution. SendTransaction(ctx context.Context, tx *types.Transaction) error // ChainID can return the chain ID of the chain. @@ -97,11 +97,11 @@ type ContractFilterer interface { // returning all the results in one batch. // // TODO(karalabe): Deprecate when the subscription one can return past data too. - FilterLogs(ctx context.Context, query klaytn.FilterQuery) ([]types.Log, error) + FilterLogs(ctx context.Context, query kaia.FilterQuery) ([]types.Log, error) // SubscribeFilterLogs creates a background log filtering operation, returning // a subscription immediately, which can be used to stream the found events. - SubscribeFilterLogs(ctx context.Context, query klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) + SubscribeFilterLogs(ctx context.Context, query kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error) } // DeployBackend wraps the operations needed by WaitMined and WaitDeployed. diff --git a/accounts/abi/bind/backends/blockchain.go b/accounts/abi/bind/backends/blockchain.go index a746e034b7..01982e46df 100644 --- a/accounts/abi/bind/backends/blockchain.go +++ b/accounts/abi/bind/backends/blockchain.go @@ -21,7 +21,7 @@ import ( "errors" "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/state" @@ -106,7 +106,7 @@ func (b *BlockchainContractBackend) CodeAt(ctx context.Context, account common.A // - VM revert error // - VM other errors (e.g. NotProgramAccount, OutOfGas) // - Error outside VM -func (b *BlockchainContractBackend) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (b *BlockchainContractBackend) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { block, state, err := b.getBlockAndState(blockNumber) if err != nil { return nil, err @@ -122,7 +122,7 @@ func (b *BlockchainContractBackend) CallContract(ctx context.Context, call klayt return res.Return(), res.Unwrap() } -func (b *BlockchainContractBackend) callContract(call klaytn.CallMsg, block *types.Block, state *state.StateDB) (*blockchain.ExecutionResult, error) { +func (b *BlockchainContractBackend) callContract(call kaia.CallMsg, block *types.Block, state *state.StateDB) (*blockchain.ExecutionResult, error) { if call.Gas == 0 { call.Gas = uint64(3e8) // enough gas for ordinary contract calls } @@ -205,7 +205,7 @@ func (b *BlockchainContractBackend) SuggestGasPrice(ctx context.Context) (*big.I } } -func (b *BlockchainContractBackend) EstimateGas(ctx context.Context, call klaytn.CallMsg) (uint64, error) { +func (b *BlockchainContractBackend) EstimateGas(ctx context.Context, call kaia.CallMsg) (uint64, error) { state, err := b.bc.State() if err != nil { return 0, err @@ -247,7 +247,7 @@ func (b *BlockchainContractBackend) ChainID(ctx context.Context) (*big.Int, erro // bind.ContractFilterer defined methods -func (b *BlockchainContractBackend) FilterLogs(ctx context.Context, query klaytn.FilterQuery) ([]types.Log, error) { +func (b *BlockchainContractBackend) FilterLogs(ctx context.Context, query kaia.FilterQuery) ([]types.Log, error) { // Convert the current block numbers into internal representations if query.FromBlock == nil { query.FromBlock = big.NewInt(b.bc.CurrentBlock().Number().Int64()) @@ -279,7 +279,7 @@ func (b *BlockchainContractBackend) FilterLogs(ctx context.Context, query klaytn return res, nil } -func (b *BlockchainContractBackend) SubscribeFilterLogs(ctx context.Context, query klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) { +func (b *BlockchainContractBackend) SubscribeFilterLogs(ctx context.Context, query kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error) { // Subscribe to contract events sink := make(chan []*types.Log) diff --git a/accounts/abi/bind/backends/blockchain_test.go b/accounts/abi/bind/backends/blockchain_test.go index 2c6052d49f..b13e38b249 100644 --- a/accounts/abi/bind/backends/blockchain_test.go +++ b/accounts/abi/bind/backends/blockchain_test.go @@ -26,7 +26,7 @@ import ( "time" "github.com/golang/mock/gomock" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/types" @@ -122,7 +122,7 @@ func TestBlockchainCallContract(t *testing.T) { data_revertNoString, _ := parsedAbi2.Pack("revertNoString") // Normal case - ret, err := c.CallContract(context.Background(), klaytn.CallMsg{ + ret, err := c.CallContract(context.Background(), kaia.CallMsg{ From: testAddr, To: &code1Addr, Gas: 1000000, @@ -132,7 +132,7 @@ func TestBlockchainCallContract(t *testing.T) { assert.Equal(t, expectedReturn, ret) // Error outside VM - Intrinsic Gas - ret, err = c.CallContract(context.Background(), klaytn.CallMsg{ + ret, err = c.CallContract(context.Background(), kaia.CallMsg{ From: testAddr, To: &code1Addr, Gas: 20000, @@ -141,7 +141,7 @@ func TestBlockchainCallContract(t *testing.T) { assert.True(t, errors.Is(err, blockchain.ErrIntrinsicGas)) // VM revert error - empty reason - ret, err = c.CallContract(context.Background(), klaytn.CallMsg{ + ret, err = c.CallContract(context.Background(), kaia.CallMsg{ From: testAddr, To: &code2Addr, Gas: 100000, @@ -150,7 +150,7 @@ func TestBlockchainCallContract(t *testing.T) { assert.Equal(t, "execution reverted: ", err.Error()) // VM revert error - string reason - ret, err = c.CallContract(context.Background(), klaytn.CallMsg{ + ret, err = c.CallContract(context.Background(), kaia.CallMsg{ From: testAddr, To: &code2Addr, Gas: 100000, @@ -208,7 +208,7 @@ func TestBlockChainEstimateGas(t *testing.T) { c := NewBlockchainContractBackend(bc, nil, nil) // Normal case - gas, err := c.EstimateGas(context.Background(), klaytn.CallMsg{ + gas, err := c.EstimateGas(context.Background(), kaia.CallMsg{ From: testAddr, To: &testAddr, Value: big.NewInt(1000), @@ -217,7 +217,7 @@ func TestBlockChainEstimateGas(t *testing.T) { assert.Equal(t, uint64(params.TxGas), gas) // Error case - simple transfer with insufficient funds with zero gasPrice - gas, err = c.EstimateGas(context.Background(), klaytn.CallMsg{ + gas, err = c.EstimateGas(context.Background(), kaia.CallMsg{ From: code1Addr, To: &code1Addr, Value: big.NewInt(1), @@ -317,16 +317,16 @@ func initBackendForFiltererTests(t *testing.T, bc *blockchain.BlockChain) *Block txPoolConfig := blockchain.DefaultTxPoolConfig txPoolConfig.Journal = "/dev/null" // disable journaling to file txPool := blockchain.NewTxPool(txPoolConfig, bc.Config(), bc) - subscribeNewTxsEvent := func(ch chan<- blockchain.NewTxsEvent) klaytn.Subscription { + subscribeNewTxsEvent := func(ch chan<- blockchain.NewTxsEvent) kaia.Subscription { return txPool.SubscribeNewTxsEvent(ch) } - subscribeLogsEvent := func(ch chan<- []*types.Log) klaytn.Subscription { + subscribeLogsEvent := func(ch chan<- []*types.Log) kaia.Subscription { return bc.SubscribeLogsEvent(ch) } - subscribeRemovedLogsEvent := func(ch chan<- blockchain.RemovedLogsEvent) klaytn.Subscription { + subscribeRemovedLogsEvent := func(ch chan<- blockchain.RemovedLogsEvent) kaia.Subscription { return bc.SubscribeRemovedLogsEvent(ch) } - subscribeChainEvent := func(ch chan<- blockchain.ChainEvent) klaytn.Subscription { + subscribeChainEvent := func(ch chan<- blockchain.ChainEvent) kaia.Subscription { return bc.SubscribeChainEvent(ch) } mockBackend.EXPECT().SubscribeNewTxsEvent(any).DoAndReturn(subscribeNewTxsEvent).AnyTimes() @@ -345,7 +345,7 @@ func TestBlockChainFilterLogs(t *testing.T) { c := initBackendForFiltererTests(t, bc) // Normal case - logs, err := c.FilterLogs(context.Background(), klaytn.FilterQuery{ + logs, err := c.FilterLogs(context.Background(), kaia.FilterQuery{ FromBlock: big.NewInt(10), ToBlock: big.NewInt(11), Addresses: []common.Address{code1Addr}, @@ -354,7 +354,7 @@ func TestBlockChainFilterLogs(t *testing.T) { assert.Equal(t, 2, len(logs)) // No logs exist for code2Addr - logs, err = c.FilterLogs(context.Background(), klaytn.FilterQuery{ + logs, err = c.FilterLogs(context.Background(), kaia.FilterQuery{ FromBlock: big.NewInt(0), ToBlock: big.NewInt(11), Addresses: []common.Address{code2Addr}, @@ -368,7 +368,7 @@ func TestBlockChainSubscribeFilterLogs(t *testing.T) { c := initBackendForFiltererTests(t, bc) logs := make(chan types.Log) - sub, err := c.SubscribeFilterLogs(context.Background(), klaytn.FilterQuery{ + sub, err := c.SubscribeFilterLogs(context.Background(), kaia.FilterQuery{ FromBlock: big.NewInt(0), ToBlock: big.NewInt(20), Addresses: []common.Address{code1Addr}, diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 7b6e38170b..c9b0e32d17 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -28,7 +28,7 @@ import ( "sync" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/bloombits" @@ -227,7 +227,7 @@ func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common. if tx != nil { return tx, false, nil } - return nil, false, klaytn.NotFound + return nil, false, kaia.NotFound } // BlockByHash retrieves a block based on the block hash. @@ -354,7 +354,7 @@ func (b *SimulatedBackend) PendingCodeAt(_ context.Context, contract common.Addr } // CallContract executes a contract call. -func (b *SimulatedBackend) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (b *SimulatedBackend) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { b.mu.Lock() defer b.mu.Unlock() @@ -377,7 +377,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call klaytn.CallMsg } // PendingCallContract executes a contract call on the pending state. -func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call klaytn.CallMsg) ([]byte, error) { +func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call kaia.CallMsg) ([]byte, error) { b.mu.Lock() defer b.mu.Unlock() defer b.pendingState.RevertToSnapshot(b.pendingState.Snapshot()) @@ -410,7 +410,7 @@ func (b *SimulatedBackend) SuggestGasPrice(_ context.Context) (*big.Int, error) // EstimateGas executes the requested code against the latest block/state and // returns the used amount of gas. -func (b *SimulatedBackend) EstimateGas(ctx context.Context, call klaytn.CallMsg) (uint64, error) { +func (b *SimulatedBackend) EstimateGas(ctx context.Context, call kaia.CallMsg) (uint64, error) { b.mu.Lock() defer b.mu.Unlock() @@ -444,7 +444,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call klaytn.CallMsg) // callContract implements common code between normal and pending contract calls. // state is modified during execution, make sure to copy it if necessary. -func (b *SimulatedBackend) callContract(_ context.Context, call klaytn.CallMsg, block *types.Block, stateDB *state.StateDB) (*blockchain.ExecutionResult, error) { +func (b *SimulatedBackend) callContract(_ context.Context, call kaia.CallMsg, block *types.Block, stateDB *state.StateDB) (*blockchain.ExecutionResult, error) { // Ensure message is initialized properly. if call.GasPrice == nil { call.GasPrice = big.NewInt(1) @@ -513,7 +513,7 @@ func (b *SimulatedBackend) SendTransaction(_ context.Context, tx *types.Transact // returning all the results in one batch. // // TODO(karalabe): Deprecate when the subscription one can return past data too. -func (b *SimulatedBackend) FilterLogs(ctx context.Context, query klaytn.FilterQuery) ([]types.Log, error) { +func (b *SimulatedBackend) FilterLogs(ctx context.Context, query kaia.FilterQuery) ([]types.Log, error) { // Initialize unset filter boundaries to run from genesis to chain head from := int64(0) if query.FromBlock != nil { @@ -545,7 +545,7 @@ func (b *SimulatedBackend) ChainID(ctx context.Context) (*big.Int, error) { // SubscribeFilterLogs creates a background log filtering operation, returning a // subscription immediately, which can be used to stream the found events. -func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) { +func (b *SimulatedBackend) SubscribeFilterLogs(_ context.Context, query kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error) { // Subscribe to contract events sink := make(chan []*types.Log) @@ -583,7 +583,7 @@ func (b *SimulatedBackend) CurrentBlockNumber(ctx context.Context) (uint64, erro } // SubscribeNewHead returns an event subscription for a new header -func (b *SimulatedBackend) SubscribeNewHead(_ context.Context, ch chan<- *types.Header) (klaytn.Subscription, error) { +func (b *SimulatedBackend) SubscribeNewHead(_ context.Context, ch chan<- *types.Header) (kaia.Subscription, error) { // subscribe to a new head sink := make(chan *types.Header) sub := b.events.SubscribeNewHeads(sink) diff --git a/accounts/abi/bind/backends/simulated_test.go b/accounts/abi/bind/backends/simulated_test.go index 94bdd63096..8ea0d96074 100644 --- a/accounts/abi/bind/backends/simulated_test.go +++ b/accounts/abi/bind/backends/simulated_test.go @@ -30,7 +30,7 @@ import ( "testing" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/blockchain" @@ -56,8 +56,8 @@ func TestSimulatedBackend(t *testing.T) { if isPending { t.Fatal("transaction should not be pending") } - if err != klaytn.NotFound { - t.Fatalf("err should be `klaytn.NotFound` but received %v", err) + if err != kaia.NotFound { + t.Fatalf("err should be `kaia.NotFound` but received %v", err) } // generate a transaction and confirm you can retrieve it @@ -424,12 +424,12 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { cases := []struct { name string - message klaytn.CallMsg + message kaia.CallMsg expect uint64 expectError error expectData interface{} }{ - {"plain transfer(valid)", klaytn.CallMsg{ + {"plain transfer(valid)", kaia.CallMsg{ From: addr, To: &addr, Gas: 0, @@ -438,7 +438,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: nil, }, params.TxGas, nil, nil}, - {"plain transfer(invalid)", klaytn.CallMsg{ + {"plain transfer(invalid)", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 0, @@ -447,7 +447,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: nil, }, 0, errors.New("evm: execution reverted"), nil}, - {"Revert", klaytn.CallMsg{ + {"Revert", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 0, @@ -456,7 +456,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: common.Hex2Bytes("d8b98391"), }, 0, errors.New("execution reverted: revert reason"), "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d72657665727420726561736f6e00000000000000000000000000000000000000"}, - {"PureRevert", klaytn.CallMsg{ + {"PureRevert", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 0, @@ -465,7 +465,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: common.Hex2Bytes("aa8b1d30"), }, 0, errors.New("evm: execution reverted"), nil}, - {"OOG", klaytn.CallMsg{ + {"OOG", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 100000, @@ -474,7 +474,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: common.Hex2Bytes("50f6fe34"), }, 0, errors.New("gas required exceeds allowance (100000)"), nil}, - {"Assert", klaytn.CallMsg{ + {"Assert", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 100000, @@ -483,7 +483,7 @@ func TestSimulatedBackend_EstimateGas(t *testing.T) { Data: common.Hex2Bytes("b9b046f9"), }, 0, errors.New("VM error occurs while running smart contract"), nil}, - {"Valid", klaytn.CallMsg{ + {"Valid", kaia.CallMsg{ From: addr, To: &contractAddr, Gas: 100000, @@ -903,7 +903,7 @@ func TestSimulatedBackend_PendingAndCallContract(t *testing.T) { } // make sure you can call the contract in pending state - res, err := sim.PendingCallContract(bgCtx, klaytn.CallMsg{ + res, err := sim.PendingCallContract(bgCtx, kaia.CallMsg{ From: testAddr, To: &addr, Data: input, @@ -923,7 +923,7 @@ func TestSimulatedBackend_PendingAndCallContract(t *testing.T) { sim.Commit() // make sure you can call the contract - res, err = sim.CallContract(bgCtx, klaytn.CallMsg{ + res, err = sim.CallContract(bgCtx, kaia.CallMsg{ From: testAddr, To: &addr, Data: input, @@ -994,14 +994,14 @@ func TestSimulatedBackend_CallContractRevert(t *testing.T) { call := make([]func([]byte) ([]byte, error), 2) call[0] = func(input []byte) ([]byte, error) { - return sim.PendingCallContract(bgCtx, klaytn.CallMsg{ + return sim.PendingCallContract(bgCtx, kaia.CallMsg{ From: testAddr, To: &addr, Data: input, }) } call[1] = func(input []byte) ([]byte, error) { - return sim.CallContract(bgCtx, klaytn.CallMsg{ + return sim.CallContract(bgCtx, kaia.CallMsg{ From: testAddr, To: &addr, Data: input, diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index f1c7d360e5..d821a358e7 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -28,7 +28,7 @@ import ( "strings" "sync" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" @@ -161,7 +161,7 @@ func (c *BoundContract) Call(opts *CallOpts, results *[]interface{}, method stri return err } var ( - msg = klaytn.CallMsg{From: opts.From, To: &c.address, Data: input} + msg = kaia.CallMsg{From: opts.From, To: &c.address, Data: input} ctx = ensureContext(opts.Context) code []byte output []byte @@ -276,7 +276,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i } } // If the contract surely has code (or code is not needed), estimate the transaction - msg := klaytn.CallMsg{From: opts.From, To: contract, GasPrice: gasPrice, Value: value, Data: input} + msg := kaia.CallMsg{From: opts.From, To: contract, GasPrice: gasPrice, Value: value, Data: input} gasLimit, err = c.transactor.EstimateGas(ensureContext(opts.Context), msg) if err != nil { return nil, fmt.Errorf("failed to estimate gas needed: %v", err) @@ -326,7 +326,7 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]int // Start the background filtering logs := make(chan types.Log, 128) - config := klaytn.FilterQuery{ + config := kaia.FilterQuery{ Addresses: []common.Address{c.address}, Topics: topics, FromBlock: new(big.Int).SetUint64(opts.Start), @@ -374,7 +374,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter // Start the background filtering logs := make(chan types.Log, 128) - config := klaytn.FilterQuery{ + config := kaia.FilterQuery{ Addresses: []common.Address{c.address}, Topics: topics, } diff --git a/accounts/abi/bind/base_test.go b/accounts/abi/bind/base_test.go index 3298ae43eb..7d4ad142c6 100644 --- a/accounts/abi/bind/base_test.go +++ b/accounts/abi/bind/base_test.go @@ -27,7 +27,7 @@ import ( "strings" "testing" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/blockchain/types" @@ -49,7 +49,7 @@ func (mc *mockCaller) CodeAt(ctx context.Context, contract common.Address, block return []byte{1, 2, 3}, nil } -func (mc *mockCaller) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (mc *mockCaller) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { mc.callContractBlockNumber = blockNumber return nil, nil } @@ -59,7 +59,7 @@ func (mc *mockCaller) PendingCodeAt(ctx context.Context, contract common.Address return nil, nil } -func (mc *mockCaller) PendingCallContract(ctx context.Context, call klaytn.CallMsg) ([]byte, error) { +func (mc *mockCaller) PendingCallContract(ctx context.Context, call kaia.CallMsg) ([]byte, error) { mc.pendingCallContractCalled = true return nil, nil } diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index a01011ee2b..851bfe50c6 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -97,7 +97,7 @@ import ( "strings" "errors" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/common" @@ -110,7 +110,7 @@ var ( _ = errors.New _ = big.NewInt _ = strings.NewReader - _ = klaytn.NotFound + _ = kaia.NotFound _ = bind.Bind _ = common.Big1 _ = types.BloomLookup @@ -438,7 +438,7 @@ var ( event string // Event name to use for unpacking event data logs chan types.Log // Log channel receiving the found contract events - sub klaytn.Subscription // Subscription for errors, completion and termination + sub kaia.Subscription // Subscription for errors, completion and termination done bool // Whether the subscription completed delivering logs fail error // Occurred error to stop iteration } diff --git a/accounts/accounts.go b/accounts/accounts.go index 7f1d37baed..31f00bcf9b 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -23,7 +23,7 @@ package accounts import ( "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/event" @@ -88,7 +88,7 @@ type Wallet interface { // // You can disable automatic account discovery by calling SelfDerive with a nil // chain state reader. - SelfDerive(base DerivationPath, chain klaytn.ChainReader) + SelfDerive(base DerivationPath, chain kaia.ChainReader) // SignHash requests the wallet to sign the given hash. // diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go index 59e633eec7..63090c2d69 100644 --- a/accounts/keystore/account_cache_test.go +++ b/accounts/keystore/account_cache_test.go @@ -101,7 +101,7 @@ func TestWatchNoDir(t *testing.T) { // Create ks but not the directory that it watches. rand.Seed(time.Now().UnixNano()) - dir := filepath.Join(os.TempDir(), fmt.Sprintf("klay-keystore-watch-test-%d-%d", os.Getpid(), rand.Int())) + dir := filepath.Join(os.TempDir(), fmt.Sprintf("kaia-keystore-watch-test-%d-%d", os.Getpid(), rand.Int())) ks := NewKeyStore(dir, LightScryptN, LightScryptP) list := ks.Accounts() @@ -330,7 +330,7 @@ func TestUpdatedKeyfileContents(t *testing.T) { // Create a temporary kesytore to test with rand.Seed(time.Now().UnixNano()) - dir := filepath.Join(os.TempDir(), fmt.Sprintf("klay-keystore-watch-test-%d-%d", os.Getpid(), rand.Int())) + dir := filepath.Join(os.TempDir(), fmt.Sprintf("kaia-keystore-watch-test-%d-%d", os.Getpid(), rand.Int())) ks := NewKeyStore(dir, LightScryptN, LightScryptP) list := ks.Accounts() diff --git a/accounts/keystore/keystore_wallet.go b/accounts/keystore/keystore_wallet.go index e3b450e49d..bc560a32e3 100644 --- a/accounts/keystore/keystore_wallet.go +++ b/accounts/keystore/keystore_wallet.go @@ -23,7 +23,7 @@ package keystore import ( "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts" "github.com/klaytn/klaytn/blockchain/types" ) @@ -80,7 +80,7 @@ func (w *keystoreWallet) Derive(path accounts.DerivationPath, pin bool) (account // SelfDerive implements accounts.Wallet, but is a noop for plain wallets since // there is no notion of hierarchical account derivation for plain keystore accounts. -func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain klaytn.ChainReader) {} +func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain kaia.ChainReader) {} // SignHash implements accounts.Wallet, attempting to sign the given hash with // the given account. If the wallet does not wrap this particular account, an From 302e737a475b40978b4ee238adccfe1148c3e941 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 21:35:57 +0900 Subject: [PATCH 07/27] Update api --- api/api_ethereum_test.go | 20 ++++++++++---------- api/api_private_account.go | 8 ++++---- api/api_private_account_test.go | 2 +- api/api_public_blockchain_test.go | 8 ++++---- api/api_public_transaction_pool.go | 4 ++-- api/backend.go | 4 ++-- api/mocks/backend_mock.go | 6 +++--- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/api/api_ethereum_test.go b/api/api_ethereum_test.go index f4428b8b42..acb90bd738 100644 --- a/api/api_ethereum_test.go +++ b/api/api_ethereum_test.go @@ -2465,9 +2465,9 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate chain = &testChainContext{header: header} // tx arguments - KLAY = hexutil.Big(*big.NewInt(params.KAIA)) - mKLAY = hexutil.Big(*big.NewInt(params.KAIA / 1000)) - KLAY2_1 = hexutil.Big(*big.NewInt(params.KAIA*2 + 1)) + KAIA = hexutil.Big(*big.NewInt(params.KAIA)) + mKAIA = hexutil.Big(*big.NewInt(params.KAIA / 1000)) + KAIA2_1 = hexutil.Big(*big.NewInt(params.KAIA*2 + 1)) gas1000 = hexutil.Uint64(1000) gas40000 = hexutil.Uint64(40000) baddata = hexutil.Bytes(hexutil.MustDecode("0xdeadbeef")) @@ -2502,7 +2502,7 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate args: EthTransactionArgs{ From: &account1, To: &account2, - Value: &KLAY, + Value: &KAIA, }, expectGas: 21000, }, @@ -2510,7 +2510,7 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate args: EthTransactionArgs{ From: &account2, // sender has 0 KAIA To: &account1, - Value: &KLAY, // transfer 1 KAIA + Value: &KAIA, // transfer 1 KAIA }, expectErr: "insufficient balance for transfer", }, @@ -2519,7 +2519,7 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate args: EthTransactionArgs{ From: &account1, // sender has 2 KAIA To: &account2, - Value: &KLAY2_1, // transfer 2.0000...1 KAIA + Value: &KAIA2_1, // transfer 2.0000...1 KAIA }, expectErr: "insufficient balance for transfer", }, @@ -2527,8 +2527,8 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate args: EthTransactionArgs{ From: &account2, // sender has 0 KAIA To: &account1, - Value: &KLAY, // transfer 1 KAIA - GasPrice: &mKLAY, + Value: &KAIA, // transfer 1 KAIA + GasPrice: &mKAIA, }, expectErr: "insufficient funds for transfer", }, @@ -2536,8 +2536,8 @@ func testEstimateGas(t *testing.T, mockBackend *mock_api.MockBackend, fnEstimate args: EthTransactionArgs{ From: &account1, // sender has 2 KAIA To: &account2, - Value: &KLAY, // transfer 1 KAIA - GasPrice: &mKLAY, // allowance = (2 - 1) / 0.001 = 1000 gas + Value: &KAIA, // transfer 1 KAIA + GasPrice: &mKAIA, // allowance = (2 - 1) / 0.001 = 1000 gas }, expectErr: "gas required exceeds allowance", }, diff --git a/api/api_private_account.go b/api/api_private_account.go index 6c7fcdfdcc..09d13686f2 100644 --- a/api/api_private_account.go +++ b/api/api_private_account.go @@ -141,7 +141,7 @@ func fetchKeystore(am accounts.AccountManager) *keystore.KeyStore { return am.Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore) } -func parseKlaytnWalletKey(k string) (string, string, *common.Address, error) { +func parseKaiaWalletKey(k string) (string, string, *common.Address, error) { // if key length is not 110, just return. if len(k) != 110 { return k, "", nil, nil @@ -149,7 +149,7 @@ func parseKlaytnWalletKey(k string) (string, string, *common.Address, error) { walletKeyType := k[66:68] if walletKeyType != "00" { - return "", "", nil, fmt.Errorf("Klaytn wallet key type must be 00.") + return "", "", nil, fmt.Errorf("Kaia wallet key type must be 00.") } a := common.HexToAddress(k[70:110]) @@ -159,7 +159,7 @@ func parseKlaytnWalletKey(k string) (string, string, *common.Address, error) { // ReplaceRawKey stores the given hex encoded ECDSA key into the key directory, // encrypting it with the passphrase. func (s *PrivateAccountAPI) ReplaceRawKey(privkey string, passphrase string, newPassphrase string) (common.Address, error) { - privkey, _, address, err := parseKlaytnWalletKey(privkey) + privkey, _, address, err := parseKaiaWalletKey(privkey) if err != nil { return common.Address{}, err } @@ -174,7 +174,7 @@ func (s *PrivateAccountAPI) ReplaceRawKey(privkey string, passphrase string, new // ImportRawKey stores the given hex encoded ECDSA key into the key directory, // encrypting it with the passphrase. func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { - privkey, _, address, err := parseKlaytnWalletKey(privkey) + privkey, _, address, err := parseKaiaWalletKey(privkey) if err != nil { return common.Address{}, err } diff --git a/api/api_private_account_test.go b/api/api_private_account_test.go index 381e323115..75818b6ac7 100644 --- a/api/api_private_account_test.go +++ b/api/api_private_account_test.go @@ -74,7 +74,7 @@ func TestPrivateAccountAPI_ImportRawKey(t *testing.T) { // 4. Allowable Wallet key type is 0x00 only. { _, err := api.ImportRawKey("f8cc7c3813ad23817466b1802ee805ee417001fcce9376ab8728c92dd8ea0a6b0x010x819104a190255e0cedbdd9d5f59a557633d79db1", "1234") - require.Equal(t, fmt.Errorf("Klaytn wallet key type must be 00."), err) + require.Equal(t, fmt.Errorf("Kaia wallet key type must be 00."), err) } // 5. Should return an error if wrong length. diff --git a/api/api_public_blockchain_test.go b/api/api_public_blockchain_test.go index 50efd6ba26..7a533cce9f 100644 --- a/api/api_public_blockchain_test.go +++ b/api/api_public_blockchain_test.go @@ -27,7 +27,7 @@ import ( "github.com/klaytn/klaytn/params" ) -func testInitForKlayApi(t *testing.T) (*gomock.Controller, *mock_api.MockBackend, *PublicBlockChainAPI) { +func testInitForKaiaApi(t *testing.T) (*gomock.Controller, *mock_api.MockBackend, *PublicBlockChainAPI) { mockCtrl := gomock.NewController(t) mockBackend := mock_api.NewMockBackend(mockCtrl) @@ -37,12 +37,12 @@ func testInitForKlayApi(t *testing.T) (*gomock.Controller, *mock_api.MockBackend return mockCtrl, mockBackend, api } -func TestKlaytnAPI_EstimateGas(t *testing.T) { - mockCtrl, mockBackend, api := testInitForKlayApi(t) +func TestKaiaAPI_EstimateGas(t *testing.T) { + mockCtrl, mockBackend, api := testInitForKaiaApi(t) defer mockCtrl.Finish() testEstimateGas(t, mockBackend, func(ethArgs EthTransactionArgs) (hexutil.Uint64, error) { - // Testcases are written in EthTransactionArgs. Convert to klay CallArgs + // Testcases are written in EthTransactionArgs. Convert to Kaia CallArgs args := CallArgs{ From: ethArgs.from(), To: ethArgs.To, diff --git a/api/api_public_transaction_pool.go b/api/api_public_transaction_pool.go index c765d1ae74..25cc6036ac 100644 --- a/api/api_public_transaction_pool.go +++ b/api/api_public_transaction_pool.go @@ -559,7 +559,7 @@ func (s *PublicTransactionPoolAPI) RecoverFromTransaction(ctx context.Context, e if len(encodedTx) == 0 { return common.Address{}, fmt.Errorf("Empty input") } - if 0 < encodedTx[0] && encodedTx[0] < 0x8 { // TODO: Add helper to distinguish eth vs klay txtypes + if 0 < encodedTx[0] && encodedTx[0] < 0x8 { // TODO: Add helper to distinguish eth vs Kaia txtypes ethEnvelope := []byte{byte(types.EthereumTxTypeEnvelope)} encodedTx = append(ethEnvelope, encodedTx...) } @@ -609,7 +609,7 @@ func (s *PublicTransactionPoolAPI) RecoverFromMessage( } key := state.GetKey(address) - // We cannot identify if the signature has signed with klay or eth prefix without the signer's address. + // We cannot identify if the signature has signed with kaia or eth prefix without the signer's address. // Even though a user signed message with eth prefix, it will return invalid something in klayEcRecover. // We should call each rcrecover function separately and the actual result will be checked in ValidateMember. var recoverErr error diff --git a/api/backend.go b/api/backend.go index 4b61eae0ec..2ad8600c91 100644 --- a/api/backend.go +++ b/api/backend.go @@ -25,7 +25,7 @@ import ( "math/big" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/state" @@ -45,7 +45,7 @@ import ( //go:generate mockgen -destination=api/mocks/backend_mock.go github.com/klaytn/klaytn/api Backend type Backend interface { // General Kaia API - Progress() klaytn.SyncProgress + Progress() kaia.SyncProgress ProtocolVersion() int SuggestPrice(ctx context.Context) (*big.Int, error) SuggestTipCap(ctx context.Context) (*big.Int, error) diff --git a/api/mocks/backend_mock.go b/api/mocks/backend_mock.go index 099e986184..8e0fd9f80d 100644 --- a/api/mocks/backend_mock.go +++ b/api/mocks/backend_mock.go @@ -11,7 +11,7 @@ import ( time "time" gomock "github.com/golang/mock/gomock" - klaytn "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" accounts "github.com/klaytn/klaytn/accounts" blockchain "github.com/klaytn/klaytn/blockchain" state "github.com/klaytn/klaytn/blockchain/state" @@ -454,10 +454,10 @@ func (mr *MockBackendMockRecorder) LowerBoundGasPrice(arg0 interface{}) *gomock. } // Progress mocks base method. -func (m *MockBackend) Progress() klaytn.SyncProgress { +func (m *MockBackend) Progress() kaia.SyncProgress { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Progress") - ret0, _ := ret[0].(klaytn.SyncProgress) + ret0, _ := ret[0].(kaia.SyncProgress) return ret0 } From 5cb2b6bffe328ca7633d490bfb378f18bde91984 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 21:40:21 +0900 Subject: [PATCH 08/27] Update blockchain --- blockchain/blockchain.go | 36 +++++++++---------- blockchain/state_migration_test.go | 2 +- blockchain/system/rebalance.go | 4 +-- blockchain/types/account/doc.go | 2 +- blockchain/types/block_test.go | 4 +-- blockchain/types/tx_internal_data.go | 2 +- .../types/tx_internal_data_fee_ratio_test.go | 4 +-- .../tx_internal_data_sender_hash_test.go | 2 +- .../types/tx_internal_data_serializer_test.go | 2 +- blockchain/vm/doc.go | 2 +- tests/account_keytype_test.go | 4 +-- tests/tx_validation_test.go | 18 +++++----- 12 files changed, 41 insertions(+), 41 deletions(-) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index 642cd7f848..ecb4694245 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -49,7 +49,7 @@ import ( "github.com/klaytn/klaytn/event" "github.com/klaytn/klaytn/fork" "github.com/klaytn/klaytn/log" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/params" "github.com/klaytn/klaytn/rlp" "github.com/klaytn/klaytn/storage/database" @@ -62,29 +62,29 @@ import ( const insertTimeLimit = common.PrettyDuration(time.Second) var ( - accountReadTimer = klaytnmetrics.NewRegisteredHybridTimer("state/account/reads", nil) - accountHashTimer = klaytnmetrics.NewRegisteredHybridTimer("state/account/hashes", nil) - accountUpdateTimer = klaytnmetrics.NewRegisteredHybridTimer("state/account/updates", nil) - accountCommitTimer = klaytnmetrics.NewRegisteredHybridTimer("state/account/commits", nil) + accountReadTimer = kaiametrics.NewRegisteredHybridTimer("state/account/reads", nil) + accountHashTimer = kaiametrics.NewRegisteredHybridTimer("state/account/hashes", nil) + accountUpdateTimer = kaiametrics.NewRegisteredHybridTimer("state/account/updates", nil) + accountCommitTimer = kaiametrics.NewRegisteredHybridTimer("state/account/commits", nil) - storageReadTimer = klaytnmetrics.NewRegisteredHybridTimer("state/storage/reads", nil) - storageHashTimer = klaytnmetrics.NewRegisteredHybridTimer("state/storage/hashes", nil) - storageUpdateTimer = klaytnmetrics.NewRegisteredHybridTimer("state/storage/updates", nil) - storageCommitTimer = klaytnmetrics.NewRegisteredHybridTimer("state/storage/commits", nil) + storageReadTimer = kaiametrics.NewRegisteredHybridTimer("state/storage/reads", nil) + storageHashTimer = kaiametrics.NewRegisteredHybridTimer("state/storage/hashes", nil) + storageUpdateTimer = kaiametrics.NewRegisteredHybridTimer("state/storage/updates", nil) + storageCommitTimer = kaiametrics.NewRegisteredHybridTimer("state/storage/commits", nil) snapshotAccountReadTimer = metrics.NewRegisteredTimer("state/snapshot/account/reads", nil) snapshotStorageReadTimer = metrics.NewRegisteredTimer("state/snapshot/storage/reads", nil) snapshotCommitTimer = metrics.NewRegisteredTimer("state/snapshot/commits", nil) blockBaseFee = metrics.NewRegisteredGauge("chain/basefee", nil) - blockInsertTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/inserts", nil) - blockProcessTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/process", nil) - blockExecutionTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/execution", nil) - blockFinalizeTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/finalize", nil) - blockValidateTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/validate", nil) - blockAgeTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/age", nil) - - blockPrefetchExecuteTimer = klaytnmetrics.NewRegisteredHybridTimer("chain/prefetch/executes", nil) + blockInsertTimer = kaiametrics.NewRegisteredHybridTimer("chain/inserts", nil) + blockProcessTimer = kaiametrics.NewRegisteredHybridTimer("chain/process", nil) + blockExecutionTimer = kaiametrics.NewRegisteredHybridTimer("chain/execution", nil) + blockFinalizeTimer = kaiametrics.NewRegisteredHybridTimer("chain/finalize", nil) + blockValidateTimer = kaiametrics.NewRegisteredHybridTimer("chain/validate", nil) + blockAgeTimer = kaiametrics.NewRegisteredHybridTimer("chain/age", nil) + + blockPrefetchExecuteTimer = kaiametrics.NewRegisteredHybridTimer("chain/prefetch/executes", nil) blockPrefetchInterruptMeter = metrics.NewRegisteredMeter("chain/prefetch/interrupts", nil) ErrNoGenesis = errors.New("genesis not found in chain") @@ -2803,7 +2803,7 @@ func GetInternalTxTrace(tracer vm.Tracer) (*vm.InternalTxTrace, error) { func CheckBlockChainVersion(chainDB database.DBManager) error { bcVersion := chainDB.ReadDatabaseVersion() if bcVersion != nil && *bcVersion > BlockChainVersion { - return fmt.Errorf("database version is v%d, Klaytn %s only supports v%d", *bcVersion, params.Version, BlockChainVersion) + return fmt.Errorf("database version is v%d, Kaia %s only supports v%d", *bcVersion, params.Version, BlockChainVersion) } else if bcVersion == nil || *bcVersion < BlockChainVersion { bcVersionStr := "N/A" if bcVersion != nil { diff --git a/blockchain/state_migration_test.go b/blockchain/state_migration_test.go index fbe68f7951..514b7d4c60 100644 --- a/blockchain/state_migration_test.go +++ b/blockchain/state_migration_test.go @@ -31,7 +31,7 @@ import ( ) func createLocalTestDB(t *testing.T) (string, database.DBManager) { - dir, err := os.MkdirTemp("", "klaytn-test-migration") + dir, err := os.MkdirTemp("", "kaia-test-migration-") if err != nil { t.Fatalf("failed to create a database: %v", err) } diff --git a/blockchain/system/rebalance.go b/blockchain/system/rebalance.go index b4c7ed1000..c21cdf997c 100644 --- a/blockchain/system/rebalance.go +++ b/blockchain/system/rebalance.go @@ -22,7 +22,7 @@ import ( "errors" "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/accounts/abi/bind/backends" "github.com/klaytn/klaytn/blockchain" @@ -102,7 +102,7 @@ func (caller *Kip103ContractCaller) CodeAt(ctx context.Context, contract common. return caller.state.GetCode(contract), nil } -func (caller *Kip103ContractCaller) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (caller *Kip103ContractCaller) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { gasPrice := big.NewInt(0) // execute call regardless of the balance of the sender gasLimit := uint64(1e8) // enough gas limit to execute kip103 contract functions intrinsicGas := uint64(0) // read operation doesn't require intrinsicGas diff --git a/blockchain/types/account/doc.go b/blockchain/types/account/doc.go index 153f628f42..0640255219 100644 --- a/blockchain/types/account/doc.go +++ b/blockchain/types/account/doc.go @@ -44,6 +44,6 @@ Account related functions and variables are defined in the files listed below. - smart_contract_account.go : SmartContractAccount containing an AccountCommon is defined. For more information on Account, please refer to the document below. -https://docs.kaia.io/docs/learn/accounts/#klaytn-accounts- +https://docs.kaia.io/docs/learn/accounts/#kaia-accounts- */ package account diff --git a/blockchain/types/block_test.go b/blockchain/types/block_test.go index 5a984b063c..6ad17a87c3 100644 --- a/blockchain/types/block_test.go +++ b/blockchain/types/block_test.go @@ -36,9 +36,9 @@ import ( type testBlockEncodingTC struct { encoded string // RLP encoded block; debug.getBlockRlp(num) - hash common.Hash // block hash; klay.getBlock(num).hash + hash common.Hash // block hash; kaia.getBlock(num).hash header *Header // expected header fields - encodedTxs [][]byte // expected transactions, RLP encoded; klay.getRawTransaction(txhash) + encodedTxs [][]byte // expected transactions, RLP encoded; kaia.getRawTransaction(txhash) } var blockEncodingTCs map[string]testBlockEncodingTC diff --git a/blockchain/types/tx_internal_data.go b/blockchain/types/tx_internal_data.go index 30f0f0dcdb..404857da4d 100644 --- a/blockchain/types/tx_internal_data.go +++ b/blockchain/types/tx_internal_data.go @@ -53,7 +53,7 @@ const ( TxTypeCancel, TxTypeFeeDelegatedCancel, TxTypeFeeDelegatedCancelWithRatio TxTypeBatch, _, _ TxTypeChainDataAnchoring, TxTypeFeeDelegatedChainDataAnchoring, TxTypeFeeDelegatedChainDataAnchoringWithRatio - TxTypeKlaytnLast, _, _ + TxTypeKaiaLast, _, _ TxTypeEthereumAccessList = TxType(0x7801) TxTypeEthereumDynamicFee = TxType(0x7802) TxTypeEthereumLast = TxType(0x7803) diff --git a/blockchain/types/tx_internal_data_fee_ratio_test.go b/blockchain/types/tx_internal_data_fee_ratio_test.go index 0dcf55de80..334d955123 100644 --- a/blockchain/types/tx_internal_data_fee_ratio_test.go +++ b/blockchain/types/tx_internal_data_fee_ratio_test.go @@ -22,7 +22,7 @@ import "testing" // This prohibits the case that GetFeeRatio() is not implemented for TxTypeFeeDelegatedWithRatio types. func TestFeeRatioCheck(t *testing.T) { for i := TxTypeLegacyTransaction; i < TxTypeEthereumLast; i++ { - if i == TxTypeKlaytnLast { + if i == TxTypeKaiaLast { i = TxTypeEthereumAccessList } @@ -39,7 +39,7 @@ func TestFeeRatioCheck(t *testing.T) { // This prohibits the case that GetFeePayer() is not implemented for TxTypeFeeDelegatedXXX types. func TestFeeDelegatedCheck(t *testing.T) { for i := TxTypeLegacyTransaction; i < TxTypeEthereumLast; i++ { - if i == TxTypeKlaytnLast { + if i == TxTypeKaiaLast { i = TxTypeEthereumAccessList } diff --git a/blockchain/types/tx_internal_data_sender_hash_test.go b/blockchain/types/tx_internal_data_sender_hash_test.go index eea453a839..9f2fbcf5a6 100644 --- a/blockchain/types/tx_internal_data_sender_hash_test.go +++ b/blockchain/types/tx_internal_data_sender_hash_test.go @@ -81,7 +81,7 @@ func TestTransactionSenderTxHash(t *testing.T) { // Below code checks whether serialization for all tx implementations is done or not. // If no serialization, make test failed. for i := TxTypeLegacyTransaction; i < TxTypeEthereumLast; i++ { - if i == TxTypeKlaytnLast { + if i == TxTypeKaiaLast { i = TxTypeEthereumAccessList } diff --git a/blockchain/types/tx_internal_data_serializer_test.go b/blockchain/types/tx_internal_data_serializer_test.go index 50b06781bf..9350914b79 100644 --- a/blockchain/types/tx_internal_data_serializer_test.go +++ b/blockchain/types/tx_internal_data_serializer_test.go @@ -98,7 +98,7 @@ func TestTransactionSerialization(t *testing.T) { // Below code checks whether serialization for all tx implementations is done or not. // If no serialization, make test failed. for i := TxTypeLegacyTransaction; i < TxTypeEthereumLast; i++ { - if i == TxTypeKlaytnLast { + if i == TxTypeKaiaLast { i = TxTypeEthereumAccessList } diff --git a/blockchain/vm/doc.go b/blockchain/vm/doc.go index 85e95914f6..3c9d8e6c80 100644 --- a/blockchain/vm/doc.go +++ b/blockchain/vm/doc.go @@ -25,6 +25,6 @@ The vm package implements one EVM, a byte code VM. The Byte Code VM loops over a set of bytes and executes them according to the set of rules defined in the Ethereum yellow paper. As well as the original functionality of the EVM, this package implemented additional pre-compiled contracts to support the native features of Kaia. -For more information about pre-compiled contracts, see KlaytnDocs (https://docs.kaia.io/docs/learn/computation/precompiled-contracts/). +For more information about pre-compiled contracts, see docs (https://docs.kaia.io/docs/learn/computation/precompiled-contracts/). */ package vm diff --git a/tests/account_keytype_test.go b/tests/account_keytype_test.go index b2f0738f9b..8fd75a905e 100644 --- a/tests/account_keytype_test.go +++ b/tests/account_keytype_test.go @@ -484,7 +484,7 @@ func TestDefaultTxsWithDefaultAccountKey(t *testing.T) { txTypes := []types.TxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -1845,7 +1845,7 @@ func TestRoleBasedKeySendTx(t *testing.T) { txTypes := []types.TxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } diff --git a/tests/tx_validation_test.go b/tests/tx_validation_test.go index 9ad5b3f7f1..6bd4761a65 100644 --- a/tests/tx_validation_test.go +++ b/tests/tx_validation_test.go @@ -103,7 +103,7 @@ func TestValidationPoolInsert(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -232,7 +232,7 @@ func TestValidationPoolInsertMagma(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -361,7 +361,7 @@ func TestValidationBlockTx(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -567,7 +567,7 @@ func invalidCodeFormat(txType types.TxType, values txValueMap, contract common.A func TestValidationInvalidSig(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -794,7 +794,7 @@ func TestLegacyTxFromNonLegacyAcc(t *testing.T) { func TestInvalidBalance(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -1187,7 +1187,7 @@ func TestInvalidBalanceBlockTx(t *testing.T) { testTxTypes := []testTxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -1601,7 +1601,7 @@ func TestInvalidBalanceBlockTx(t *testing.T) { func TestValidationTxSizeAfterRLP(t *testing.T) { testTxTypes := []types.TxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -1767,7 +1767,7 @@ func TestValidationTxSizeAfterRLP(t *testing.T) { func TestValidationPoolResetAfterSenderKeyChange(t *testing.T) { txTypes := []types.TxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } @@ -1912,7 +1912,7 @@ func TestValidationPoolResetAfterSenderKeyChange(t *testing.T) { func TestValidationPoolResetAfterFeePayerKeyChange(t *testing.T) { txTypes := []types.TxType{} for i := types.TxTypeLegacyTransaction; i < types.TxTypeEthereumLast; i++ { - if i == types.TxTypeKlaytnLast { + if i == types.TxTypeKaiaLast { i = types.TxTypeEthereumAccessList } From 6e68227bff78117d64bd1c1771e7a24fca9055e2 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 21:50:20 +0900 Subject: [PATCH 09/27] Update build --- build/ci.go | 22 +++++++++---------- build/package-rpm.sh | 8 +++---- build/package-tar.sh | 14 ++++++------ build/packaging/linux/bin/kbnd | 2 +- build/packaging/linux/bin/kcnd | 2 +- build/packaging/linux/bin/kend | 2 +- build/packaging/linux/bin/kpnd | 2 +- build/packaging/linux/bin/kscnd | 2 +- build/packaging/linux/bin/ksend | 2 +- build/packaging/linux/bin/kspnd | 2 +- build/rpm/etc/init.d/kbnd | 4 ++-- build/rpm/etc/init.d/kcnd | 4 ++-- build/rpm/etc/init.d/kend | 4 ++-- build/rpm/etc/init.d/kpnd | 4 ++-- build/rpm/etc/init.d/kscnd | 4 ++-- build/rpm/etc/init.d/ksend | 4 ++-- build/rpm/etc/init.d/kspnd | 4 ++-- build/rpm/main.go | 38 ++++++++++++++++----------------- utils/build/env.go | 20 ++++++++--------- 19 files changed, 72 insertions(+), 72 deletions(-) diff --git a/build/ci.go b/build/ci.go index 0ec758046a..f3e8089cbb 100644 --- a/build/ci.go +++ b/build/ci.go @@ -43,7 +43,7 @@ import ( var ( // Files that end up in the klay*.zip archive. - klayArchiveFiles = []string{ + kaiaArchiveFiles = []string{ "COPYING", executablePath("klay"), } @@ -58,7 +58,7 @@ var ( debExecutables = []debExecutable{ { Name: "klay", - Description: "Klaytn CLI client.", + Description: "Kaia CLI client.", }, } @@ -139,7 +139,7 @@ func doInstall(cmdline []string) { if minor < 9 { log.Println("You have Go version", runtime.Version()) - log.Println("klaytn requires at least Go version 1.9 and cannot") + log.Println("Kaia requires at least Go version 1.9 and cannot") log.Println("be compiled with an earlier version. Please upgrade your Go installation.") os.Exit(1) } @@ -216,7 +216,7 @@ func buildFlags(env build.Environment) (flags []string) { // By default, cmd/link will use external linking mode when non-standard cgo packages are involved. ld = append(ld, "-linkmode", "external", "-extldflags", "-static") } - if env.IsKlaytnRaceDetectionOn { + if env.IsKaiaRaceDetectionOn { flags = append(flags, "-race") } if len(ld) > 0 { @@ -448,17 +448,17 @@ func doArchive(cmdline []string) { var ( env = build.Env() base = archiveBasename(*arch, env) - klaybin = "klay-" + base + ext + kaiabin = "klay-" + base + ext alltools = "klay-alltools-" + base + ext ) maybeSkipArchive(env) - if err := build.WriteArchive(klaybin, klayArchiveFiles); err != nil { + if err := build.WriteArchive(kaiabin, kaiaArchiveFiles); err != nil { log.Fatal(err) } if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil { log.Fatal(err) } - for _, archive := range []string{klaybin, alltools} { + for _, archive := range []string{kaiabin, alltools} { if err := archiveUpload(archive, *upload, *signer); err != nil { log.Fatal(err) } @@ -604,7 +604,7 @@ type debExecutable struct { func newDebMetadata(distro, author string, env build.Environment, t time.Time) debMetadata { if author == "" { // No signing key, use default author. - author = "Klaytn Builds " + author = "Kaia Builds " } return debMetadata{ Env: env, @@ -718,7 +718,7 @@ func doWindowsInstaller(cmdline []string) { var ( devTools []string allTools []string - klayTool string + kaiaTool string ) for _, file := range allToolsArchiveFiles { if file == "COPYING" { // license, copied later @@ -726,7 +726,7 @@ func doWindowsInstaller(cmdline []string) { } allTools = append(allTools, filepath.Base(file)) if filepath.Base(file) == "klay.exe" { - klayTool = file + kaiaTool = file } else { devTools = append(devTools, file) } @@ -736,7 +736,7 @@ func doWindowsInstaller(cmdline []string) { // first section contains the Kaia binary, second section holds the dev tools. templateData := map[string]interface{}{ "License": "COPYING", - "Klay": klayTool, + "Klay": kaiaTool, "DevTools": devTools, } build.Render("build/nsis.klay.nsi", filepath.Join(*workdir, "klay.nsi"), 0o644, nil) diff --git a/build/package-rpm.sh b/build/package-rpm.sh index a55adf2756..817240d7b5 100755 --- a/build/package-rpm.sh +++ b/build/package-rpm.sh @@ -41,8 +41,8 @@ function finish { } trap finish EXIT -KLAYTN_VERSION=$(go run build/rpm/main.go version) -KLAYTN_RELEASE_NUM=$(go run build/rpm/main.go release_num) +KAIA_VERSION=$(go run build/rpm/main.go version) +KAIA_RELEASE_NUM=$(go run build/rpm/main.go release_num) PLATFORM_SUFFIX=$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m) PACK_NAME= @@ -52,7 +52,7 @@ PACK_VERSION= for b in ${DAEMON_BINARIES[*]}; do if [ "$TARGET" == "$b" ]; then PACK_NAME=${b}-${PLATFORM_SUFFIX} - PACK_VERSION=${b}d${BAOBAB_PREFIX}-${KLAYTN_VERSION} + PACK_VERSION=${b}d${BAOBAB_PREFIX}-${KAIA_VERSION} fi done @@ -60,7 +60,7 @@ done for b in ${BINARIES[*]}; do if [ "$TARGET" == "$b" ]; then PACK_NAME=${b}-${PLATFORM_SUFFIX} - PACK_VERSION=${b}${BAOBAB_PREFIX}-${KLAYTN_VERSION} + PACK_VERSION=${b}${BAOBAB_PREFIX}-${KAIA_VERSION} fi done diff --git a/build/package-tar.sh b/build/package-tar.sh index ad9752012f..746515f022 100755 --- a/build/package-tar.sh +++ b/build/package-tar.sh @@ -73,19 +73,19 @@ function finish { } trap finish EXIT -KLAYTN_VERSION=$(go run build/rpm/main.go version) -KLAYTN_RELEASE_NUM=$(go run build/rpm/main.go release_num) -PACKAGE_SUFFIX="${KLAYTN_VERSION}-${KLAYTN_RELEASE_NUM}-${PLATFORM_SUFFIX}.tar.gz" +KAIA_VERSION=$(go run build/rpm/main.go version) +KAIA_RELEASE_NUM=$(go run build/rpm/main.go release_num) +PACKAGE_SUFFIX="${KAIA_VERSION}-${KAIA_RELEASE_NUM}-${PLATFORM_SUFFIX}.tar.gz" PACK_NAME= -KLAYTN_PACKAGE_NAME= +KAIA_PACKAGE_NAME= DAEMON= # Search the target from DAEMON_BINARIES. for b in ${DAEMON_BINARIES[*]}; do if [ "$TARGET" == "$b" ]; then PACK_NAME=${b}-${PLATFORM_SUFFIX} - KLAYTN_PACKAGE_NAME="${b}${BAOBAB}-${PACKAGE_SUFFIX}" + KAIA_PACKAGE_NAME="${b}${BAOBAB}-${PACKAGE_SUFFIX}" DAEMON=1 fi done @@ -94,7 +94,7 @@ done for b in ${BINARIES[*]}; do if [ "$TARGET" == "$b" ]; then PACK_NAME=${b}-${PLATFORM_SUFFIX} - KLAYTN_PACKAGE_NAME="${b}${BAOBAB}-${PACKAGE_SUFFIX}" + KAIA_PACKAGE_NAME="${b}${BAOBAB}-${PACKAGE_SUFFIX}" fi done @@ -126,4 +126,4 @@ fi # Compress! mkdir -p packages -tar czf packages/$KLAYTN_PACKAGE_NAME $PACK_NAME +tar czf packages/$KAIA_PACKAGE_NAME $PACK_NAME diff --git a/build/packaging/linux/bin/kbnd b/build/packaging/linux/bin/kbnd index 35ef56d6e5..9526f55a8d 100755 --- a/build/packaging/linux/bin/kbnd +++ b/build/packaging/linux/bin/kbnd @@ -106,7 +106,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/kcnd b/build/packaging/linux/bin/kcnd index 9adade85c1..9803f5b4d8 100755 --- a/build/packaging/linux/bin/kcnd +++ b/build/packaging/linux/bin/kcnd @@ -117,7 +117,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/kend b/build/packaging/linux/bin/kend index 4ec0f6c1c4..9eecd3cbfc 100755 --- a/build/packaging/linux/bin/kend +++ b/build/packaging/linux/bin/kend @@ -118,7 +118,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/kpnd b/build/packaging/linux/bin/kpnd index 7f5f4b0d4b..29e544df8e 100755 --- a/build/packaging/linux/bin/kpnd +++ b/build/packaging/linux/bin/kpnd @@ -118,7 +118,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/kscnd b/build/packaging/linux/bin/kscnd index fc6b9d0fd2..de4d4e3ad4 100755 --- a/build/packaging/linux/bin/kscnd +++ b/build/packaging/linux/bin/kscnd @@ -118,7 +118,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/ksend b/build/packaging/linux/bin/ksend index b331b402f3..3948daf2aa 100755 --- a/build/packaging/linux/bin/ksend +++ b/build/packaging/linux/bin/ksend @@ -118,7 +118,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/packaging/linux/bin/kspnd b/build/packaging/linux/bin/kspnd index df095ed2b0..d1c4276973 100755 --- a/build/packaging/linux/bin/kspnd +++ b/build/packaging/linux/bin/kspnd @@ -118,7 +118,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- __check_option() { if [ ! -d $LOG_DIR ]; then diff --git a/build/rpm/etc/init.d/kbnd b/build/rpm/etc/init.d/kbnd index cc3d237344..1533b423a4 100755 --- a/build/rpm/etc/init.d/kbnd +++ b/build/rpm/etc/init.d/kbnd @@ -3,7 +3,7 @@ # kbnd Startup script for the kbn # # chkconfig: - 85 15 -# description : kbnd is Klaytn boot node daemon +# description : kbnd is Kaia boot node daemon # # processname: kbnd # config: /etc/kbnd/conf/kbnd.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- start_node() { echo -n "Starting $prog: " diff --git a/build/rpm/etc/init.d/kcnd b/build/rpm/etc/init.d/kcnd index 5a4fb7bc76..4e773cbb42 100755 --- a/build/rpm/etc/init.d/kcnd +++ b/build/rpm/etc/init.d/kcnd @@ -3,7 +3,7 @@ # kcnd Startup script for the kcn # # chkconfig: - 85 15 -# description : kcnd is Klaytn consensus node daemon +# description : kcnd is Kaia consensus node daemon # # processname: kcnd # config: /etc/kcnd/conf/kcnd.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- set -f OPTIONS="" diff --git a/build/rpm/etc/init.d/kend b/build/rpm/etc/init.d/kend index 5651894484..3d357e6742 100755 --- a/build/rpm/etc/init.d/kend +++ b/build/rpm/etc/init.d/kend @@ -3,7 +3,7 @@ # kend Startup script for the ken # # chkconfig: - 85 15 -# description : kend is the Klaytn endpoint node daemon +# description : kend is the Kaia endpoint node daemon # # processname: kend # config: /etc/kend/conf/kend.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- set -f OPTIONS="" diff --git a/build/rpm/etc/init.d/kpnd b/build/rpm/etc/init.d/kpnd index 1527d28b39..57a5ae441d 100755 --- a/build/rpm/etc/init.d/kpnd +++ b/build/rpm/etc/init.d/kpnd @@ -3,7 +3,7 @@ # kpnd Startup script for the kpn # # chkconfig: - 85 15 -# description : kpnd is the Klaytn proxy node daemon +# description : kpnd is the Kaia proxy node daemon # # processname: kpnd # config: /etc/kpnd/conf/kpnd.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- set -f OPTIONS="" diff --git a/build/rpm/etc/init.d/kscnd b/build/rpm/etc/init.d/kscnd index 70a044f72a..f1d06af1cc 100755 --- a/build/rpm/etc/init.d/kscnd +++ b/build/rpm/etc/init.d/kscnd @@ -3,7 +3,7 @@ # kscnd Startup script for the kscnd # # chkconfig: - 85 15 -# description : kscnd is Klaytn consensus node daemon +# description : kscnd is Kaia consensus node daemon # # processname: kscnd # config: /etc/kscnd/conf/kscnd.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- set -f OPTIONS="--nodiscover" diff --git a/build/rpm/etc/init.d/ksend b/build/rpm/etc/init.d/ksend index bdc7035b03..f904917337 100755 --- a/build/rpm/etc/init.d/ksend +++ b/build/rpm/etc/init.d/ksend @@ -3,7 +3,7 @@ # ksend Startup script for the ksen # # chkconfig: - 85 15 -# description : ksend is the Klaytn endpoint node daemon +# description : ksend is the Kaia endpoint node daemon # # processname: ksend # config: /etc/ksend/conf/ksend.conf @@ -101,7 +101,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- set -f OPTIONS="" diff --git a/build/rpm/etc/init.d/kspnd b/build/rpm/etc/init.d/kspnd index e309e22fce..c7a52bb854 100755 --- a/build/rpm/etc/init.d/kspnd +++ b/build/rpm/etc/init.d/kspnd @@ -3,7 +3,7 @@ # kspnd Startup script for the kspn # # chkconfig: - 85 15 -# description : kspnd is the Klaytn proxy node daemon +# description : kspnd is the Kaia proxy node daemon # # processname: kspnd # config: /etc/kspnd/conf/kspnd.conf @@ -104,7 +104,7 @@ status_auto_restart_daemon() { fi } -#------------------------Related to Klaytn node functions----------------------------- +#------------------------Related to Kaia node functions----------------------------- if [[ ! -z $METRICS ]] && [[ $METRICS -eq 1 ]]; then OPTIONS="$OPTIONS --metrics" diff --git a/build/rpm/main.go b/build/rpm/main.go index 2e4bf2d220..d9cd8f040f 100644 --- a/build/rpm/main.go +++ b/build/rpm/main.go @@ -32,38 +32,38 @@ type NodeInfo struct { var BINARY_TYPE = map[string]NodeInfo{ CN: { "kcnd", - "Klaytn consensus node daemon", - "kcnd is a daemon for Klaytn consensus node (kcn). For more information, please refer to https://docs.kaia.io.", + "Kaia consensus node daemon", + "kcnd is a daemon for Kaia consensus node (kcn). For more information, please refer to https://docs.kaia.io.", }, PN: { "kpnd", - "Klaytn proxy node daemon", - "kpnd is a daemon for Klaytn proxy node (kpn). For more information, please refer to https://docs.kaia.io.", + "Kaia proxy node daemon", + "kpnd is a daemon for Kaia proxy node (kpn). For more information, please refer to https://docs.kaia.io.", }, EN: { "kend", - "Klaytn endpoint node daemon", - "kend is a daemon for Klaytn endpoint node (ken). For more information, please refer to https://docs.kaia.io.", + "Kaia endpoint node daemon", + "kend is a daemon for Kaia endpoint node (ken). For more information, please refer to https://docs.kaia.io.", }, SCN: { "kscnd", - "Klaytn servicechain consensus node daemon", - "kscnd is a daemon for Klaytn servicechain consensus node (kscn). For more information, please refer to https://docs.kaia.io.", + "Kaia servicechain consensus node daemon", + "kscnd is a daemon for Kaia servicechain consensus node (kscn). For more information, please refer to https://docs.kaia.io.", }, SPN: { "kspnd", - "Klaytn servicechain proxy node daemon", - "kspnd is a daemon for Klaytn servicechain proxy node (kspn). For more information, please refer to https://docs.kaia.io.", + "Kaia servicechain proxy node daemon", + "kspnd is a daemon for Kaia servicechain proxy node (kspn). For more information, please refer to https://docs.kaia.io.", }, SEN: { "ksend", - "Klaytn servicechain endpoint node daemon", - "ksend is a daemon for Klaytn servicechain endpoint node (ksen). For more information, please refer to https://docs.kaia.io.", + "Kaia servicechain endpoint node daemon", + "ksend is a daemon for Kaia servicechain endpoint node (ksen). For more information, please refer to https://docs.kaia.io.", }, BN: { "kbnd", - "Klaytn boot node daemon", - "kbnd is a daemon for Klaytn boot node (kbn). For more information, please refer to https://docs.kaia.io.", + "Kaia boot node daemon", + "kbnd is a daemon for Kaia boot node (kbn). For more information, please refer to https://docs.kaia.io.", }, HOMI: { "homi", @@ -107,7 +107,7 @@ func (r RpmSpec) String() string { func main() { app := cli.NewApp() - app.Name = "klaytn_rpmtool" + app.Name = "kaia_rpmtool" app.Version = "0.2" app.Commands = []*cli.Command{ { @@ -117,7 +117,7 @@ func main() { Flags: []cli.Flag{ &cli.StringFlag{ Name: "binary_type", - Usage: "Klaytn binary type (kcn, kpn, ken, kscn, kspn, ksen, kbn, kgen, homi)", + Usage: "Kaia binary type (kcn, kpn, ken, kscn, kspn, ksen, kbn, kgen, homi)", }, &cli.BoolFlag{ Name: "devel", @@ -137,7 +137,7 @@ func main() { { Name: "version", Aliases: []string{"v"}, - Usage: "return klaytn version", + Usage: "return Kaia version", Action: func(c *cli.Context) error { fmt.Print(params.Version) return nil @@ -146,7 +146,7 @@ func main() { { Name: "release_num", Aliases: []string{"r"}, - Usage: "return klaytn release number", + Usage: "return Kaia release number", Action: func(c *cli.Context) error { fmt.Print(params.ReleaseNum) return nil @@ -202,7 +202,7 @@ Summary: {{ .Summary }} Group: Application/blockchain License: GNU -URL: https://www.klaytn.com +URL: https://kaia.io Source0: %{name}-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) diff --git a/utils/build/env.go b/utils/build/env.go index a1b8666bf6..97374492a5 100644 --- a/utils/build/env.go +++ b/utils/build/env.go @@ -39,15 +39,15 @@ var ( // Environment contains metadata provided by the build environment. type Environment struct { - Name string // name of the environment - Repo string // name of GitHub repo - Commit, Branch, Tag string // Git info - Buildnum string - IsPullRequest bool - IsCronJob bool - IsKlaytnRaceDetectionOn bool - IsStaticLink bool - IsDisabledSymbolTable bool + Name string // name of the environment + Repo string // name of GitHub repo + Commit, Branch, Tag string // Git info + Buildnum string + IsPullRequest bool + IsCronJob bool + IsKaiaRaceDetectionOn bool + IsStaticLink bool + IsDisabledSymbolTable bool } func (env Environment) String() string { @@ -91,7 +91,7 @@ func LocalEnv() Environment { env := applyEnvFlags(Environment{Name: "local", Repo: "klaytn/klaytn"}) if os.Getenv("KLAYTN_RACE_DETECT") == "1" { - env.IsKlaytnRaceDetectionOn = true + env.IsKaiaRaceDetectionOn = true } if os.Getenv("KLAYTN_STATIC_LINK") == "1" { env.IsStaticLink = true From 617f71c96142030747e28d57b7e5b5b42d892b7e Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 21:55:08 +0900 Subject: [PATCH 10/27] Update client --- build/update-license.go | 4 +- client/bridge_client.go | 4 +- client/{klay_client.go => kaia_client.go} | 38 +++++++++---------- ...lay_client_test.go => kaia_client_test.go} | 28 +++++++------- client/signer.go | 12 +++--- 5 files changed, 43 insertions(+), 43 deletions(-) rename client/{klay_client.go => kaia_client.go} (95%) rename client/{klay_client_test.go => kaia_client_test.go} (65%) diff --git a/build/update-license.go b/build/update-license.go index 883685f92a..199909ec18 100644 --- a/build/update-license.go +++ b/build/update-license.go @@ -728,8 +728,8 @@ var ( "event/example_subscription_test.go": "event/example_subscription_test.go", "event/filter/generic_filter.go": "event/filter/generic_filter.go", "event/filter/filter.go": "event/filter/filter.go", - "client/klay_client.go": "ethclient/ethclient.go", - "client/klay_client_test.go": "ethclient/ethclient_test.go", + "client/kaia_client.go": "ethclient/ethclient.go", + "client/kaia_client_test.go": "ethclient/ethclient_test.go", "client/signer.go": "ethclient/signer.go", "client/bridge_client.go": "ethclient/ethclient.go", "console/prompter.go": "console/prompter.go", diff --git a/client/bridge_client.go b/client/bridge_client.go index ddb6f51b1c..673ab14976 100644 --- a/client/bridge_client.go +++ b/client/bridge_client.go @@ -25,7 +25,7 @@ import ( "errors" "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/common/hexutil" @@ -102,7 +102,7 @@ func (ec *Client) BridgeGetReceiptFromParentChain(ctx context.Context, hash comm var result *types.Receipt err := ec.c.CallContext(ctx, &result, "subbridge_getReceiptFromParentChain", hash) if err == nil && result == nil { - return nil, klaytn.NotFound + return nil, kaia.NotFound } return result, err } diff --git a/client/klay_client.go b/client/kaia_client.go similarity index 95% rename from client/klay_client.go rename to client/kaia_client.go index 9c3842a285..1c04cc14f5 100644 --- a/client/klay_client.go +++ b/client/kaia_client.go @@ -27,7 +27,7 @@ import ( "fmt" "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/api" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" @@ -100,7 +100,7 @@ func (ec *Client) getBlock(ctx context.Context, method string, args ...interface if err != nil { return nil, err } else if len(raw) == 0 { - return nil, klaytn.NotFound + return nil, kaia.NotFound } // Decode header and transactions. var head *types.Header @@ -135,7 +135,7 @@ func (ec *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.He var head *types.Header err := ec.c.CallContext(ctx, &head, "klay_getBlockByHash", hash, false) if err == nil && head == nil { - err = klaytn.NotFound + err = kaia.NotFound } return head, err } @@ -146,7 +146,7 @@ func (ec *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.H var head *types.Header err := ec.c.CallContext(ctx, &head, "klay_getBlockByNumber", toBlockNumArg(number), false) if err == nil && head == nil { - err = klaytn.NotFound + err = kaia.NotFound } return head, err } @@ -176,7 +176,7 @@ func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx * if err != nil { return nil, false, err } else if json == nil { - return nil, false, klaytn.NotFound + return nil, false, kaia.NotFound } else if sigs := json.tx.RawSignatureValues(); sigs[0].V == nil { return nil, false, fmt.Errorf("server returned transaction without signature") } @@ -229,7 +229,7 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, return nil, err } if json == nil { - return nil, klaytn.NotFound + return nil, kaia.NotFound } else if sigs := json.tx.RawSignatureValues(); sigs[0].V == nil { return nil, fmt.Errorf("server returned transaction without signature") } @@ -246,7 +246,7 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (* err := ec.c.CallContext(ctx, &r, "klay_getTransactionReceipt", txHash) if err == nil { if r == nil { - return nil, klaytn.NotFound + return nil, kaia.NotFound } } return r, err @@ -256,7 +256,7 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (* func (ec *Client) TransactionReceiptRpcOutput(ctx context.Context, txHash common.Hash) (r map[string]interface{}, err error) { err = ec.c.CallContext(ctx, &r, "klay_getTransactionReceipt", txHash) if err == nil && r == nil { - return nil, klaytn.NotFound + return nil, kaia.NotFound } return } @@ -278,7 +278,7 @@ type rpcProgress struct { // SyncProgress retrieves the current progress of the sync algorithm. If there's // no sync currently running, it returns nil. -func (ec *Client) SyncProgress(ctx context.Context) (*klaytn.SyncProgress, error) { +func (ec *Client) SyncProgress(ctx context.Context) (*kaia.SyncProgress, error) { var raw json.RawMessage if err := ec.c.CallContext(ctx, &raw, "klay_syncing"); err != nil { return nil, err @@ -292,7 +292,7 @@ func (ec *Client) SyncProgress(ctx context.Context) (*klaytn.SyncProgress, error if err := json.Unmarshal(raw, &progress); err != nil { return nil, err } - return &klaytn.SyncProgress{ + return &kaia.SyncProgress{ StartingBlock: uint64(progress.StartingBlock), CurrentBlock: uint64(progress.CurrentBlock), HighestBlock: uint64(progress.HighestBlock), @@ -303,7 +303,7 @@ func (ec *Client) SyncProgress(ctx context.Context) (*klaytn.SyncProgress, error // SubscribeNewHead subscribes to notifications about the current blockchain head // on the given channel. -func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (klaytn.Subscription, error) { +func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (kaia.Subscription, error) { return ec.c.KlaySubscribe(ctx, ch, "newHeads") } @@ -357,18 +357,18 @@ func (ec *Client) NonceAt(ctx context.Context, account common.Address, blockNumb // Filters // FilterLogs executes a filter query. -func (ec *Client) FilterLogs(ctx context.Context, q klaytn.FilterQuery) ([]types.Log, error) { +func (ec *Client) FilterLogs(ctx context.Context, q kaia.FilterQuery) ([]types.Log, error) { var result []types.Log err := ec.c.CallContext(ctx, &result, "klay_getLogs", toFilterArg(q)) return result, err } // SubscribeFilterLogs subscribes to the results of a streaming filter query. -func (ec *Client) SubscribeFilterLogs(ctx context.Context, q klaytn.FilterQuery, ch chan<- types.Log) (klaytn.Subscription, error) { +func (ec *Client) SubscribeFilterLogs(ctx context.Context, q kaia.FilterQuery, ch chan<- types.Log) (kaia.Subscription, error) { return ec.c.KlaySubscribe(ctx, ch, "logs", toFilterArg(q)) } -func toFilterArg(q klaytn.FilterQuery) interface{} { +func toFilterArg(q kaia.FilterQuery) interface{} { arg := map[string]interface{}{ "fromBlock": toBlockNumArg(q.FromBlock), "toBlock": toBlockNumArg(q.ToBlock), @@ -429,7 +429,7 @@ func (ec *Client) PendingTransactionCount(ctx context.Context) (uint, error) { // blockNumber selects the block height at which the call runs. It can be nil, in which // case the code is taken from the latest known block. Note that state from very old // blocks might not be available. -func (ec *Client) CallContract(ctx context.Context, msg klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (ec *Client) CallContract(ctx context.Context, msg kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { var hex hexutil.Bytes err := ec.c.CallContext(ctx, &hex, "klay_call", toCallArg(msg), toBlockNumArg(blockNumber)) if err != nil { @@ -440,7 +440,7 @@ func (ec *Client) CallContract(ctx context.Context, msg klaytn.CallMsg, blockNum // PendingCallContract executes a message call transaction using the EVM. // The state seen by the contract call is the pending state. -func (ec *Client) PendingCallContract(ctx context.Context, msg klaytn.CallMsg) ([]byte, error) { +func (ec *Client) PendingCallContract(ctx context.Context, msg kaia.CallMsg) ([]byte, error) { var hex hexutil.Bytes err := ec.c.CallContext(ctx, &hex, "klay_call", toCallArg(msg), "pending") if err != nil { @@ -463,7 +463,7 @@ func (ec *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) { // the latest state of the backend blockchain. There is no guarantee that this is // the true gas limit requirement as other transactions may be added or removed by miners, // but it should provide a basis for setting a reasonable default. -func (ec *Client) EstimateGas(ctx context.Context, msg klaytn.CallMsg) (uint64, error) { +func (ec *Client) EstimateGas(ctx context.Context, msg kaia.CallMsg) (uint64, error) { var hex hexutil.Uint64 err := ec.c.CallContext(ctx, &hex, "klay_estimateGas", toCallArg(msg)) if err != nil { @@ -548,7 +548,7 @@ func (ec *Client) UnlockAccount(ctx context.Context, address common.Address, pas return result, err } -func toCallArg(msg klaytn.CallMsg) interface{} { +func toCallArg(msg kaia.CallMsg) interface{} { arg := map[string]interface{}{ "from": msg.From, "to": msg.To, @@ -629,7 +629,7 @@ func (ec *Client) RemovePeer(ctx context.Context, url string) (bool, error) { // CreateAccessList tries to create an access list for a specific transaction based on the // current pending state of the blockchain. -func (ec *Client) CreateAccessList(ctx context.Context, msg klaytn.CallMsg) (*types.AccessList, uint64, string, error) { +func (ec *Client) CreateAccessList(ctx context.Context, msg kaia.CallMsg) (*types.AccessList, uint64, string, error) { type AccessListResult struct { Accesslist *types.AccessList `json:"accessList"` Error string `json:"error,omitempty"` diff --git a/client/klay_client_test.go b/client/kaia_client_test.go similarity index 65% rename from client/klay_client_test.go rename to client/kaia_client_test.go index f9dae8413a..46ae527fc5 100644 --- a/client/klay_client_test.go +++ b/client/kaia_client_test.go @@ -20,21 +20,21 @@ package client -import "github.com/klaytn/klaytn" +import kaia "github.com/klaytn/klaytn" // Verify that Client implements the Kaia interfaces. var ( - // _ = Kaia.Subscription(&Client{}) - _ = klaytn.ChainReader(&Client{}) - _ = klaytn.TransactionReader(&Client{}) - _ = klaytn.ChainStateReader(&Client{}) - _ = klaytn.ChainSyncReader(&Client{}) - _ = klaytn.ContractCaller(&Client{}) - _ = klaytn.LogFilterer(&Client{}) - _ = klaytn.TransactionSender(&Client{}) - _ = klaytn.GasPricer(&Client{}) - _ = klaytn.PendingStateReader(&Client{}) - _ = klaytn.PendingContractCaller(&Client{}) - _ = klaytn.GasEstimator(&Client{}) - // _ = Kaia.PendingStateEventer(&Client{}) + // _ = kaia.Subscription(&Client{}) + _ = kaia.ChainReader(&Client{}) + _ = kaia.TransactionReader(&Client{}) + _ = kaia.ChainStateReader(&Client{}) + _ = kaia.ChainSyncReader(&Client{}) + _ = kaia.ContractCaller(&Client{}) + _ = kaia.LogFilterer(&Client{}) + _ = kaia.TransactionSender(&Client{}) + _ = kaia.GasPricer(&Client{}) + _ = kaia.PendingStateReader(&Client{}) + _ = kaia.PendingContractCaller(&Client{}) + _ = kaia.GasEstimator(&Client{}) + // _ = kaia.PendingStateEventer(&Client{}) ) diff --git a/client/signer.go b/client/signer.go index 2131e41afe..8d2081847b 100644 --- a/client/signer.go +++ b/client/signer.go @@ -58,36 +58,36 @@ func (s *senderFromServer) Sender(tx *types.Transaction) (common.Address, error) func (s *senderFromServer) ChainID() *big.Int { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("ChainID should not be called!") } func (s *senderFromServer) SenderPubkey(tx *types.Transaction) ([]*ecdsa.PublicKey, error) { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("SenderPubkey should not be called!") } func (s *senderFromServer) SenderFeePayer(tx *types.Transaction) ([]*ecdsa.PublicKey, error) { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("SenderFeePayer should not be called!") } func (s *senderFromServer) Hash(tx *types.Transaction) common.Hash { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("can't sign with senderFromServer") } func (s *senderFromServer) HashFeePayer(tx *types.Transaction) (common.Hash, error) { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("can't sign with senderFromServer") } func (s *senderFromServer) SignatureValues(tx *types.Transaction, sig []byte) (R, S, V *big.Int, err error) { // TODO-Kaia: need to check this routine is never called or not. - // `senderFromServer` is only used in klay_client.go. + // `senderFromServer` is only used in kaia_client.go. panic("can't sign with senderFromServer") } From 1f555a7845b779a9eeeebb34ca736e7c0c597792 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:05:46 +0900 Subject: [PATCH 11/27] Update cmd --- cmd/homi/docker/compose/homi.go | 2 +- cmd/homi/docker/service/doc.go | 2 +- cmd/homi/docker/service/eth_stats.go | 14 ++++++------ cmd/homi/main.go | 4 ++-- cmd/homi/setup/doc.go | 2 +- .../{klaytn_config.go => kaia_config.go} | 0 cmd/utils/config.go | 22 +++++++++---------- cmd/utils/nodecmd/accountcmd.go | 2 +- cmd/utils/nodecmd/consolecmd_test.go | 2 +- cmd/utils/nodecmd/run_test.go | 12 +++++----- cmd/utils/nodecmd/versioncmd.go | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) rename cmd/homi/setup/{klaytn_config.go => kaia_config.go} (100%) diff --git a/cmd/homi/docker/compose/homi.go b/cmd/homi/docker/compose/homi.go index a6b3e437d6..c075153797 100644 --- a/cmd/homi/docker/compose/homi.go +++ b/cmd/homi/docker/compose/homi.go @@ -28,7 +28,7 @@ import ( type Homi struct { IPPrefix string - EthStats *service.KlayStats + EthStats *service.KaiaStats Services []*service.Validator PrometheusService *service.PrometheusService GrafanaService *service.GrafanaService diff --git a/cmd/homi/docker/service/doc.go b/cmd/homi/docker/service/doc.go index c2e32e4b52..7ad827d003 100644 --- a/cmd/homi/docker/service/doc.go +++ b/cmd/homi/docker/service/doc.go @@ -26,7 +26,7 @@ service package provides various templates to build a docker-compose.yml Each file contains following contents - constellation.go : Deprecated. This is not being used in Kaia - - eth_stats.go : Defines `KlayStats` and provides a yaml template for a KlayStats service + - eth_stats.go : Defines `KaiaStats` and provides a yaml template for a KaiaStats service - grafana.go : Defines `GrafanaService` and provides a yaml template for a Grafana service - prometheus.go : Defines `PrometheusService` and provides a yaml template for a Prometheus service - txgen.go : Defines `TxGenService` and provides a yaml template for a txgen service diff --git a/cmd/homi/docker/service/eth_stats.go b/cmd/homi/docker/service/eth_stats.go index e1a85709e2..fc96380b29 100644 --- a/cmd/homi/docker/service/eth_stats.go +++ b/cmd/homi/docker/service/eth_stats.go @@ -22,24 +22,24 @@ import ( "text/template" ) -type KlayStats struct { +type KaiaStats struct { Secret string IP string } -func NewEthStats(ip string, secret string) *KlayStats { - return &KlayStats{ +func NewEthStats(ip string, secret string) *KaiaStats { + return &KaiaStats{ IP: ip, Secret: secret, } } -func (c KlayStats) Host() string { +func (c KaiaStats) Host() string { return fmt.Sprintf("%v@%v:3000", c.Secret, c.IP) } -func (c KlayStats) String() string { - tmpl, err := template.New("klay_stats").Parse(klayStatsTemplate) +func (c KaiaStats) String() string { + tmpl, err := template.New("klay_stats").Parse(kaiaStatsTemplate) if err != nil { fmt.Printf("Failed to parse template, %v", err) return "" @@ -55,7 +55,7 @@ func (c KlayStats) String() string { return result.String() } -var klayStatsTemplate = `klay-stats: +var kaiaStatsTemplate = `klay-stats: image: quay.io/amis/klaystats:latest ports: - '3000:3000' diff --git a/cmd/homi/main.go b/cmd/homi/main.go index c8a2656489..0c80ef70c8 100644 --- a/cmd/homi/main.go +++ b/cmd/homi/main.go @@ -34,10 +34,10 @@ func main() { app.Name = filepath.Base(os.Args[0]) // app.Author = "" // app.Email = "" - app.Usage = "the klaytn-tools command line interface" + app.Usage = "the kaia-tools command line interface" app.Version = "v0.3.3" - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ setup.SetupCommand, extra.ExtraCommand, diff --git a/cmd/homi/setup/doc.go b/cmd/homi/setup/doc.go index 9b54b07077..6591f112be 100644 --- a/cmd/homi/setup/doc.go +++ b/cmd/homi/setup/doc.go @@ -28,7 +28,7 @@ It creates the given number of genesis.json and nodekeys Each file contains the following contents - cmd.go : Provides functions to generate config files with given deployment configuration - flags.go : Defines command line flags which can be used in `setup` command - - klaytn_config.go : Defines `KlaytnConfig` and provides a template to build it + - kaia_config.go : Defines `KaiaConfig` and provides a template to build it - prometheus_config.go : Defines `PrometheusConfig` and provides a template to build it */ package setup diff --git a/cmd/homi/setup/klaytn_config.go b/cmd/homi/setup/kaia_config.go similarity index 100% rename from cmd/homi/setup/klaytn_config.go rename to cmd/homi/setup/kaia_config.go diff --git a/cmd/utils/config.go b/cmd/utils/config.go index aec93b2bdb..7d0350b62b 100644 --- a/cmd/utils/config.go +++ b/cmd/utils/config.go @@ -90,7 +90,7 @@ var TomlSettings = toml.Config{ }, } -type KlayConfig struct { +type KaiaConfig struct { CN cn.Config Node node.Config DB dbsyncer.DBConfig @@ -98,7 +98,7 @@ type KlayConfig struct { ServiceChain sc.SCConfig } -func LoadConfig(file string, cfg *KlayConfig) error { +func LoadConfig(file string, cfg *KaiaConfig) error { f, err := os.Open(file) if err != nil { return err @@ -123,9 +123,9 @@ func DefaultNodeConfig() node.Config { return cfg } -func MakeConfigNode(ctx *cli.Context) (*node.Node, KlayConfig) { +func MakeConfigNode(ctx *cli.Context) (*node.Node, KaiaConfig) { // Load defaults. - cfg := KlayConfig{ + cfg := KaiaConfig{ CN: *cn.GetDefaultConfig(), Node: DefaultNodeConfig(), DB: *dbsyncer.DefaultDBConfig(), @@ -147,7 +147,7 @@ func MakeConfigNode(ctx *cli.Context) (*node.Node, KlayConfig) { if err != nil { log.Fatalf("Failed to create the protocol stack: %v", err) } - cfg.SetKlayConfig(ctx, stack) + cfg.SetKaiaConfig(ctx, stack) cfg.SetDBSyncerConfig(ctx) cfg.SetChainDataFetcherConfig(ctx) @@ -344,7 +344,7 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { } // setNodeConfig applies node-related command line flags to the config. -func (kCfg *KlayConfig) SetNodeConfig(ctx *cli.Context) { +func (kCfg *KaiaConfig) SetNodeConfig(ctx *cli.Context) { cfg := &kCfg.Node // ntp check enable with remote server if ctx.Bool(NtpDisableFlag.Name) { @@ -505,8 +505,8 @@ func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) { } } -// setKlayConfig applies klay-related command line flags to the config. -func (kCfg *KlayConfig) SetKlayConfig(ctx *cli.Context, stack *node.Node) { +// SetKaiaConfig applies klay-related command line flags to the config. +func (kCfg *KaiaConfig) SetKaiaConfig(ctx *cli.Context, stack *node.Node) { // TODO-Kaia-Bootnode: better have to check conflicts about network flags when we add Kaia's `mainnet` parameter // checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag) cfg := &kCfg.CN @@ -873,7 +873,7 @@ func setTxResendConfig(ctx *cli.Context, cfg *cn.Config) { logger.Debug("TxResend config", "Interval", cfg.TxResendInterval, "TxResendCount", cfg.TxResendCount, "UseLegacy", cfg.TxResendUseLegacy) } -func (kCfg *KlayConfig) SetChainDataFetcherConfig(ctx *cli.Context) { +func (kCfg *KaiaConfig) SetChainDataFetcherConfig(ctx *cli.Context) { cfg := &kCfg.ChainDataFetcher if ctx.Bool(EnableChainDataFetcherFlag.Name) { cfg.EnabledChainDataFetcher = true @@ -985,7 +985,7 @@ func makeKafkaConfig(ctx *cli.Context) *kafka.KafkaConfig { return kafkaConfig } -func (kCfg *KlayConfig) SetDBSyncerConfig(ctx *cli.Context) { +func (kCfg *KaiaConfig) SetDBSyncerConfig(ctx *cli.Context) { cfg := &kCfg.DB if ctx.Bool(EnableDBSyncerFlag.Name) { cfg.EnabledDBSyncer = true @@ -1054,7 +1054,7 @@ func (kCfg *KlayConfig) SetDBSyncerConfig(ctx *cli.Context) { } } -func (kCfg *KlayConfig) SetServiceChainConfig(ctx *cli.Context) { +func (kCfg *KaiaConfig) SetServiceChainConfig(ctx *cli.Context) { cfg := &kCfg.ServiceChain // bridge service diff --git a/cmd/utils/nodecmd/accountcmd.go b/cmd/utils/nodecmd/accountcmd.go index 6325e120fc..2e9db7c3e4 100644 --- a/cmd/utils/nodecmd/accountcmd.go +++ b/cmd/utils/nodecmd/accountcmd.go @@ -318,7 +318,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr // accountCreate creates a new account into the keystore defined by the CLI flags. func accountCreate(ctx *cli.Context) error { - cfg := utils.KlayConfig{Node: utils.DefaultNodeConfig()} + cfg := utils.KaiaConfig{Node: utils.DefaultNodeConfig()} // Load config file. if file := ctx.String(utils.ConfigFileFlag.Name); file != "" { if err := utils.LoadConfig(file, &cfg); err != nil { diff --git a/cmd/utils/nodecmd/consolecmd_test.go b/cmd/utils/nodecmd/consolecmd_test.go index 553037d93c..dff342bd7a 100644 --- a/cmd/utils/nodecmd/consolecmd_test.go +++ b/cmd/utils/nodecmd/consolecmd_test.go @@ -119,7 +119,7 @@ func TestWSAttachWelcome(t *testing.T) { kaia.Kill() } -func testAttachWelcome(t *testing.T, klay *testklay, endpoint, apis string) { +func testAttachWelcome(t *testing.T, klay *testKaia, endpoint, apis string) { // Attach to a running Kaia node and terminate immediately attach := runKaia(t, "kaia-test", "attach", endpoint) defer attach.ExpectExit() diff --git a/cmd/utils/nodecmd/run_test.go b/cmd/utils/nodecmd/run_test.go index c4958d53bd..29348d49fd 100644 --- a/cmd/utils/nodecmd/run_test.go +++ b/cmd/utils/nodecmd/run_test.go @@ -47,7 +47,7 @@ func tmpdir(t *testing.T) string { return dir } -type testklay struct { +type testKaia struct { *utils.TestCmd // template variables for expect @@ -69,7 +69,7 @@ func init() { // Initialize the CLI app and start Kaia app.Action = RunKaiaNode app.HideVersion = true // we have a command to print the version - app.Copyright = "Copyright 2018-2023 The klaytn Authors" + app.Copyright = "Copyright 2018-2024 The Kaia Authors" app.Commands = []*cli.Command{ // See chaincmd.go: InitCommand, @@ -119,7 +119,7 @@ func init() { os.Exit(0) }) reexec.Register("kaia-test-flag", func() { - app.Action = RunTestKlaytnNode + app.Action = RunTestKaiaNode if err := app.Run(os.Args); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) @@ -138,8 +138,8 @@ func TestMain(m *testing.M) { // spawns Kaia with the given command line args. If the args don't set --datadir, the // child g gets a temporary data directory. -func runKaia(t *testing.T, name string, args ...string) *testklay { - tt := &testklay{} +func runKaia(t *testing.T, name string, args ...string) *testKaia { + tt := &testKaia{} tt.TestCmd = utils.NewTestCmd(t, tt) for i, arg := range args { switch { @@ -197,7 +197,7 @@ func waitForEndpoint(t *testing.T, endpoint string, timeout time.Duration) { } } -func RunTestKlaytnNode(ctx *cli.Context) error { +func RunTestKaiaNode(ctx *cli.Context) error { fullNode := MakeFullNode(ctx) fullNode.Wait() return nil diff --git a/cmd/utils/nodecmd/versioncmd.go b/cmd/utils/nodecmd/versioncmd.go index bfcb34d3eb..b38c282b69 100644 --- a/cmd/utils/nodecmd/versioncmd.go +++ b/cmd/utils/nodecmd/versioncmd.go @@ -44,7 +44,7 @@ var VersionCommand = &cli.Command{ } func version(ctx *cli.Context) error { - fmt.Print("Klaytn ") + fmt.Print("Kaia ") if gitTag != "" { // stable version fmt.Println(params.Version) From 2b7959cc625f7a4d82f94406d74929620a2acc4f Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:07:46 +0900 Subject: [PATCH 12/27] Update consensus --- consensus/istanbul/backend/api.go | 10 +++++----- consensus/istanbul/core/vrank.go | 2 +- consensus/istanbul/validator/doc.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/consensus/istanbul/backend/api.go b/consensus/istanbul/backend/api.go index e1040fe01a..386e90b93b 100644 --- a/consensus/istanbul/backend/api.go +++ b/consensus/istanbul/backend/api.go @@ -28,7 +28,7 @@ import ( "reflect" "github.com/klaytn/klaytn/accounts/abi/bind/backends" - klaytnApi "github.com/klaytn/klaytn/api" + kaiaApi "github.com/klaytn/klaytn/api" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/system" "github.com/klaytn/klaytn/blockchain/types" @@ -312,7 +312,7 @@ func (api *APIExtension) makeRPCBlockOutput(b *types.Block, if bc, ok := api.chain.(*blockchain.BlockChain); ok { td = bc.GetTd(hash, b.NumberU64()) } - r, err := klaytnApi.RpcOutputBlock(b, td, false, false, api.chain.Config().Rules(b.Header().Number)) + r, err := kaiaApi.RpcOutputBlock(b, td, false, false, api.chain.Config().Rules(b.Header().Number)) if err != nil { logger.Error("failed to RpcOutputBlock", "err", err) return nil @@ -323,10 +323,10 @@ func (api *APIExtension) makeRPCBlockOutput(b *types.Block, rpcTransactions := make([]map[string]interface{}, numTxs) for i, tx := range transactions { if len(receipts) == len(transactions) { - rpcTransactions[i] = klaytnApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i]) + rpcTransactions[i] = kaiaApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i]) } else { // fill the transaction output if receipt is not found - rpcTransactions[i] = klaytnApi.NewRPCTransaction(b, tx, hash, head.Number.Uint64(), uint64(i)) + rpcTransactions[i] = kaiaApi.NewRPCTransaction(b, tx, hash, head.Number.Uint64(), uint64(i)) } } @@ -352,7 +352,7 @@ func RecoverCommittedSeals(extra *types.IstanbulExtra, headerHash common.Hash) ( return committers, nil } -// TODO-Kaia: This API functions should be managed with API functions with namespace "klay" +// TODO-Kaia: This API functions should be managed with API functions with namespace "kaia" func (api *APIExtension) GetBlockWithConsensusInfoByNumber(number *rpc.BlockNumber) (map[string]interface{}, error) { b, ok := api.chain.(*blockchain.BlockChain) if !ok { diff --git a/consensus/istanbul/core/vrank.go b/consensus/istanbul/core/vrank.go index 3fe994135a..ae6bd8a8f8 100644 --- a/consensus/istanbul/core/vrank.go +++ b/consensus/istanbul/core/vrank.go @@ -212,7 +212,7 @@ func assessBatch(ts []time.Duration, threshold time.Duration) []uint8 { // serialize serializes arrivalTime hashmap into array. // If committee is sorted, we can simply figure out the validator position in the output array -// by sorting the output of `klay.getCommittee()` +// by sorting the output of `kaia.getCommittee()` func serialize(committee istanbul.Validators, arrivalTimeMap map[common.Address]time.Duration) []time.Duration { sortedCommittee := make(istanbul.Validators, len(committee)) copy(sortedCommittee[:], committee[:]) diff --git a/consensus/istanbul/validator/doc.go b/consensus/istanbul/validator/doc.go index 1958113833..071c1392c4 100644 --- a/consensus/istanbul/validator/doc.go +++ b/consensus/istanbul/validator/doc.go @@ -37,9 +37,9 @@ A validator selected as a block proposer will have a chance to make a block. # Implementation in Kaia Kaia implements `Validator` and `ValidatorSet` interface for Kaia consensus. -Klaytn reflects the ratio of staking amounts to the probability of selecting a proposer. +Kaia reflects the ratio of staking amounts to the probability of selecting a proposer. This is called weightedRandom policy. -Detailed information can be found in https://docs.kaia.io/docs/learn/token-economy/#klaytn-governance-council-reward-mechanism-. +Detailed information can be found in https://docs.kaia.io/docs/learn/token-economy/#kaia-governance-council-reward-mechanism-. Implementation structures are weightedValidator and weightedCouncil in weighted.go file. # Files From 4a98489235ad39032ed8b8e20065846ffd88298b Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:13:28 +0900 Subject: [PATCH 13/27] Update crypto --- crypto/secp256k1/curve_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/secp256k1/curve_test.go b/crypto/secp256k1/curve_test.go index 9c35dca20b..a7fd1bb65d 100644 --- a/crypto/secp256k1/curve_test.go +++ b/crypto/secp256k1/curve_test.go @@ -25,7 +25,7 @@ import ( func TestAddSamePoint(t *testing.T) { /* - This test is intended to highlight the bug in klaytn/crypto/secp256k1/curve.go#affineFromJacobian. + This test is intended to highlight the bug in kaia/crypto/secp256k1/curve.go#affineFromJacobian. When passed with same points, BitCurve.Add invokes affineFromJacobian(0, 0, 0) which then invokes (big.Int).Mul(nil, nil). From 9ce765116de3a09acfa68eefe8d2562249294b7b Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:20:25 +0900 Subject: [PATCH 14/27] Update datasync --- datasync/chaindatafetcher/kafka/utils.go | 6 +++--- datasync/chaindatafetcher/kas/contract_caller.go | 10 +++++----- datasync/downloader/api.go | 8 ++++---- datasync/downloader/downloader.go | 6 +++--- datasync/downloader/downloader_fake.go | 6 +++--- datasync/downloader/metrics.go | 10 +++++----- datasync/downloader/queue.go | 4 ++-- datasync/fetcher/metrics.go | 6 +++--- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/datasync/chaindatafetcher/kafka/utils.go b/datasync/chaindatafetcher/kafka/utils.go index 9fdaa906c9..ec86a11df1 100644 --- a/datasync/chaindatafetcher/kafka/utils.go +++ b/datasync/chaindatafetcher/kafka/utils.go @@ -17,7 +17,7 @@ package kafka import ( - klaytnApi "github.com/klaytn/klaytn/api" + kaiaApi "github.com/klaytn/klaytn/api" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" @@ -67,14 +67,14 @@ func makeBlockGroupOutput(blockchain *blockchain.BlockChain, block *types.Block, hash := head.Hash() td := blockchain.GetTd(hash, block.NumberU64()) - r, _ := klaytnApi.RpcOutputBlock(block, td, false, false, blockchain.Config().Rules(block.Header().Number)) + r, _ := kaiaApi.RpcOutputBlock(block, td, false, false, blockchain.Config().Rules(block.Header().Number)) // make transactions transactions := block.Transactions() numTxs := len(transactions) rpcTransactions := make([]map[string]interface{}, numTxs) for i, tx := range transactions { - rpcTransactions[i] = klaytnApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i]) + rpcTransactions[i] = kaiaApi.RpcOutputReceipt(head, tx, hash, head.Number.Uint64(), uint64(i), receipts[i]) } r["committee"] = cInfo.Committee diff --git a/datasync/chaindatafetcher/kas/contract_caller.go b/datasync/chaindatafetcher/kas/contract_caller.go index e68ec60147..ebd6153c4a 100644 --- a/datasync/chaindatafetcher/kas/contract_caller.go +++ b/datasync/chaindatafetcher/kas/contract_caller.go @@ -25,7 +25,7 @@ import ( "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/vm" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/api" "github.com/klaytn/klaytn/common" @@ -38,15 +38,15 @@ import ( const callTimeout = 300 * time.Millisecond var ( - // KIP 13: Interface Query Standard - https://kips.klaytn.com/KIPs/kip-13 + // KIP 13: Interface Query Standard - https://kips.kaia.io/KIPs/kip-13 IKIP13Id = [4]byte{0x01, 0xff, 0xc9, 0xa7} InvalidId = [4]byte{0xff, 0xff, 0xff, 0xff} - // KIP 7: Fungible Token Standard - https://kips.klaytn.com/KIPs/kip-7 + // KIP 7: Fungible Token Standard - https://kips.kaia.io/KIPs/kip-7 IKIP7Id = [4]byte{0x65, 0x78, 0x73, 0x71} IKIP7MetadataId = [4]byte{0xa2, 0x19, 0xa0, 0x25} - // KIP 17: Non-fungible Token Standard - https://kips.klaytn.com/KIPs/kip-17 + // KIP 17: Non-fungible Token Standard - https://kips.kaia.io/KIPs/kip-17 IKIP17Id = [4]byte{0x80, 0xac, 0x58, 0xcd} IKIP17MetadataId = [4]byte{0x5b, 0x5e, 0x13, 0x9f} @@ -79,7 +79,7 @@ func (f *contractCaller) CodeAt(ctx context.Context, contract common.Address, bl return f.blockchainAPI.GetCode(ctx, contract, rpc.NewBlockNumberOrHashWithNumber(num)) } -func (f *contractCaller) CallContract(ctx context.Context, call klaytn.CallMsg, blockNumber *big.Int) ([]byte, error) { +func (f *contractCaller) CallContract(ctx context.Context, call kaia.CallMsg, blockNumber *big.Int) ([]byte, error) { num := rpc.LatestBlockNumber if blockNumber != nil { num = rpc.BlockNumber(blockNumber.Int64()) diff --git a/datasync/downloader/api.go b/datasync/downloader/api.go index 8163b2fdb8..789f359d97 100644 --- a/datasync/downloader/api.go +++ b/datasync/downloader/api.go @@ -24,7 +24,7 @@ import ( "context" "sync" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/event" "github.com/klaytn/klaytn/networks/rpc" ) @@ -39,7 +39,7 @@ type PublicDownloaderAPI struct { } type downloader interface { - Progress() klaytn.SyncProgress + Progress() kaia.SyncProgress SyncStakingInfo(id string, from, to uint64) error SyncStakingInfoStatus() *SyncingStatus } @@ -131,8 +131,8 @@ func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, // SyncingResult provides information about the current synchronisation status for this node. type SyncingResult struct { - Syncing bool `json:"syncing"` - Status klaytn.SyncProgress `json:"status"` + Syncing bool `json:"syncing"` + Status kaia.SyncProgress `json:"status"` } // uninstallSyncSubscriptionRequest uninstalles a syncing subscription in the API event loop. diff --git a/datasync/downloader/downloader.go b/datasync/downloader/downloader.go index 30b3e7840f..240a4ef620 100644 --- a/datasync/downloader/downloader.go +++ b/datasync/downloader/downloader.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/event" @@ -270,7 +270,7 @@ func New(mode SyncMode, stateDB database.DBManager, stateBloom *statedb.SyncBloo // In addition, during the state download phase of fast synchronisation the number // of processed and the total number of known states are also returned. Otherwise // these are zero. -func (d *Downloader) Progress() klaytn.SyncProgress { +func (d *Downloader) Progress() kaia.SyncProgress { // Lock the current stats and return the progress d.syncStatsLock.RLock() defer d.syncStatsLock.RUnlock() @@ -287,7 +287,7 @@ func (d *Downloader) Progress() klaytn.SyncProgress { case LightSync: current = d.lightchain.CurrentHeader().Number.Uint64() } - return klaytn.SyncProgress{ + return kaia.SyncProgress{ StartingBlock: d.syncStatsChainOrigin, CurrentBlock: current, HighestBlock: d.syncStatsChainHeight, diff --git a/datasync/downloader/downloader_fake.go b/datasync/downloader/downloader_fake.go index 1ba048f807..d093bac5e2 100644 --- a/datasync/downloader/downloader_fake.go +++ b/datasync/downloader/downloader_fake.go @@ -19,7 +19,7 @@ package downloader import ( "math/big" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/node/cn/snap" @@ -55,8 +55,8 @@ func (*FakeDownloader) Terminate() {} func (*FakeDownloader) Synchronise(id string, head common.Hash, td *big.Int, mode SyncMode) error { return nil } -func (*FakeDownloader) Progress() klaytn.SyncProgress { return klaytn.SyncProgress{} } -func (*FakeDownloader) Cancel() {} +func (*FakeDownloader) Progress() kaia.SyncProgress { return kaia.SyncProgress{} } +func (*FakeDownloader) Cancel() {} func (*FakeDownloader) GetSnapSyncer() *snap.Syncer { return nil } func (*FakeDownloader) SyncStakingInfo(id string, from, to uint64) error { return nil } diff --git a/datasync/downloader/metrics.go b/datasync/downloader/metrics.go index 09727b2911..eb489c88e6 100644 --- a/datasync/downloader/metrics.go +++ b/datasync/downloader/metrics.go @@ -21,28 +21,28 @@ package downloader import ( - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/rcrowley/go-metrics" ) var ( headerInMeter = metrics.NewRegisteredMeter("klay/downloader/headers/in", nil) - headerReqTimer = klaytnmetrics.NewRegisteredHybridTimer("klay/downloader/headers/req", nil) + headerReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/headers/req", nil) headerDropMeter = metrics.NewRegisteredMeter("klay/downloader/headers/drop", nil) headerTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/headers/timeout", nil) bodyInMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/in", nil) - bodyReqTimer = klaytnmetrics.NewRegisteredHybridTimer("klay/downloader/bodies/req", nil) + bodyReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/bodies/req", nil) bodyDropMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/drop", nil) bodyTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/timeout", nil) receiptInMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/in", nil) - receiptReqTimer = klaytnmetrics.NewRegisteredHybridTimer("klay/downloader/receipts/req", nil) + receiptReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/receipts/req", nil) receiptDropMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/drop", nil) receiptTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/timeout", nil) stakingInfoInMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/in", nil) - stakingInfoReqTimer = klaytnmetrics.NewRegisteredHybridTimer("klay/downloader/stakinginfo/req", nil) + stakingInfoReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/stakinginfo/req", nil) stakingInfoDropMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/drop", nil) stakingInfoTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/timeout", nil) diff --git a/datasync/downloader/queue.go b/datasync/downloader/queue.go index 5c20fd37c7..4c8b4e3540 100644 --- a/datasync/downloader/queue.go +++ b/datasync/downloader/queue.go @@ -31,7 +31,7 @@ import ( "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/common/prque" "github.com/klaytn/klaytn/consensus/istanbul" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/params" "github.com/klaytn/klaytn/reward" "github.com/rcrowley/go-metrics" @@ -924,7 +924,7 @@ func (q *queue) DeliverStakingInfos(id string, stakingInfoList []*reward.Staking // reason this lock is not obtained in here is because the parameters already need // to access the queue, so they already need a lock anyway. func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque, - pendPool map[string]*fetchRequest, reqTimer klaytnmetrics.HybridTimer, + pendPool map[string]*fetchRequest, reqTimer kaiaMetrics.HybridTimer, results int, validate func(index int, header *types.Header) error, reconstruct func(index int, result *fetchResult), ) (int, error) { diff --git a/datasync/fetcher/metrics.go b/datasync/fetcher/metrics.go index f338f889d2..0dd15dd444 100644 --- a/datasync/fetcher/metrics.go +++ b/datasync/fetcher/metrics.go @@ -21,18 +21,18 @@ package fetcher import ( - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/rcrowley/go-metrics" ) var ( propAnnounceInMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/in", nil) - propAnnounceOutTimer = klaytnmetrics.NewRegisteredHybridTimer("cn/fetcher/prop/announces/out", nil) + propAnnounceOutTimer = kaiaMetrics.NewRegisteredHybridTimer("cn/fetcher/prop/announces/out", nil) propAnnounceDropMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/drop", nil) propAnnounceDOSMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/dos", nil) propBroadcastInMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/in", nil) - propBroadcastOutTimer = klaytnmetrics.NewRegisteredHybridTimer("cn/fetcher/prop/broadcasts/out", nil) + propBroadcastOutTimer = kaiaMetrics.NewRegisteredHybridTimer("cn/fetcher/prop/broadcasts/out", nil) propBroadcastDropMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/drop", nil) propBroadcastDOSMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/dos", nil) From 3856702666be040fea6f07bf2e6d178325215bf2 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:20:57 +0900 Subject: [PATCH 15/27] Update db_migration --- db_migration/db_migration.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db_migration/db_migration.sh b/db_migration/db_migration.sh index af8fd22542..9593b0991a 100755 --- a/db_migration/db_migration.sh +++ b/db_migration/db_migration.sh @@ -5,7 +5,7 @@ # To checkout migration status, `tail -f logs-body.out` # BIN file -KLAYTN_BIN=~/klaytn/bin/ken +KAIA_BIN=~/klaytn/bin/ken # src DB SRC_DB_TYPE=LevelDB # one of "LevelDB", "BadgerDB", "MemoryDB", "DynamoDBS3" @@ -26,7 +26,7 @@ export AWS_ACCESS_KEY_ID= export AWS_SECRET_ACCESS_KEY= # call db migration -$KLAYTN_BIN db-migration start \ +$KAIA_BIN db-migration start \ --db.single --db.dst.single \ --dbtype $SRC_DB_TYPE --dst.dbtype $DST_DB_TYPE \ --datadir $SRC_DB_DIR \ From 67e251b8fce771f60a45e86e4f0f1ff68185f895 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:21:57 +0900 Subject: [PATCH 16/27] Update governance --- governance/api.go | 4 ++-- governance/doc.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/governance/api.go b/governance/api.go index 2b589f9d89..13f5dff759 100644 --- a/governance/api.go +++ b/governance/api.go @@ -445,7 +445,7 @@ func (api *GovernanceAPI) isGovernanceModeBallot() bool { } // Disabled APIs -// func (api *GovernanceKlayAPI) GetTxGasHumanReadable(num *rpc.BlockNumber) (uint64, error) { +// func (api *GovernanceKaiaAPI) GetTxGasHumanReadable(num *rpc.BlockNumber) (uint64, error) { // if num == nil || *num == rpc.LatestBlockNumber || *num == rpc.PendingBlockNumber { // // If the value hasn't been set in governance, set it with default value // if ret := api.governance.GetGovernanceValue(params.ConstTxGasHumanReadable); ret == nil { @@ -469,7 +469,7 @@ func (api *GovernanceAPI) isGovernanceModeBallot() bool { // } // } // -// func (api *GovernanceKlayAPI) setDefaultTxGasHumanReadable() (uint64, error) { +// func (api *GovernanceKaiaAPI) setDefaultTxGasHumanReadable() (uint64, error) { // err := api.governance.currentSet.SetValue(params.ConstTxGasHumanReadable, params.TxGasHumanReadable) // if err != nil { // return 0, errSetDefaultFailure diff --git a/governance/doc.go b/governance/doc.go index bf6d84cf51..b085db02c9 100644 --- a/governance/doc.go +++ b/governance/doc.go @@ -30,7 +30,7 @@ In the console of the node, "governance.vote(key, value)" API can be used to cas Following keys can be handled as of 7/20/2019. - "governance.governancemode" : To change the governance mode - "governance.governingnode" : To change the governing node if the governance mode is "single" - - "governance.unitprice" : To change the unitprice of Klaytn (Unit price is same as gasprice in Ethereum) + - "governance.unitprice" : To change the unitprice of Kaia (Unit price is same as gasprice in Ethereum) - "governance.addvalidator" : To add new node as a council node - "governance.removevalidator" : To remove a node from the governance council - "istanbul.epoch" : To change Epoch, the period to gather votes From 1a88af4531500ab184add56574a2bf5a2cb11484 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:22:47 +0900 Subject: [PATCH 17/27] Update log --- log/log_modules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/log/log_modules.go b/log/log_modules.go index 1eb7d8849f..f11410d2d5 100644 --- a/log/log_modules.go +++ b/log/log_modules.go @@ -75,7 +75,7 @@ const ( CMDKCN CMDKEN CMDKGEN - CMDKlay + CMDKaia CMDKPN CMDKSCN CMDUtils From 8db7b4b5fce203f475a1d9cbd441ecbec6a216c1 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:23:24 +0900 Subject: [PATCH 18/27] Update metrics --- metrics/prometheus/prometheusmetrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metrics/prometheus/prometheusmetrics.go b/metrics/prometheus/prometheusmetrics.go index 1bfd02f21f..92544f801e 100644 --- a/metrics/prometheus/prometheusmetrics.go +++ b/metrics/prometheus/prometheusmetrics.go @@ -10,7 +10,7 @@ import ( "strings" "time" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/prometheus/client_golang/prometheus" "github.com/rcrowley/go-metrics" @@ -70,7 +70,7 @@ func (c *PrometheusConfig) gaugeFromNameAndValue(name string, val float64) { func (c *PrometheusConfig) UpdatePrometheusMetrics() { for range time.Tick(c.FlushInterval) { c.UpdatePrometheusMetricsOnce() - klaytnmetrics.ResetMaxGauges() + kaiaMetrics.ResetMaxGauges() } } From 3f46d58e994def736ee3c0906622d7ed4684d5de Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:29:23 +0900 Subject: [PATCH 19/27] Update networks --- networks/grpc/gClient.go | 18 +++++++++--------- networks/grpc/gRPC_test.go | 8 ++++---- networks/grpc/gServer.go | 12 ++++++------ networks/rpc/http_datadog.go | 8 ++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/networks/grpc/gClient.go b/networks/grpc/gClient.go index ae135cb07f..a86c2487ca 100644 --- a/networks/grpc/gClient.go +++ b/networks/grpc/gClient.go @@ -30,7 +30,7 @@ import ( "google.golang.org/grpc" ) -type gKlaytnClient struct { +type gKaiaClient struct { addr string ctx context.Context cancel context.CancelFunc @@ -56,13 +56,13 @@ type jsonSubscription struct { Result interface{} `json:"result,omitempty"` } -func NewgKlaytnClient(addr string) (*gKlaytnClient, error) { - return &gKlaytnClient{addr: addr}, nil +func NewgKaiaClient(addr string) (*gKaiaClient, error) { + return &gKaiaClient{addr: addr}, nil } const timeout = 5 * time.Minute -func (gkc *gKlaytnClient) makeKlaytnClient(timeout time.Duration) (KlaytnNodeClient, error) { +func (gkc *gKaiaClient) makeKaiaClient(timeout time.Duration) (KlaytnNodeClient, error) { gkc.ctx, gkc.cancel = context.WithTimeout(context.Background(), timeout) conn, err := grpc.DialContext(gkc.ctx, gkc.addr, grpc.WithInsecure()) if err != nil { @@ -74,7 +74,7 @@ func (gkc *gKlaytnClient) makeKlaytnClient(timeout time.Duration) (KlaytnNodeCli return NewKlaytnNodeClient(gkc.conn), nil } -func (gkc *gKlaytnClient) makeRPCRequest(service string, method string, args []interface{}) (*RPCRequest, error) { +func (gkc *gKaiaClient) makeRPCRequest(service string, method string, args []interface{}) (*RPCRequest, error) { payload, err := json.Marshal(args) if err != nil { return nil, err @@ -93,7 +93,7 @@ func (gkc *gKlaytnClient) makeRPCRequest(service string, method string, args []i return &RPCRequest{Service: service, Method: method, Params: params}, nil } -func (gkc *gKlaytnClient) handleRPCResponse(response *RPCResponse) error { +func (gkc *gKaiaClient) handleRPCResponse(response *RPCResponse) error { var out jsonSuccessResponse if err := json.Unmarshal(response.Payload, &out); err != nil { logger.Error("failed to handle response", "err", err) @@ -104,7 +104,7 @@ func (gkc *gKlaytnClient) handleRPCResponse(response *RPCResponse) error { return nil } -func (gkc *gKlaytnClient) handleSubscribe(client KlaytnNode_SubscribeClient, handle func(response *RPCResponse) error) { +func (gkc *gKaiaClient) handleSubscribe(client KlaytnNode_SubscribeClient, handle func(response *RPCResponse) error) { var waitGroup sync.WaitGroup waitGroup.Add(1) @@ -133,7 +133,7 @@ loop: waitGroup.Wait() } -func (gkc *gKlaytnClient) handleBiCall(stream KlaytnNode_BiCallClient, request func() (*RPCRequest, error), handle func(response *RPCResponse) error) { +func (gkc *gKaiaClient) handleBiCall(stream KlaytnNode_BiCallClient, request func() (*RPCRequest, error), handle func(response *RPCResponse) error) { var waitGroup sync.WaitGroup waitGroup.Add(2) @@ -173,7 +173,7 @@ func (gkc *gKlaytnClient) handleBiCall(stream KlaytnNode_BiCallClient, request f waitGroup.Wait() } -func (gkc *gKlaytnClient) Close() { +func (gkc *gKaiaClient) Close() { if gkc.cancel != nil { gkc.cancel() } diff --git a/networks/grpc/gRPC_test.go b/networks/grpc/gRPC_test.go index ac56b472cc..52fa6061ad 100644 --- a/networks/grpc/gRPC_test.go +++ b/networks/grpc/gRPC_test.go @@ -59,10 +59,10 @@ func TestGRPC(t *testing.T) { func testCall(t *testing.T, addr string, wg *sync.WaitGroup) { defer wg.Done() - kclient, _ := NewgKlaytnClient(addr) + kclient, _ := NewgKaiaClient(addr) defer kclient.Close() - knclient, err := kclient.makeKlaytnClient(timeout) + knclient, err := kclient.makeKaiaClient(timeout) assert.NoError(t, err) request, err := kclient.makeRPCRequest("klay", "klay_blockNumber", nil) @@ -83,10 +83,10 @@ func testCall(t *testing.T, addr string, wg *sync.WaitGroup) { func testBiCall(t *testing.T, addr string, wg *sync.WaitGroup) { defer wg.Done() - kclient, _ := NewgKlaytnClient(addr) + kclient, _ := NewgKaiaClient(addr) defer kclient.Close() - knclient, err := kclient.makeKlaytnClient(timeout) + knclient, err := kclient.makeKaiaClient(timeout) assert.NoError(t, err) stream, _ := knclient.BiCall(kclient.ctx) diff --git a/networks/grpc/gServer.go b/networks/grpc/gServer.go index acbe4cb8ed..b2d4121405 100644 --- a/networks/grpc/gServer.go +++ b/networks/grpc/gServer.go @@ -57,8 +57,8 @@ func (t *grpcReadWriteNopCloser) Close() error { return nil } -// klaytnServer is an implementation of KlaytnNodeServer. -type klaytnServer struct { +// kaiaServer is an implementation of KlaytnNodeServer. +type kaiaServer struct { handler *rpc.Server } @@ -94,7 +94,7 @@ func (gw *bufWriter) Write(p []byte) (n int, err error) { } // BiCall handles bidirectional communication between client and server. -func (kns *klaytnServer) BiCall(stream KlaytnNode_BiCallServer) error { +func (kns *kaiaServer) BiCall(stream KlaytnNode_BiCallServer) error { for { request, err := stream.Recv() if err == io.EOF { @@ -134,7 +134,7 @@ func (kns *klaytnServer) BiCall(stream KlaytnNode_BiCallServer) error { } // only server can send message to client repeatedly -func (kns *klaytnServer) Subscribe(request *RPCRequest, stream KlaytnNode_SubscribeServer) error { +func (kns *kaiaServer) Subscribe(request *RPCRequest, stream KlaytnNode_SubscribeServer) error { var ( writeErr = make(chan error, 1) readErr = make(chan error, 1) @@ -188,7 +188,7 @@ loop: } // general RPC call, such as one-to-one communication -func (kns *klaytnServer) Call(ctx context.Context, request *RPCRequest) (*RPCResponse, error) { +func (kns *kaiaServer) Call(ctx context.Context, request *RPCRequest) (*RPCResponse, error) { var ( err error writeErr = make(chan error, 1) @@ -260,7 +260,7 @@ func (gs *Listener) Start() { } gs.grpcServer = grpc.NewServer() - RegisterKlaytnNodeServer(gs.grpcServer, &klaytnServer{handler: gs.handler}) + RegisterKlaytnNodeServer(gs.grpcServer, &kaiaServer{handler: gs.handler}) // Register reflection service on gRPC server. reflection.Register(gs.grpcServer) diff --git a/networks/rpc/http_datadog.go b/networks/rpc/http_datadog.go index 4bd878b6b7..72318fb85a 100644 --- a/networks/rpc/http_datadog.go +++ b/networks/rpc/http_datadog.go @@ -20,9 +20,9 @@ type tagInfo struct { } type DatadogTracer struct { - Tags []tagInfo - Service string - KlaytnResponse bool + Tags []tagInfo + Service string + KaiaResponse bool } func newDatadogTracer() *DatadogTracer { @@ -159,7 +159,7 @@ func (dt *DatadogTracer) traceRpcResponse(response []byte, method string, span t span.SetTag("response.code", 0) } - if dt.KlaytnResponse { + if dt.KaiaResponse { var rpcSuccess jsonSuccessResponse if err := json.Unmarshal(response, &rpcSuccess); err == nil && rpcSuccess.Result != nil { successJson, _ := json.Marshal(rpcSuccess.Result) From d52a1c2d49f9cdde56c83b112c5115212249a951 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:38:21 +0900 Subject: [PATCH 20/27] Update node --- node/cn/api_backend.go | 4 ++-- node/cn/backend.go | 4 ++-- node/cn/handler.go | 12 ++++++------ node/cn/peer.go | 6 +++--- node/cn/protocol.go | 4 ++-- node/config.go | 6 +++--- node/node.go | 2 +- node/sc/bridge_manager.go | 10 +++++----- node/sc/bridge_manager_test.go | 24 ++++++++++++------------ node/sc/mainbridge.go | 8 ++++---- node/sc/subbridge.go | 12 ++++++------ node/sc/vt_contract_test.go | 4 ++-- node/sc/vt_recovery_test.go | 34 +++++++++++++++++----------------- 13 files changed, 65 insertions(+), 65 deletions(-) diff --git a/node/cn/api_backend.go b/node/cn/api_backend.go index de5ee68d94..9d03a2579d 100644 --- a/node/cn/api_backend.go +++ b/node/cn/api_backend.go @@ -26,7 +26,7 @@ import ( "math/big" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts" "github.com/klaytn/klaytn/blockchain" "github.com/klaytn/klaytn/blockchain/bloombits" @@ -300,7 +300,7 @@ func (b *CNAPIBackend) SubscribeNewTxsEvent(ch chan<- blockchain.NewTxsEvent) ev return b.cn.TxPool().SubscribeNewTxsEvent(ch) } -func (b *CNAPIBackend) Progress() klaytn.SyncProgress { +func (b *CNAPIBackend) Progress() kaia.SyncProgress { return b.cn.Progress() } diff --git a/node/cn/backend.go b/node/cn/backend.go index 72a3814e82..08a264f9ab 100644 --- a/node/cn/backend.go +++ b/node/cn/backend.go @@ -29,7 +29,7 @@ import ( "sync" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts" "github.com/klaytn/klaytn/api" "github.com/klaytn/klaytn/blockchain" @@ -661,7 +661,7 @@ func (s *CN) ChainDB() database.DBManager { return s.chainDB } func (s *CN) IsListening() bool { return true } // Always listening func (s *CN) ProtocolVersion() int { return s.protocolManager.ProtocolVersion() } func (s *CN) NetVersion() uint64 { return s.networkId } -func (s *CN) Progress() klaytn.SyncProgress { return s.protocolManager.Downloader().Progress() } +func (s *CN) Progress() kaia.SyncProgress { return s.protocolManager.Downloader().Progress() } func (s *CN) Governance() governance.Engine { return s.governance } func (s *CN) ReBroadcastTxs(transactions types.Transactions) { diff --git a/node/cn/handler.go b/node/cn/handler.go index 365a60a6b8..042817658b 100644 --- a/node/cn/handler.go +++ b/node/cn/handler.go @@ -354,7 +354,7 @@ func (pm *ProtocolManager) removePeer(id string) { if peer == nil { return } - logger.Debug("Removing Klaytn peer", "peer", id) + logger.Debug("Removing Kaia peer", "peer", id) if peer.ExistSnapExtension() { pm.downloader.GetSnapSyncer().Unregister(id) } @@ -393,7 +393,7 @@ func (pm *ProtocolManager) Start(maxPeers int) { } func (pm *ProtocolManager) Stop() { - logger.Info("Stopping Klaytn protocol") + logger.Info("Stopping Kaia protocol") pm.txsSub.Unsubscribe() // quits txBroadcastLoop pm.minedBlockSub.Unsubscribe() // quits blockBroadcastLoop @@ -419,7 +419,7 @@ func (pm *ProtocolManager) Stop() { // Wait for all peer handler goroutines and the loops to come down. pm.wg.Wait() - logger.Info("Klaytn protocol stopped") + logger.Info("Kaia protocol stopped") } // SetSyncStop sets value of syncStop flag. If it's true, peer sync process does not proceed. @@ -478,7 +478,7 @@ func (pm *ProtocolManager) handle(p Peer) error { if pm.peers.Len() >= pm.maxPeers && !p.GetP2PPeer().Info().Networks[p2p.ConnDefault].Trusted { return p2p.DiscTooManyPeers } - p.GetP2PPeer().Log().Debug("Klaytn peer connected", "name", p.GetP2PPeer().Name()) + p.GetP2PPeer().Log().Debug("Kaia peer connected", "name", p.GetP2PPeer().Name()) pm.peerWg.Add(1) defer pm.peerWg.Done() @@ -493,7 +493,7 @@ func (pm *ProtocolManager) handle(p Peer) error { ) if err := p.Handshake(pm.networkId, pm.getChainID(), td, hash, genesis.Hash()); err != nil { - p.GetP2PPeer().Log().Debug("Klaytn peer handshake failed", "err", err) + p.GetP2PPeer().Log().Debug("Kaia peer handshake failed", "err", err) return err } reject := false @@ -521,7 +521,7 @@ func (pm *ProtocolManager) handle(p Peer) error { // Register the peer locally if err := pm.peers.Register(p, snap); err != nil { // if starting node with unlock account, can't register peer until finish unlock - p.GetP2PPeer().Log().Info("Klaytn peer registration failed", "err", err) + p.GetP2PPeer().Log().Info("Kaia peer registration failed", "err", err) return err } defer pm.removePeer(p.GetID()) diff --git a/node/cn/peer.go b/node/cn/peer.go index ce2780fef8..7ab8140171 100644 --- a/node/cn/peer.go +++ b/node/cn/peer.go @@ -1073,7 +1073,7 @@ func (p *multiChannelPeer) Handle(pm *ProtocolManager) error { if pm.peers.Len() >= pm.maxPeers && !p.GetP2PPeer().Info().Networks[p2p.ConnDefault].Trusted { return p2p.DiscTooManyPeers } - p.GetP2PPeer().Log().Debug("Klaytn peer connected", "name", p.GetP2PPeer().Name()) + p.GetP2PPeer().Log().Debug("Kaia peer connected", "name", p.GetP2PPeer().Name()) pm.peerWg.Add(1) defer pm.peerWg.Done() @@ -1088,7 +1088,7 @@ func (p *multiChannelPeer) Handle(pm *ProtocolManager) error { ) if err := p.Handshake(pm.networkId, pm.getChainID(), td, hash, genesis.Hash()); err != nil { - p.GetP2PPeer().Log().Debug("Klaytn peer handshake failed", "err", err) + p.GetP2PPeer().Log().Debug("Kaia peer handshake failed", "err", err) return err } reject := false @@ -1114,7 +1114,7 @@ func (p *multiChannelPeer) Handle(pm *ProtocolManager) error { // Register the peer locally if err := pm.peers.Register(p, snap); err != nil { // if starting node with unlock account, can't register peer until finish unlock - p.GetP2PPeer().Log().Info("Klaytn peer registration failed", "err", err) + p.GetP2PPeer().Log().Info("Kaia peer registration failed", "err", err) return err } defer pm.removePeer(p.GetID()) diff --git a/node/cn/protocol.go b/node/cn/protocol.go index d550844e84..b9b0d496d5 100644 --- a/node/cn/protocol.go +++ b/node/cn/protocol.go @@ -26,7 +26,7 @@ import ( "math/big" "time" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/blockchain/types" "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/datasync/downloader" @@ -144,7 +144,7 @@ type ProtocolManagerDownloader interface { Terminate() Synchronise(id string, head common.Hash, td *big.Int, mode downloader.SyncMode) error - Progress() klaytn.SyncProgress + Progress() kaia.SyncProgress Cancel() GetSnapSyncer() *snap.Syncer diff --git a/node/config.go b/node/config.go index b506b148a6..75c3551dbc 100644 --- a/node/config.go +++ b/node/config.go @@ -309,7 +309,7 @@ func (c *Config) name() string { return c.Name } -var isKlaytnResource = map[string]bool{ +var isKaiaResource = map[string]bool{ "chaindata": true, "nodes": true, "nodekey": true, @@ -326,7 +326,7 @@ func (c *Config) ResolvePath(path string) string { if c.DataDir == "" { return "" } - if c.name() == "klay" && isKlaytnResource[path] { + if c.name() == "klay" && isKaiaResource[path] { oldpath := "" if c.Name == "klay" { oldpath = filepath.Join(c.DataDir, path) @@ -493,7 +493,7 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) { var ephemeral string if keydir == "" { // There is no datadir. - keydir, err = os.MkdirTemp("", "klaytn-keystore") + keydir, err = os.MkdirTemp("", "kaia-keystore") ephemeral = keydir } diff --git a/node/node.go b/node/node.go index ce9ec1b433..120b098297 100644 --- a/node/node.go +++ b/node/node.go @@ -736,7 +736,7 @@ func (n *Node) apis() []rpc.API { Version: "1.0", Service: NewPublicDebugAPI(n), }, { - // "web3" namespace will be deprecated soon. The same APIs in "web3" are available in "klay" namespace. + // "web3" namespace will be deprecated soon. The same APIs in "web3" are available in "kaia" namespace. Namespace: "web3", Version: "1.0", Service: NewPublicKaiaAPI(n), diff --git a/node/sc/bridge_manager.go b/node/sc/bridge_manager.go index 4c2d1d9476..8377eb108b 100644 --- a/node/sc/bridge_manager.go +++ b/node/sc/bridge_manager.go @@ -44,7 +44,7 @@ const ( ) const ( - KLAY uint8 = iota + KAIA uint8 = iota ERC20 ERC721 ) @@ -66,7 +66,7 @@ var ( ) var handleVTmethods = map[uint8]string{ - KLAY: "handleKLAYTransfer", + KAIA: "handleKLAYTransfer", ERC20: "handleERC20Transfer", ERC721: "handleERC721Transfer", } @@ -300,7 +300,7 @@ func (bi *BridgeInfo) handleRequestValueTransferEvent(ev IRequestValueTransferEv ctpartTokenAddr := bi.GetCounterPartToken(tokenAddr) // TODO-Kaia-Servicechain Add counterpart token address in requestValueTransferEvent - if tokenType != KLAY && ctpartTokenAddr == (common.Address{}) { + if tokenType != KAIA && ctpartTokenAddr == (common.Address{}) { logger.Warn("Unregistered counter part token address.", "addr", ctpartTokenAddr.Hex()) ctTokenAddr, err := bi.counterpartBridge.RegisteredTokens(nil, tokenAddr) if err != nil { @@ -327,12 +327,12 @@ func (bi *BridgeInfo) handleRequestValueTransferEvent(ev IRequestValueTransferEv var err error switch tokenType { - case KLAY: + case KAIA: handleTx, err = bi.bridge.HandleKLAYTransfer(auth, txHash, from, to, valueOrTokenId, requestNonce, blkNumber, extraData) if err != nil { return err } - handleValueTransferLog(bi.onChildChain, handleVTmethods[KLAY], handleTx.Hash().String(), requestNonce, from, to, valueOrTokenId) + handleValueTransferLog(bi.onChildChain, handleVTmethods[KAIA], handleTx.Hash().String(), requestNonce, from, to, valueOrTokenId) case ERC20: handleTx, err = bi.bridge.HandleERC20Transfer(auth, txHash, from, to, ctpartTokenAddr, valueOrTokenId, requestNonce, blkNumber, extraData) if err != nil { diff --git a/node/sc/bridge_manager_test.go b/node/sc/bridge_manager_test.go index 4d13cbec48..27e8ad03f1 100644 --- a/node/sc/bridge_manager_test.go +++ b/node/sc/bridge_manager_test.go @@ -175,7 +175,7 @@ func TestBridgeManager(t *testing.T) { assert.NoError(t, err) testToken := big.NewInt(123) - testKLAY := big.NewInt(321) + testKAIA := big.NewInt(321) // 1. Deploy Bridge Contract addr, err := bridgeManager.DeployBridgeTest(sim, 10000, false) @@ -294,7 +294,7 @@ func TestBridgeManager(t *testing.T) { // 8. RequestKLAYTransfer from Alice to Bob { - tx, err = bridge.RequestKLAYTransfer(&bind.TransactOpts{From: alice.From, Signer: alice.Signer, Value: testKLAY, GasLimit: testGasLimit}, bob.From, testKLAY, nil) + tx, err = bridge.RequestKLAYTransfer(&bind.TransactOpts{From: alice.From, Signer: alice.Signer, Value: testKAIA, GasLimit: testGasLimit}, bob.From, testKAIA, nil) assert.NoError(t, err) t.Log("DepositKLAY Transaction", tx.Hash().Hex()) @@ -333,7 +333,7 @@ func TestBridgeManager(t *testing.T) { { balance, err = sim.BalanceAt(context.Background(), bob.From, nil) assert.Equal(t, nil, err) - assert.Equal(t, testKLAY.String(), balance.String()) + assert.Equal(t, testKAIA.String(), balance.String()) } // 12. Check NFT owner sent by RequestValueTransfer() @@ -575,7 +575,7 @@ func TestBridgeManagerWithFee(t *testing.T) { testToken := int64(100000) testKAIA := int64(100000) - KLAYFee := int64(500) + KAIAFee := int64(500) ERC20Fee := int64(500) // 1. Deploy Bridge Contract @@ -623,14 +623,14 @@ func TestBridgeManagerWithFee(t *testing.T) { assert.NoError(t, err) _, err = pBridge.RegisterOperator(&bind.TransactOpts{From: cAuth.From, Signer: cAuth.Signer, GasLimit: testGasLimit}, cAuth.From) assert.NoError(t, err) - pBridge.SetKLAYFee(&bind.TransactOpts{From: cAuth.From, Signer: cAuth.Signer, GasLimit: testGasLimit}, big.NewInt(KLAYFee), cn) + pBridge.SetKLAYFee(&bind.TransactOpts{From: cAuth.From, Signer: cAuth.Signer, GasLimit: testGasLimit}, big.NewInt(KAIAFee), cn) pBridge.SetERC20Fee(&bind.TransactOpts{From: cAuth.From, Signer: cAuth.Signer, GasLimit: testGasLimit}, tokenAddr, big.NewInt(ERC20Fee), cn+1) sim.Commit() // block { fee, err := pBridge.FeeOfKLAY(nil) assert.Equal(t, nil, err) - assert.Equal(t, KLAYFee, fee.Int64()) + assert.Equal(t, KAIAFee, fee.Int64()) } { @@ -823,7 +823,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-1. Request KAIA transfer from Alice to Bob with same feeLimit with fee { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + KLAYFee), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + KAIAFee), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) if err != nil { log.Fatalf("Failed to RequestKLAYTransfer: %v", err) } @@ -846,7 +846,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-3. Request KAIA transfer from Alice to Bob with insufficient feeLimit { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KLAYFee - 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KAIAFee - 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) assert.Equal(t, nil, err) sim.Commit() // block @@ -856,7 +856,7 @@ func TestBridgeManagerWithFee(t *testing.T) { // 9-4. Request KAIA transfer from Alice to Bob with enough feeLimit { - tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KLAYFee + 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) + tx, err = pBridge.RequestKLAYTransfer(&bind.TransactOpts{From: Alice.From, Signer: Alice.Signer, Value: big.NewInt(testKAIA + (KAIAFee + 1)), GasLimit: testGasLimit}, Bob.From, big.NewInt(testKAIA), nil) assert.Equal(t, nil, err) sim.Commit() // block @@ -868,7 +868,7 @@ func TestBridgeManagerWithFee(t *testing.T) { { nonce, _ := sim.PendingNonceAt(context.Background(), Alice.From) gasPrice, _ := sim.SuggestGasPrice(context.Background()) - unsignedTx := types.NewTransaction(nonce, pBridgeAddr, big.NewInt(testKAIA+KLAYFee), testGasLimit, gasPrice, []byte{}) + unsignedTx := types.NewTransaction(nonce, pBridgeAddr, big.NewInt(testKAIA+KAIAFee), testGasLimit, gasPrice, []byte{}) chainID, _ := sim.ChainID(context.Background()) tx, err = types.SignTx(unsignedTx, types.LatestSignerForChainID(chainID), AliceKey) @@ -905,7 +905,7 @@ func TestBridgeManagerWithFee(t *testing.T) { { balance, _ = sim.BalanceAt(context.Background(), Alice.From, nil) t.Log("Alice KAIA balance :", balance) - assert.Equal(t, initialValue-(testKAIA+KLAYFee)*2-KLAYFee, balance.Int64()) + assert.Equal(t, initialValue-(testKAIA+KAIAFee)*2-KAIAFee, balance.Int64()) balance, _ = sim.BalanceAt(context.Background(), Bob.From, nil) t.Log("Bob KAIA balance :", balance) @@ -913,7 +913,7 @@ func TestBridgeManagerWithFee(t *testing.T) { balance, _ = sim.BalanceAt(context.Background(), receiver.From, nil) t.Log("receiver KAIA balance :", balance) - assert.Equal(t, KLAYFee*3, balance.Int64()) + assert.Equal(t, KAIAFee*3, balance.Int64()) } bridgeManager.Stop() diff --git a/node/sc/mainbridge.go b/node/sc/mainbridge.go index f91110fefa..491baa0273 100644 --- a/node/sc/mainbridge.go +++ b/node/sc/mainbridge.go @@ -355,7 +355,7 @@ func (mb *MainBridge) handle(p BridgePeer) error { if mb.peers.Len() >= mb.maxPeers && !p.GetP2PPeer().Info().Networks[p2p.ConnDefault].Trusted { return p2p.DiscTooManyPeers } - p.GetP2PPeer().Log().Debug("Klaytn peer connected", "name", p.GetP2PPeer().Name()) + p.GetP2PPeer().Log().Debug("Kaia peer connected", "name", p.GetP2PPeer().Name()) // Execute the handshake var ( @@ -367,14 +367,14 @@ func (mb *MainBridge) handle(p BridgePeer) error { err := p.Handshake(mb.networkId, mb.getChainID(), td, hash) if err != nil { - p.GetP2PPeer().Log().Debug("Klaytn peer handshake failed", "err", err) + p.GetP2PPeer().Log().Debug("Kaia peer handshake failed", "err", err) return err } // Register the peer locally if err := mb.peers.Register(p); err != nil { // if starting node with unlock account, can't register peer until finish unlock - p.GetP2PPeer().Log().Info("Klaytn peer registration failed", "err", err) + p.GetP2PPeer().Log().Info("Kaia peer registration failed", "err", err) return err } defer mb.removePeer(p.GetID()) @@ -457,7 +457,7 @@ func (mb *MainBridge) removePeer(id string) { if peer == nil { return } - logger.Debug("Removing Klaytn peer", "peer", id) + logger.Debug("Removing Kaia peer", "peer", id) if err := mb.peers.Unregister(id); err != nil { logger.Error("Peer removal failed", "peer", id, "err", err) diff --git a/node/sc/subbridge.go b/node/sc/subbridge.go index 735acde4dd..2848ad5291 100644 --- a/node/sc/subbridge.go +++ b/node/sc/subbridge.go @@ -212,7 +212,7 @@ func NewSubBridge(ctx *node.ServiceContext, config *SCConfig) (*SubBridge, error GlobalQueue: 8192, } - logger.Info("Initialising Klaytn-Bridge protocol", "network", config.NetworkId) + logger.Info("Initialising Kaia-Bridge protocol", "network", config.NetworkId) sb.APIBackend = &SubBridgeAPI{sb} sb.bridgeTxPool = bridgepool.NewBridgeTxPool(bridgetxConfig) @@ -512,7 +512,7 @@ func (sb *SubBridge) handle(p BridgePeer) error { if sb.peers.Len() >= sb.maxPeers && !p.GetP2PPeer().Info().Networks[p2p.ConnDefault].Trusted { return p2p.DiscTooManyPeers } - p.GetP2PPeer().Log().Debug("Klaytn peer connected", "name", p.GetP2PPeer().Name()) + p.GetP2PPeer().Log().Debug("Kaia peer connected", "name", p.GetP2PPeer().Name()) // Execute the handshake var ( @@ -524,7 +524,7 @@ func (sb *SubBridge) handle(p BridgePeer) error { err := p.Handshake(sb.networkId, sb.getChainID(), td, hash) if err != nil { - p.GetP2PPeer().Log().Debug("Klaytn peer handshake failed", "err", err) + p.GetP2PPeer().Log().Debug("Kaia peer handshake failed", "err", err) fmt.Println(err) return err } @@ -532,7 +532,7 @@ func (sb *SubBridge) handle(p BridgePeer) error { // Register the peer locally if err := sb.peers.Register(p); err != nil { // if starting node with unlock account, can't register peer until finish unlock - p.GetP2PPeer().Log().Info("Klaytn peer registration failed", "err", err) + p.GetP2PPeer().Log().Info("Kaia peer registration failed", "err", err) fmt.Println(err) return err } @@ -545,7 +545,7 @@ func (sb *SubBridge) handle(p BridgePeer) error { // main loop. handle incoming messages. for { if err := sb.handleMsg(p); err != nil { - p.GetP2PPeer().Log().Debug("Klaytn message handling failed", "err", err) + p.GetP2PPeer().Log().Debug("Kaia message handling failed", "err", err) return err } } @@ -694,7 +694,7 @@ func (sb *SubBridge) removePeer(id string) { if peer == nil { return } - logger.Debug("Removing Klaytn peer", "peer", id) + logger.Debug("Removing Kaia peer", "peer", id) if err := sb.peers.Unregister(id); err != nil { logger.Error("Peer removal failed", "peer", id, "err", err) diff --git a/node/sc/vt_contract_test.go b/node/sc/vt_contract_test.go index 0869c39a08..f272a82935 100644 --- a/node/sc/vt_contract_test.go +++ b/node/sc/vt_contract_test.go @@ -41,7 +41,7 @@ func TestTokenPublicVariables(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -88,7 +88,7 @@ func TestNFTPublicVariables(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() diff --git a/node/sc/vt_recovery_test.go b/node/sc/vt_recovery_test.go index 5de9dd17d6..ff53e392ec 100644 --- a/node/sc/vt_recovery_test.go +++ b/node/sc/vt_recovery_test.go @@ -79,7 +79,7 @@ type operations struct { } var ops = map[uint8]*operations{ - KLAY: { + KAIA: { request: requestKLAYTransfer, handle: handleKLAYTransfer, dummyHandle: dummyHandleRequestKLAYTransfer, @@ -109,7 +109,7 @@ func TestBasicKLAYTransferRecovery(t *testing.T) { // 1. Init dummy chain and do some value transfers. info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -147,7 +147,7 @@ func TestBasicKLAYTransferRecovery(t *testing.T) { // 5. Recover pending events info.recoveryCh <- true assert.Equal(t, nil, vtr.recoverPendingEvents()) - ops[KLAY].dummyHandle(info, info.remoteInfo) + ops[KAIA].dummyHandle(info, info.remoteInfo) // 6. Check empty pending events. err = vtr.updateRecoveryHint() @@ -179,7 +179,7 @@ func TestKLAYTransferLongRangeRecovery(t *testing.T) { // 1. Init dummy chain and do some value transfers. info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) for i := uint64(0); i < filterLogsStride; i++ { info.sim.Commit() } @@ -325,7 +325,7 @@ func TestMethodRecover(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -342,7 +342,7 @@ func TestMethodRecover(t *testing.T) { if err != nil { t.Fatal("fail to recover the value transfer") } - ops[KLAY].dummyHandle(info, info.remoteInfo) + ops[KAIA].dummyHandle(info, info.remoteInfo) err = vtr.updateRecoveryHint() if err != nil { @@ -363,7 +363,7 @@ func TestMethodStop(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -400,7 +400,7 @@ func TestFlagVTRecovery(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -427,7 +427,7 @@ func TestAlreadyStartedVTRecovery(t *testing.T) { }() info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -455,7 +455,7 @@ func TestScenarioMainChainRecovery(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.remoteInfo) + ops[KAIA].request(info, info.remoteInfo) } }) defer info.sim.Close() @@ -472,7 +472,7 @@ func TestScenarioMainChainRecovery(t *testing.T) { if err != nil { t.Fatal("fail to recover the value transfer") } - ops[KLAY].dummyHandle(info, info.localInfo) + ops[KAIA].dummyHandle(info, info.localInfo) err = vtr.updateRecoveryHint() if err != nil { @@ -493,7 +493,7 @@ func TestScenarioAutomaticRecovery(t *testing.T) { info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -511,7 +511,7 @@ func TestScenarioAutomaticRecovery(t *testing.T) { t.Fatal("fail to start the value transfer") } assert.Equal(t, nil, vtr.WaitRunningStatus(true, 5*time.Second)) - ops[KLAY].dummyHandle(info, info.remoteInfo) + ops[KAIA].dummyHandle(info, info.remoteInfo) err = vtr.updateRecoveryHint() if err != nil { @@ -534,7 +534,7 @@ func TestMultiOperatorRequestRecovery(t *testing.T) { // 1. Init dummy chain and do some value transfers. info := prepare(t, func(info *testInfo) { for i := 0; i < testTxCount; i++ { - ops[KLAY].request(info, info.localInfo) + ops[KAIA].request(info, info.localInfo) } }) defer info.sim.Close() @@ -593,7 +593,7 @@ func TestMultiOperatorRequestRecovery(t *testing.T) { // 7. Recover pending events info.recoveryCh <- true assert.Equal(t, nil, vtr.recoverPendingEvents()) - ops[KLAY].dummyHandle(info, info.remoteInfo) + ops[KAIA].dummyHandle(info, info.remoteInfo) // 8. Recover from the other operator (value transfer is not recovered yet). err = vtr.updateRecoveryHint() @@ -611,7 +611,7 @@ func TestMultiOperatorRequestRecovery(t *testing.T) { assert.Equal(t, testPendingCount, len(vtr.childEvents)) assert.Equal(t, nil, vtr.recoverPendingEvents()) info.remoteInfo.account = info.localInfo.account // other operator - ops[KLAY].dummyHandle(info, info.remoteInfo) + ops[KAIA].dummyHandle(info, info.remoteInfo) if info.sim.BlockChain().CurrentBlock().Transactions().Len() == 0 { // sometimes recovered pending requests are already acquired by BridgeInfo loop, not dummyHandle // for this case, give enough time for the BridgeInfo loop process the pending requests @@ -811,7 +811,7 @@ func prepare(t *testing.T, vtcallback func(*testInfo)) *testInfo { t.Log("missing handle value transfer", "nonce", ev.GetRequestNonce()) } else { switch ev.GetTokenType() { - case KLAY, ERC20, ERC721: + case KAIA, ERC20, ERC721: break default: t.Errorf("received ev.TokenType is unknown: %v", ev.GetTokenType()) From 965ff5c6266ad4e19e9b679f97a13e73aeb0947f Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 22:39:51 +0900 Subject: [PATCH 21/27] Update reward --- reward/doc.go | 4 ++-- reward/reward_distributor.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/reward/doc.go b/reward/doc.go index 03fad69b24..d4d4aa415e 100644 --- a/reward/doc.go +++ b/reward/doc.go @@ -60,9 +60,9 @@ and returns correct stakingInfo to use. Kaia distributes the reward of a block to proposer, KFF and KCF. The detail information of KFF and KCF is available on Kaia docs. -Token Economy - https://docs.klaytn.foundation/content/klaytn/design/token-economy +Token Economy - https://docs.kaia.io/docs/learn/token-economy/ -Configurations related to the reward system such as mintingAmount, ratio and unitPrice are determined by the Klaytn governance. +Configurations related to the reward system such as mintingAmount, ratio and unitPrice are determined by the Kaia governance. All configurations are saved as rewardConfig on every epoch block (default 604,800 blocks) and managed by a rewardConfigCache. A proposer which has made a current block will get the reward of the block. diff --git a/reward/reward_distributor.go b/reward/reward_distributor.go index 0675d45cd7..e430c2210f 100644 --- a/reward/reward_distributor.go +++ b/reward/reward_distributor.go @@ -192,7 +192,7 @@ func CalcRewardParamBlock(num, epoch uint64, rules params.Rules) uint64 { } // GetBlockReward returns the actual reward amounts paid in this block -// Used in klay_getReward RPC API +// Used in kaia_getReward RPC API func GetBlockReward(header *types.Header, rules params.Rules, pset *params.GovParamSet) (*RewardSpec, error) { var spec *RewardSpec var err error @@ -240,8 +240,8 @@ func GetBlockReward(header *types.Header, rules params.Rules, pset *params.GovPa } // CalcDeferredRewardSimple distributes rewards to proposer after optional fee burning -// this behaves similar to the previous MintKLAY -// MintKLAY has been superseded because we need to split reward distribution +// this behaves similar to the previous MintKAIA +// MintKAIA has been superseded because we need to split reward distribution // logic into (1) calculation, and (2) actual distribution. // CalcDeferredRewardSimple does the former and DistributeBlockReward does the latter func CalcDeferredRewardSimple(header *types.Header, rules params.Rules, pset *params.GovParamSet) (*RewardSpec, error) { @@ -507,7 +507,7 @@ func calcShares(stakingInfo *StakingInfo, stakeReward *big.Int, minStake uint64) totalStakesInt := uint64(0) for _, node := range cns.GetAllNodes() { - if node.StakingAmount > minStake { // comparison in Klay + if node.StakingAmount > minStake { // comparison in KAIA totalStakesInt += (node.StakingAmount - minStake) } } @@ -520,7 +520,7 @@ func calcShares(stakingInfo *StakingInfo, stakeReward *big.Int, minStake uint64) if node.StakingAmount > minStake { effectiveStake := new(big.Int).SetUint64(node.StakingAmount - minStake) // The KAIA unit will cancel out: - // rewardAmount (peb) = stakeReward (peb) * effectiveStake (KLAY) / totalStakes (KLAY) + // rewardAmount (peb) = stakeReward (peb) * effectiveStake (KAIA) / totalStakes (KAIA) rewardAmount := new(big.Int).Mul(stakeReward, effectiveStake) rewardAmount = rewardAmount.Div(rewardAmount, totalStakes) remaining = remaining.Sub(remaining, rewardAmount) From ddbf093fdef6f7ac8d09f2f3117bbf82c5a07a22 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 23:14:18 +0900 Subject: [PATCH 22/27] Update storage --- storage/database/dynamodb.go | 10 +- .../leveldb_bench_compaction_table_test.go | 10 +- .../database/leveldb_bench_multidisks_test.go | 18 +-- .../database/leveldb_bench_options_test.go | 112 +++++++++--------- storage/database/leveldb_database.go | 28 ++--- storage/database/rocksdb_database.go | 14 +-- 6 files changed, 96 insertions(+), 96 deletions(-) diff --git a/storage/database/dynamodb.go b/storage/database/dynamodb.go index ab0c3a6029..ef9d3e9cfd 100644 --- a/storage/database/dynamodb.go +++ b/storage/database/dynamodb.go @@ -33,7 +33,7 @@ import ( "sync" "time" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/client" @@ -106,8 +106,8 @@ type dynamoDB struct { logger log.Logger // Contextual logger tracking the database path // metrics - getTimer klaytnmetrics.HybridTimer - putTimer klaytnmetrics.HybridTimer + getTimer kaiaMetrics.HybridTimer + putTimer kaiaMetrics.HybridTimer } type DynamoData struct { @@ -442,8 +442,8 @@ func (dynamo *dynamoDB) Close() { } func (dynamo *dynamoDB) Meter(prefix string) { - dynamo.getTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - dynamo.putTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + dynamo.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + dynamo.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) dynamoBatchWriteTimeMeter = metrics.NewRegisteredMeter(prefix+"batchwrite/time", nil) } diff --git a/storage/database/leveldb_bench_compaction_table_test.go b/storage/database/leveldb_bench_compaction_table_test.go index 01afa6bc61..d210c42afa 100644 --- a/storage/database/leveldb_bench_compaction_table_test.go +++ b/storage/database/leveldb_bench_compaction_table_test.go @@ -39,7 +39,7 @@ const ( // getLDBOptionsForTableSize gets default options except for `CompactionTableSize` which equals to `tableSize` * `unit`. func getLDBOptionsForTableSize(tableSize, unit int) *opt.Options { - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() opts.CompactionTableSize = tableSize * unit return opts @@ -87,7 +87,7 @@ func BenchmarkOptionsLDBTableSizeGet(b *testing.B) { list := getTestLDBOptionsList(getLDBOptionsForTableSize) for _, bm := range list { b.Run(bm.Name, func(b *testing.B) { - benchmarkKlayOptionsGet(b, bm.Opts, bm.ValueLength, bm.NumInsertions, bm.NumGets, randomRead) + benchmarkKaiaOptionsGet(b, bm.Opts, bm.ValueLength, bm.NumInsertions, bm.NumGets, randomRead) }) } } @@ -100,7 +100,7 @@ func BenchmarkOptionsLDBTableSizeMultiplierGet(b *testing.B) { list := getTestLDBOptionsList(getLDBOptionsForTableSizeWithMultiplier) for _, bm := range list { b.Run(bm.Name, func(b *testing.B) { - benchmarkKlayOptionsGet(b, bm.Opts, bm.ValueLength, bm.NumInsertions, bm.NumGets, randomRead) + benchmarkKaiaOptionsGet(b, bm.Opts, bm.ValueLength, bm.NumInsertions, bm.NumGets, randomRead) }) } } @@ -113,7 +113,7 @@ func BenchmarkOptionsLDBTableSizePut(b *testing.B) { list := getTestLDBOptionsList(getLDBOptionsForTableSize) for _, bm := range list { b.Run(bm.Name, func(b *testing.B) { - benchmarkKlayOptionsPut(b, bm.Opts, bm.ValueLength, bm.NumInsertions) + benchmarkKaiaOptionsPut(b, bm.Opts, bm.ValueLength, bm.NumInsertions) }) } } @@ -126,7 +126,7 @@ func BenchmarkOptionsLDBTableSizeMultiplierPut(b *testing.B) { list := getTestLDBOptionsList(getLDBOptionsForTableSizeWithMultiplier) for _, bm := range list { b.Run(bm.Name, func(b *testing.B) { - benchmarkKlayOptionsPut(b, bm.Opts, bm.ValueLength, bm.NumInsertions) + benchmarkKaiaOptionsPut(b, bm.Opts, bm.ValueLength, bm.NumInsertions) }) } } diff --git a/storage/database/leveldb_bench_multidisks_test.go b/storage/database/leveldb_bench_multidisks_test.go index 45f4882c70..1afed344b3 100644 --- a/storage/database/leveldb_bench_multidisks_test.go +++ b/storage/database/leveldb_bench_multidisks_test.go @@ -58,7 +58,7 @@ func benchmark_MDP_Put_GoRoutine(b *testing.B, mdo *multiDiskOption) { dirs := genDirForMDPTest(b, mdo.numDisks, mdo.numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -94,7 +94,7 @@ func benchmark_MDP_Put_NoGoRoutine(b *testing.B, mdo *multiDiskOption) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -167,7 +167,7 @@ func benchmark_MDP_Batch_GoRoutine(b *testing.B, mdo *multiDiskOption) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -222,7 +222,7 @@ func benchmark_MDP_Batch_NoGoRoutine(b *testing.B, mdo *multiDiskOption) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -318,7 +318,7 @@ func benchmark_MDP_Get_NoGoRotine(b *testing.B, mdo *multiDiskOption, numReads i dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -357,7 +357,7 @@ func benchmark_MDP_Get_GoRoutine(b *testing.B, mdo *multiDiskOption, numReads in dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -458,7 +458,7 @@ func Benchmark_MDP_Parallel_Get(b *testing.B) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -498,7 +498,7 @@ func Benchmark_MDP_Parallel_Put(b *testing.B) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) @@ -532,7 +532,7 @@ func Benchmark_MDP_Parallel_Batch(b *testing.B) { dirs := genDirForMDPTest(b, numDisks, numShards) defer removeDirs(dirs) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() databases := genDatabases(b, dirs, opts) defer closeDBs(databases) diff --git a/storage/database/leveldb_bench_options_test.go b/storage/database/leveldb_bench_options_test.go index 2b8ac98202..209c57ae8d 100644 --- a/storage/database/leveldb_bench_options_test.go +++ b/storage/database/leveldb_bench_options_test.go @@ -36,12 +36,12 @@ func genTempDirForTestDB(b *testing.B) string { return dir } -func getKlayLDBOptions() *opt.Options { +func getKaiaLDBOptions() *opt.Options { return getLevelDBOptions(&DBConfig{LevelDBCacheSize: 128, OpenFilesLimit: 128}) } -func getKlayLDBOptionsForGetX(x int) *opt.Options { - opts := getKlayLDBOptions() +func getKaiaLDBOptionsForGetX(x int) *opt.Options { + opts := getKaiaLDBOptions() opts.WriteBuffer *= x opts.BlockCacheCapacity *= x opts.OpenFilesCacheCapacity *= x @@ -50,8 +50,8 @@ func getKlayLDBOptionsForGetX(x int) *opt.Options { return opts } -func getKlayLDBOptionsForPutX(x int) *opt.Options { - opts := getKlayLDBOptions() +func getKaiaLDBOptionsForPutX(x int) *opt.Options { + opts := getKaiaLDBOptions() opts.BlockCacheCapacity *= x opts.BlockRestartInterval *= x @@ -66,8 +66,8 @@ func getKlayLDBOptionsForPutX(x int) *opt.Options { return opts } -func getKlayLDBOptionsForBatchX(x int) *opt.Options { - opts := getKlayLDBOptions() +func getKaiaLDBOptionsForBatchX(x int) *opt.Options { + opts := getKaiaLDBOptions() opts.BlockCacheCapacity *= x opts.BlockRestartInterval *= x @@ -83,7 +83,7 @@ func getKlayLDBOptionsForBatchX(x int) *opt.Options { } // readTypeFunc determines requested index -func benchmarkKlayOptionsGet(b *testing.B, opts *opt.Options, valueLength, numInsertions, numGets int, readTypeFunc func(int, int) int) { +func benchmarkKaiaOptionsGet(b *testing.B, opts *opt.Options, valueLength, numInsertions, numGets int, readTypeFunc func(int, int) int) { b.StopTimer() b.ReportAllocs() @@ -128,47 +128,47 @@ func zipfRead(currIndex, numInsertions int) int { } const ( - getKlayValueLegnth = 250 - getKlayNumInsertions = 1000 * 100 - getKlaynumGets = 1000 + getKaiaValueLegnth = 250 + getKaiaNumInsertions = 1000 * 100 + getKaiaNumGets = 1000 ) -var getKlayOptions = [...]struct { +var getKaiaOptions = [...]struct { name string valueLength int numInsertions int numGets int opts *opt.Options }{ - {"X1", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(1)}, - {"X2", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(2)}, - {"X4", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(4)}, - {"X8", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(8)}, - //{"X16", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(16)}, - //{"X32", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(32)}, - //{"X64", getKlayValueLegnth, getKlayNumInsertions, getKlaynumGets, getKlayLDBOptionsForGetX(64)}, + {"X1", getKaiaValueLegnth, getKaiaNumInsertions, getKaiaNumGets, getKaiaLDBOptionsForGetX(1)}, + {"X2", getKaiaValueLegnth, getKaiaNumInsertions, getKaiaNumGets, getKaiaLDBOptionsForGetX(2)}, + {"X4", getKaiaValueLegnth, getKaiaNumInsertions, getKaiaNumGets, getKaiaLDBOptionsForGetX(4)}, + {"X8", getKaiaValueLegnth, getKaiaNumInsertions, getKaiaNumGets, getKaiaLDBOptionsForGetX(8)}, + //{"X16", getKaiaValueLegnth, getKaiaNumInsertions, getKaianumGets, getKaiaLDBOptionsForGetX(16)}, + //{"X32", getKaiaValueLegnth, getKaiaNumInsertions, getKaianumGets, getKaiaLDBOptionsForGetX(32)}, + //{"X64", getKaiaValueLegnth, getKaiaNumInsertions, getKaianumGets, getKaiaLDBOptionsForGetX(64)}, } -func Benchmark_KlayOptions_Get_Random(b *testing.B) { - for _, bm := range getKlayOptions { +func Benchmark_KaiaOptions_Get_Random(b *testing.B) { + for _, bm := range getKaiaOptions { b.Run(bm.name, func(b *testing.B) { - benchmarkKlayOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, randomRead) + benchmarkKaiaOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, randomRead) }) } } -func Benchmark_KlayOptions_Get_Sequential(b *testing.B) { - for _, bm := range getKlayOptions { +func Benchmark_KaiaOptions_Get_Sequential(b *testing.B) { + for _, bm := range getKaiaOptions { b.Run(bm.name, func(b *testing.B) { - benchmarkKlayOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, sequentialRead) + benchmarkKaiaOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, sequentialRead) }) } } -func Benchmark_KlayOptions_Get_Zipf(b *testing.B) { - for _, bm := range getKlayOptions { +func Benchmark_KaiaOptions_Get_Zipf(b *testing.B) { + for _, bm := range getKaiaOptions { b.Run(bm.name, func(b *testing.B) { - benchmarkKlayOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, zipfRead) + benchmarkKaiaOptionsGet(b, bm.opts, bm.valueLength, bm.numInsertions, bm.numGets, zipfRead) }) } } @@ -177,7 +177,7 @@ func Benchmark_KlayOptions_Get_Zipf(b *testing.B) { ////////////////////////////// Put Insertion Tests Beginning ////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// -func benchmarkKlayOptionsPut(b *testing.B, opts *opt.Options, valueLength, numInsertions int) { +func benchmarkKaiaOptionsPut(b *testing.B, opts *opt.Options, valueLength, numInsertions int) { b.StopTimer() dir := genTempDirForTestDB(b) @@ -195,31 +195,31 @@ func benchmarkKlayOptionsPut(b *testing.B, opts *opt.Options, valueLength, numIn } } -func Benchmark_KlayOptions_Put(b *testing.B) { +func Benchmark_KaiaOptions_Put(b *testing.B) { b.StopTimer() b.ReportAllocs() const ( - putKlayValueLegnth = 250 - putKlayNumInsertions = 1000 * 10 + putKaiaValueLegnth = 250 + putKaiaNumInsertions = 1000 * 10 ) - putKlayOptions := [...]struct { + putKaiaOptions := [...]struct { name string valueLength int numInsertions int opts *opt.Options }{ - {"X1", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(1)}, - {"X2", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(2)}, - {"X4", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(4)}, - {"X8", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(8)}, - //{"X16", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(16)}, - //{"X32", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(32)}, - //{"X64", putKlayValueLegnth, putKlayNumInsertions, getKlayLDBOptionsForPutX(64)}, + {"X1", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(1)}, + {"X2", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(2)}, + {"X4", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(4)}, + {"X8", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(8)}, + //{"X16", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(16)}, + //{"X32", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(32)}, + //{"X64", putKaiaValueLegnth, putKaiaNumInsertions, getKaiaLDBOptionsForPutX(64)}, } - for _, bm := range putKlayOptions { + for _, bm := range putKaiaOptions { b.Run(bm.name, func(b *testing.B) { - benchmarkKlayOptionsPut(b, bm.opts, bm.valueLength, bm.numInsertions) + benchmarkKaiaOptionsPut(b, bm.opts, bm.valueLength, bm.numInsertions) }) } } @@ -266,7 +266,7 @@ func genKeysAndValues(valueLength, numInsertions int) ([][]byte, [][]byte) { ///////////////////////////// Batch Insertion Tests Beginning ///////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// -func benchmarkKlayOptionsBatch(b *testing.B, opts *opt.Options, valueLength, numInsertions int) { +func benchmarkKaiaOptionsBatch(b *testing.B, opts *opt.Options, valueLength, numInsertions int) { b.StopTimer() dir := genTempDirForTestDB(b) defer os.RemoveAll(dir) @@ -287,32 +287,32 @@ func benchmarkKlayOptionsBatch(b *testing.B, opts *opt.Options, valueLength, num } } -func Benchmark_KlayOptions_Batch(b *testing.B) { +func Benchmark_KaiaOptions_Batch(b *testing.B) { b.StopTimer() b.ReportAllocs() const ( batchValueLength = 250 - batchKlayNumInsertions = 1000 * 10 + batchKaiaNumInsertions = 1000 * 10 ) - putKlayOptions := [...]struct { + putKaiaOptions := [...]struct { name string valueLength int numInsertions int opts *opt.Options }{ - {"X1", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(1)}, - {"X2", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(2)}, - {"X4", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(4)}, - {"X8", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(8)}, - //{"X16", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(16)}, - //{"X32", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(32)}, - //{"X64", batchValueLength, batchKlayNumInsertions, getKlayLDBOptionsForBatchX(64)}, + {"X1", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(1)}, + {"X2", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(2)}, + {"X4", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(4)}, + {"X8", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(8)}, + //{"X16", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(16)}, + //{"X32", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(32)}, + //{"X64", batchValueLength, batchKaiaNumInsertions, getKaiaLDBOptionsForBatchX(64)}, } - for _, bm := range putKlayOptions { + for _, bm := range putKaiaOptions { b.Run(bm.name, func(b *testing.B) { - benchmarkKlayOptionsBatch(b, bm.opts, bm.valueLength, bm.numInsertions) + benchmarkKaiaOptionsBatch(b, bm.opts, bm.valueLength, bm.numInsertions) }) } } @@ -340,7 +340,7 @@ func benchmarkIdealBatchSize(b *testing.B, bm idealBatchBM) { dir := genTempDirForTestDB(b) defer os.RemoveAll(dir) - opts := getKlayLDBOptions() + opts := getKaiaLDBOptions() db, err := NewLevelDBWithOption(dir, opts) require.NoError(b, err) defer db.Close() diff --git a/storage/database/leveldb_database.go b/storage/database/leveldb_database.go index 394bd687c4..ec9786880c 100644 --- a/storage/database/leveldb_database.go +++ b/storage/database/leveldb_database.go @@ -26,7 +26,7 @@ import ( "sync" "time" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/common/fdlimit" "github.com/klaytn/klaytn/log" @@ -103,12 +103,12 @@ type levelDB struct { aliveSnapshotsMeter metrics.Meter // Meter for measuring the number of alive snapshots aliveIteratorsMeter metrics.Meter // Meter for measuring the number of alive iterators - compTimer klaytnmetrics.HybridTimer // Meter for measuring the total time spent in database compaction - compReadMeter metrics.Meter // Meter for measuring the data read during compaction - compWriteMeter metrics.Meter // Meter for measuring the data written during compaction - diskReadMeter metrics.Meter // Meter for measuring the effective amount of data read - diskWriteMeter metrics.Meter // Meter for measuring the effective amount of data written - blockCacheGauge metrics.Gauge // Gauge for measuring the current size of block cache + compTimer kaiaMetrics.HybridTimer // Meter for measuring the total time spent in database compaction + compReadMeter metrics.Meter // Meter for measuring the data read during compaction + compWriteMeter metrics.Meter // Meter for measuring the data written during compaction + diskReadMeter metrics.Meter // Meter for measuring the effective amount of data read + diskWriteMeter metrics.Meter // Meter for measuring the effective amount of data written + blockCacheGauge metrics.Gauge // Gauge for measuring the current size of block cache openedTablesCountMeter metrics.Meter memCompGauge metrics.Gauge // Gauge for tracking the number of memory compaction level0CompGauge metrics.Gauge // Gauge for tracking the number of table compaction in level0 @@ -122,9 +122,9 @@ type levelDB struct { levelDurationsGauge []metrics.Gauge perfCheck bool - getTimer klaytnmetrics.HybridTimer - putTimer klaytnmetrics.HybridTimer - batchWriteTimer klaytnmetrics.HybridTimer + getTimer kaiaMetrics.HybridTimer + putTimer kaiaMetrics.HybridTimer + batchWriteTimer kaiaMetrics.HybridTimer quitLock sync.Mutex // Mutex protecting the quit channel access quitChan chan chan error // Quit channel to stop the metrics collection before closing the database @@ -363,7 +363,7 @@ func (db *levelDB) Meter(prefix string) { db.writeDelayDurationMeter = metrics.NewRegisteredMeter(prefix+"writedelay/duration", nil) db.aliveSnapshotsMeter = metrics.NewRegisteredMeter(prefix+"snapshots", nil) db.aliveIteratorsMeter = metrics.NewRegisteredMeter(prefix+"iterators", nil) - db.compTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"compaction/time", nil) + db.compTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"compaction/time", nil) db.compReadMeter = metrics.NewRegisteredMeter(prefix+"compaction/read", nil) db.compWriteMeter = metrics.NewRegisteredMeter(prefix+"compaction/write", nil) db.diskReadMeter = metrics.NewRegisteredMeter(prefix+"disk/read", nil) @@ -372,9 +372,9 @@ func (db *levelDB) Meter(prefix string) { db.openedTablesCountMeter = metrics.NewRegisteredMeter(prefix+"opendedtables", nil) - db.getTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - db.putTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) - db.batchWriteTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) + db.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + db.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + db.batchWriteTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) db.memCompGauge = metrics.NewRegisteredGauge(prefix+"compact/memory", nil) db.level0CompGauge = metrics.NewRegisteredGauge(prefix+"compact/level0", nil) diff --git a/storage/database/rocksdb_database.go b/storage/database/rocksdb_database.go index abb17f9a25..1c2e80ce19 100644 --- a/storage/database/rocksdb_database.go +++ b/storage/database/rocksdb_database.go @@ -26,7 +26,7 @@ import ( "time" "github.com/klaytn/klaytn/log" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" metricutils "github.com/klaytn/klaytn/metrics/utils" "github.com/linxGnu/grocksdb" "github.com/rcrowley/go-metrics" @@ -73,9 +73,9 @@ type rocksDB struct { quitCh chan struct{} metrics []metrics.Meter - getTimer klaytnmetrics.HybridTimer - putTimer klaytnmetrics.HybridTimer - batchWriteTimer klaytnmetrics.HybridTimer + getTimer kaiaMetrics.HybridTimer + putTimer kaiaMetrics.HybridTimer + batchWriteTimer kaiaMetrics.HybridTimer prefix string logger log.Logger @@ -312,9 +312,9 @@ func (db *rocksDB) Meter(prefix string) { name := strings.ReplaceAll(splited[1], "-", "/") db.metrics = append(db.metrics, metrics.NewRegisteredMeter(prefix+name, nil)) } - db.getTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - db.putTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) - db.batchWriteTimer = klaytnmetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) + db.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + db.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + db.batchWriteTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) // Short circuit metering if the metrics system is disabled // Above meters are initialized by NilMeter if metricutils.Enabled == false From 6c2dcc06d2794f594277109f3cbec421e26b7e50 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 23:32:24 +0900 Subject: [PATCH 23/27] Update tests --- tests/README.md | 26 +++++++++---------- tests/hard_fork_test.go | 6 ++--- ...kchain_test.go => kaia_blockchain_test.go} | 16 ++++++------ ...scenario_test.go => kaia_scenario_test.go} | 0 tests/{klay_test.go => kaia_test.go} | 0 ..._test.go => kaia_test_account_map_test.go} | 0 ...n_test.go => kaia_test_blockchain_test.go} | 0 tests/race_test.go | 2 +- tests/randao_fork_test.go | 4 +-- tests/state_migration_test.go | 4 +-- tests/tx_gas_calculation_test.go | 4 +-- 11 files changed, 31 insertions(+), 31 deletions(-) rename tests/{klay_blockchain_test.go => kaia_blockchain_test.go} (96%) rename tests/{klay_scenario_test.go => kaia_scenario_test.go} (100%) rename tests/{klay_test.go => kaia_test.go} (100%) rename tests/{klay_test_account_map_test.go => kaia_test_account_map_test.go} (100%) rename tests/{klay_test_blockchain_test.go => kaia_test_blockchain_test.go} (100%) diff --git a/tests/README.md b/tests/README.md index bf74d83b64..b26a10c150 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,34 +1,34 @@ -# How to use Klaytn tests +# How to use Kaia tests -[Klaytn tests](https://github.com/klaytn/klaytn-tests) is not currently included +[Kaia tests](https://github.com/kaiachain/kaia-tests) is not currently included here due to its relatively large size. It will be added as a git submodule later. -In order to use Klaytn tests, you would need to clone it as `testdata`; or +In order to use Kaia tests, you would need to clone it as `testdata`; or clone it somewhere and make a symbolic link to it. This document assumes -Klaytn tests is cloned outside the klaytn source tree, and the following -instructions describe how to use Klaytn tests with `go test`. +Kaia tests is cloned outside the Kaia source tree, and the following +instructions describe how to use Kaia tests with `go test`. -## 1. Clone Klaytn tests +## 1. Clone Kaia tests -Clone Klaytn tests in the location where you'd like to have it. Let's say we +Clone Kaia tests in the location where you'd like to have it. Let's say we clone it in `$HOME/workspace`. ``` $ cd $HOME/workspace -$ git clone git@github.com:klaytn/klaytn-tests.git +$ git clone git@github.com:kaiachain/kaia-tests.git ``` ## 2. Create a symbolic link -We assume Klaytn source tree is located in -`$HOME/workspace/go/src/github.com/klaytn/klaytn`. +We assume Kaia source tree is located in +`$HOME/workspace/go/src/github.com/kaiachain/kaia`. ``` -$ cd $HOME/workspace/go/src/github.com/klaytn/klaytn/tests -$ ln -s $HOME/workspace/klaytn-tests testdata +$ cd $HOME/workspace/go/src/github.com/kaiachain/kaia/tests +$ ln -s $HOME/workspace/kaia-tests testdata ``` @@ -43,7 +43,7 @@ $ go test ## 3-2. Run a specific test -There are five test sets available in Klaytn tests, which can be put after +There are five test sets available in Kaia tests, which can be put after `-run` flag. - Blockchain - NOTE: all test cases in BlockchainTests are skipped at this moment because diff --git a/tests/hard_fork_test.go b/tests/hard_fork_test.go index 16a06abdb3..ae1db58c06 100644 --- a/tests/hard_fork_test.go +++ b/tests/hard_fork_test.go @@ -152,7 +152,7 @@ func genBlocks(t *testing.T) { Type string account TestAccount }{ - {"KlaytnLegacy", genKaiaLegacyAccount(t)}, + {"KaiaLegacy", genKaiaLegacyAccount(t)}, {"Public", genPublicAccount(t)}, {"MultiSig", genMultiSigAccount(t)}, {"RoleBasedWithPublic", genRoleBasedWithPublicAccount(t)}, @@ -213,7 +213,7 @@ func genBlocks(t *testing.T) { reservoir.AddNonce() } - // Preparing step. Send KAIA to KlaytnAcounts. + // Preparing step. Send KAIA to KaiaAcounts. for i := 1; i < len(accountTypes); i++ { // create an account which account key will be replaced to one of account key types. anon, err := createAnonymousAccount(getRandomPrivateKeyString(t)) @@ -432,7 +432,7 @@ func genBlocks(t *testing.T) { for _, sender := range accountTypes { toAccount := reservoir - // LegacyTransaction can be used only with LegacyAccount and KlaytnAccount with AccountKeyLegacy. + // LegacyTransaction can be used only with LegacyAccount and KaiaAccount with AccountKeyLegacy. if !strings.Contains(sender.Type, "Legacy") && strings.Contains(f.Name, "Legacy") { continue } diff --git a/tests/klay_blockchain_test.go b/tests/kaia_blockchain_test.go similarity index 96% rename from tests/klay_blockchain_test.go rename to tests/kaia_blockchain_test.go index 7653f1d4dd..135f2af59f 100644 --- a/tests/klay_blockchain_test.go +++ b/tests/kaia_blockchain_test.go @@ -75,7 +75,7 @@ func TestSimpleBlockchain(t *testing.T) { time.Sleep(2 * time.Second) // start full node with previous db - fullNode, node, err := newKlaytnNode(t, workspace, validator, nil, nil) + fullNode, node, err := newKaiaNode(t, workspace, validator, nil, nil) assert.NoError(t, err) if err := node.StartMining(false); err != nil { t.Fatal() @@ -104,7 +104,7 @@ func newBlockchain(t *testing.T, config *params.ChainConfig, genesis *blockchain } // Create a Kaia node - fullNode, node, err := newKlaytnNode(t, workspace, validator, config, genesis) + fullNode, node, err := newKaiaNode(t, workspace, validator, config, genesis) assert.NoError(t, err) if err := node.StartMining(false); err != nil { t.Fatal() @@ -141,9 +141,9 @@ func createAccount(t *testing.T, numAccounts int, validator *TestAccountType) (* return richAccount, accounts, contractAccounts } -// newKlaytnNode creates a Kaia node -func newKlaytnNode(t *testing.T, dir string, validator *TestAccountType, config *params.ChainConfig, genesis *blockchain.Genesis) (*node.Node, *cn.CN, error) { - var klaytnNode *cn.CN +// newKaiaNode creates a Kaia node +func newKaiaNode(t *testing.T, dir string, validator *TestAccountType, config *params.ChainConfig, genesis *blockchain.Genesis) (*node.Node, *cn.CN, error) { + var kaiaNode *cn.CN fullNode, err := node.New(&node.Config{ DataDir: dir, @@ -188,18 +188,18 @@ func newKlaytnNode(t *testing.T, dir string, validator *TestAccountType, config _, _ = ks.ImportECDSA(validator.Keys[0], "") // import a node key if err = fullNode.Register(func(ctx *node.ServiceContext) (node.Service, error) { return cn.New(ctx, cnConf) }); err != nil { - return nil, nil, errors.WithMessage(err, "failed to register Klaytn protocol") + return nil, nil, errors.WithMessage(err, "failed to register Kaia protocol") } if err = fullNode.Start(); err != nil { return nil, nil, errors.WithMessage(err, "failed to start test fullNode") } - if err := fullNode.Service(&klaytnNode); err != nil { + if err := fullNode.Service(&kaiaNode); err != nil { return nil, nil, err } - return fullNode, klaytnNode, nil + return fullNode, kaiaNode, nil } // deployRandomTxs creates a random transaction diff --git a/tests/klay_scenario_test.go b/tests/kaia_scenario_test.go similarity index 100% rename from tests/klay_scenario_test.go rename to tests/kaia_scenario_test.go diff --git a/tests/klay_test.go b/tests/kaia_test.go similarity index 100% rename from tests/klay_test.go rename to tests/kaia_test.go diff --git a/tests/klay_test_account_map_test.go b/tests/kaia_test_account_map_test.go similarity index 100% rename from tests/klay_test_account_map_test.go rename to tests/kaia_test_account_map_test.go diff --git a/tests/klay_test_blockchain_test.go b/tests/kaia_test_blockchain_test.go similarity index 100% rename from tests/klay_test_blockchain_test.go rename to tests/kaia_test_blockchain_test.go diff --git a/tests/race_test.go b/tests/race_test.go index 6b72ea07a3..95f4c31f84 100644 --- a/tests/race_test.go +++ b/tests/race_test.go @@ -110,7 +110,7 @@ func TestRaceAsMessageWithAccountPickerForFeePayer(t *testing.T) { from, _ = createAnonymousAccount("a5c9a50938a089618167c9d67dbebc0deaffc3c76ddc6b40c2777ae594389999") feePayer, _ = createAnonymousAccount("ed580f5bd71a2ee4dae5cb43e331b7d0318596e561e6add7844271ed94156b20") - funds = new(big.Int).Mul(big.NewInt(1e16), big.NewInt(params.KLAY)) + funds = new(big.Int).Mul(big.NewInt(1e16), big.NewInt(params.KAIA)) gspec = &blockchain.Genesis{ Config: params.TestChainConfig, Alloc: blockchain.GenesisAlloc{ diff --git a/tests/randao_fork_test.go b/tests/randao_fork_test.go index 2b02fb01b8..f76ee3f080 100644 --- a/tests/randao_fork_test.go +++ b/tests/randao_fork_test.go @@ -5,7 +5,7 @@ import ( "math/big" "testing" - "github.com/klaytn/klaytn" + kaia "github.com/klaytn/klaytn" "github.com/klaytn/klaytn/accounts/abi/bind" "github.com/klaytn/klaytn/accounts/abi/bind/backends" "github.com/klaytn/klaytn/blockchain" @@ -356,7 +356,7 @@ func testRandao_checkKip114(t *testing.T, ctx *blockchainTestContext, randomAddr // Call the contract to check RANDOM opcode result callRandom := func(num uint64) []byte { - tx := klaytn.CallMsg{ + tx := kaia.CallMsg{ To: &randomAddr, Data: hexutil.MustDecode("0x5ec01e4d"), // random() } diff --git a/tests/state_migration_test.go b/tests/state_migration_test.go index 9ec94ea307..f83a2acaf5 100644 --- a/tests/state_migration_test.go +++ b/tests/state_migration_test.go @@ -100,7 +100,7 @@ func TestMigration_StartMigrationByMiscDB(t *testing.T) { // an error expected on node start stopNode(t, fullNode) - _, _, err = newKlaytnNode(t, workspace, validator, nil, nil) + _, _, err = newKaiaNode(t, workspace, validator, nil, nil) assert.Error(t, err, "start failure expected, changed state trie db has no data") // error expected } } @@ -211,7 +211,7 @@ func restartNode(t *testing.T, fullNode *node.Node, node *cn.CN, workspace strin func startNode(t *testing.T, workspace string, validator *TestAccountType) (fullNode *node.Node, node *cn.CN) { t.Log("=========== starting node ==============") - newFullNode, newNode, err := newKlaytnNode(t, workspace, validator, nil, nil) + newFullNode, newNode, err := newKaiaNode(t, workspace, validator, nil, nil) assert.NoError(t, err) if err := newNode.StartMining(false); err != nil { t.Fatal() diff --git a/tests/tx_gas_calculation_test.go b/tests/tx_gas_calculation_test.go index 4a431d8dfd..37ec39481e 100644 --- a/tests/tx_gas_calculation_test.go +++ b/tests/tx_gas_calculation_test.go @@ -131,7 +131,7 @@ func TestGasCalculation(t *testing.T) { signer := types.LatestSignerForChainID(bcdata.bc.Config().ChainID) gasPrice := new(big.Int).SetUint64(bcdata.bc.Config().UnitPrice) - // Preparing step. Send KAIA to a KlaytnAcount. + // Preparing step. Send KAIA to a KaiaAcount. { var txs types.Transactions @@ -149,7 +149,7 @@ func TestGasCalculation(t *testing.T) { reservoir.AddNonce() } - // Preparing step. Send KAIA to KlaytnAcounts. + // Preparing step. Send KAIA to KaiaAcounts. for i := 1; i < len(accountTypes); i++ { // create an account which account key will be replaced to one of account key types. anon, err := createAnonymousAccount(getRandomPrivateKeyString(t)) From 9a6e3e8957e134ee821573d97e047a242b98377f Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Thu, 9 May 2024 23:33:58 +0900 Subject: [PATCH 24/27] Update utils, work --- utils/build/env.go | 2 +- work/worker.go | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/utils/build/env.go b/utils/build/env.go index 97374492a5..3e4304c5b4 100644 --- a/utils/build/env.go +++ b/utils/build/env.go @@ -88,7 +88,7 @@ func Env() Environment { // LocalEnv returns build environment metadata gathered from git. func LocalEnv() Environment { - env := applyEnvFlags(Environment{Name: "local", Repo: "klaytn/klaytn"}) + env := applyEnvFlags(Environment{Name: "local", Repo: "kaiachain/kaia"}) if os.Getenv("KLAYTN_RACE_DETECT") == "1" { env.IsKaiaRaceDetectionOn = true diff --git a/work/worker.go b/work/worker.go index 575e04718e..dbb709fd95 100644 --- a/work/worker.go +++ b/work/worker.go @@ -34,7 +34,7 @@ import ( "github.com/klaytn/klaytn/consensus" "github.com/klaytn/klaytn/consensus/misc" "github.com/klaytn/klaytn/event" - klaytnmetrics "github.com/klaytn/klaytn/metrics" + kaiaMetrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/params" "github.com/klaytn/klaytn/reward" "github.com/klaytn/klaytn/storage/database" @@ -71,20 +71,20 @@ var ( strangeErrorTxsCounter = metrics.NewRegisteredCounter("miner/strangeerror/txs", nil) blockBaseFee = metrics.NewRegisteredGauge("miner/block/mining/basefee", nil) - blockMiningTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/mining/time", nil) - blockMiningExecuteTxTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/execute/time", nil) - blockMiningCommitTxTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/commit/time", nil) - blockMiningFinalizeTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/finalize/time", nil) - - accountReadTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/account/reads", nil) - accountHashTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/account/hashes", nil) - accountUpdateTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/account/updates", nil) - accountCommitTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/account/commits", nil) - - storageReadTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/storage/reads", nil) - storageHashTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/storage/hashes", nil) - storageUpdateTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/storage/updates", nil) - storageCommitTimer = klaytnmetrics.NewRegisteredHybridTimer("miner/block/storage/commits", nil) + blockMiningTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/mining/time", nil) + blockMiningExecuteTxTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/execute/time", nil) + blockMiningCommitTxTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/commit/time", nil) + blockMiningFinalizeTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/finalize/time", nil) + + accountReadTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/reads", nil) + accountHashTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/hashes", nil) + accountUpdateTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/updates", nil) + accountCommitTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/commits", nil) + + storageReadTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/reads", nil) + storageHashTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/hashes", nil) + storageUpdateTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/updates", nil) + storageCommitTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/commits", nil) snapshotAccountReadTimer = metrics.NewRegisteredTimer("miner/snapshot/account/reads", nil) snapshotStorageReadTimer = metrics.NewRegisteredTimer("miner/snapshot/storage/reads", nil) From 028f042972dfd2c3fa8bae3355908cec0aec873e Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Fri, 10 May 2024 22:08:14 +0900 Subject: [PATCH 25/27] Lowercase package name --- datasync/downloader/metrics.go | 10 ++++----- datasync/downloader/queue.go | 4 ++-- datasync/fetcher/metrics.go | 6 ++--- metrics/prometheus/prometheusmetrics.go | 4 ++-- storage/database/dynamodb.go | 10 ++++----- storage/database/leveldb_database.go | 18 +++++++-------- storage/database/rocksdb_database.go | 14 ++++++------ work/worker.go | 30 ++++++++++++------------- 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/datasync/downloader/metrics.go b/datasync/downloader/metrics.go index eb489c88e6..5b054045ca 100644 --- a/datasync/downloader/metrics.go +++ b/datasync/downloader/metrics.go @@ -21,28 +21,28 @@ package downloader import ( - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/rcrowley/go-metrics" ) var ( headerInMeter = metrics.NewRegisteredMeter("klay/downloader/headers/in", nil) - headerReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/headers/req", nil) + headerReqTimer = kaiametrics.NewRegisteredHybridTimer("klay/downloader/headers/req", nil) headerDropMeter = metrics.NewRegisteredMeter("klay/downloader/headers/drop", nil) headerTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/headers/timeout", nil) bodyInMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/in", nil) - bodyReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/bodies/req", nil) + bodyReqTimer = kaiametrics.NewRegisteredHybridTimer("klay/downloader/bodies/req", nil) bodyDropMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/drop", nil) bodyTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/bodies/timeout", nil) receiptInMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/in", nil) - receiptReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/receipts/req", nil) + receiptReqTimer = kaiametrics.NewRegisteredHybridTimer("klay/downloader/receipts/req", nil) receiptDropMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/drop", nil) receiptTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/receipts/timeout", nil) stakingInfoInMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/in", nil) - stakingInfoReqTimer = kaiaMetrics.NewRegisteredHybridTimer("klay/downloader/stakinginfo/req", nil) + stakingInfoReqTimer = kaiametrics.NewRegisteredHybridTimer("klay/downloader/stakinginfo/req", nil) stakingInfoDropMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/drop", nil) stakingInfoTimeoutMeter = metrics.NewRegisteredMeter("klay/downloader/stakinginfo/timeout", nil) diff --git a/datasync/downloader/queue.go b/datasync/downloader/queue.go index 4c8b4e3540..1dd5822bea 100644 --- a/datasync/downloader/queue.go +++ b/datasync/downloader/queue.go @@ -31,7 +31,7 @@ import ( "github.com/klaytn/klaytn/common" "github.com/klaytn/klaytn/common/prque" "github.com/klaytn/klaytn/consensus/istanbul" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/params" "github.com/klaytn/klaytn/reward" "github.com/rcrowley/go-metrics" @@ -924,7 +924,7 @@ func (q *queue) DeliverStakingInfos(id string, stakingInfoList []*reward.Staking // reason this lock is not obtained in here is because the parameters already need // to access the queue, so they already need a lock anyway. func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header, taskQueue *prque.Prque, - pendPool map[string]*fetchRequest, reqTimer kaiaMetrics.HybridTimer, + pendPool map[string]*fetchRequest, reqTimer kaiametrics.HybridTimer, results int, validate func(index int, header *types.Header) error, reconstruct func(index int, result *fetchResult), ) (int, error) { diff --git a/datasync/fetcher/metrics.go b/datasync/fetcher/metrics.go index 0dd15dd444..4387bc7266 100644 --- a/datasync/fetcher/metrics.go +++ b/datasync/fetcher/metrics.go @@ -21,18 +21,18 @@ package fetcher import ( - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/rcrowley/go-metrics" ) var ( propAnnounceInMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/in", nil) - propAnnounceOutTimer = kaiaMetrics.NewRegisteredHybridTimer("cn/fetcher/prop/announces/out", nil) + propAnnounceOutTimer = kaiametrics.NewRegisteredHybridTimer("cn/fetcher/prop/announces/out", nil) propAnnounceDropMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/drop", nil) propAnnounceDOSMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/announces/dos", nil) propBroadcastInMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/in", nil) - propBroadcastOutTimer = kaiaMetrics.NewRegisteredHybridTimer("cn/fetcher/prop/broadcasts/out", nil) + propBroadcastOutTimer = kaiametrics.NewRegisteredHybridTimer("cn/fetcher/prop/broadcasts/out", nil) propBroadcastDropMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/drop", nil) propBroadcastDOSMeter = metrics.NewRegisteredMeter("cn/fetcher/prop/broadcasts/dos", nil) diff --git a/metrics/prometheus/prometheusmetrics.go b/metrics/prometheus/prometheusmetrics.go index 92544f801e..eb437bfd5c 100644 --- a/metrics/prometheus/prometheusmetrics.go +++ b/metrics/prometheus/prometheusmetrics.go @@ -10,7 +10,7 @@ import ( "strings" "time" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/prometheus/client_golang/prometheus" "github.com/rcrowley/go-metrics" @@ -70,7 +70,7 @@ func (c *PrometheusConfig) gaugeFromNameAndValue(name string, val float64) { func (c *PrometheusConfig) UpdatePrometheusMetrics() { for range time.Tick(c.FlushInterval) { c.UpdatePrometheusMetricsOnce() - kaiaMetrics.ResetMaxGauges() + kaiametrics.ResetMaxGauges() } } diff --git a/storage/database/dynamodb.go b/storage/database/dynamodb.go index ef9d3e9cfd..a82d2694e0 100644 --- a/storage/database/dynamodb.go +++ b/storage/database/dynamodb.go @@ -33,7 +33,7 @@ import ( "sync" "time" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/client" @@ -106,8 +106,8 @@ type dynamoDB struct { logger log.Logger // Contextual logger tracking the database path // metrics - getTimer kaiaMetrics.HybridTimer - putTimer kaiaMetrics.HybridTimer + getTimer kaiametrics.HybridTimer + putTimer kaiametrics.HybridTimer } type DynamoData struct { @@ -442,8 +442,8 @@ func (dynamo *dynamoDB) Close() { } func (dynamo *dynamoDB) Meter(prefix string) { - dynamo.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - dynamo.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + dynamo.getTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + dynamo.putTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"put/time", nil) dynamoBatchWriteTimeMeter = metrics.NewRegisteredMeter(prefix+"batchwrite/time", nil) } diff --git a/storage/database/leveldb_database.go b/storage/database/leveldb_database.go index ec9786880c..07bf8b9599 100644 --- a/storage/database/leveldb_database.go +++ b/storage/database/leveldb_database.go @@ -26,7 +26,7 @@ import ( "sync" "time" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/common/fdlimit" "github.com/klaytn/klaytn/log" @@ -103,7 +103,7 @@ type levelDB struct { aliveSnapshotsMeter metrics.Meter // Meter for measuring the number of alive snapshots aliveIteratorsMeter metrics.Meter // Meter for measuring the number of alive iterators - compTimer kaiaMetrics.HybridTimer // Meter for measuring the total time spent in database compaction + compTimer kaiametrics.HybridTimer // Meter for measuring the total time spent in database compaction compReadMeter metrics.Meter // Meter for measuring the data read during compaction compWriteMeter metrics.Meter // Meter for measuring the data written during compaction diskReadMeter metrics.Meter // Meter for measuring the effective amount of data read @@ -122,9 +122,9 @@ type levelDB struct { levelDurationsGauge []metrics.Gauge perfCheck bool - getTimer kaiaMetrics.HybridTimer - putTimer kaiaMetrics.HybridTimer - batchWriteTimer kaiaMetrics.HybridTimer + getTimer kaiametrics.HybridTimer + putTimer kaiametrics.HybridTimer + batchWriteTimer kaiametrics.HybridTimer quitLock sync.Mutex // Mutex protecting the quit channel access quitChan chan chan error // Quit channel to stop the metrics collection before closing the database @@ -363,7 +363,7 @@ func (db *levelDB) Meter(prefix string) { db.writeDelayDurationMeter = metrics.NewRegisteredMeter(prefix+"writedelay/duration", nil) db.aliveSnapshotsMeter = metrics.NewRegisteredMeter(prefix+"snapshots", nil) db.aliveIteratorsMeter = metrics.NewRegisteredMeter(prefix+"iterators", nil) - db.compTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"compaction/time", nil) + db.compTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"compaction/time", nil) db.compReadMeter = metrics.NewRegisteredMeter(prefix+"compaction/read", nil) db.compWriteMeter = metrics.NewRegisteredMeter(prefix+"compaction/write", nil) db.diskReadMeter = metrics.NewRegisteredMeter(prefix+"disk/read", nil) @@ -372,9 +372,9 @@ func (db *levelDB) Meter(prefix string) { db.openedTablesCountMeter = metrics.NewRegisteredMeter(prefix+"opendedtables", nil) - db.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - db.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) - db.batchWriteTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) + db.getTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + db.putTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + db.batchWriteTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) db.memCompGauge = metrics.NewRegisteredGauge(prefix+"compact/memory", nil) db.level0CompGauge = metrics.NewRegisteredGauge(prefix+"compact/level0", nil) diff --git a/storage/database/rocksdb_database.go b/storage/database/rocksdb_database.go index 1c2e80ce19..b4ba54b1c0 100644 --- a/storage/database/rocksdb_database.go +++ b/storage/database/rocksdb_database.go @@ -26,7 +26,7 @@ import ( "time" "github.com/klaytn/klaytn/log" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" metricutils "github.com/klaytn/klaytn/metrics/utils" "github.com/linxGnu/grocksdb" "github.com/rcrowley/go-metrics" @@ -73,9 +73,9 @@ type rocksDB struct { quitCh chan struct{} metrics []metrics.Meter - getTimer kaiaMetrics.HybridTimer - putTimer kaiaMetrics.HybridTimer - batchWriteTimer kaiaMetrics.HybridTimer + getTimer kaiametrics.HybridTimer + putTimer kaiametrics.HybridTimer + batchWriteTimer kaiametrics.HybridTimer prefix string logger log.Logger @@ -312,9 +312,9 @@ func (db *rocksDB) Meter(prefix string) { name := strings.ReplaceAll(splited[1], "-", "/") db.metrics = append(db.metrics, metrics.NewRegisteredMeter(prefix+name, nil)) } - db.getTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"get/time", nil) - db.putTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"put/time", nil) - db.batchWriteTimer = kaiaMetrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) + db.getTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"get/time", nil) + db.putTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"put/time", nil) + db.batchWriteTimer = kaiametrics.NewRegisteredHybridTimer(prefix+"batchwrite/time", nil) // Short circuit metering if the metrics system is disabled // Above meters are initialized by NilMeter if metricutils.Enabled == false diff --git a/work/worker.go b/work/worker.go index dbb709fd95..da62cfeabe 100644 --- a/work/worker.go +++ b/work/worker.go @@ -34,7 +34,7 @@ import ( "github.com/klaytn/klaytn/consensus" "github.com/klaytn/klaytn/consensus/misc" "github.com/klaytn/klaytn/event" - kaiaMetrics "github.com/klaytn/klaytn/metrics" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/klaytn/klaytn/params" "github.com/klaytn/klaytn/reward" "github.com/klaytn/klaytn/storage/database" @@ -71,20 +71,20 @@ var ( strangeErrorTxsCounter = metrics.NewRegisteredCounter("miner/strangeerror/txs", nil) blockBaseFee = metrics.NewRegisteredGauge("miner/block/mining/basefee", nil) - blockMiningTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/mining/time", nil) - blockMiningExecuteTxTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/execute/time", nil) - blockMiningCommitTxTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/commit/time", nil) - blockMiningFinalizeTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/finalize/time", nil) - - accountReadTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/reads", nil) - accountHashTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/hashes", nil) - accountUpdateTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/updates", nil) - accountCommitTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/account/commits", nil) - - storageReadTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/reads", nil) - storageHashTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/hashes", nil) - storageUpdateTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/updates", nil) - storageCommitTimer = kaiaMetrics.NewRegisteredHybridTimer("miner/block/storage/commits", nil) + blockMiningTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/mining/time", nil) + blockMiningExecuteTxTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/execute/time", nil) + blockMiningCommitTxTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/commit/time", nil) + blockMiningFinalizeTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/finalize/time", nil) + + accountReadTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/account/reads", nil) + accountHashTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/account/hashes", nil) + accountUpdateTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/account/updates", nil) + accountCommitTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/account/commits", nil) + + storageReadTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/storage/reads", nil) + storageHashTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/storage/hashes", nil) + storageUpdateTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/storage/updates", nil) + storageCommitTimer = kaiametrics.NewRegisteredHybridTimer("miner/block/storage/commits", nil) snapshotAccountReadTimer = metrics.NewRegisteredTimer("miner/snapshot/account/reads", nil) snapshotStorageReadTimer = metrics.NewRegisteredTimer("miner/snapshot/storage/reads", nil) From 98f95188e9293a1dfcbbaffcae2fd1019a3e4d77 Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Fri, 10 May 2024 22:14:17 +0900 Subject: [PATCH 26/27] Apply gci --- storage/database/dynamodb.go | 3 +-- storage/database/leveldb_database.go | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/storage/database/dynamodb.go b/storage/database/dynamodb.go index a82d2694e0..7c77c37b89 100644 --- a/storage/database/dynamodb.go +++ b/storage/database/dynamodb.go @@ -33,8 +33,6 @@ import ( "sync" "time" - kaiametrics "github.com/klaytn/klaytn/metrics" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/client" "github.com/aws/aws-sdk-go/aws/request" @@ -43,6 +41,7 @@ import ( "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/klaytn/klaytn/common/hexutil" "github.com/klaytn/klaytn/log" + kaiametrics "github.com/klaytn/klaytn/metrics" "github.com/pkg/errors" "github.com/rcrowley/go-metrics" ) diff --git a/storage/database/leveldb_database.go b/storage/database/leveldb_database.go index 07bf8b9599..ce5fa2482b 100644 --- a/storage/database/leveldb_database.go +++ b/storage/database/leveldb_database.go @@ -26,10 +26,9 @@ import ( "sync" "time" - kaiametrics "github.com/klaytn/klaytn/metrics" - "github.com/klaytn/klaytn/common/fdlimit" "github.com/klaytn/klaytn/log" + kaiametrics "github.com/klaytn/klaytn/metrics" metricutils "github.com/klaytn/klaytn/metrics/utils" "github.com/rcrowley/go-metrics" "github.com/syndtr/goleveldb/leveldb" From c1b7d8645a94b8e3c8b87328c78df7e9d02e61ff Mon Sep 17 00:00:00 2001 From: Chihyun Song Date: Fri, 10 May 2024 22:15:02 +0900 Subject: [PATCH 27/27] Use errors.New --- api/api_private_account.go | 8 ++++---- api/api_private_account_test.go | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/api_private_account.go b/api/api_private_account.go index 09d13686f2..c13dcd7fa4 100644 --- a/api/api_private_account.go +++ b/api/api_private_account.go @@ -149,7 +149,7 @@ func parseKaiaWalletKey(k string) (string, string, *common.Address, error) { walletKeyType := k[66:68] if walletKeyType != "00" { - return "", "", nil, fmt.Errorf("Kaia wallet key type must be 00.") + return "", "", nil, errors.New("Kaia wallet key type must be 00.") } a := common.HexToAddress(k[70:110]) @@ -347,7 +347,7 @@ func (s *PrivateAccountAPI) SendValueTransfer(ctx context.Context, args ValueTra func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs, passwd string) (*SignTransactionResult, error) { if args.TypeInt != nil && args.TypeInt.IsEthTypedTransaction() { if args.Price == nil && (args.MaxPriorityFeePerGas == nil || args.MaxFeePerGas == nil) { - return nil, fmt.Errorf("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") + return nil, errors.New("missing gasPrice or maxFeePerGas/maxPriorityFeePerGas") } } @@ -487,10 +487,10 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover func (s *PrivateAccountAPI) EcRecover(ctx context.Context, data, sig hexutil.Bytes) (common.Address, error) { if len(sig) != crypto.SignatureLength { - return common.Address{}, fmt.Errorf("signature must be 65 bytes long") + return common.Address{}, errors.New("signature must be 65 bytes long") } if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 { - return common.Address{}, fmt.Errorf("invalid Klaytn signature (V is not 27 or 28)") + return common.Address{}, errors.New("invalid Klaytn signature (V is not 27 or 28)") } // Transform yellow paper V from 27/28 to 0/1 diff --git a/api/api_private_account_test.go b/api/api_private_account_test.go index 75818b6ac7..27adfe73b6 100644 --- a/api/api_private_account_test.go +++ b/api/api_private_account_test.go @@ -17,7 +17,7 @@ package api import ( - "fmt" + "errors" "os" "testing" @@ -60,7 +60,7 @@ func TestPrivateAccountAPI_ImportRawKey(t *testing.T) { // 2. Import Kaia Wallet Key. Since the same address is already registered, it should fail. { _, err := api.ImportRawKey("f8cc7c3813ad23817466b1802ee805ee417001fcce9376ab8728c92dd8ea0a6b0x000x819104a190255e0cedbdd9d5f59a557633d79db1", "1234") - require.Equal(t, fmt.Errorf("account already exists"), err) + require.Equal(t, errors.New("account already exists"), err) } // 3. Replace Kaia Wallet key. It should work. @@ -74,19 +74,19 @@ func TestPrivateAccountAPI_ImportRawKey(t *testing.T) { // 4. Allowable Wallet key type is 0x00 only. { _, err := api.ImportRawKey("f8cc7c3813ad23817466b1802ee805ee417001fcce9376ab8728c92dd8ea0a6b0x010x819104a190255e0cedbdd9d5f59a557633d79db1", "1234") - require.Equal(t, fmt.Errorf("Kaia wallet key type must be 00."), err) + require.Equal(t, errors.New("Kaia wallet key type must be 00."), err) } // 5. Should return an error if wrong length. { _, err := api.ImportRawKey("1ea7b7bc7f525cc936ec65e0e93f146bd6fad4b3158067ad64560defd9bba0b0x010x3b3d49ebac925797b2471c7b01108ba16bb36950", "1234") - require.Equal(t, fmt.Errorf("invalid hex string"), err) + require.Equal(t, errors.New("invalid hex string"), err) } // 6. Should return an error if wrong length. { _, err := api.ImportRawKey("1ea7b7bc7f525cc936ec65e0e93f146bd6fad4b3158067ad64560defd9bba0b", "1234") - require.Equal(t, fmt.Errorf("invalid hex string"), err) + require.Equal(t, errors.New("invalid hex string"), err) } // 7. Import Kaia Wallet Key.