Skip to content

Commit

Permalink
Merge pull request BuildOnViction#449 from tungng98/refactor/optimize…
Browse files Browse the repository at this point in the history
…-network-profile

Correct mainnet and testnet profile
  • Loading branch information
tungng98 authored Jul 7, 2024
2 parents 217d352 + e26eebd commit f01fa41
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 90 deletions.
4 changes: 2 additions & 2 deletions cmd/puppeth/wizard_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (w *wizard) makeGenesis() {

fmt.Println()
fmt.Println("What is foundation wallet address? (default = 0x0000000000000000000000000000000000000068)")
genesis.Config.Posv.FoudationWalletAddr = w.readDefaultAddress(common.HexToAddress(common.FoudationAddr))
genesis.Config.Posv.FoudationWalletAddr = w.readDefaultAddress(common.HexToAddress(common.FoundationAddr))

// Validator Smart Contract Code
pKey, _ := crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down Expand Up @@ -244,7 +244,7 @@ func (w *wizard) makeGenesis() {
fBalance := big.NewInt(0) // 16m
fBalance.Add(fBalance, big.NewInt(16*1000*1000))
fBalance.Mul(fBalance, big.NewInt(1000000000000000000))
genesis.Alloc[common.HexToAddress(common.FoudationAddr)] = core.GenesisAccount{
genesis.Alloc[common.HexToAddress(common.FoundationAddr)] = core.GenesisAccount{
Balance: fBalance,
Code: code,
Storage: storage,
Expand Down
76 changes: 41 additions & 35 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,60 @@ const (
EpocBlockRandomize = 900
MaxMasternodes = 150
LimitPenaltyEpoch = 4
BlocksPerYear = uint64(15768000)
LimitThresholdNonceInQueue = 10
DefaultMinGasPrice = 250000000
MergeSignRange = 15
RangeReturnSigner = 150
MinimunMinerBlockPerEpoch = 1
IgnoreSignerCheckBlock = uint64(14458500)
OneYear = uint64(365 * 86400)
LiquidateLendingTradeBlock = uint64(100)
OneYear = uint64(31536000)
BlocksPerYear = uint64(15768000)
EpochsPerYear = uint64(17520)
)

var Rewound = uint64(0)

// hardforks
var TIP2019Block = big.NewInt(1050000)
var TIPSigningBlock = big.NewInt(3000000)
var TIPRandomizeBlock = big.NewInt(3464000)
var BlackListHFNumberBlock = uint64(9349100)
var TIPTRC21FeeBlock = big.NewInt(13523400)
var TIPTomoXBlock = big.NewInt(20581700)
var TIPTomoXLendingBlock = big.NewInt(21430200)
var TIPTomoXCancellationFeeBlock = big.NewInt(30915660)
var IsTestnet bool = false
var StoreRewardFolder string
var RollbackHash Hash
var BasePrice = big.NewInt(1000000000000000000) // 1
var RelayerLockedFund = big.NewInt(20000) // 20000 TOMO
var RelayerFee = big.NewInt(1000000000000000) // 0.001
var TomoXBaseFee = big.NewInt(10000) // 1 / TomoXBaseFee
var RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
var TomoXBaseCancelFee = new(big.Int).Mul(TomoXBaseFee, big.NewInt(10)) // 1/ (TomoXBaseFee *10)
var RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
var RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
var BaseLendingInterest = big.NewInt(100000000) // 1e8
var (
TIP2019Block = big.NewInt(1050000)
TIPSigningBlock = big.NewInt(3000000)
TIPRandomizeBlock = big.NewInt(3464000)
BlackListHFNumberBlock = uint64(9349100)
TIPTRC21FeeBlock = big.NewInt(13523400)
TIPTomoXBlock = big.NewInt(20581700)
TIPTomoXLendingBlock = big.NewInt(21430200)
TIPTomoXCancellationFeeBlock = big.NewInt(30915660)
IsTestnet bool = false
StoreRewardFolder string
RollbackHash Hash
BasePrice = big.NewInt(1000000000000000000) // 1
RelayerLockedFund = big.NewInt(20000) // 20000 TOMO
RelayerFee = big.NewInt(1000000000000000) // 0.001
TomoXBaseFee = big.NewInt(10000) // 1 / TomoXBaseFee
RelayerCancelFee = big.NewInt(100000000000000) // 0.0001
TomoXBaseCancelFee = new(big.Int).Mul(TomoXBaseFee, big.NewInt(10)) // 1/ (TomoXBaseFee *10)
RelayerLendingFee = big.NewInt(10000000000000000) // 0.01
RelayerLendingCancelFee = big.NewInt(1000000000000000) // 0.001
BaseLendingInterest = big.NewInt(100000000) // 1e8
)

var (
MinGasPrice = big.NewInt(DefaultMinGasPrice)
RelayerRegistrationSMC = "0x16c63b79f9C8784168103C0b74E6A59EC2de4a02"
RelayerRegistrationSMCTestnet = "0xA1996F69f47ba14Cb7f661010A7C31974277958c"
LendingRegistrationSMC = "0x7d761afd7ff65a79e4173897594a194e3c506e57"
LendingRegistrationSMCTestnet = "0x28d7fC2Cf5c18203aaCD7459EFC6Af0643C97bE8"
TRC21IssuerSMC = HexToAddress("0x8c0faeb5C6bEd2129b8674F262Fd45c4e9468bee")
TomoXListingSMC = HexToAddress("0xDE34dD0f536170993E8CFF639DdFfCF1A85D3E53")
TomoXListingSMCTestNet = HexToAddress("0x14B2Bf043b9c31827A472CE4F94294fE9a6277e0")
TRC21GasPriceBefore = big.NewInt(2500)
TRC21GasPrice = big.NewInt(250000000)
RateTopUp = big.NewInt(90) // 90%
BaseTopUp = big.NewInt(100)
BaseRecall = big.NewInt(100)
)

var MinGasPrice = big.NewInt(DefaultMinGasPrice)
var RelayerRegistrationSMC = "0x16c63b79f9C8784168103C0b74E6A59EC2de4a02"
var RelayerRegistrationSMCTestnet = "0xA1996F69f47ba14Cb7f661010A7C31974277958c"
var LendingRegistrationSMC = "0x7d761afd7ff65a79e4173897594a194e3c506e57"
var LendingRegistrationSMCTestnet = "0x28d7fC2Cf5c18203aaCD7459EFC6Af0643C97bE8"
var TRC21IssuerSMC = HexToAddress("0x8c0faeb5C6bEd2129b8674F262Fd45c4e9468bee")
var TomoXListingSMC = HexToAddress("0xDE34dD0f536170993E8CFF639DdFfCF1A85D3E53")
var TomoXListingSMCTestNet = HexToAddress("0x14B2Bf043b9c31827A472CE4F94294fE9a6277e0")
var TRC21GasPriceBefore = big.NewInt(2500)
var TRC21GasPrice = big.NewInt(250000000)
var RateTopUp = big.NewInt(90) // 90%
var BaseTopUp = big.NewInt(100)
var BaseRecall = big.NewInt(100)
var Blacklist = map[Address]bool{
HexToAddress("0x5248bfb72fd4f234e062d3e9bb76f08643004fcd"): true,
HexToAddress("0x5ac26105b35ea8935be382863a70281ec7a985e9"): true,
Expand Down
2 changes: 1 addition & 1 deletion common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
BlockSigners = "0x0000000000000000000000000000000000000089"
MasternodeVotingSMC = "0x0000000000000000000000000000000000000088"
RandomizeSMC = "0x0000000000000000000000000000000000000090"
FoudationAddr = "0x0000000000000000000000000000000000000068"
FoundationAddr = "0x0000000000000000000000000000000000000068"
TeamAddr = "0x0000000000000000000000000000000000000099"
TomoXAddr = "0x0000000000000000000000000000000000000091"
TradingStateAddr = "0x0000000000000000000000000000000000000092"
Expand Down
2 changes: 1 addition & 1 deletion contracts/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestRewardBalance(t *testing.T) {
logCaps[i] = &logCap{accounts[randIndex].From.String(), randCap}
}

foundationAddr := common.HexToAddress(common.FoudationAddr)
foundationAddr := common.HexToAddress(common.FoundationAddr)
totalReward := new(big.Int).SetInt64(15 * 1000)
rewards, err := GetRewardBalancesRate(foundationAddr, acc3Addr, totalReward, baseValidator)
if err != nil {
Expand Down
36 changes: 26 additions & 10 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
if (stored == common.Hash{}) {
if genesis == nil {
log.Info("Writing default main-net genesis block")
genesis = DefaultGenesisBlock()
genesis = DefaultVicMainnetGenesisBlock()
} else {
log.Info("Writing custom genesis block")
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func SetupGenesisBlock(db ethdb.Database, genesis *Genesis) (*params.ChainConfig
// 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 && stored != params.MainnetGenesisHash {
if genesis == nil && stored != params.VicMainnetGenesisHash {
return storedcfg, stored, nil
}

Expand All @@ -211,8 +211,12 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
switch {
case g != nil:
return g.Config
case ghash == params.MainnetGenesisHash:
case ghash == params.VicMainnetGenesisHash:
return params.VicMainnetChainConfig
case ghash == params.VicTestnetGenesisHash:
return params.VicTestnetChainConfig
case ghash == params.MainnetGenesisHash:
return params.MainnetChainConfig
case ghash == params.TestnetGenesisHash:
return params.TestnetChainConfig
default:
Expand Down Expand Up @@ -309,19 +313,31 @@ func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big
return g.MustCommit(db)
}

// DefaultGenesisBlock returns the Ethereum main net genesis block.
func DefaultGenesisBlock() *Genesis {
// DefaultVicMainnetGenesisBlock returns the Viction main net genesis block.
func DefaultVicMainnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.VicMainnetChainConfig,
Nonce: 0,
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001b82c4bf317fcafe3d77e8b444c82715d216afe845b7bd987fa22c9bac89b71f0ded03f6e150ba31ad670b2b166684657ffff95f4810380ae7381e9bce41231d5dd8cdd7499e418b648c00af75d184a2f9aba09a6fa4a46fb1a6a3919b027d9cac5aa6890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 4700000,
Difficulty: big.NewInt(1),
Alloc: DecodeMainnet(),
Alloc: decodeJsonAlloc(vicMainnetAllocData),
Timestamp: 1544771829,
}
}

func DefaultVicTestnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.VicTestnetChainConfig,
Nonce: 0,
ExtraData: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000001acc82e4cafc08af311852da4722fb34529322c91e7c9fae96ec2efb129b69ff5e0e8a8b8acb6add4f4b5983cdf8f674fa63de933713f245502f97676fdef2bd0d35de1c72016cfbbf2a6f2c59b8c2977e40b530a68d1dd71b7941cfb53534c3806aa5180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 4700000,
Difficulty: big.NewInt(1),
Alloc: decodeJsonAlloc(vicTestnetAllocData),
Timestamp: 1697684999,
}
}

// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
func DefaultTestnetGenesisBlock() *Genesis {
return &Genesis{
Expand Down Expand Up @@ -385,8 +401,8 @@ func decodePrealloc(data string) GenesisAlloc {
return ga
}

func DecodeMainnet() GenesisAlloc {
mainnetAlloc := GenesisAlloc{}
json.Unmarshal([]byte(tomoAllocData), &mainnetAlloc)
return mainnetAlloc
func decodeJsonAlloc(data string) GenesisAlloc {
alloc := GenesisAlloc{}
json.Unmarshal([]byte(data), &alloc)
return alloc
}
3 changes: 2 additions & 1 deletion core/genesis_alloc.go

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions core/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import (
)

func TestDefaultGenesisBlock(t *testing.T) {
block := DefaultGenesisBlock().ToBlock(nil)
if block.Hash() != params.TomoMainnetGenesisHash {
t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash().String(), params.TomoMainnetGenesisHash.String())
block := DefaultVicMainnetGenesisBlock().ToBlock(nil)
if block.Hash() != params.VicMainnetGenesisHash {
t.Errorf("wrong mainnet genesis hash, got %v, want %v", block.Hash().String(), params.VicMainnetGenesisHash.String())
}
block = DefaultTestnetGenesisBlock().ToBlock(nil)
if block.Hash() != params.TestnetGenesisHash {
t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash().String(), params.TestnetGenesisHash.String())
block = DefaultVicTestnetGenesisBlock().ToBlock(nil)
if block.Hash() != params.VicTestnetGenesisHash {
t.Errorf("wrong testnet genesis hash, got %v, want %v", block.Hash().String(), params.VicTestnetGenesisHash.String())
}
}

Expand Down Expand Up @@ -73,16 +73,16 @@ func TestSetupGenesis(t *testing.T) {
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
return SetupGenesisBlock(db, nil)
},
wantHash: params.TomoMainnetGenesisHash,
wantHash: params.VicMainnetGenesisHash,
wantConfig: params.VicMainnetChainConfig,
},
{
name: "mainnet block in DB, genesis == nil",
fn: func(db ethdb.Database) (*params.ChainConfig, common.Hash, error) {
DefaultGenesisBlock().MustCommit(db)
DefaultVicMainnetGenesisBlock().MustCommit(db)
return SetupGenesisBlock(db, nil)
},
wantHash: params.TomoMainnetGenesisHash,
wantHash: params.VicMainnetGenesisHash,
wantConfig: params.VicMainnetChainConfig,
},
{
Expand Down
8 changes: 3 additions & 5 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package params
// MainnetBootnodes are the enode URLs of the P2P bootstrap nodes running on
// the main Ethereum network.
var MainnetBootnodes = []string{
// TomoChain Bootnodes Mainnet
// Viction Bootnodes Mainnet
"enode://fd3da177f9492a39d1e7ce036b05745512894df251399cb3ec565081cb8c6dfa1092af8fac27991e66b6af47e9cb42e02420cc89f8549de0ce513ee25ebffc3a@3.212.20.0:30303",
"enode://97f0ca95a653e3c44d5df2674e19e9324ea4bf4d47a46b1d8560f3ed4ea328f725acec3fcfcb37eb11706cf07da669e9688b091f1543f89b2425700a68bc8876@104.248.98.78:30301",
"enode://b72927f349f3a27b789d0ca615ffe3526f361665b496c80e7cc19dace78bd94785fdadc270054ab727dbb172d9e3113694600dd31b2558dd77ad85a869032dea@188.166.207.189:30301",
Expand All @@ -39,10 +39,8 @@ var MainnetBootnodes = []string{
// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Ropsten test network.
var TestnetBootnodes = []string{
// TomoChain Bootnodes Testnet
"enode://4d3c2cc0ce7135c1778c6f1cfda623ab44b4b6db55289543d48ecfde7d7111fd420c42174a9f2fea511a04cf6eac4ec69b4456bfaaae0e5bd236107d3172b013@52.221.28.223:30301",
"enode://298780104303fcdb37a84c5702ebd9ec660971629f68a933fd91f7350c54eea0e294b0857f1fd2e8dba2869fcc36b83e6de553c386cf4ff26f19672955d9f312@13.251.101.216:30301",
"enode://46dba3a8721c589bede3c134d755eb1a38ae7c5a4c69249b8317c55adc8d46a369f98b06514ecec4b4ff150712085176818d18f59a9e6311a52dbe68cff5b2ae@13.250.94.232:30301",
// Viction Bootnodes Testnet
"enode://0f41c53da72e07e3514efd7ce9e3f758acc2066d8ae66955e540620f7108fff91f8ebdc734b89dca14db2a70cdaf8c957579ec94e3dfdfe91b2923272f1cc099@13.214.64.64:30601",
// "enode://30b7ab30a01c124a6cceca36863ece12c4f5fa68e3ba9b0b51407ccc002eeed3b3102d20a88f1c1d3c3154e2449317b8ef95090e77b312d5cc39354f86d5d606@52.176.7.10:30303", // US-Azure geth
// "enode://865a63255b3bb68023b6bffd5095118fcc13e79dcf014fe4e47e065c350c7cc72af2e53eff895f11ba1bbb6a2b33271c1116ee870f266618eadfc2e78aa7349c@52.176.100.77:30303", // US-Azure parity
// "enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303", // Parity
Expand Down
42 changes: 16 additions & 26 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,22 @@ import (
)

var (
TomoMainnetGenesisHash = common.HexToHash("9326145f8a2c8c00bbe13afc7d7f3d9c868b5ef39d89f2f4e9390e9720298624") // Tomo Mainnet genesis hash to enforce below configs on
MainnetGenesisHash = common.HexToHash("8d13370621558f4ed0da587934473c0404729f28b0ff1d50e5fdd840457a2f17") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("dffc8ae3b45965404b4fd73ce7f0e13e822ac0fc23ce7e95b42bc5f1e57023a5") // Testnet genesis hash to enforce below configs on
VicMainnetGenesisHash = common.HexToHash("9326145f8a2c8c00bbe13afc7d7f3d9c868b5ef39d89f2f4e9390e9720298624") // Viction Mainnet genesis hash to enforce below configs on
VicTestnetGenesisHash = common.HexToHash("296f14cfe39dd2ce9cd2dcf2bd5973c9b59531bc239e7d445c66268b172e52e3") // Viction Testnet genesis hash to enforce below configs on
MainnetGenesisHash = common.HexToHash("8d13370621558f4ed0da587934473c0404729f28b0ff1d50e5fdd840457a2f17") // Ethereum Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("dffc8ae3b45965404b4fd73ce7f0e13e822ac0fc23ce7e95b42bc5f1e57023a5") // Ethereum Testnet genesis hash to enforce below configs on
)

var (
// VicMainnetChainConfig contains the chain parameters to run a Viction node on the main network.
VicMainnetChainConfig = &ChainConfig{
ChainId: big.NewInt(88),
HomesteadBlock: big.NewInt(1),
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
TIP2019Block: big.NewInt(1050000),
TIPSigningBlock: big.NewInt(3000000),
TIPRandomizeBlock: big.NewInt(3464000),
BlackListHFBlock: big.NewInt(9349100),
TIPTRC21FeeBlock: big.NewInt(13523400),
TIPTomoXBlock: big.NewInt(20581700),
TIPTomoXLendingBlock: big.NewInt(21430200),
TIPTomoXCancellationFeeBlock: big.NewInt(30915660),
ChainId: big.NewInt(88),
HomesteadBlock: big.NewInt(1),
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
Posv: &PosvConfig{
Period: 2,
Epoch: 900,
Expand All @@ -60,15 +53,12 @@ var (
// VicTestnetChainConfig contains the chain parameters to run a Viction node on the test network.
VicTestnetChainConfig = &ChainConfig{
ChainId: big.NewInt(89),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
HomesteadBlock: big.NewInt(1),
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: big.NewInt(0),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
TIP2019Block: big.NewInt(0),
TIPSigningBlock: big.NewInt(0),
TIPRandomizeBlock: big.NewInt(0),
Expand Down

0 comments on commit f01fa41

Please sign in to comment.