mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-21 06:16:45 +00:00

* Update constants * Add to transaction SigOpCount * Update mass calculation, and move it from InContext to InIsolation * Update block validation accordingly * Add SigOpCount validation during TransactionInContext * Remove checking of mass vs maxMassAcceptedByBlock from consensusStateManager * Update mining manager with latest changes * Add SigOpCount to MsgTx.Copy() * Fix initTestTransactionAcceptanceDataForClone * Fix all tests in transaction_equal_clone_test.go * Fix TestBlockMass * Fix tests in transactionvalidator package * Add SigOpCount to sighash * Fix TestPruningDepth * Fix problems in libkaspawalelt * Fix integration tests * Fix CalculateSignatureHash tests * Remove remaining places talking about block size * Add sanity check to checkBlockMass to make sure all transactions have their mass filled * always add own sigOpCount to sigHash * Update protowire/rpc.md * Start working on removing any remaining reference to block/tx size * Update rpc transaction verbose data to include mass rather then size * Convert verboseData and block size check to mass * Remove remaining usages of tx size in mempool * Move transactionEstimatedSerializedSize to transactionvalidator * Add PopulateMass to fakeRelayInvsContext * Move PopulateMass to beggining of ValidateAndInsertTransaction + fix in it * Assign mass a new number for backward-compatibility
75 lines
3.3 KiB
Go
75 lines
3.3 KiB
Go
package mempool
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/constants"
|
|
|
|
"github.com/kaspanet/kaspad/util"
|
|
|
|
"github.com/kaspanet/kaspad/domain/dagconfig"
|
|
)
|
|
|
|
const (
|
|
defaultMaximumTransactionCount = 1_000_000
|
|
|
|
defaultTransactionExpireIntervalSeconds uint64 = 60
|
|
defaultTransactionExpireScanIntervalSeconds uint64 = 10
|
|
defaultOrphanExpireIntervalSeconds uint64 = 60
|
|
defaultOrphanExpireScanIntervalSeconds uint64 = 10
|
|
|
|
defaultMaximumOrphanTransactionMass = 100000
|
|
// defaultMaximumOrphanTransactionCount should remain small as long as we have recursion in
|
|
// removeOrphans when removeRedeemers = true
|
|
defaultMaximumOrphanTransactionCount = 50
|
|
|
|
// defaultMinimumRelayTransactionFee specifies the minimum transaction fee for a transaction to be accepted to
|
|
// the mempool and relayed. It is specified in sompi per 1kg (or 1000 grams) of transaction mass.
|
|
defaultMinimumRelayTransactionFee = util.Amount(1000)
|
|
|
|
// Standard transaction version range might be different from what consensus accepts, therefore
|
|
// we define separate values in mempool.
|
|
// However, currently there's exactly one transaction version, so mempool accepts the same version
|
|
// as consensus.
|
|
defaultMinimumStandardTransactionVersion = constants.MaxTransactionVersion
|
|
defaultMaximumStandardTransactionVersion = constants.MaxTransactionVersion
|
|
)
|
|
|
|
// Config represents a mempool configuration
|
|
type Config struct {
|
|
MaximumTransactionCount uint64
|
|
TransactionExpireIntervalDAAScore uint64
|
|
TransactionExpireScanIntervalDAAScore uint64
|
|
TransactionExpireScanIntervalSeconds uint64
|
|
OrphanExpireIntervalDAAScore uint64
|
|
OrphanExpireScanIntervalDAAScore uint64
|
|
MaximumOrphanTransactionMass uint64
|
|
MaximumOrphanTransactionCount uint64
|
|
AcceptNonStandard bool
|
|
MaximumMassPerBlock uint64
|
|
MinimumRelayTransactionFee util.Amount
|
|
MinimumStandardTransactionVersion uint16
|
|
MaximumStandardTransactionVersion uint16
|
|
}
|
|
|
|
// DefaultConfig returns the default mempool configuration
|
|
func DefaultConfig(dagParams *dagconfig.Params) *Config {
|
|
targetBlocksPerSecond := uint64(time.Second / dagParams.TargetTimePerBlock)
|
|
|
|
return &Config{
|
|
MaximumTransactionCount: defaultMaximumTransactionCount,
|
|
TransactionExpireIntervalDAAScore: defaultTransactionExpireIntervalSeconds / targetBlocksPerSecond,
|
|
TransactionExpireScanIntervalDAAScore: defaultTransactionExpireScanIntervalSeconds / targetBlocksPerSecond,
|
|
TransactionExpireScanIntervalSeconds: defaultTransactionExpireScanIntervalSeconds,
|
|
OrphanExpireIntervalDAAScore: defaultOrphanExpireIntervalSeconds / targetBlocksPerSecond,
|
|
OrphanExpireScanIntervalDAAScore: defaultOrphanExpireScanIntervalSeconds / targetBlocksPerSecond,
|
|
MaximumOrphanTransactionMass: defaultMaximumOrphanTransactionMass,
|
|
MaximumOrphanTransactionCount: defaultMaximumOrphanTransactionCount,
|
|
AcceptNonStandard: dagParams.RelayNonStdTxs,
|
|
MaximumMassPerBlock: dagParams.MaxBlockMass,
|
|
MinimumRelayTransactionFee: defaultMinimumRelayTransactionFee,
|
|
MinimumStandardTransactionVersion: defaultMinimumStandardTransactionVersion,
|
|
MaximumStandardTransactionVersion: defaultMaximumStandardTransactionVersion,
|
|
}
|
|
}
|