Skip to content

Commit

Permalink
fix ut (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
siovanus authored Oct 13, 2023
1 parent 5fbe3fd commit f60cd05
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cmd/geth/dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var daoProForkGenesis = `{
}
}`

var daoGenesisHash = common.HexToHash("0x6d8fc923564013394cab956685849483496544fdc301fd2b00aa7aca9193d374")
var daoGenesisHash = common.HexToHash("0xe97094ce20626acf7f8d84c16a7160a18855b1a1f42e223cc12a5731acaf923a")
var daoGenesisForkBlock = big.NewInt(314)

// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
Expand Down
2 changes: 1 addition & 1 deletion contracts/native/governance/node_manager/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
GenesisMaxCommissionChange, _ = new(big.Int).SetString("500", 10) // 5%
GenesisMinInitialStake = new(big.Int).Mul(big.NewInt(100000), params.ZNT1)
GenesisMinProposalStake = new(big.Int).Mul(big.NewInt(1000), params.ZNT1)
GenesisBlockPerEpoch = new(big.Int).SetUint64(40)
GenesisBlockPerEpoch = new(big.Int).SetUint64(200000)
GenesisConsensusValidatorNum uint64 = 4
GenesisVoterValidatorNum uint64 = 4

Expand Down
41 changes: 22 additions & 19 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {

// checkExtra validators should be sorted and do not allow dump validators.
func (g *Genesis) checkExtra() {
if g.Config == nil || g.Config.HotStuff == nil { return }
if g.Config == nil || g.Config.HotStuff == nil {
return
}
extra, err := types.ExtractHotstuffExtraPayload(g.ExtraData)
if err != nil {
panic(err)
Expand Down Expand Up @@ -388,6 +390,7 @@ func (g *Genesis) createNativeContract(db *state.StateDB, addr common.Address) {
}

var CheckAllocWithTotalSupply bool = true

func (g *Genesis) mintNativeToken(statedb *state.StateDB) {
// check total balance
total := new(big.Int)
Expand Down Expand Up @@ -464,12 +467,12 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big
// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis {
return &Genesis{
Config: params.MainnetChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
GasLimit: 5000,
Difficulty: big.NewInt(17179869184),
Alloc: decodePrealloc(mainnetAllocData),
Config: params.MainnetChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
GasLimit: 5000,
Difficulty: big.NewInt(17179869184),
Alloc: decodePrealloc(mainnetAllocData),
CommunityRate: big.NewInt(2000),
CommunityAddress: common.HexToAddress("0x79ad3ca3faa0F30f4A0A2839D2DaEb4Eb6B6820D"),
}
Expand All @@ -491,12 +494,12 @@ func TestGenesisBlock() *Genesis {
// DefaultRopstenGenesisBlock returns the Ropsten network genesis block.
func DefaultRopstenGenesisBlock() *Genesis {
return &Genesis{
Config: params.RopstenChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
GasLimit: 16777216,
Difficulty: big.NewInt(1048576),
Alloc: decodePrealloc(ropstenAllocData),
Config: params.RopstenChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"),
GasLimit: 16777216,
Difficulty: big.NewInt(1048576),
Alloc: decodePrealloc(ropstenAllocData),
CommunityRate: big.NewInt(10),
}
}
Expand Down Expand Up @@ -545,12 +548,12 @@ func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {

// Assemble and return the genesis with the precompiles and faucet pre-funded
return &Genesis{
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 11500000,
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(1),
CommunityRate: big.NewInt(20),
Config: &config,
ExtraData: append(append(make([]byte, 32), faucet[:]...), make([]byte, crypto.SignatureLength)...),
GasLimit: 11500000,
BaseFee: big.NewInt(params.InitialBaseFee),
Difficulty: big.NewInt(1),
CommunityRate: big.NewInt(20),
CommunityAddress: common.BytesToAddress([]byte{1}),
Alloc: map[common.Address]GenesisAccount{
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // Recover
Expand Down

0 comments on commit f60cd05

Please sign in to comment.