mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 21:54:30 +00:00
add v2 specific config struct
This commit is contained in:
parent
bf56a64fe0
commit
1d48ed7d06
3 changed files with 23 additions and 31618 deletions
|
|
@ -22,8 +22,7 @@ type XDPoS_v2 struct {
|
|||
|
||||
func New(config *params.XDPoSConfig, db ethdb.Database) *XDPoS_v2 {
|
||||
// Setup Timer
|
||||
// TODO: (hashlab) Introduce consensus v2 engine specific config under the main config struct
|
||||
duration := 50000 * time.Millisecond // Hardcoded value until we move it to a config (XIN-72)
|
||||
duration := time.Duration(config.ConsensusV2Config.TimeoutWorkerDuration) * time.Millisecond
|
||||
timer := countdown.NewCountDown(duration)
|
||||
|
||||
engine := &XDPoS_v2{
|
||||
|
|
@ -41,11 +40,15 @@ func NewFaker(db ethdb.Database, config *params.XDPoSConfig) *XDPoS_v2 {
|
|||
var fakeEngine *XDPoS_v2
|
||||
// Set any missing consensus parameters to their defaults
|
||||
conf := config
|
||||
// Setup Timer
|
||||
duration := time.Duration(config.ConsensusV2Config.TimeoutWorkerDuration) * time.Millisecond
|
||||
timer := countdown.NewCountDown(duration)
|
||||
|
||||
// Allocate the snapshot caches and create the engine
|
||||
fakeEngine = &XDPoS_v2{
|
||||
config: conf,
|
||||
db: db,
|
||||
config: conf,
|
||||
db: db,
|
||||
timeoutWorker: timer,
|
||||
}
|
||||
return fakeEngine
|
||||
}
|
||||
|
|
|
|||
31609
coverage.txt
31609
coverage.txt
File diff suppressed because it is too large
Load diff
|
|
@ -35,6 +35,10 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
XDPoSV2Config = &ConsensusV2Config{
|
||||
TimeoutWorkerDuration: 50000,
|
||||
}
|
||||
|
||||
// XDPoSChain mainnet config
|
||||
XDCMainnetChainConfig = &ChainConfig{
|
||||
ChainId: big.NewInt(88),
|
||||
|
|
@ -51,6 +55,7 @@ var (
|
|||
RewardCheckpoint: 900,
|
||||
Gap: 5,
|
||||
FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"),
|
||||
ConsensusV2Config: *XDPoSV2Config,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +102,9 @@ var (
|
|||
ByzantiumBlock: big.NewInt(1035301),
|
||||
ConstantinopleBlock: nil,
|
||||
XDPoS: &XDPoSConfig{
|
||||
Period: 15,
|
||||
Epoch: 30000,
|
||||
Period: 15,
|
||||
Epoch: 30000,
|
||||
ConsensusV2Config: *XDPoSV2Config,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -117,11 +123,11 @@ var (
|
|||
AllXDPoSProtocolChanges = &ChainConfig{big.NewInt(89), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &XDPoSConfig{Period: 0, Epoch: 30000}}
|
||||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}, nil}
|
||||
|
||||
TestXDPoSChanConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &XDPoSConfig{Period: 2, Epoch: 900, Reward: 250, RewardCheckpoint: 900, Gap: 890, FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068")}}
|
||||
TestXDPoSChanConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, &XDPoSConfig{Period: 2, Epoch: 900, Reward: 250, RewardCheckpoint: 900, Gap: 890, FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"), ConsensusV2Config: *XDPoSV2Config}}
|
||||
// XDPoS config in use for v1 engine only
|
||||
TestXDPoSMockChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, &XDPoSConfig{Epoch: 900, Gap: 450, SkipValidation: true}}
|
||||
TestXDPoSMockChainConfig = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, &XDPoSConfig{Epoch: 900, Gap: 450, SkipValidation: true, ConsensusV2Config: *XDPoSV2Config}}
|
||||
// XDPoS config with v2 engine after block 10
|
||||
TestXDPoSMockChainConfigWithV2Engine = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, &XDPoSConfig{Epoch: 900, Gap: 450, SkipValidation: true, V2ConsensusBlockNumber: big.NewInt(10)}}
|
||||
TestXDPoSMockChainConfigWithV2Engine = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, &XDPoSConfig{Epoch: 900, Gap: 450, SkipValidation: true, V2ConsensusBlockNumber: big.NewInt(10), ConsensusV2Config: *XDPoSV2Config}}
|
||||
|
||||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, nil}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||
|
|
@ -185,6 +191,11 @@ type XDPoSConfig struct {
|
|||
FoudationWalletAddr common.Address `json:"foudationWalletAddr"` // Foundation Address Wallet
|
||||
SkipValidation bool //Skip Block Validation for testing purpose
|
||||
V2ConsensusBlockNumber *big.Int
|
||||
ConsensusV2Config ConsensusV2Config
|
||||
}
|
||||
|
||||
type ConsensusV2Config struct {
|
||||
TimeoutWorkerDuration int64 `json:"TimeoutWorkerDuration"` // Duration in ms
|
||||
}
|
||||
|
||||
// String implements the stringer interface, returning the consensus engine details.
|
||||
|
|
|
|||
Loading…
Reference in a new issue