Skip to content

Commit

Permalink
Rename testnet to Kairos
Browse files Browse the repository at this point in the history
  • Loading branch information
ian0371 committed Jul 3, 2024
1 parent 99be85e commit a772752
Show file tree
Hide file tree
Showing 57 changed files with 253 additions and 253 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ for the details of CC bootstrapping process.

## Running an Endpoint Node

Endpoint Node (EN) is an entry point from the outside of the network in order to interact with the Kaia network. Currently, two official networks are available: Testnet and Mainnet (legacy names: Baobab and Cypress). Please visit the official
Endpoint Node (EN) is an entry point from the outside of the network in order to interact with the Kaia network. Currently, two official networks are available: Kairos and Mainnet (legacy names: Baobab and Cypress). Please visit the official
[EN Operation Guide](https://docs.kaia.io/docs/nodes/endpoint-node/).

## Running a Service Chain Node
Expand Down
28 changes: 14 additions & 14 deletions blockchain/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func findBlockWithState(db database.DBManager) *types.Block {
//
// genesis == nil genesis != nil
// +-------------------------------------------------------------------
// db has no genesis | Mainnet default, Testnet if specified | genesis
// db has no genesis | Mainnet default, Kairos if specified | genesis
// db has genesis | from DB | genesis (if compatible)
//
// The stored chain configuration will be updated if it is compatible (i.e. does not
Expand All @@ -193,9 +193,9 @@ func SetupGenesisBlock(db database.DBManager, genesis *Genesis, networkId uint64
case isPrivate:
logger.Error("No genesis is provided. --networkid should be omitted if you want to use preconfigured network")
return params.AllGxhashProtocolChanges, common.Hash{}, errNoGenesis
case networkId == params.TestnetNetworkId:
logger.Info("Writing default Testnet genesis block")
genesis = DefaultTestnetGenesisBlock()
case networkId == params.KairosNetworkId:
logger.Info("Writing default Kairos genesis block")
genesis = DefaultKairosGenesisBlock()
case networkId == params.MainnetNetworkId:
fallthrough
default:
Expand Down Expand Up @@ -268,7 +268,7 @@ func SetupGenesisBlock(db database.DBManager, genesis *Genesis, networkId uint64
// Special case: don't change the existing config of a non-mainnet chain if no new
// config is supplied. These chains would get AllProtocolChanges (and a compat error)
// if we just continued here.
if genesis == nil && params.MainnetGenesisHash != stored && params.TestnetGenesisHash != stored {
if genesis == nil && params.MainnetGenesisHash != stored && params.KairosGenesisHash != stored {
return storedcfg, stored, nil
}

Expand All @@ -292,8 +292,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return g.Config
case ghash == params.MainnetGenesisHash:
return params.MainnetChainConfig
case ghash == params.TestnetGenesisHash:
return params.TestnetChainConfig
case ghash == params.KairosGenesisHash:
return params.KairosChainConfig
default:
return params.AllGxhashProtocolChanges
}
Expand Down Expand Up @@ -415,14 +415,14 @@ func DefaultGenesisBlock() *Genesis {
return ret
}

// DefaultTestnetGenesisBlock returns the Testnet genesis block.
func DefaultTestnetGenesisBlock() *Genesis {
// DefaultKairosGenesisBlock returns the Kairos genesis block.
func DefaultKairosGenesisBlock() *Genesis {
ret := &Genesis{}
if err := json.Unmarshal(testnetGenesisJson, &ret); err != nil {
logger.Error("Error in Unmarshalling Testnet Genesis Json", "err", err)
if err := json.Unmarshal(kairosGenesisJson, &ret); err != nil {
logger.Error("Error in Unmarshalling Kairos Genesis Json", "err", err)
return nil
}
ret.Config = params.TestnetChainConfig
ret.Config = params.KairosChainConfig
return ret
}

Expand All @@ -441,8 +441,8 @@ func decodePrealloc(data string) GenesisAlloc {
func commitGenesisState(genesis *Genesis, db database.DBManager, networkId uint64) {
if genesis == nil {
switch {
case networkId == params.TestnetNetworkId:
genesis = DefaultTestnetGenesisBlock()
case networkId == params.KairosNetworkId:
genesis = DefaultKairosGenesisBlock()
case networkId == params.MainnetNetworkId:
fallthrough
default:
Expand Down
4 changes: 2 additions & 2 deletions blockchain/genesis_alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ package blockchain
// nolint: misspell
const mainnetAllocData = "\xda\u0654\x19t\x18\x1a?\x1bE+\x00\xec\u06ab\x19\xa2j\xf3\x8f\xcb\xff\x1e\x83\x98\x96\x80"

const testnetAllocData = "\xda\u0654\x19t\x18\x1a?\x1bE+\x00\xec\u06ab\x19\xa2j\xf3\x8f\xcb\xff\x1e\x83\x98\x96\x80"
const kairosAllocData = "\xda\u0654\x19t\x18\x1a?\x1bE+\x00\xec\u06ab\x19\xa2j\xf3\x8f\xcb\xff\x1e\x83\x98\x96\x80"

var (
testnetGenesisJson = []byte(`{
kairosGenesisJson = []byte(`{
"config": {
"chainId": 1001,
"deriveShaImpl": 2,
Expand Down
90 changes: 45 additions & 45 deletions blockchain/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ import (
"github.com/stretchr/testify/assert"
)

// TestDefaultGenesisBlock tests the genesis block generation functions: DefaultGenesisBlock, DefaultTestnetGenesisBlock
// TestDefaultGenesisBlock tests the genesis block generation functions: DefaultGenesisBlock, DefaultKairosGenesisBlock
func TestDefaultGenesisBlock(t *testing.T) {
block := genMainnetGenesisBlock().ToBlock(common.Hash{}, nil)
if block.Hash() != params.MainnetGenesisHash {
t.Errorf("wrong Mainnet genesis hash, got %v, want %v", block.Hash(), params.MainnetGenesisHash)
}
block = genTestnetGenesisBlock().ToBlock(common.Hash{}, nil)
if block.Hash() != params.TestnetGenesisHash {
t.Errorf("wrong Testnet genesis hash, got %v, want %v", block.Hash(), params.TestnetGenesisHash)
block = genKairosGenesisBlock().ToBlock(common.Hash{}, nil)
if block.Hash() != params.KairosGenesisHash {
t.Errorf("wrong Kairos genesis hash, got %v, want %v", block.Hash(), params.KairosGenesisHash)
}
}

// TestHardCodedChainConfigUpdate tests the public network's chainConfig update.
func TestHardCodedChainConfigUpdate(t *testing.T) {
mainnetGenesisBlock, testnetGenesisBlock := genMainnetGenesisBlock(), genTestnetGenesisBlock()
mainnetGenesisBlock, kairosGenesisBlock := genMainnetGenesisBlock(), genKairosGenesisBlock()
tests := []struct {
name string
newHFBlock *big.Int
Expand All @@ -79,28 +79,28 @@ func TestHardCodedChainConfigUpdate(t *testing.T) {
// TODO-Kaia: add more Mainnet test cases after Mainnet hard fork block numbers are added
{
// Because of the fork-ordering check logic, the istanbulCompatibleBlock should be less than the londonCompatibleBlock
name: "Testnet chainConfig update - correct hard-fork block number order",
name: "Kairos chainConfig update - correct hard-fork block number order",
newHFBlock: big.NewInt(79999999),
fn: func(db database.DBManager, newHFBlock *big.Int) (*params.ChainConfig, common.Hash, error) {
testnetGenesisBlock.MustCommit(db)
testnetGenesisBlock.Config.IstanbulCompatibleBlock = newHFBlock
return SetupGenesisBlock(db, testnetGenesisBlock, params.TestnetNetworkId, false, false)
kairosGenesisBlock.MustCommit(db)
kairosGenesisBlock.Config.IstanbulCompatibleBlock = newHFBlock
return SetupGenesisBlock(db, kairosGenesisBlock, params.KairosNetworkId, false, false)
},
wantHash: params.TestnetGenesisHash,
wantConfig: testnetGenesisBlock.Config,
wantStoredConfig: testnetGenesisBlock.Config,
wantHash: params.KairosGenesisHash,
wantConfig: kairosGenesisBlock.Config,
wantStoredConfig: kairosGenesisBlock.Config,
},
{
// This test fails because the new istanbulCompatibleBlock(90909999) is larger than londonCompatibleBlock(80295291)
name: "Testnet chainConfig update - wrong hard-fork block number order",
name: "Kairos chainConfig update - wrong hard-fork block number order",
newHFBlock: big.NewInt(90909999),
fn: func(db database.DBManager, newHFBlock *big.Int) (*params.ChainConfig, common.Hash, error) {
testnetGenesisBlock.MustCommit(db)
testnetGenesisBlock.Config.IstanbulCompatibleBlock = newHFBlock
return SetupGenesisBlock(db, testnetGenesisBlock, params.TestnetNetworkId, false, false)
kairosGenesisBlock.MustCommit(db)
kairosGenesisBlock.Config.IstanbulCompatibleBlock = newHFBlock
return SetupGenesisBlock(db, kairosGenesisBlock, params.KairosNetworkId, false, false)
},
wantHash: common.Hash{},
wantConfig: testnetGenesisBlock.Config,
wantConfig: kairosGenesisBlock.Config,
wantStoredConfig: nil,
wantErr: fmt.Errorf("unsupported fork ordering: %v enabled at %v, but %v enabled at %v",
"istanbulBlock", big.NewInt(90909999), "londonBlock", big.NewInt(80295291)),
Expand Down Expand Up @@ -187,12 +187,12 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: params.MainnetChainConfig,
},
{
name: "no block in DB, genesis == nil, Testnet networkId",
name: "no block in DB, genesis == nil, Kairos networkId",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
return SetupGenesisBlock(db, nil, params.TestnetNetworkId, false, false)
return SetupGenesisBlock(db, nil, params.KairosNetworkId, false, false)
},
wantHash: params.TestnetGenesisHash,
wantConfig: params.TestnetChainConfig,
wantHash: params.KairosGenesisHash,
wantConfig: params.KairosChainConfig,
},
{
name: "no block in DB, genesis == customGenesis, private network",
Expand All @@ -212,13 +212,13 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: params.MainnetChainConfig,
},
{
name: "Testnet block in DB, genesis == nil, Testnet networkId",
name: "Kairos block in DB, genesis == nil, Kairos networkId",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
genTestnetGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, nil, params.TestnetNetworkId, false, false)
genKairosGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, nil, params.KairosNetworkId, false, false)
},
wantHash: params.TestnetGenesisHash,
wantConfig: params.TestnetChainConfig,
wantHash: params.KairosGenesisHash,
wantConfig: params.KairosChainConfig,
},
{
name: "custom block in DB, genesis == nil, custom networkId",
Expand All @@ -230,22 +230,22 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: customGenesis.Config,
},
{
name: "Mainnet block in DB, genesis == Testnet",
name: "Mainnet block in DB, genesis == Kairos",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
genMainnetGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, genTestnetGenesisBlock(), params.TestnetNetworkId, false, false)
return SetupGenesisBlock(db, genKairosGenesisBlock(), params.KairosNetworkId, false, false)
},
wantErr: &GenesisMismatchError{Stored: params.MainnetGenesisHash, New: params.TestnetGenesisHash},
wantHash: params.TestnetGenesisHash,
wantConfig: params.TestnetChainConfig,
wantErr: &GenesisMismatchError{Stored: params.MainnetGenesisHash, New: params.KairosGenesisHash},
wantHash: params.KairosGenesisHash,
wantConfig: params.KairosChainConfig,
},
{
name: "Testnet block in DB, genesis == Mainnet",
name: "Kairos block in DB, genesis == Mainnet",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
genTestnetGenesisBlock().MustCommit(db)
genKairosGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, genMainnetGenesisBlock(), params.MainnetNetworkId, false, false)
},
wantErr: &GenesisMismatchError{Stored: params.TestnetGenesisHash, New: params.MainnetGenesisHash},
wantErr: &GenesisMismatchError{Stored: params.KairosGenesisHash, New: params.MainnetGenesisHash},
wantHash: params.MainnetGenesisHash,
wantConfig: params.MainnetChainConfig,
},
Expand All @@ -260,12 +260,12 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: customGenesis.Config,
},
{
name: "Testnet block in DB, genesis == custom",
name: "Kairos block in DB, genesis == custom",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
genTestnetGenesisBlock().MustCommit(db)
genKairosGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, customGenesis, customChainId, true, false)
},
wantErr: &GenesisMismatchError{Stored: params.TestnetGenesisHash, New: customGenesisHash},
wantErr: &GenesisMismatchError{Stored: params.KairosGenesisHash, New: customGenesisHash},
wantHash: customGenesisHash,
wantConfig: customGenesis.Config,
},
Expand All @@ -280,14 +280,14 @@ func TestSetupGenesis(t *testing.T) {
wantConfig: params.MainnetChainConfig,
},
{
name: "custom block in DB, genesis == Testnet",
name: "custom block in DB, genesis == Kairos",
fn: func(db database.DBManager) (*params.ChainConfig, common.Hash, error) {
customGenesis.MustCommit(db)
return SetupGenesisBlock(db, genTestnetGenesisBlock(), params.TestnetNetworkId, false, false)
return SetupGenesisBlock(db, genKairosGenesisBlock(), params.KairosNetworkId, false, false)
},
wantErr: &GenesisMismatchError{Stored: customGenesisHash, New: params.TestnetGenesisHash},
wantHash: params.TestnetGenesisHash,
wantConfig: params.TestnetChainConfig,
wantErr: &GenesisMismatchError{Stored: customGenesisHash, New: params.KairosGenesisHash},
wantHash: params.KairosGenesisHash,
wantConfig: params.KairosChainConfig,
},
{
name: "compatible config in DB",
Expand Down Expand Up @@ -379,9 +379,9 @@ func genMainnetGenesisBlock() *Genesis {
return genesis
}

func genTestnetGenesisBlock() *Genesis {
genesis := DefaultTestnetGenesisBlock()
genesis.Config = params.TestnetChainConfig.Copy()
func genKairosGenesisBlock() *Genesis {
genesis := DefaultKairosGenesisBlock()
genesis.Config = params.KairosChainConfig.Copy()
genesis.Governance = SetGenesisGovernance(genesis)
InitDeriveSha(genesis.Config)
return genesis
Expand Down
Loading

0 comments on commit a772752

Please sign in to comment.