mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +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 {
|
func New(config *params.XDPoSConfig, db ethdb.Database) *XDPoS_v2 {
|
||||||
// Setup Timer
|
// Setup Timer
|
||||||
// TODO: (hashlab) Introduce consensus v2 engine specific config under the main config struct
|
duration := time.Duration(config.ConsensusV2Config.TimeoutWorkerDuration) * time.Millisecond
|
||||||
duration := 50000 * time.Millisecond // Hardcoded value until we move it to a config (XIN-72)
|
|
||||||
timer := countdown.NewCountDown(duration)
|
timer := countdown.NewCountDown(duration)
|
||||||
|
|
||||||
engine := &XDPoS_v2{
|
engine := &XDPoS_v2{
|
||||||
|
|
@ -41,11 +40,15 @@ func NewFaker(db ethdb.Database, config *params.XDPoSConfig) *XDPoS_v2 {
|
||||||
var fakeEngine *XDPoS_v2
|
var fakeEngine *XDPoS_v2
|
||||||
// Set any missing consensus parameters to their defaults
|
// Set any missing consensus parameters to their defaults
|
||||||
conf := config
|
conf := config
|
||||||
|
// Setup Timer
|
||||||
|
duration := time.Duration(config.ConsensusV2Config.TimeoutWorkerDuration) * time.Millisecond
|
||||||
|
timer := countdown.NewCountDown(duration)
|
||||||
|
|
||||||
// Allocate the snapshot caches and create the engine
|
// Allocate the snapshot caches and create the engine
|
||||||
fakeEngine = &XDPoS_v2{
|
fakeEngine = &XDPoS_v2{
|
||||||
config: conf,
|
config: conf,
|
||||||
db: db,
|
db: db,
|
||||||
|
timeoutWorker: timer,
|
||||||
}
|
}
|
||||||
return fakeEngine
|
return fakeEngine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31609
coverage.txt
31609
coverage.txt
File diff suppressed because it is too large
Load diff
|
|
@ -35,6 +35,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
XDPoSV2Config = &ConsensusV2Config{
|
||||||
|
TimeoutWorkerDuration: 50000,
|
||||||
|
}
|
||||||
|
|
||||||
// XDPoSChain mainnet config
|
// XDPoSChain mainnet config
|
||||||
XDCMainnetChainConfig = &ChainConfig{
|
XDCMainnetChainConfig = &ChainConfig{
|
||||||
ChainId: big.NewInt(88),
|
ChainId: big.NewInt(88),
|
||||||
|
|
@ -51,6 +55,7 @@ var (
|
||||||
RewardCheckpoint: 900,
|
RewardCheckpoint: 900,
|
||||||
Gap: 5,
|
Gap: 5,
|
||||||
FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"),
|
FoudationWalletAddr: common.HexToAddress("0x0000000000000000000000000000000000000068"),
|
||||||
|
ConsensusV2Config: *XDPoSV2Config,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,8 +102,9 @@ var (
|
||||||
ByzantiumBlock: big.NewInt(1035301),
|
ByzantiumBlock: big.NewInt(1035301),
|
||||||
ConstantinopleBlock: nil,
|
ConstantinopleBlock: nil,
|
||||||
XDPoS: &XDPoSConfig{
|
XDPoS: &XDPoSConfig{
|
||||||
Period: 15,
|
Period: 15,
|
||||||
Epoch: 30000,
|
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}}
|
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}
|
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
|
// 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
|
// 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}
|
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))
|
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||||
|
|
@ -185,6 +191,11 @@ type XDPoSConfig struct {
|
||||||
FoudationWalletAddr common.Address `json:"foudationWalletAddr"` // Foundation Address Wallet
|
FoudationWalletAddr common.Address `json:"foudationWalletAddr"` // Foundation Address Wallet
|
||||||
SkipValidation bool //Skip Block Validation for testing purpose
|
SkipValidation bool //Skip Block Validation for testing purpose
|
||||||
V2ConsensusBlockNumber *big.Int
|
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.
|
// String implements the stringer interface, returning the consensus engine details.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue