Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Blockcore/BlockPulling/BlockPuller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public BlockPuller(IChainState chainState, NodeSettings nodeSettings, IDateTimeP

this.networkPeerRequirement = new NetworkPeerRequirement
{
MinVersion = nodeSettings.MinProtocolVersion ?? nodeSettings.Network.Consensus.ConsensusProtocol.ProtocolVersion,
MinVersion = nodeSettings.MinProtocolVersion ?? nodeSettings.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion,
RequiredServices = NetworkPeerServices.Network
};

Expand Down
2 changes: 1 addition & 1 deletion src/Blockcore/Configuration/NodeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public NodeSettings(Network network = null, string agent = "Blockcore",
// Log arguments.
this.Logger.LogDebug("Arguments: network='{0}', protocolVersion='{1}', agent='{2}', args='{3}'.",
this.Network == null ? "(None)" : this.Network.Name,
this.Network?.Consensus.ConsensusProtocol.ProtocolVersion,
this.Network?.Consensus.ConsensusFactory.Protocol.ProtocolVersion,
this.Agent,
args == null ? "(None)" : string.Join(" ", args));

Expand Down
2 changes: 1 addition & 1 deletion src/Blockcore/Connection/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ConnectionManager(IDateTimeProvider dateTimeProvider,

this.Parameters.UserAgent = $"{this.ConnectionSettings.Agent}:{versionProvider.GetVersion()}";

this.Parameters.Version = this.NodeSettings.Network.Consensus.ConsensusProtocol.ProtocolVersion;
this.Parameters.Version = this.NodeSettings.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion;

nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name, 1100);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blockcore/Controllers/NodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public IActionResult Status()
var model = new StatusModel
{
Version = this.fullNode.Version?.ToString() ?? "0",
ProtocolVersion = (uint)(this.nodeSettings.Network.Consensus.ConsensusProtocol.ProtocolVersion),
ProtocolVersion = (uint)(this.nodeSettings.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion),
Difficulty = GetNetworkDifficulty(this.networkDifficulty)?.Difficulty ?? 0,
Agent = this.connectionManager.ConnectionSettings.Agent,
ExternalAddress = this.selfEndpointTracker.MyExternalAddress.Address.ToString(),
Expand Down
2 changes: 1 addition & 1 deletion src/Blockcore/P2P/PeerConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected PeerConnector(
this.PeerAddressManager = peerAddressManager;
this.networkPeerDisposer = new NetworkPeerDisposer(this.loggerFactory, this.asyncProvider, this.OnPeerDisposed);
this.selfEndpointTracker = selfEndpointTracker;
this.Requirements = new NetworkPeerRequirement { MinVersion = nodeSettings.MinProtocolVersion ?? nodeSettings.Network.Consensus.ConsensusProtocol.ProtocolVersion };
this.Requirements = new NetworkPeerRequirement { MinVersion = nodeSettings.MinProtocolVersion ?? nodeSettings.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion };

this.connectionInterval = this.CalculateConnectionInterval();
}
Expand Down
9 changes: 0 additions & 9 deletions src/External/NBitcoin/Consensus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ public class Consensus : IConsensus
/// <inheritdoc />
public List<Type> MempoolRules { get; set; }

/// <inheritdoc />
public ConsensusProtocol ConsensusProtocol { get; }

public Consensus(
ConsensusFactory consensusFactory,
ConsensusProtocol consensusProtocol,
ConsensusOptions consensusOptions,
int coinType,
uint256 hashGenesisBlock,
Expand Down Expand Up @@ -170,11 +166,6 @@ public Consensus(
this.ConsensusRules = new ConsensusRules();
this.MempoolRules = new List<Type>();
this.ProofOfStakeTimestampMask = proofOfStakeTimestampMask;
this.ConsensusProtocol = consensusProtocol;

// this is a small hack to allow acess to protocol verison
// form serialization code.
this.ConsensusFactory.Protocol = this.ConsensusProtocol;
}
}
}
2 changes: 1 addition & 1 deletion src/External/NBitcoin/ConsensusFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public virtual Transaction CreateTransaction(byte[] bytes)

public class ConsensusProtocol
{
public uint ProtocolVersion { get; set; } = Protocol.ProtocolVersion.WITNESS_VERSION;
public uint ProtocolVersion { get; set; } = Protocol.ProtocolVersion.FEEFILTER_VERSION;

public uint MinProtocolVersion { get; set; } = Protocol.ProtocolVersion.SENDHEADERS_VERSION;
}
Expand Down
5 changes: 0 additions & 5 deletions src/External/NBitcoin/IConsensus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,5 @@ public interface IConsensus

/// <summary>Group of mempool validation rules used by the given network.</summary>
List<Type> MempoolRules { get; set; }

/// <summary>
/// Information about the consensus protocol.
/// </summary>
ConsensusProtocol ConsensusProtocol { get; }
}
}
7 changes: 3 additions & 4 deletions src/Features/Blockcore.Features.PoA/PoANetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,14 @@ public PoANetwork()

var bip9Deployments = new NoBIP9Deployments();

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = (uint)ProtocolVersion.PROVEN_HEADER_VERSION,
MinProtocolVersion = (uint)ProtocolVersion.POS_PROTOCOL_VERSION,
ProtocolVersion = ProtocolVersion.PROVEN_HEADER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: consensusOptions,
coinType: 105,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public GetInfoModel GetInfo()
var model = new GetInfoModel
{
Version = this.FullNode?.Version?.ToUint() ?? 0,
ProtocolVersion = this.Network.Consensus.ConsensusProtocol.ProtocolVersion,
ProtocolVersion = this.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion,
Blocks = this.ChainState?.ConsensusTip?.Height ?? 0,
TimeOffset = this.ConnectionManager?.ConnectedPeers?.GetMedianTimeOffset() ?? 0,
Connections = this.ConnectionManager?.ConnectedPeers?.Count(),
Expand Down Expand Up @@ -429,7 +429,7 @@ public NetworkInfoModel GetNetworkInfo()
{
Version = this.FullNode?.Version?.ToUint() ?? 0,
SubVersion = this.Settings?.Agent,
ProtocolVersion = this.Network.Consensus.ConsensusProtocol.ProtocolVersion,
ProtocolVersion = this.Network.Consensus.ConsensusFactory.Protocol.ProtocolVersion,
IsLocalRelay = this.ConnectionManager?.Parameters?.IsRelay ?? false,
TimeOffset = this.ConnectionManager?.ConnectedPeers?.GetMedianTimeOffset() ?? 0,
Connections = this.ConnectionManager?.ConnectedPeers?.Count(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ public BitcoinMain()
[BitcoinBIP9Deployments.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, 1479168000, 1510704000, BIP9DeploymentsParameters.DefaultMainnetThreshold)
};

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.SENDHEADERS_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: new ConsensusOptions(), // Default - set to Bitcoin params.
coinType: 0,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ public BitcoinRegTest()
[BitcoinBIP9Deployments.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive)
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.SENDHEADERS_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: new ConsensusOptions(), // Default - set to Bitcoin params.
coinType: 0,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ public BitcoinTest()
[BitcoinBIP9Deployments.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, 1462060800, 1493596800, BIP9DeploymentsParameters.DefaultTestnetThreshold)
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.SENDHEADERS_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: new ConsensusOptions(), // Default - set to Bitcoin params.
coinType: 1,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
5 changes: 2 additions & 3 deletions src/Networks/City/City/Networks/CityMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ public CityMain()
[BuriedDeployments.BIP66] = 0
};

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.PROVEN_HEADER_VERSION,
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: consensusOptions,
coinType: setup.CoinType,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
8 changes: 7 additions & 1 deletion src/Networks/City/City/Networks/CityRegTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NBitcoin;
using NBitcoin.BouncyCastle.Math;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;

namespace City.Networks
{
Expand Down Expand Up @@ -64,9 +65,14 @@ public CityRegTest()
[BuriedDeployments.BIP66] = 0
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: consensusOptions,
coinType: setup.CoinType,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
8 changes: 7 additions & 1 deletion src/Networks/City/City/Networks/CityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NBitcoin;
using NBitcoin.BouncyCastle.Math;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;

namespace City.Networks
{
Expand Down Expand Up @@ -64,9 +65,14 @@ public CityTest()
[BuriedDeployments.BIP66] = 0
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: consensusOptions,
coinType: setup.CoinType,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ public StratisMain()
BIP9DeploymentsParameters.DefaultMainnetThreshold)
};

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.PROVEN_HEADER_VERSION,
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: consensusOptions,
coinType: 105,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ public StratisRegTest()
[StratisBIP9Deployments.ColdStaking] = new BIP9DeploymentsParameters("ColdStaking", 2, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive),
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: consensusOptions,
coinType: 105,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ public StratisTest()
BIP9DeploymentsParameters.DefaultTestnetThreshold)
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: consensusOptions,
coinType: 105,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
7 changes: 3 additions & 4 deletions src/Networks/Xds/Blockcore.Networks.Xds/XdsMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@ public XdsMain()
[XdsBIP9Deployments.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, BIP9DeploymentsParameters.AlwaysActive, 999999999, BIP9DeploymentsParameters.AlwaysActive)
};

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = (uint)ProtocolVersion.PROVEN_HEADER_VERSION,
MinProtocolVersion = (uint)ProtocolVersion.POS_PROTOCOL_VERSION,
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new NBitcoin.Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: consensusOptions,
coinType: (int)this.GenesisNonce,
hashGenesisBlock: this.Genesis.GetHash(),
Expand Down
5 changes: 0 additions & 5 deletions src/Networks/x42/x42/Networks/Consensus/x42Consensus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ public class x42Consensus : IConsensus
/// <inheritdoc />
public Money LastProofOfStakeRewardHeight { get; }

/// <inheritdoc />
public ConsensusProtocol ConsensusProtocol { get; }

public x42Consensus(
ConsensusFactory consensusFactory,
ConsensusProtocol consensusProtocol,
ConsensusOptions consensusOptions,
int coinType,
uint256 hashGenesisBlock,
Expand Down Expand Up @@ -233,7 +229,6 @@ uint proofOfStakeTimestampMask
this.MempoolRules = new List<Type>();
this.PosEmptyCoinbase = posEmptyCoinbase;
this.ProofOfStakeTimestampMask = proofOfStakeTimestampMask;
this.ConsensusProtocol = consensusProtocol;
}
}
}
5 changes: 2 additions & 3 deletions src/Networks/x42/x42/Networks/x42Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ public x42Main()
[x42BIP9Deployments.Segwit] = new BIP9DeploymentsParameters("Segwit", 1, new DateTime(2020, 3, 1, 0, 0, 0, DateTimeKind.Utc), new DateTime(2021, 3, 1, 0, 0, 0, DateTimeKind.Utc), BIP9DeploymentsParameters.DefaultMainnetThreshold)
};

ConsensusProtocol consensusProtocol = new ConsensusProtocol()
consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.PROVEN_HEADER_VERSION,
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new x42Consensus(
consensusFactory: consensusFactory,
consensusProtocol: consensusProtocol,
consensusOptions: consensusOptions,
coinType: setup.CoinType,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
8 changes: 7 additions & 1 deletion src/Networks/x42/x42/Networks/x42RegTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using NBitcoin;
using NBitcoin.BouncyCastle.Math;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;

namespace x42.Networks
{
Expand Down Expand Up @@ -64,9 +65,14 @@ public x42RegTest()
[BuriedDeployments.BIP66] = 0
};

consensusFactory.Protocol = new ConsensusProtocol()
{
ProtocolVersion = ProtocolVersion.FEEFILTER_VERSION,
MinProtocolVersion = ProtocolVersion.POS_PROTOCOL_VERSION,
};

this.Consensus = new x42Consensus(
consensusFactory: consensusFactory,
consensusProtocol: this.Consensus.ConsensusProtocol,
consensusOptions: consensusOptions,
coinType: setup.CoinType,
hashGenesisBlock: genesisBlock.GetHash(),
Expand Down
Loading