mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-02-27 13:43:19 +00:00
Compare commits
5 Commits
opow
...
mainnet-dn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a388112e86 | ||
|
|
0a1daae319 | ||
|
|
49285d64f2 | ||
|
|
131cd3357e | ||
|
|
ff72568d6b |
@@ -102,7 +102,7 @@ func (flow *handleRequestPruningPointUTXOSetFlow) sendPruningPointUTXOSet(
|
||||
return err
|
||||
}
|
||||
|
||||
if len(pruningPointUTXOs) < step {
|
||||
if len(pruningPointUTXOs) < step && chunksSent%ibdBatchSize == 0 {
|
||||
log.Debugf("Finished sending UTXOs for pruning block %s",
|
||||
msgRequestPruningPointUTXOSet.PruningPointHash)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func (s *server) CreateUnsignedTransaction(_ context.Context, request *pb.Create
|
||||
}
|
||||
|
||||
// TODO: Implement a better fee estimation mechanism
|
||||
const feePerInput = 1000
|
||||
const feePerInput = 10000
|
||||
selectedUTXOs, changeSompi, err := s.selectUTXOs(request.Amount, feePerInput)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -206,7 +206,7 @@ func (f *factory) NewConsensus(config *Config, db infrastructuredatabase.Databas
|
||||
config.CoinbasePayloadScriptPublicKeyMaxLength,
|
||||
config.GenesisHash,
|
||||
config.FixedSubsidySwitchPruningPointInterval,
|
||||
config.FixedSubsidySwitchHashRateDifference,
|
||||
config.FixedSubsidySwitchHashRateThreshold,
|
||||
dagTraversalManager,
|
||||
ghostdagDataStore,
|
||||
acceptanceDataStore,
|
||||
|
||||
@@ -49,7 +49,7 @@ func (c *coinbaseManager) isBlockRewardFixed(stagingArea *model.StagingArea, blo
|
||||
blueWorkDifference := new(big.Int).Sub(highPruningPointHeader.BlueWork(), lowPruningPointHeader.BlueWork())
|
||||
blueScoreDifference := new(big.Int).SetUint64(highPruningPointHeader.BlueScore() - lowPruningPointHeader.BlueScore())
|
||||
estimatedAverageHashRate := new(big.Int).Div(blueWorkDifference, blueScoreDifference)
|
||||
if estimatedAverageHashRate.Cmp(c.fixedSubsidySwitchHashRateDifference) >= 0 {
|
||||
if estimatedAverageHashRate.Cmp(c.fixedSubsidySwitchHashRateThreshold) >= 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestBlockRewardSwitch(t *testing.T) {
|
||||
// Set the hash rate difference such that the switch would trigger exactly
|
||||
// on the `FixedSubsidySwitchPruningPointInterval + 1`th pruning point
|
||||
workToAcceptGenesis := difficulty.CalcWork(consensusConfig.GenesisBlock.Header.Bits())
|
||||
consensusConfig.FixedSubsidySwitchHashRateDifference = workToAcceptGenesis
|
||||
consensusConfig.FixedSubsidySwitchHashRateThreshold = workToAcceptGenesis
|
||||
|
||||
// Set the min, max, and post-switch subsidies to values that would make it
|
||||
// easy to tell whether the switch happened
|
||||
|
||||
@@ -22,7 +22,7 @@ type coinbaseManager struct {
|
||||
coinbasePayloadScriptPublicKeyMaxLength uint8
|
||||
genesisHash *externalapi.DomainHash
|
||||
fixedSubsidySwitchPruningPointInterval uint64
|
||||
fixedSubsidySwitchHashRateDifference *big.Int
|
||||
fixedSubsidySwitchHashRateThreshold *big.Int
|
||||
|
||||
databaseContext model.DBReader
|
||||
dagTraversalManager model.DAGTraversalManager
|
||||
@@ -364,7 +364,7 @@ func New(
|
||||
coinbasePayloadScriptPublicKeyMaxLength uint8,
|
||||
genesisHash *externalapi.DomainHash,
|
||||
fixedSubsidySwitchPruningPointInterval uint64,
|
||||
fixedSubsidySwitchHashRateDifference *big.Int,
|
||||
fixedSubsidySwitchHashRateThreshold *big.Int,
|
||||
|
||||
dagTraversalManager model.DAGTraversalManager,
|
||||
ghostdagDataStore model.GHOSTDAGDataStore,
|
||||
@@ -385,7 +385,7 @@ func New(
|
||||
coinbasePayloadScriptPublicKeyMaxLength: coinbasePayloadScriptPublicKeyMaxLength,
|
||||
genesisHash: genesisHash,
|
||||
fixedSubsidySwitchPruningPointInterval: fixedSubsidySwitchPruningPointInterval,
|
||||
fixedSubsidySwitchHashRateDifference: fixedSubsidySwitchHashRateDifference,
|
||||
fixedSubsidySwitchHashRateThreshold: fixedSubsidySwitchHashRateThreshold,
|
||||
|
||||
dagTraversalManager: dagTraversalManager,
|
||||
ghostdagDataStore: ghostdagDataStore,
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||
"github.com/kaspanet/kaspad/util/staging"
|
||||
"github.com/pkg/errors"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// pruningManager resolves and manages the current pruning point
|
||||
@@ -928,7 +929,6 @@ func (pm *pruningManager) PruningPointAndItsAnticoneWithTrustedData() ([]*extern
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blocks = append(blocks, pruningPointWithTrustedData)
|
||||
for _, blockHash := range pruningPointAnticone {
|
||||
blockWithTrustedData, err := pm.blockWithTrustedData(stagingArea, blockHash)
|
||||
if err != nil {
|
||||
@@ -938,6 +938,14 @@ func (pm *pruningManager) PruningPointAndItsAnticoneWithTrustedData() ([]*extern
|
||||
blocks = append(blocks, blockWithTrustedData)
|
||||
}
|
||||
|
||||
// Sorting the blocks in topological order
|
||||
sort.Slice(blocks, func(i, j int) bool {
|
||||
return blocks[i].Block.Header.BlueWork().Cmp(blocks[j].Block.Header.BlueWork()) < 0
|
||||
})
|
||||
|
||||
// The pruning point should always come first
|
||||
blocks = append([]*externalapi.BlockWithTrustedData{pruningPointWithTrustedData}, blocks...)
|
||||
|
||||
return blocks, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ type Params struct {
|
||||
|
||||
FixedSubsidySwitchPruningPointInterval uint64
|
||||
|
||||
FixedSubsidySwitchHashRateDifference *big.Int
|
||||
FixedSubsidySwitchHashRateThreshold *big.Int
|
||||
}
|
||||
|
||||
// NormalizeRPCServerAddress returns addr with the current network default
|
||||
@@ -211,6 +211,7 @@ var MainnetParams = Params{
|
||||
Net: appmessage.Mainnet,
|
||||
RPCPort: "16110",
|
||||
DefaultPort: "16111",
|
||||
DNSSeeds: []string{"mainnet-dnsseed.daglabs-dev.com"},
|
||||
|
||||
// DAG parameters
|
||||
GenesisBlock: &genesisBlock,
|
||||
@@ -262,7 +263,7 @@ var MainnetParams = Params{
|
||||
CoinbasePayloadScriptPublicKeyMaxLength: defaultCoinbasePayloadScriptPublicKeyMaxLength,
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateDifference: big.NewInt(1_000_000),
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
}
|
||||
|
||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||
@@ -324,7 +325,7 @@ var TestnetParams = Params{
|
||||
CoinbasePayloadScriptPublicKeyMaxLength: defaultCoinbasePayloadScriptPublicKeyMaxLength,
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateDifference: big.NewInt(1_000_000),
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
}
|
||||
|
||||
// SimnetParams defines the network parameters for the simulation test Kaspa
|
||||
@@ -390,7 +391,7 @@ var SimnetParams = Params{
|
||||
CoinbasePayloadScriptPublicKeyMaxLength: defaultCoinbasePayloadScriptPublicKeyMaxLength,
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateDifference: big.NewInt(1_000_000),
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
}
|
||||
|
||||
// DevnetParams defines the network parameters for the development Kaspa network.
|
||||
@@ -452,7 +453,7 @@ var DevnetParams = Params{
|
||||
CoinbasePayloadScriptPublicKeyMaxLength: defaultCoinbasePayloadScriptPublicKeyMaxLength,
|
||||
PruningProofM: defaultPruningProofM,
|
||||
FixedSubsidySwitchPruningPointInterval: defaultFixedSubsidySwitchPruningPointInterval,
|
||||
FixedSubsidySwitchHashRateDifference: big.NewInt(1_000_000),
|
||||
FixedSubsidySwitchHashRateThreshold: big.NewInt(150_000_000_000),
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -81,10 +81,6 @@ func (networkFlags *NetworkFlags) ResolveNetwork(parser *flags.Parser) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if numNets == 0 {
|
||||
return errors.Errorf("Mainnet has not launched yet, use --testnet to run in testnet mode")
|
||||
}
|
||||
|
||||
err := networkFlags.overrideDAGParams()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestDAA(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "sudden hash rate drop",
|
||||
runDuration: 15 * time.Minute,
|
||||
runDuration: 45 * time.Minute,
|
||||
targetHashNanosecondsFunction: func(totalElapsedDuration time.Duration) int64 {
|
||||
if totalElapsedDuration < 5*time.Minute {
|
||||
return machineHashNanoseconds * 2
|
||||
@@ -130,7 +130,7 @@ func TestDAA(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "constant exponential hash rate decrease",
|
||||
runDuration: 15 * time.Minute,
|
||||
runDuration: 45 * time.Minute,
|
||||
targetHashNanosecondsFunction: func(totalElapsedDuration time.Duration) int64 {
|
||||
fromHashNanoseconds := machineHashNanoseconds * 2
|
||||
toHashNanoseconds := machineHashNanoseconds * 10
|
||||
|
||||
Reference in New Issue
Block a user