From bbffc2a0a83c658bb8967fa6f0d9224c14760046 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 27 Nov 2020 12:37:16 +0000 Subject: [PATCH 01/55] Add federation member detailed model (#231) --- .../Models/FederationMemberModel.cs | 5 ++++- .../Voting/DefaultVotingController.cs | 2 +- .../Controllers/WalletController.cs | 17 ++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/Models/FederationMemberModel.cs b/src/Stratis.Bitcoin.Features.PoA/Models/FederationMemberModel.cs index b6ee808773..f1d889cbd4 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Models/FederationMemberModel.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Models/FederationMemberModel.cs @@ -4,7 +4,7 @@ namespace Stratis.Bitcoin.Features.PoA.Models { - public sealed class FederationMemberModel + public class FederationMemberModel { [JsonProperty("pubkey")] public PubKey PubKey { get; set; } @@ -14,7 +14,10 @@ public sealed class FederationMemberModel [JsonProperty("periodOfInactivity")] public TimeSpan PeriodOfInActivity { get; set; } + } + public sealed class FederationMemberDetailedModel : FederationMemberModel + { [JsonProperty("pollStartBlockHeight")] public int PollStartBlockHeight { get; set; } diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/DefaultVotingController.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/DefaultVotingController.cs index 992b2b7328..be22bb92a2 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/DefaultVotingController.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/DefaultVotingController.cs @@ -71,7 +71,7 @@ public IActionResult CurrentFederationMemberInfo() { IFederationMember federationMember = this.federationManager.GetCurrentFederationMember(); - var federationMemberModel = new FederationMemberModel + var federationMemberModel = new FederationMemberDetailedModel { PubKey = federationMember.PubKey }; diff --git a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs index 7129b7c405..8692ef5848 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs @@ -56,10 +56,10 @@ public WalletController( public async Task GenerateMnemonic([FromQuery] string language = "English", int wordCount = 12, CancellationToken cancellationToken = default(CancellationToken)) { - return await this.ExecuteAsAsync(new {Language = language, WordCount = wordCount}, + return await this.ExecuteAsAsync(new { Language = language, WordCount = wordCount }, cancellationToken, (req, token) => // Generate the Mnemonic - this.Json(new Mnemonic(language, (WordCount) wordCount).ToString())); + this.Json(new Mnemonic(language, (WordCount)wordCount).ToString())); } /// @@ -447,8 +447,8 @@ public async Task SendTransaction([FromBody] SendTransactionReque [HttpGet] public async Task ListWallets(CancellationToken cancellationToken = default(CancellationToken)) { - return await this.ExecuteAsAsync((object) null, cancellationToken, (req, token) => - this.Json(new WalletInfoModel(this.walletManager.GetWalletsNames())), false); + return await this.ExecuteAsAsync((object)null, cancellationToken, (req, token) => + this.Json(new WalletInfoModel(this.walletManager.GetWalletsNames())), false); } /// @@ -813,21 +813,20 @@ public async Task Sweep([FromBody] SweepRequest request, [Route("build-offline-sign-request")] [HttpPost] - public async Task BuildOfflineSignRequest([FromBody] BuildOfflineSignRequest req, + public async Task BuildOfflineSignRequest([FromBody] BuildOfflineSignRequest request, CancellationToken cancellationToken = default(CancellationToken)) { - return await this.Execute(req, cancellationToken, + return await this.Execute(request, cancellationToken, async (req, token) => this.Json(await this.walletService.BuildOfflineSignRequest(req, token))); } // TODO: Make this support PSBT directly? [Route("offline-sign-request")] [HttpPost] - public async Task OfflineSignRequest([FromBody] OfflineSignRequest req, + public async Task OfflineSignRequest([FromBody] OfflineSignRequest request, CancellationToken cancellationToken = default(CancellationToken)) { - return await this.Execute(req, cancellationToken, - async (req, token) => this.Json(await this.walletService.OfflineSignRequest(req, token))); + return await this.Execute(request, cancellationToken, async (req, token) => this.Json(await this.walletService.OfflineSignRequest(req, token))); } private TransactionItemModel FindSimilarReceivedTransactionOutput(List items, From 50e3c291f7708ff22f8b24e409d74dad43dd8faa Mon Sep 17 00:00:00 2001 From: zeptin Date: Mon, 30 Nov 2020 07:48:09 +0000 Subject: [PATCH 02/55] Implement importpubkey and watchonly flag for gettransaction (#236) --- .../ColdStakingWalletRPCController.cs | 7 +- .../RPCClient.Wallet.cs | 5 ++ .../RPCOperations.cs | 1 + .../HdAddress.cs | 2 +- .../Interfaces/IWalletManager.cs | 8 ++ .../Services/WalletService.cs | 2 +- src/Stratis.Bitcoin.Features.Wallet/Wallet.cs | 11 +++ .../WalletManager.cs | 59 +++++++++++++ .../WalletRPCController.cs | 84 ++++++++++++++++++- .../RPC/RPCTestsMutable.cs | 44 ++++++++++ .../External/ITransactionsToLists.cs | 3 +- .../SQLiteWalletRepository.cs | 20 ++++- 12 files changed, 234 insertions(+), 12 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingWalletRPCController.cs b/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingWalletRPCController.cs index 930a91b21a..52022a7af8 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingWalletRPCController.cs +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingWalletRPCController.cs @@ -25,9 +25,10 @@ public ColdStakingWalletRPCController( StoreSettings storeSettings, IWalletManager walletManager, WalletSettings walletSettings, - IWalletTransactionHandler walletTransactionHandler) : - base(blockStore, broadcasterManager, chainIndexer, consensusManager, fullNode, loggerFactory, network, scriptAddressReader, storeSettings, walletManager, walletSettings, walletTransactionHandler) + IWalletTransactionHandler walletTransactionHandler, + IWalletSyncManager walletSyncManager) : + base(blockStore, broadcasterManager, chainIndexer, consensusManager, fullNode, loggerFactory, network, scriptAddressReader, storeSettings, walletManager, walletSettings, walletTransactionHandler, walletSyncManager) { } } -} \ No newline at end of file +} diff --git a/src/Stratis.Bitcoin.Features.RPC/RPCClient.Wallet.cs b/src/Stratis.Bitcoin.Features.RPC/RPCClient.Wallet.cs index 575c19bc40..27ec412c62 100644 --- a/src/Stratis.Bitcoin.Features.RPC/RPCClient.Wallet.cs +++ b/src/Stratis.Bitcoin.Features.RPC/RPCClient.Wallet.cs @@ -262,6 +262,11 @@ public Money GetReceivedByAddress(BitcoinAddress address, int confirmations) return Money.Coins(response.Result.Value()); } + public void ImportPubKey(string pubkey, bool rescan = true) + { + SendCommand(RPCOperations.importpubkey, pubkey, "", rescan); + } + // importprivkey public void ImportPrivKey(BitcoinSecret secret) diff --git a/src/Stratis.Bitcoin.Features.RPC/RPCOperations.cs b/src/Stratis.Bitcoin.Features.RPC/RPCOperations.cs index c33069b9e6..5a831638ba 100644 --- a/src/Stratis.Bitcoin.Features.RPC/RPCOperations.cs +++ b/src/Stratis.Bitcoin.Features.RPC/RPCOperations.cs @@ -13,6 +13,7 @@ public enum RPCOperations dumpprivkey, importprivkey, importaddress, + importpubkey, dumpwallet, importwallet, diff --git a/src/Stratis.Bitcoin.Features.Wallet/HdAddress.cs b/src/Stratis.Bitcoin.Features.Wallet/HdAddress.cs index 08d8f97726..9b36de492a 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/HdAddress.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/HdAddress.cs @@ -165,7 +165,7 @@ public HdAddress AsPaginated(long? prevOutputTxTime, int? prevOutputIndex, int l public Script Pubkey { get; set; } /// - /// The base32 representation of a segwit (P2WPH) address. + /// The bech32 representation of a segwit (P2WPKH) address. /// [JsonProperty(PropertyName = "bech32Address")] public string Bech32Address { get; set; } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletManager.cs b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletManager.cs index 81ff13bae0..0fa8a9cfba 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletManager.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletManager.cs @@ -287,6 +287,14 @@ public interface IWalletManager /// The list of all accounts. IEnumerable GetAllAccounts(); + HdAccount GetAccount(string walletName, string accountName); + + HdAccount GetAccount(WalletAccountReference accountReference); + + HdAccount GetOrCreateWatchOnlyAccount(string walletName); + + void AddWatchOnlyAddress(string walletName, string accountName, Script p2pkScriptPubKey, Script p2pkhScriptPubKey); + /// /// Gets the last block height. /// diff --git a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs index 1dbd811812..b9e8fa7a17 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs @@ -1390,4 +1390,4 @@ private TransactionItemModel FindSimilarReceivedTransactionOutput(ListAccount numbers greater or equal to this number are reserved for special purpose account indexes. public const int SpecialPurposeAccountIndexesStart = 100_000_000; + /// + /// The wallet account used for storing watched addresses that the wallet does not possess a private key for. + /// This is intended to supersede the WatchOnlyWallet feature going forwards. + /// Note that indices 0 and 1 are used for cold staking. + /// + public const int WatchOnlyAccountIndex = SpecialPurposeAccountIndexesStart + 2; + + public const string WatchOnlyAccountName = "watchOnly"; + /// Filter for identifying normal wallet accounts. public static Func NormalAccounts = a => a.Index < SpecialPurposeAccountIndexesStart; + public static Func WatchOnlyAccount = a => a.Index == WatchOnlyAccountIndex; + /// Filter for all wallet accounts. public static Func AllAccounts = a => true; diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs index d08e406388..271c1ca3b3 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs @@ -994,9 +994,68 @@ public IEnumerable GetAccounts(string walletName) { res = wallet.GetAccounts().ToArray(); } + + return res; + } + + public HdAccount GetAccount(string walletName, string accountName) + { + Guard.NotEmpty(walletName, nameof(walletName)); + + Wallet wallet = this.GetWallet(walletName); + + HdAccount res = null; + lock (this.lockObject) + { + res = wallet.GetAccounts().FirstOrDefault(a => a.Name == accountName); + } + return res; } + public HdAccount GetAccount(WalletAccountReference accountReference) + { + return GetAccount(accountReference.WalletName, accountReference.AccountName); + } + + public HdAccount GetOrCreateWatchOnlyAccount(string walletName) + { + Guard.NotEmpty(walletName, nameof(walletName)); + + Wallet wallet = this.GetWallet(walletName); + + HdAccount[] res = null; + lock (this.lockObject) + { + res = wallet.GetAccounts(Wallet.WatchOnlyAccount).ToArray(); + } + + HdAccount watchOnlyAccount = res.FirstOrDefault(a => a.Index == Wallet.WatchOnlyAccountIndex); + + if (watchOnlyAccount == null) + { + watchOnlyAccount = this.WalletRepository.CreateAccount(walletName, Wallet.WatchOnlyAccountIndex, Wallet.WatchOnlyAccountName, null); + } + + return watchOnlyAccount; + } + + // TODO: Perhaps this shouldn't be in the WalletManager itself, although it doesn't fit well with HdAccount either + public void AddWatchOnlyAddress(string walletName, string accountName, Script p2pkScriptPubKey, Script p2pkhScriptPubKey) + { + string address = p2pkhScriptPubKey.GetDestinationAddress(this.network).ToString(); + + // TODO: Is it sufficient to only define these fields here, or do we need all the other available fields? + var hdAddress = new HdAddress() + { + ScriptPubKey = p2pkhScriptPubKey, + Pubkey = p2pkScriptPubKey, + Address = address + }; + + this.WalletRepository.AddWatchOnlyAddresses(walletName, accountName, 0, new List() { hdAddress }); + } + public IEnumerable GetAllAccounts() { HdAccount[] res = null; diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs index 2f6a736c9f..47b567cb7d 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletRPCController.cs @@ -42,6 +42,8 @@ public class WalletRPCController : FeatureController private readonly IWalletTransactionHandler walletTransactionHandler; + private readonly IWalletSyncManager walletSyncManager; + private readonly IReserveUtxoService reserveUtxoService; private readonly WalletSettings walletSettings; @@ -64,6 +66,7 @@ public WalletRPCController( IWalletManager walletManager, WalletSettings walletSettings, IWalletTransactionHandler walletTransactionHandler, + IWalletSyncManager walletSyncManager, IReserveUtxoService reserveUtxoService = null) : base(fullNode: fullNode, consensusManager: consensusManager, chainIndexer: chainIndexer, network: network) { this.blockStore = blockStore; @@ -74,6 +77,7 @@ public WalletRPCController( this.walletManager = walletManager; this.walletSettings = walletSettings; this.walletTransactionHandler = walletTransactionHandler; + this.walletSyncManager = walletSyncManager; this.reserveUtxoService = reserveUtxoService; } @@ -453,11 +457,12 @@ public decimal GetBalance(string accountName, int minConfirmations = 0) /// Transaction information. [ActionName("gettransaction")] [ActionDescription("Get detailed information about an in-wallet transaction.")] - public GetTransactionModel GetTransaction(string txid) + public GetTransactionModel GetTransaction(string txid, bool include_watchonly = false) { if (!uint256.TryParse(txid, out uint256 trxid)) throw new ArgumentException(nameof(txid)); + // First check the regular wallet accounts. WalletAccountReference accountReference = this.GetWalletAccountReference(); Wallet hdWallet = this.walletManager.WalletRepository.GetWallet(accountReference.WalletName); @@ -477,6 +482,24 @@ bool IsChangeAddress(Script scriptPubKey) TransactionData firstReceivedTransaction = receivedTransactions.FirstOrDefault(); TransactionData firstSendTransaction = sentTransactions.FirstOrDefault(); + + if (firstReceivedTransaction == null && firstSendTransaction == null && include_watchonly) + { + accountReference = this.GetWatchOnlyWalletAccountReference(); + + hdAccount = this.walletManager.GetOrCreateWatchOnlyAccount(accountReference.WalletName); + + addressLookup = this.walletManager.WalletRepository.GetWalletAddressLookup(accountReference.WalletName); + + // Get the transaction from the wallet by looking into received and send transactions. + receivedTransactions = this.walletManager.WalletRepository.GetTransactionOutputs(hdAccount, null, trxid, true) + .Where(td => !IsChangeAddress(td.ScriptPubKey)).ToList(); + sentTransactions = this.walletManager.WalletRepository.GetTransactionInputs(hdAccount, null, trxid, true).ToList(); + + firstReceivedTransaction = receivedTransactions.FirstOrDefault(); + firstSendTransaction = sentTransactions.FirstOrDefault(); + } + if (firstReceivedTransaction == null && firstSendTransaction == null) throw new RPCServerException(RPCErrorCode.RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id."); @@ -619,6 +642,27 @@ bool IsChangeAddress(Script scriptPubKey) return model; } + [ActionName("importpubkey")] + public bool ImportPubkey(string pubkey, string label = "", bool rescan = true) + { + WalletAccountReference walletAccountReference = this.GetWatchOnlyWalletAccountReference(); + + // As we are not sure whether the P2PK or P2PKH was desired, we have to add both to the watch only account simultaneously. + // We would not be able to infer the P2PK from the P2PKH later anyhow. + Script p2pkScriptPubKey = new PubKey(pubkey).ScriptPubKey; + Script p2pkhScriptPubKey = new PubKey(pubkey).Hash.ScriptPubKey; + + this.walletManager.AddWatchOnlyAddress(walletAccountReference.WalletName, walletAccountReference.AccountName, p2pkScriptPubKey, p2pkhScriptPubKey); + + // As we cannot be sure when an imported pubkey was transacted against, we have to rescan from genesis if requested. + if (rescan) + { + this.walletSyncManager.SyncFromHeight(0, walletAccountReference.WalletName); + } + + return true; + } + [ActionName("listaddressgroupings")] [ActionDescription("Returns a list of grouped addresses which have had their common ownership made public by common use as inputs or as the resulting change in past transactions.")] public List ListAddressGroupings() @@ -874,7 +918,7 @@ private int GetConfirmationCount(TransactionData transaction) } /// - /// Gets the first account from the "default" wallet if it specified, + /// Gets the first account from the "default" wallet if it is specified, /// otherwise returns the first available account in the existing wallets. /// /// Reference to the default wallet account, or the first available if no default wallet is specified. @@ -908,5 +952,41 @@ private WalletAccountReference GetWalletAccountReference() return new WalletAccountReference(walletName, account.Name); } + + /// + /// Gets the first watch only account from the "default" wallet if it is specified, + /// otherwise returns the first available watch only account in the existing wallets. + /// + /// Reference to the default wallet watch only account, or the first available if no default wallet is specified. + private WalletAccountReference GetWatchOnlyWalletAccountReference() + { + string walletName = null; + + if (string.IsNullOrWhiteSpace(WalletRPCController.CurrentWalletName)) + { + if (this.walletSettings.IsDefaultWalletEnabled()) + walletName = this.walletManager.GetWalletsNames().FirstOrDefault(w => w == this.walletSettings.DefaultWalletName); + else + { + // TODO: Support multi wallet like core by mapping passed RPC credentials to a wallet/account + walletName = this.walletManager.GetWalletsNames().FirstOrDefault(); + } + } + else + { + // Read the wallet name from the class instance. + walletName = WalletRPCController.CurrentWalletName; + } + + if (walletName == null) + throw new RPCServerException(RPCErrorCode.RPC_INVALID_REQUEST, "No wallet found"); + + HdAccount account = this.walletManager.GetOrCreateWatchOnlyAccount(walletName); + + if (account == null) + throw new RPCServerException(RPCErrorCode.RPC_INVALID_REQUEST, "Unable to retrieve watch only account"); + + return new WalletAccountReference(walletName, account.Name); + } } } diff --git a/src/Stratis.Bitcoin.IntegrationTests/RPC/RPCTestsMutable.cs b/src/Stratis.Bitcoin.IntegrationTests/RPC/RPCTestsMutable.cs index 4d0caefdfb..21967c16cc 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/RPC/RPCTestsMutable.cs +++ b/src/Stratis.Bitcoin.IntegrationTests/RPC/RPCTestsMutable.cs @@ -8,7 +8,9 @@ using NBitcoin.DataEncoders; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using Stratis.Bitcoin.Base; using Stratis.Bitcoin.Features.RPC; +using Stratis.Bitcoin.Features.Wallet; using Stratis.Bitcoin.IntegrationTests.Common; using Stratis.Bitcoin.IntegrationTests.Common.EnvironmentMockUpHelpers; using Stratis.Bitcoin.IntegrationTests.Common.ReadyData; @@ -61,6 +63,48 @@ public void TestRpcGetTransactionIsSuccessful() } } + [Fact] + public void TestRpcImportPubkeyIsSuccessful() + { + using (NodeBuilder builder = NodeBuilder.Create(this)) + { + CoreNode node = builder.CreateStratisPowNode(new BitcoinRegTest()).AlwaysFlushBlocks().WithWallet().Start(); + CoreNode node2 = builder.CreateStratisPowNode(new BitcoinRegTest()).WithReadyBlockchainData(ReadyBlockchain.BitcoinRegTest10Miner).Start(); + + TestHelper.ConnectAndSync(node, node2); + + UnspentOutputReference tx = node2.FullNode.WalletManager().GetUnspentTransactionsInWallet("mywallet", 0, Features.Wallet.Wallet.NormalAccounts).First(); + + RPCClient rpc = node.CreateRPCClient(); + + PubKey pubKey = PayToPubkeyTemplate.Instance.ExtractScriptPubKeyParameters(tx.Address.Pubkey); + + Assert.Throws(() => rpc.SendCommand(RPCOperations.gettransaction, tx.Transaction.Id.ToString(), true)); + + rpc.ImportPubKey(pubKey.ToHex()); + + TestBase.WaitLoop(() => node.FullNode.WalletManager().WalletTipHeight == node2.FullNode.WalletManager().WalletTipHeight); + + TestBase.WaitLoop(() => + { + try + { + // Check if gettransaction can now find the transaction in the watch only account. + RPCResponse walletTx = rpc.SendCommand(RPCOperations.gettransaction, tx.Transaction.Id.ToString(), true); + + return walletTx != null; + } + catch (RPCException e) + { + return false; + } + }); + + // Check that when include_watchonly is not set, the watched transaction cannot be located in the normal wallet accounts. + Assert.Throws(() => rpc.SendCommand(RPCOperations.gettransaction, tx.Transaction.Id.ToString(), false)); + } + } + [Fact] public void TestRpcGetBlockWithValidHashIsSuccessful() { diff --git a/src/Stratis.Features.SQLiteWalletRepository/External/ITransactionsToLists.cs b/src/Stratis.Features.SQLiteWalletRepository/External/ITransactionsToLists.cs index 77d00f8695..4213121851 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/External/ITransactionsToLists.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/External/ITransactionsToLists.cs @@ -152,7 +152,8 @@ public bool ProcessTransactions(IEnumerable transactions, HashHeigh { // This tests the converse. // Don't allow special-purpose accounts (e.g. coldstaking) to be used like normal accounts. - if (address.AccountIndex >= Wallet.SpecialPurposeAccountIndexesStart) + // However, for the purposes of recording transactions to watch-only accounts we need to make an allowance. + if (address.AccountIndex >= Wallet.SpecialPurposeAccountIndexesStart && address.AccountIndex != Wallet.WatchOnlyAccountIndex) continue; } diff --git a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs index 851a1c5c08..51169fefd6 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs @@ -1574,11 +1574,23 @@ public IEnumerable GetTransactionOutputs(HdAccount hdAccount, D if (!addressDict.TryGetValue(addressIdentifier, out HdAddress hdAddress)) { - ExtPubKey extPubKey = ExtPubKey.Parse(hdAccount.ExtendedPubKey, this.Network); + string pubKeyHex = null; - var keyPath = new KeyPath($"{tranData.AddressType}/{tranData.AddressIndex}"); + if (hdAccount.ExtendedPubKey != null) + { + ExtPubKey extPubKey = ExtPubKey.Parse(hdAccount.ExtendedPubKey, this.Network); - PubKey pubKey = extPubKey.Derive(keyPath).PubKey; + var keyPath = new KeyPath($"{tranData.AddressType}/{tranData.AddressIndex}"); + + PubKey pubKey = extPubKey.Derive(keyPath).PubKey; + + pubKeyHex = pubKey.ScriptPubKey.ToHex(); + } + else + { + // If it is a watch only account we have limited information available. + pubKeyHex = addressIdentifier.PubKeyScript; + } hdAddress = this.ToHdAddress(new HDAddress() { @@ -1587,7 +1599,7 @@ public IEnumerable GetTransactionOutputs(HdAccount hdAccount, D AddressType = (int)addressIdentifier.AddressType, AddressIndex = (int)addressIdentifier.AddressIndex, ScriptPubKey = addressIdentifier.ScriptPubKey, - PubKey = pubKey.ScriptPubKey.ToHex(), + PubKey = pubKeyHex, Address = tranData.Address }, this.Network); From fe1c6fb8be9cc56f0dafd430a6e5ea064f32b3b7 Mon Sep 17 00:00:00 2001 From: quantumagi Date: Mon, 30 Nov 2020 18:48:45 +1100 Subject: [PATCH 03/55] Fix console mining slots (#232) * Fix console mining slots * Refactor * Make own mining slot more visible * More characters * Fix console message * Add no mining information message --- src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs | 57 ++++++++++++-------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs b/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs index 80450f1a1e..956382000d 100644 --- a/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs +++ b/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs @@ -403,44 +403,59 @@ private void AddComponentStats(StringBuilder log) log.AppendLine(); log.AppendLine("======PoA Miner======"); + if (this.ibdState.IsInitialBlockDownload()) + { + log.AppendLine($"Mining information is not available during IBD."); + log.AppendLine(); + return; + } + ChainedHeader tip = this.consensusManager.Tip; ChainedHeader currentHeader = tip; - uint currentTime = currentHeader.Header.Time; - int pubKeyTakeCharacters = 4; - int depthReached = 0; + int pubKeyTakeCharacters = 5; int hitCount = 0; List modifiedFederation = this.votingManager?.GetModifiedFederation(currentHeader) ?? this.federationManager.GetFederationMembers(); + int maxDepth = modifiedFederation.Count; - log.AppendLine($"Mining information for the last {maxDepth} blocks."); - log.AppendLine("MISS means that miner didn't produce a block at the timestamp he was supposed to."); + log.AppendLine($"Mining information for the last { maxDepth } blocks."); + log.AppendLine("Note that '<' and '>' surrounds a slot where a miner didn't produce a block."); + + uint timeHeader = (uint)this.dateTimeProvider.GetAdjustedTimeAsUnixTimestamp(); + timeHeader -= timeHeader % this.network.ConsensusOptions.TargetSpacingSeconds; + if (timeHeader < currentHeader.Header.Time) + timeHeader += this.network.ConsensusOptions.TargetSpacingSeconds; - for (int i = tip.Height; (i > 0) && (i > tip.Height - maxDepth); i--) + // Iterate mining slots. + for (int i = 0; i < maxDepth; i++) { - // Add stats for current header. - string pubKeyRepresentation = this.slotsManager.GetFederationMemberForTimestamp(currentHeader.Header.Time, modifiedFederation).PubKey.ToString().Substring(0, pubKeyTakeCharacters); + int headerSlot = (int)(timeHeader / this.network.ConsensusOptions.TargetSpacingSeconds) % modifiedFederation.Count; - log.Append("[" + pubKeyRepresentation + "]-"); - depthReached++; - hitCount++; + PubKey pubKey = modifiedFederation[headerSlot].PubKey; - currentHeader = currentHeader.Previous; - currentTime -= this.network.ConsensusOptions.TargetSpacingSeconds; + string pubKeyRepresentation = (pubKey == this.federationManager.CurrentFederationKey?.PubKey) ? "█████" : pubKey.ToString().Substring(0, pubKeyTakeCharacters); - if (currentHeader.Height == 0) - break; + // Mined in this slot? + if (timeHeader == currentHeader.Header.Time) + { + log.Append($"[{ pubKeyRepresentation }] "); + + currentHeader = currentHeader.Previous; + hitCount++; - while ((currentHeader.Header.Time != currentTime) && (depthReached <= maxDepth)) + modifiedFederation = this.votingManager?.GetModifiedFederation(currentHeader) ?? this.federationManager.GetFederationMembers(); + } + else { - log.Append("MISS-"); - currentTime -= this.network.ConsensusOptions.TargetSpacingSeconds; - depthReached++; + log.Append($"<{ pubKeyRepresentation }> "); } - if (depthReached >= maxDepth) - break; + timeHeader -= this.network.ConsensusOptions.TargetSpacingSeconds; + + if ((i % 20) == 19) + log.AppendLine(); } log.Append("..."); From 67734e4589add1cee1840dfca22b75e936a868c0 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 30 Nov 2020 07:55:58 +0000 Subject: [PATCH 04/55] Update ApiSteps.cs (#237) --- .../API/ApiSteps.cs | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/Stratis.Bitcoin.IntegrationTests/API/ApiSteps.cs b/src/Stratis.Bitcoin.IntegrationTests/API/ApiSteps.cs index ca1a2a5367..401e6a1656 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/API/ApiSteps.cs +++ b/src/Stratis.Bitcoin.IntegrationTests/API/ApiSteps.cs @@ -419,44 +419,7 @@ private void a_full_list_of_available_commands_is_returned() { var commands = JsonDataSerializer.Instance.Deserialize>(this.responseText); - commands.Count.Should().Be(36); - commands.Should().Contain(x => x.Command == "stop"); - commands.Should().Contain(x => x.Command == "getrawtransaction [] []"); - commands.Should().Contain(x => x.Command == "gettxout []"); - commands.Should().Contain(x => x.Command == "gettxoutproof []"); - commands.Should().Contain(x => x.Command == "getblockcount"); - commands.Should().Contain(x => x.Command == "getinfo"); - commands.Should().Contain(x => x.Command == "getblockheader []"); - commands.Should().Contain(x => x.Command == "validateaddress
"); - commands.Should().Contain(x => x.Command == "addnode "); - commands.Should().Contain(x => x.Command == "getpeerinfo"); - commands.Should().Contain(x => x.Command == "getbestblockhash"); - commands.Should().Contain(x => x.Command == "getblockhash "); - commands.Should().Contain(x => x.Command == "getrawmempool"); - commands.Should().Contain(x => x.Command == "setwallet "); - commands.Should().Contain(x => x.Command == "generate "); - commands.Should().Contain(x => x.Command == "generatetoaddress
"); - commands.Should().Contain(x => x.Command == "stopstaking"); - commands.Should().Contain(x => x.Command == "startstaking "); - commands.Should().Contain(x => x.Command == "getstakinginfo []"); - commands.Should().Contain(x => x.Command == "sendtoaddress
"); - commands.Should().Contain(x => x.Command == "getnewaddress "); - commands.Should().Contain(x => x.Command == "getbalance []"); - commands.Should().Contain(x => x.Command == "gettransaction "); - commands.Should().Contain(x => x.Command == "fundrawtransaction [] []"); - commands.Should().Contain(x => x.Command == "signrawtransaction "); - commands.Should().Contain(x => x.Command == "sendrawtransaction "); - commands.Should().Contain(x => x.Command == "decoderawtransaction "); - commands.Should().Contain(x => x.Command == "getblock []"); - commands.Should().Contain(x => x.Command == "walletlock"); - commands.Should().Contain(x => x.Command == "walletpassphrase "); - commands.Should().Contain(x => x.Command == "listunspent [] [] []"); - commands.Should().Contain(x => x.Command == "sendmany [] [] [] [] [] []"); - commands.Should().Contain(x => x.Command == "getwalletinfo"); - commands.Should().Contain(x => x.Command == "getblockchaininfo"); - commands.Should().Contain(x => x.Command == "getnetworkinfo"); - commands.Should().Contain(x => x.Command == "listaddressgroupings"); - // TODO: Some are missing from this list + commands.Count.Should().Be(37); } private void status_information_is_returned() From a5fe54a1ee942593c6221b04682083fc9abf8824 Mon Sep 17 00:00:00 2001 From: zeptin Date: Mon, 30 Nov 2020 13:03:53 +0000 Subject: [PATCH 05/55] Add consolidate endpoint and adjust subtractfee logic (#235) * Add consolidate endpoint and adjust subtractfee logic * Fix and augment tests * Update src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs --- src/NBitcoin/TransactionBuilder.cs | 4 +- .../SmartContractWalletTransactionHandler.cs | 3 +- .../WalletTransactionHandlerTest.cs | 135 +++++++++++++++++- .../Controllers/WalletController.cs | 9 ++ .../Interfaces/IWalletTransactionHandler.cs | 2 + .../Models/RequestModels.cs | 39 +++++ .../Services/IWalletService.cs | 3 + .../Services/WalletService.cs | 95 ++++++++++++ .../WalletTransactionHandler.cs | 43 +++++- 9 files changed, 322 insertions(+), 11 deletions(-) diff --git a/src/NBitcoin/TransactionBuilder.cs b/src/NBitcoin/TransactionBuilder.cs index 5d1506d0cd..f7bd466f7a 100644 --- a/src/NBitcoin/TransactionBuilder.cs +++ b/src/NBitcoin/TransactionBuilder.cs @@ -1545,7 +1545,7 @@ public ICoin[] FindSpentCoins(Transaction tx) /// Estimate the physical size of the transaction /// /// The transaction to be estimated - /// + /// The estimated size of the transaction in bytes. public int EstimateSize(Transaction tx) { return EstimateSize(tx, false); @@ -1617,7 +1617,7 @@ private void EstimateScriptSigSize(ICoin coin, ref int witSize, ref int baseSize } if (scriptSigSize == -1) - scriptSigSize += coin.TxOut.ScriptPubKey.Length; //Using heurestic to approximate size of unknown scriptPubKey + scriptSigSize += coin.TxOut.ScriptPubKey.Length; //Using heuristic to approximate size of unknown scriptPubKey if (coin.GetHashVersion(this.Network) == HashVersion.Witness) witSize += scriptSigSize + 1; //Account for the push diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Wallet/SmartContractWalletTransactionHandler.cs b/src/Stratis.Bitcoin.Features.SmartContracts/Wallet/SmartContractWalletTransactionHandler.cs index fee317ffd6..414ed73b6f 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Wallet/SmartContractWalletTransactionHandler.cs +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Wallet/SmartContractWalletTransactionHandler.cs @@ -57,8 +57,9 @@ protected override void AddRecipients(TransactionBuildContext context) if (context.Recipients.Any(recipient => recipient.Amount == Money.Zero && !recipient.ScriptPubKey.IsSmartContractExec())) throw new WalletException("No amount specified."); + // TODO: Port the necessary logic from the regular wallet transaction handler if (context.Recipients.Any(a => a.SubtractFeeFromAmount)) - throw new NotImplementedException("Substracting the fee from the recipient is not supported yet."); + throw new NotImplementedException("Subtracting the fee from the recipient is not supported yet."); foreach (Recipient recipient in context.Recipients) context.TransactionBuilder.Send(recipient.ScriptPubKey, recipient.Amount); diff --git a/src/Stratis.Bitcoin.Features.Wallet.Tests/WalletTransactionHandlerTest.cs b/src/Stratis.Bitcoin.Features.Wallet.Tests/WalletTransactionHandlerTest.cs index 5d3e2dfd2c..112ba5a6ab 100644 --- a/src/Stratis.Bitcoin.Features.Wallet.Tests/WalletTransactionHandlerTest.cs +++ b/src/Stratis.Bitcoin.Features.Wallet.Tests/WalletTransactionHandlerTest.cs @@ -620,7 +620,7 @@ public void When_BuildTransactionIsCalled_Then_FeeIsDeductedFromAmountsInTransac { AccountReference = walletReference, MinConfirmations = 0, - FeeType = FeeType.Low, + TransactionFee = Money.Coins(0.0001m), WalletPassword = "password", Recipients = new[] { @@ -636,6 +636,139 @@ public void When_BuildTransactionIsCalled_Then_FeeIsDeductedFromAmountsInTransac Assert.True(transaction.Outputs.Count(i => i.Value.Satoshi < 5_000_000_000) == 2); // 2 outputs should have fees taken from the amount } + [Fact] + public void When_BuildTransactionIsCalledWithoutTransactionFee_Then_FeeIsDeductedFromSingleOutputInTransaction() + { + DataFolder dataFolder = CreateDataFolder(this); + + IWalletRepository walletRepository = new SQLiteWalletRepository(this.LoggerFactory.Object, dataFolder, this.Network, DateTimeProvider.Default, new ScriptAddressReader()) + { + TestMode = true + }; + + var walletFeePolicy = new Mock(); + walletFeePolicy.Setup(w => w.GetFeeRate(FeeType.Low.ToConfirmations())).Returns(new FeeRate(20000)); + + var walletManager = new WalletManager(this.LoggerFactory.Object, this.Network, new ChainIndexer(this.Network), new WalletSettings(NodeSettings.Default(this.Network)), + dataFolder, walletFeePolicy.Object, new Mock().Object, new NodeLifetime(), DateTimeProvider.Default, this.scriptAddressReader, walletRepository); + + walletManager.Start(); + + var reserveUtxoService = new ReserveUtxoService(this.loggerFactory, new Mock().Object); + + var walletTransactionHandler = new WalletTransactionHandler(this.LoggerFactory.Object, walletManager, walletFeePolicy.Object, this.Network, this.standardTransactionPolicy, reserveUtxoService); + + (Wallet wallet, ExtKey extKey) = WalletTestsHelpers.GenerateBlankWalletWithExtKey("myWallet1", "password", walletRepository); + + walletManager.Wallets.Add(wallet); + + int accountIndex = 0; + ExtKey addressExtKey = extKey.Derive(new KeyPath($"m/44'/{this.Network.Consensus.CoinType}'/{accountIndex}'")); + ExtPubKey extPubKey = addressExtKey.Neuter(); + + HdAccount account = wallet.AddNewAccount(extPubKey, accountName: "account1"); + + var address = account.ExternalAddresses.First(); + var destination = account.InternalAddresses.First(); + var destination2 = account.InternalAddresses.Skip(1).First(); + var destination3 = account.InternalAddresses.Skip(2).First(); + + // Wallet with 4 coinbase outputs of 50 = 200. + var chain = new ChainIndexer(wallet.Network); + WalletTestsHelpers.AddBlocksWithCoinbaseToChain(wallet.Network, chain, address, 4); + + var walletReference = new WalletAccountReference + { + AccountName = "account1", + WalletName = "myWallet1" + }; + + // Create a transaction with 3 outputs 50 + 50 + 50 = 150 but with fees charged to recipients. + var context = new TransactionBuildContext(this.Network) + { + AccountReference = walletReference, + MinConfirmations = 0, + FeeType = FeeType.Low, + WalletPassword = "password", + Recipients = new[] + { + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination.ScriptPubKey, SubtractFeeFromAmount = true }, + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination2.ScriptPubKey, SubtractFeeFromAmount = false }, + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination3.ScriptPubKey, SubtractFeeFromAmount = false } + }.ToList() + }; + + Transaction transaction = walletTransactionHandler.BuildTransaction(context); + Assert.Equal(3, transaction.Inputs.Count); // 3 inputs + Assert.Equal(3, transaction.Outputs.Count); // 3 outputs with change + Assert.True(transaction.Outputs.Count(i => i.Value.Satoshi < 5_000_000_000) == 1); // 1 output should have fees taken from the amount + } + + [Fact] + public void When_BuildTransactionIsCalledWithoutTransactionFee_Then_MultipleSubtractFeeRecipients_ThrowsException() + { + DataFolder dataFolder = CreateDataFolder(this); + + IWalletRepository walletRepository = new SQLiteWalletRepository(this.LoggerFactory.Object, dataFolder, this.Network, DateTimeProvider.Default, new ScriptAddressReader()) + { + TestMode = true + }; + + var walletFeePolicy = new Mock(); + walletFeePolicy.Setup(w => w.GetFeeRate(FeeType.Low.ToConfirmations())).Returns(new FeeRate(20000)); + + var walletManager = new WalletManager(this.LoggerFactory.Object, this.Network, new ChainIndexer(this.Network), new WalletSettings(NodeSettings.Default(this.Network)), + dataFolder, walletFeePolicy.Object, new Mock().Object, new NodeLifetime(), DateTimeProvider.Default, this.scriptAddressReader, walletRepository); + + walletManager.Start(); + + var reserveUtxoService = new ReserveUtxoService(this.loggerFactory, new Mock().Object); + + var walletTransactionHandler = new WalletTransactionHandler(this.LoggerFactory.Object, walletManager, walletFeePolicy.Object, this.Network, this.standardTransactionPolicy, reserveUtxoService); + + (Wallet wallet, ExtKey extKey) = WalletTestsHelpers.GenerateBlankWalletWithExtKey("myWallet1", "password", walletRepository); + + walletManager.Wallets.Add(wallet); + + int accountIndex = 0; + ExtKey addressExtKey = extKey.Derive(new KeyPath($"m/44'/{this.Network.Consensus.CoinType}'/{accountIndex}'")); + ExtPubKey extPubKey = addressExtKey.Neuter(); + + HdAccount account = wallet.AddNewAccount(extPubKey, accountName: "account1"); + + var address = account.ExternalAddresses.First(); + var destination = account.InternalAddresses.First(); + var destination2 = account.InternalAddresses.Skip(1).First(); + var destination3 = account.InternalAddresses.Skip(2).First(); + + // Wallet with 4 coinbase outputs of 50 = 200. + var chain = new ChainIndexer(wallet.Network); + WalletTestsHelpers.AddBlocksWithCoinbaseToChain(wallet.Network, chain, address, 4); + + var walletReference = new WalletAccountReference + { + AccountName = "account1", + WalletName = "myWallet1" + }; + + // Create a transaction with 3 outputs 50 + 50 + 50 = 150 but with fees charged to recipients. + var context = new TransactionBuildContext(this.Network) + { + AccountReference = walletReference, + MinConfirmations = 0, + FeeType = FeeType.Low, + WalletPassword = "password", + Recipients = new[] + { + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination.ScriptPubKey, SubtractFeeFromAmount = true }, + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination2.ScriptPubKey, SubtractFeeFromAmount = true }, + new Recipient { Amount = new Money(50, MoneyUnit.BTC), ScriptPubKey = destination3.ScriptPubKey, SubtractFeeFromAmount = false } + }.ToList() + }; + + Assert.Throws(() => walletTransactionHandler.BuildTransaction(context)); + } + public static TransactionBuildContext CreateContext(Network network, WalletAccountReference accountReference, string password, Script destinationScript, Money amount, FeeType feeType, int minConfirmations, string opReturnData = null, List recipients = null) { diff --git a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs index 8692ef5848..3a71fb5455 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletController.cs @@ -829,6 +829,15 @@ public async Task OfflineSignRequest([FromBody] OfflineSignReques return await this.Execute(request, cancellationToken, async (req, token) => this.Json(await this.walletService.OfflineSignRequest(req, token))); } + [HttpPost] + [Route("consolidate")] + public async Task Consolidate([FromBody] ConsolidationRequest request, + CancellationToken cancellationToken = default(CancellationToken)) + { + return await this.Execute(request, cancellationToken, + async (req, token) => this.Json(await this.walletService.Consolidate(req, token))); + } + private TransactionItemModel FindSimilarReceivedTransactionOutput(List items, TransactionData transaction) { diff --git a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletTransactionHandler.cs b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletTransactionHandler.cs index fd3d45b30a..2abd265982 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletTransactionHandler.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletTransactionHandler.cs @@ -40,5 +40,7 @@ public interface IWalletTransactionHandler /// The context that is used to build a new transaction. /// The estimated fee. Money EstimateFee(TransactionBuildContext context); + + int EstimateSize(TransactionBuildContext context); } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs b/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs index cc64891e62..2869060eb5 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs @@ -989,4 +989,43 @@ public class SweepRequest : RequestModel public bool Broadcast { get; set; } } + + public sealed class ConsolidationRequest : RequestModel + { + public ConsolidationRequest() + { + this.AccountName = WalletManager.DefaultAccount; + } + + [Required(ErrorMessage = "The name of the wallet is missing.")] + public string WalletName { get; set; } + + /// + /// The account from which UTXOs should be consolidated. + /// If this is not set the default account of the selected wallet will be used. + /// + public string AccountName { get; set; } + + [Required(ErrorMessage = "A password is required.")] + public string WalletPassword { get; set; } + + /// + /// If this is set, only UTXOs within this wallet address will be consolidated. + /// If it is not set, all the UTXOs within the selected account will be consolidated. + /// + public string SingleAddress { get; set; } + + /// + /// Which address the UTXOs should be sent to. It does not have to be within the wallet. + /// If it is not provided the UTXOs will be consolidated to an unused address within the specified wallet. + /// + public string DestinationAddress { get; set; } + + /// + /// If provided, UTXOs that are larger in value will not be consolidated. + /// Dust UTXOs will not be consolidated regardless of their value, so there is an implicit lower bound as well. + /// + [MoneyFormat(isRequired: false, ErrorMessage = "The amount is not in the correct format.")] + public string UtxoValueThreshold { get; set; } + } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Services/IWalletService.cs b/src/Stratis.Bitcoin.Features.Wallet/Services/IWalletService.cs index 4b689f4f23..90a50682da 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Services/IWalletService.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Services/IWalletService.cs @@ -59,5 +59,8 @@ Task BuildOfflineSignRequest(BuildOfflineSignRequest r Task OfflineSignRequest(OfflineSignRequest request, CancellationToken cancellationToken); + + Task Consolidate(ConsolidationRequest request, + CancellationToken cancellationToken); } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs index b9e8fa7a17..276af61df5 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs @@ -1382,6 +1382,101 @@ public async Task OfflineSignRequest(OfflineSignReq }, cancellationToken); } + public async Task Consolidate(ConsolidationRequest request, CancellationToken cancellationToken) + { + return await Task.Run(() => + { + var utxos = new List(); + var accountReference = new WalletAccountReference(request.WalletName, request.AccountName); + + if (!string.IsNullOrWhiteSpace(request.SingleAddress)) + { + utxos = this.walletManager.GetSpendableTransactionsInWallet(request.WalletName).Where(u => u.Address.Address == request.SingleAddress || u.Address.Address == request.SingleAddress).OrderBy(u2 => u2.Transaction.Amount).ToList(); + } + else + { + utxos = this.walletManager.GetSpendableTransactionsInAccount(accountReference).OrderBy(u2 => u2.Transaction.Amount).ToList(); + } + + if (utxos.Count == 0) + { + throw new FeatureException(HttpStatusCode.BadRequest, "Failed to locate any unspent outputs to consolidate.", + "Failed to locate any unspent outputs to consolidate."); + } + + if (utxos.Count == 1) + { + throw new FeatureException(HttpStatusCode.BadRequest, "Already consolidated.", + "Already consolidated."); + } + + + if (!string.IsNullOrWhiteSpace(request.UtxoValueThreshold)) + { + var threshold = Money.Parse(request.UtxoValueThreshold); + + utxos = utxos.Where(u => u.Transaction.Amount <= threshold).ToList(); + } + + Script destination; + if (!string.IsNullOrWhiteSpace(request.DestinationAddress)) + { + destination = BitcoinAddress.Create(request.DestinationAddress, this.network).ScriptPubKey; + } + else + { + destination = this.walletManager.GetUnusedAddress(accountReference).ScriptPubKey; + } + + Money totalToSend = Money.Zero; + var outpoints = new List(); + + TransactionBuildContext context = null; + + foreach (var utxo in utxos) + { + totalToSend += utxo.Transaction.Amount; + outpoints.Add(utxo.ToOutPoint()); + + context = new TransactionBuildContext(this.network) + { + AccountReference = accountReference, + AllowOtherInputs = false, + FeeType = FeeType.Medium, + // It is intended that consolidation should result in no change address, so the fee has to be subtracted from the single recipient. + Recipients = new List() { new Recipient() { ScriptPubKey = destination, Amount = totalToSend, SubtractFeeFromAmount = true } }, + SelectedInputs = outpoints, + + Sign = false + }; + + // Note that this is the virtual size taking the witness scale factor of the current network into account, and not the raw byte count. + int size = this.walletTransactionHandler.EstimateSize(context); + + // Leave a bit of an error margin for size estimates that are not completely correct. + if (size > (0.95m * this.network.Consensus.Options.MaxStandardTxWeight)) + break; + } + + // Build the final version of the consolidation transaction. + context = new TransactionBuildContext(this.network) + { + AccountReference = accountReference, + AllowOtherInputs = false, + FeeType = FeeType.Medium, + Recipients = new List() { new Recipient() { ScriptPubKey = destination, Amount = totalToSend, SubtractFeeFromAmount = true } }, + SelectedInputs = outpoints, + WalletPassword = request.WalletPassword, + + Sign = true + }; + + Transaction transaction = this.walletTransactionHandler.BuildTransaction(context); + + return transaction.ToHex(); + }, cancellationToken); + } + private TransactionItemModel FindSimilarReceivedTransactionOutput(List items, TransactionData transaction) { diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletTransactionHandler.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletTransactionHandler.cs index 8b77ab3c22..112736a284 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletTransactionHandler.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletTransactionHandler.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using NBitcoin; using NBitcoin.Policy; -using Stratis.Bitcoin.Features.Wallet; using Stratis.Bitcoin.Features.Wallet.Interfaces; using Stratis.Bitcoin.Features.Wallet.Services; using Stratis.Bitcoin.Utilities; @@ -216,6 +215,15 @@ public Money EstimateFee(TransactionBuildContext context) return context.TransactionFee; } + public int EstimateSize(TransactionBuildContext context) + { + this.InitializeTransactionBuilder(context); + + Transaction transaction = context.TransactionBuilder.BuildTransaction(false); + + return context.TransactionBuilder.EstimateSize(transaction, true); + } + /// /// Initializes the context transaction builder from information in . /// @@ -403,16 +411,27 @@ protected virtual void AddRecipients(TransactionBuildContext context) if (context.Recipients.Any(a => a.Amount == Money.Zero)) throw new WalletException("No amount specified."); - int totalRecipients = context.Recipients.Count(r => r.SubtractFeeFromAmount); + int totalSubtractingRecipients = context.Recipients.Count(r => r.SubtractFeeFromAmount); - // If we have any recipients that require a fee to be subtracted from the amount, then - // calculate fee and evenly distribute it among all recipients. Any remaining fee should be + // If none of them need the fee subtracted then it's simply a matter of adding the individual recipients to the builder. + if (totalSubtractingRecipients == 0) + { + foreach (Recipient recipient in context.Recipients) + { + context.TransactionBuilder.Send(recipient.ScriptPubKey, recipient.Amount); + } + + return; + } + + // If the transaction fee has been explicitly specified, and we have any recipients that require a fee to be subtracted + // from the amount to be sent, then evenly distribute the chosen fee among all recipients. Any remaining fee should be // subtracted from the first recipient. - if (totalRecipients > 0 && context.TransactionFee != null) + if (context.TransactionFee != null) { Money fee = context.TransactionFee; - long recipientFee = fee.Satoshi / totalRecipients; - long remainingFee = fee.Satoshi % totalRecipients; + long recipientFee = fee.Satoshi / totalSubtractingRecipients; + long remainingFee = fee.Satoshi % totalSubtractingRecipients; for (int i = 0; i < context.Recipients.Count; i++) { @@ -434,9 +453,19 @@ protected virtual void AddRecipients(TransactionBuildContext context) } else { + // This is currently a limitation of the NBitcoin TransactionBuilder. + // The only alternative would possibly be to recompute the output sizes after the AddFee call. + if (totalSubtractingRecipients > 1) + throw new WalletException($"Cannot subtract fee from more than 1 recipient if {nameof(context.TransactionFee)} is not set."); + + // If the transaction fee has not been explicitly specified yet, then the builder needs to assign it later from the wallet fee policy. + // So we just need to indicate to the builder that the fees must be subtracted from the specified recipient. foreach (Recipient recipient in context.Recipients) { context.TransactionBuilder.Send(recipient.ScriptPubKey, recipient.Amount); + + if (recipient.SubtractFeeFromAmount) + context.TransactionBuilder.SubtractFees(); } } } From 212bf6ad4e2a41008916b3d2aea0b0c1054f3002 Mon Sep 17 00:00:00 2001 From: quantumagi Date: Tue, 1 Dec 2020 00:23:13 +1100 Subject: [PATCH 06/55] Add Bech32Address if not present (#238) * Add Bech32Address if not present * Refactor * Change Update to InsertOrReplace --- .../Interfaces/IWalletRepository.cs | 2 ++ .../WalletManager.cs | 11 +++++++ .../DBConnection.cs | 2 +- .../SQLiteWalletRepository.cs | 2 ++ .../Tables/HDAddress.cs | 29 +++++++++++++++---- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletRepository.cs b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletRepository.cs index 9ea86f35a1..80f02a8898 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletRepository.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Interfaces/IWalletRepository.cs @@ -356,5 +356,7 @@ public interface IWalletRepository /// The Account Name to Query /// The Transaction Count int GetTransactionCount(string walletName, string accountName = null); + + Func Bech32AddressFunc { get; set; } } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs index 271c1ca3b3..1739d8d4a3 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs @@ -242,6 +242,17 @@ public void Start() { this.logger.LogInformation("Wallet Manager starting..."); + this.WalletRepository.Bech32AddressFunc = scriptPubKey => + { + if (string.IsNullOrEmpty(scriptPubKey)) + return string.Empty; + + var pubKey = PayToPubkeyTemplate.Instance.ExtractScriptPubKeyParameters(Script.FromHex(scriptPubKey)); + Script witScriptPubKey = PayToWitPubKeyHashTemplate.Instance.GenerateScriptPubKey(pubKey); + + return witScriptPubKey.GetDestinationAddress(this.network).ToString(); + }; + this.WalletRepository.Initialize(false); // Ensure that any legacy JSON wallets are loaded to active storage. diff --git a/src/Stratis.Features.SQLiteWalletRepository/DBConnection.cs b/src/Stratis.Features.SQLiteWalletRepository/DBConnection.cs index 9e3351957b..60ea9d7ea2 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/DBConnection.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/DBConnection.cs @@ -383,7 +383,7 @@ internal void CreateTable() else { if (typeof(T) == typeof(HDAddress)) - HDAddress.MigrateTable(this); + HDAddress.MigrateTable(this, this.Repository.Bech32AddressFunc); else if (typeof(T) == typeof(HDPayment)) HDPayment.MigrateTable(this); } diff --git a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs index 51169fefd6..f948353f8c 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs @@ -66,6 +66,8 @@ internal string DBPath // Metrics. internal Metrics Metrics; + public Func Bech32AddressFunc { get; set; } = null; + public SQLiteWalletRepository(ILoggerFactory loggerFactory, DataFolder dataFolder, Network network, IDateTimeProvider dateTimeProvider, IScriptAddressReader scriptAddressReader) { this.TestMode = false; diff --git a/src/Stratis.Features.SQLiteWalletRepository/Tables/HDAddress.cs b/src/Stratis.Features.SQLiteWalletRepository/Tables/HDAddress.cs index c465502895..3da0106133 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Tables/HDAddress.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/Tables/HDAddress.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using SQLite; @@ -46,7 +47,7 @@ PRIMARY KEY(WalletId, AccountIndex, AddressType, AddressIndex) yield return "CREATE UNIQUE INDEX UX_HDAddress_PubKey ON HDAddress(WalletId, PubKey)"; } - internal static IEnumerable MigrateScript() + internal static IEnumerable MigrateScript(bool hasBech32Address) { yield return $@" PRAGMA foreign_keys=off; @@ -56,7 +57,7 @@ internal static IEnumerable MigrateScript() // TODO: Copy the data. yield return $@" - INSERT INTO new_HDAddress SELECT WalletId, AccountIndex, AddressType, AddressIndex, ScriptPubKey, PubKey, Address, Bech32Address FROM HDAddress; + INSERT INTO new_HDAddress SELECT WalletId, AccountIndex, AddressType, AddressIndex, ScriptPubKey, PubKey, Address, { (hasBech32Address ? "Bech32Address" : "''") } FROM HDAddress; "; yield return $@" @@ -81,11 +82,27 @@ internal static void CreateTable(SQLiteConnection conn) conn.Execute(command); } - internal static void MigrateTable(SQLiteConnection conn) + internal static void MigrateTable(SQLiteConnection conn, Func bech32AddressFunc) { - if (conn.ExecuteScalar("SELECT COUNT(*) AS CNTREC FROM pragma_table_info('HDAddress') WHERE name='Bech32ScriptPubKey'") != 0) - foreach (string command in MigrateScript()) + bool hasBech32Address = conn.ExecuteScalar("SELECT COUNT(*) AS CNTREC FROM pragma_table_info('HDAddress') WHERE name='Bech32Address'") != 0; + bool hasBech32ScriptPubKey = conn.ExecuteScalar("SELECT COUNT(*) AS CNTREC FROM pragma_table_info('HDAddress') WHERE name='Bech32ScriptPubKey'") != 0; + + if (hasBech32ScriptPubKey || !hasBech32Address) + foreach (string command in MigrateScript(hasBech32Address)) conn.Execute(command); + + if (bech32AddressFunc != null) + { + List addresses = conn.Query($@"SELECT * FROM HDAddress WHERE Bech32Address = ''"); + if (addresses.Any()) + { + foreach (HDAddress address in addresses) + { + address.Bech32Address = bech32AddressFunc(address.PubKey); + conn.InsertOrReplace(address); + } + } + } } internal static IEnumerable GetAccountAddresses(SQLiteConnection conn, int walletId, int accountIndex, int addressType, int count) From 481190b2c67fd5ff6e0760f8abe5b026692d1f63 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 30 Nov 2020 13:53:26 +0000 Subject: [PATCH 07/55] Remove change-over code (#239) --- .../CheckCollateralFullValidationRule.cs | 54 +------------------ .../CheckCollateralFullValidationRuleTests.cs | 2 +- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/Stratis.Features.Collateral/CheckCollateralFullValidationRule.cs b/src/Stratis.Features.Collateral/CheckCollateralFullValidationRule.cs index 907f4ff4a7..2fee36d4db 100644 --- a/src/Stratis.Features.Collateral/CheckCollateralFullValidationRule.cs +++ b/src/Stratis.Features.Collateral/CheckCollateralFullValidationRule.cs @@ -1,18 +1,14 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NBitcoin; -using Stratis.Bitcoin; -using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; using Stratis.Bitcoin.Features.BlockStore.AddressIndexing; using Stratis.Bitcoin.Features.PoA; using Stratis.Bitcoin.Features.PoA.Voting; using Stratis.Bitcoin.Interfaces; using Stratis.Bitcoin.Utilities; -using Stratis.Features.Collateral.CounterChain; namespace Stratis.Features.Collateral { @@ -26,8 +22,6 @@ public class CheckCollateralFullValidationRule : FullValidationConsensusRule private readonly ISlotsManager slotsManager; - private readonly IFullNode fullNode; - private readonly IDateTimeProvider dateTime; private readonly Network network; @@ -38,13 +32,12 @@ public class CheckCollateralFullValidationRule : FullValidationConsensusRule private readonly VotingManager votingManager; public CheckCollateralFullValidationRule(IInitialBlockDownloadState ibdState, ICollateralChecker collateralChecker, - ISlotsManager slotsManager, IFullNode fullNode, IDateTimeProvider dateTime, Network network, VotingManager votingManager) + ISlotsManager slotsManager, IDateTimeProvider dateTime, Network network, VotingManager votingManager) { this.network = network; this.ibdState = ibdState; this.collateralChecker = collateralChecker; this.slotsManager = slotsManager; - this.fullNode = fullNode; this.dateTime = dateTime; this.votingManager = votingManager; @@ -70,51 +63,6 @@ public override Task RunAsync(RuleContext context) this.Logger.LogDebug("Commitment is: {0}. Magic is: {1}", commitmentHeight, commitmentNetworkMagic); - // Strategy: - // 1. I'm a Cirrus miner on STRAX. If the block's miner is also on STRAX then check the collateral. Pass or Fail as appropriate. - // 2. The block miner is on STRAT. If most nodes were on STRAT(prev round) then they will check the rule. Pass the rule. - // 3. The miner is on STRAT and most nodes were on STRAX(prev round).Fail the rule. - - // 1. If the block miner is on STRAX then skip this code and go check the collateral. - Network counterChainNetwork = this.fullNode.NodeService().CounterChainNetwork; - if (this.network.Name.StartsWith("Cirrus") && commitmentNetworkMagic != counterChainNetwork.Magic) - { - // 2. The block miner is on STRAT. - IConsensusManager consensusManager = this.fullNode.NodeService(); - int memberCount = 1; - int membersOnDifferentCounterChain = 1; - uint minimumRoundLength = this.slotsManager.GetRoundLengthSeconds() - ((PoAConsensusOptions)this.network.Consensus.Options).TargetSpacingSeconds / 2; - - // Check and any prior blocks in the same round. - foreach (ChainedHeader chainedHeader in context.ValidationContext.ChainedHeaderToValidate.EnumerateToGenesis().Skip(1)) - { - Block block = chainedHeader?.Block ?? consensusManager.GetBlockData(chainedHeader.HashBlock).Block; - if (block == null || (block.Header.Time + minimumRoundLength) < context.ValidationContext.BlockToValidate.Header.Time) - break; - - (int? commitmentHeight2, uint? magic2) = commitmentHeightEncoder.DecodeCommitmentHeight(block.Transactions.First()); - if (commitmentHeight2 == null) - continue; - - if (magic2 != counterChainNetwork.Magic) - membersOnDifferentCounterChain++; - - memberCount++; - }; - - // If most nodes were on STRAT(prev round) then they will check the rule. Pass the rule. - // This condition will execute if everyone is still on STRAT. - if (membersOnDifferentCounterChain * 2 > memberCount) - { - this.Logger.LogTrace("(-)SKIPPED_DURING_SWITCHOVER]"); - return Task.CompletedTask; - } - - // 3. The miner is on STRAT and most nodes were on STRAX(prev round). Fail the rule. - this.Logger.LogTrace("(-)[DISALLOW_STRAT_MINER]"); - PoAConsensusErrors.InvalidCollateralAmount.Throw(); - } - // TODO: Both this and CollateralPoAMiner are using this chain's MaxReorg instead of the Counter chain's MaxReorg. Beware: fixing requires fork. int counterChainHeight = this.collateralChecker.GetCounterChainConsensusHeight(); int maxReorgLength = AddressIndexer.GetMaxReorgOrFallbackMaxReorg(this.network); diff --git a/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs b/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs index 16c9286534..7c2997853d 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs @@ -76,7 +76,7 @@ public CheckCollateralFullValidationRuleTests() var consensusManager = new Mock(); fullnode.Setup(x => x.NodeService(false)).Returns(consensusManager.Object); - this.rule = new CheckCollateralFullValidationRule(this.ibdMock.Object, this.collateralCheckerMock.Object, this.slotsManagerMock.Object, fullnode.Object, new Mock().Object, new PoANetwork(), null) + this.rule = new CheckCollateralFullValidationRule(this.ibdMock.Object, this.collateralCheckerMock.Object, this.slotsManagerMock.Object, new Mock().Object, new PoANetwork(), null) { Logger = logger }; From 4d31acd85283368507d645b38ed3bdafe4d570dd Mon Sep 17 00:00:00 2001 From: quantumagi Date: Tue, 1 Dec 2020 00:54:15 +1100 Subject: [PATCH 08/55] Use header size constant for faster start-ups (#233) * Use header size constant * Remove ChainedBlocksDataBytes entirely --- src/Stratis.Bitcoin/Consensus/ChainedHeaderTree.cs | 10 ---------- src/Stratis.Bitcoin/Consensus/ConsensusManager.cs | 2 -- 2 files changed, 12 deletions(-) diff --git a/src/Stratis.Bitcoin/Consensus/ChainedHeaderTree.cs b/src/Stratis.Bitcoin/Consensus/ChainedHeaderTree.cs index 1653908c62..c7ccd2a9ae 100644 --- a/src/Stratis.Bitcoin/Consensus/ChainedHeaderTree.cs +++ b/src/Stratis.Bitcoin/Consensus/ChainedHeaderTree.cs @@ -44,9 +44,6 @@ internal interface IChainedHeaderTree /// Total amount of unconsumed blocks. long UnconsumedBlocksCount { get; } - /// Total size of ChainedHeaders data in bytes. - long ChainedBlocksDataBytes { get; } - /// /// Initialize the tree with consensus tip. /// @@ -181,9 +178,6 @@ internal class ChainedHeaderTree : IChainedHeaderTree /// public long UnconsumedBlocksCount { get; private set; } - /// - public long ChainedBlocksDataBytes { get; private set; } - /// A special peer identifier that represents our local node. internal const int LocalPeerId = -1; @@ -250,7 +244,6 @@ public void Initialize(ChainedHeader consensusTip) { current.Previous.Next.Add(current); this.chainedHeadersByHash.Add(current.HashBlock, current); - this.ChainedBlocksDataBytes += current.Header.HeaderSize; // TODO when pruned node is implemented it should be header only for pruned blocks current.BlockDataAvailability = BlockDataAvailabilityState.BlockAvailable; @@ -261,7 +254,6 @@ public void Initialize(ChainedHeader consensusTip) // Add the genesis block. this.chainedHeadersByHash.Add(current.HashBlock, current); - this.ChainedBlocksDataBytes += current.Header.HeaderSize; if (current.HashBlock != this.network.GenesisHash) { @@ -605,7 +597,6 @@ private void DisconnectChainHeader(ChainedHeader header) { header.Previous.Next.Remove(header); this.chainedHeadersByHash.Remove(header.HashBlock); - this.ChainedBlocksDataBytes -= header.Header.HeaderSize; if (header.Block != null) { @@ -1103,7 +1094,6 @@ private ChainedHeader CreateAndValidateNewChainedHeader(BlockHeader currentBlock previousChainedHeader.Next.Add(newChainedHeader); this.chainedHeadersByHash.Add(newChainedHeader.HashBlock, newChainedHeader); - this.ChainedBlocksDataBytes += newChainedHeader.Header.HeaderSize; return newChainedHeader; } diff --git a/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs b/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs index 2ddb5111fb..073ffeada6 100644 --- a/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs +++ b/src/Stratis.Bitcoin/Consensus/ConsensusManager.cs @@ -1505,8 +1505,6 @@ private void AddComponentStats(StringBuilder log) log.AppendLine($"Tip Age: { TimeSpan.FromSeconds(tipAge).ToString(@"dd\.hh\:mm\:ss") } (maximum is { TimeSpan.FromSeconds(maxTipAge).ToString(@"dd\.hh\:mm\:ss") })"); log.AppendLine($"In IBD Stage: { (this.isIbd ? "Yes" : "No") }"); - log.AppendLine($"Chained header tree size: {this.chainedHeaderTree.ChainedBlocksDataBytes.BytesToMegaBytes()} MB"); - string unconsumedBlocks = this.FormatBigNumber(this.chainedHeaderTree.UnconsumedBlocksCount); double filledPercentage = Math.Round((this.chainedHeaderTree.UnconsumedBlocksDataBytes / (double)this.maxUnconsumedBlocksDataBytes) * 100, 2); From a2d34a3e9c1299f7e0d058a29424fcce9f699ece Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 1 Dec 2020 14:13:47 +0000 Subject: [PATCH 09/55] Bump version (#242) --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- .../Stratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- .../Stratis.Bitcoin.Features.Notifications.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.Networks.csproj | 6 +++--- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 4 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Features.SQLiteWalletRepository.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 29 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index 9c379081e0..8f5845b3a9 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index 975e5f452f..44babf3f47 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 05db92b820..be5ed58e6d 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index 1f38ced005..fbf3824b3b 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.4.0 + 1.0.4.1 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index 3274f105c3..669a7e2f51 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index 93f84896fd..0dbd4ac61e 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index ac8da72a25..da59efe59f 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index 5c5420710b..4283410085 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index d060687311..84b35dece0 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 8e6f777ed0..1ca1303553 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 09689fa3a4..096994e974 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index db46cd7ed1..7f24921ed6 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index 4b1f18e88f..1e6b376481 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 43651b80b2..8ff3e3184e 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index 6a9786a3dd..68b4f20e92 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 8ff661c628..193e77dcdf 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index 873731c934..5b380fb439 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index ff5d33eaf5..fd956528cb 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index a0f8875fd3..e0782a21f2 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.4.0 - 1.0.4.0 - 1.0.4.0 + 1.0.4.1 + 1.0.4.1 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 4e999396e5..e9b51115ba 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.4.0")] -[assembly: AssemblyFileVersion("1.0.4.0")] +[assembly: AssemblyVersion("1.0.4.1")] +[assembly: AssemblyFileVersion("1.0.4.1")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 4768828220..94e01628b5 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False ..\Stratis.ruleset Stratis Group Ltd. diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index 7fc5e25941..94870f64de 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index d08f7b9b7e..4dbdd4d1ab 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.4.0 + 1.0.4.1 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 995dabbe68..4a99afab0f 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index d43020c724..8498d48c60 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index bc2d39535a..6e74ff8684 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index 6e73ab75e3..3aec7e2401 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.4.0 + 1.0.4.1 False Stratis Group Ltd. diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index 4d1bcecc5a..1e4005aaf0 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index a765d8612c..94d4ec0702 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.4.0 + 1.0.4.1 Stratis Group Ltd. From 5e8afbf3707c6651c715c8a05d430b3bb30d077b Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 1 Dec 2020 14:04:09 +0000 Subject: [PATCH 10/55] Update CreateMempoolEntryMempoolRule.cs (#241) --- .../Rules/CreateMempoolEntryMempoolRule.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Rules/CreateMempoolEntryMempoolRule.cs b/src/Stratis.Bitcoin.Features.MemoryPool/Rules/CreateMempoolEntryMempoolRule.cs index 606f194cce..d301d4e62c 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Rules/CreateMempoolEntryMempoolRule.cs +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Rules/CreateMempoolEntryMempoolRule.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.Extensions.Logging; using NBitcoin; using Stratis.Bitcoin.Base.Deployments; @@ -196,7 +197,7 @@ private bool AreInputsStandard(Network network, Transaction tx, MempoolCoinView return true; // Coinbases don't use vin normally. } - for (int i=0; i o.Code).Contains(OpcodeType.OP_FEDERATION)) { if (redeemScript.GetSigOpCount(true) > MaxP2SHSigOps) { From 531982cd5616281b54f65a91c48bc0a558d51932 Mon Sep 17 00:00:00 2001 From: StratisIain <32906542+StratisIain@users.noreply.github.com> Date: Mon, 21 Dec 2020 14:25:54 +0000 Subject: [PATCH 11/55] Update Registration Script (#320) * updateScript * addPercentage * additionalPercentages * addTimeStamp * update * fix * fix * fix * update * signed * removeTestnet * Signed --- Scripts/STRAXSidechainRegistrationScript.ps1 | 346 ++++++++++--------- 1 file changed, 189 insertions(+), 157 deletions(-) diff --git a/Scripts/STRAXSidechainRegistrationScript.ps1 b/Scripts/STRAXSidechainRegistrationScript.ps1 index 0dd83305e7..424d5856df 100644 --- a/Scripts/STRAXSidechainRegistrationScript.ps1 +++ b/Scripts/STRAXSidechainRegistrationScript.ps1 @@ -1,25 +1,26 @@ #Create Functions function Get-IndexerStatus { - $Headers = @{} - $Headers.Add("Accept","application/json") - $AsyncLoopStats = Invoke-WebRequest -Uri http://localhost:$API/api/Dashboard/AsyncLoopsStats | Select-Object -ExpandProperty content - if ( $AsyncLoopStats.Contains("Fault Reason: Missing outpoint data") ) + $indexerStatusHeader = @{ + Accept = "application/json" + } + $asyncLoopStats = Invoke-WebRequest -Uri http://localhost:$API/api/Dashboard/AsyncLoopsStats -Headers $indexerStatusHeader | Select-Object -ExpandProperty content + if ( $asyncLoopStats.Contains("Fault Reason: Missing outpoint data") ) { Write-Host "ERROR: Indexing Database is corrupt" -ForegroundColor Red Write-Host "Would you like to delete the database?" - $DeleteDB = Read-Host -Prompt "Enter 'Yes' to remove the Indexing Database or 'No' to exit the script" - While ( $DeleteDB -ne "Yes" -and $DeleteDB -ne "No" ) + $deleteDB = Read-Host -Prompt "Enter 'Yes' to remove the Indexing Database or 'No' to exit the script" + While ( $deleteDB -ne "Yes" -and $deleteDB -ne "No" ) { - $DeleteDB = Read-Host -Prompt "Enter 'Yes' to remove the indexing database or 'No' to exit the script" + $deleteDB = Read-Host -Prompt "Enter 'Yes' to remove the indexing database or 'No' to exit the script" } - Switch ( $DeleteDB ) + Switch ( $deleteDB ) { Yes { Shutdown-MainchainNode - Remove-Item -Path $API\addressindex.litedb -Force - if ( -not ( Get-Item -Path $API\addressindex.litedb ) ) + Remove-Item -Path $mainChainDataDir\addressindex.litedb -Force + if ( -not ( Get-Item -Path $mainChainDataDir\addressindex.litedb ) ) { Write-Host "SUCCESS: Indexing Database has been removed. Please re-run the script" -ForegroundColor Green Start-Sleep 10 @@ -46,9 +47,10 @@ function Get-IndexerStatus function Shutdown-MainchainNode { Write-Host "Shutting down Mainchain Node..." -ForegroundColor Yellow - $Headers = @{} - $Headers.Add("Accept","application/json") - Invoke-WebRequest -Uri http://localhost:$mainChainAPIPort/api/Node/shutdown -Method Post -ContentType application/json-patch+json -Headers $Headers -Body "true" -ErrorAction SilentlyContinue | Out-Null + $shutdownHeader = @{ + Accept = "application/json" + } + Invoke-WebRequest -Uri http://localhost:$mainChainAPIPort/api/Node/shutdown -Method Post -ContentType application/json-patch+json -Headers $shutdownHeader -Body "true" | Out-Null While ( Test-Connection -TargetName 127.0.0.1 -TCPPort $mainChainAPIPort -ErrorAction SilentlyContinue ) { @@ -63,9 +65,10 @@ function Shutdown-MainchainNode function Shutdown-SidechainNode { Write-Host "Shutting down Sidechain Node..." -ForegroundColor Yellow - $Headers = @{} - $Headers.Add("Accept","application/json") - Invoke-WebRequest -Uri http://localhost:$sideChainAPIPort/api/Node/shutdown -Method Post -ContentType application/json-patch+json -Headers $Headers -Body "true" -ErrorAction SilentlyContinue | Out-Null + $shutdownHeader = @{ + Accept = "application/json" + } + Invoke-WebRequest -Uri http://localhost:$sideChainAPIPort/api/Node/shutdown -Method Post -ContentType application/json-patch+json -Headers $shutdownHeader -Body "true" | Out-Null While ( Test-Connection -TargetName 127.0.0.1 -TCPPort $sideChainAPIPort -ErrorAction SilentlyContinue ) { @@ -79,56 +82,50 @@ function Shutdown-SidechainNode function Get-MaxHeight { - $Height = @{} - $Peers = Invoke-WebRequest -Uri http://localhost:$API/api/ConnectionManager/getpeerinfo | ConvertFrom-Json - foreach ( $Peer in $Peers ) + $height = @{} + $peers = Invoke-WebRequest -Uri http://localhost:$API/api/ConnectionManager/getpeerinfo | ConvertFrom-Json + foreach ( $peer in $peers ) { - if ( $Peer.subver -eq "StratisNode:0.13.0 (70000)" ) - { - } - Else - { - $Height.Add($Peer.id,$Peer.startingheight) - } + $height.Add($peer.id,$peer.startingheight) } - $MaxHeight = $Height.Values | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum - $MaxHeight + $maxHeight = $height.Values | Measure-Object -Maximum | Select-Object -ExpandProperty Maximum + $maxHeight } function Get-LocalHeight { - $StatsRequest = Invoke-WebRequest -Uri http://localhost:$API/api/Node/status - $Stats = ConvertFrom-Json $StatsRequest - $LocalHeight = $Stats.blockStoreHeight - $LocalHeight + $statsRequest = Invoke-WebRequest -Uri http://localhost:$API/api/Node/status -UseBasicParsing + $stats = ConvertFrom-Json $statsRequest + $localHeight = $stats.blockStoreHeight + $localHeight } function GetCollateral-WalletHeight { - $WalletHeight = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/general-info?Name=$CollateralWallet | ConvertFrom-Json | Select-Object -ExpandProperty lastBlockSyncedHeight - $WalletHeight + $collateralWalletHeight = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/general-info?Name=$collateralWallet -UseBasicParsing| ConvertFrom-Json | Select-Object -ExpandProperty lastBlockSyncedHeight + $collateralWalletHeight } function GetCirrus-WalletHeight { - $WalletHeight = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/general-info?Name=$CirrusWallet | ConvertFrom-Json | Select-Object -ExpandProperty lastBlockSyncedHeight - $WalletHeight + $cirrusWalletHeight = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/general-info?Name=$cirrusWallet -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty lastBlockSyncedHeight + $cirrusWalletHeight } function Get-LocalIndexerHeight { - $IndexStatsRequest = Invoke-WebRequest -Uri http://localhost:$API/api/BlockStore/addressindexertip - $IndexStats = ConvertFrom-Json $IndexStatsRequest - $LocalIndexHeight = $IndexStats.tipHeight - $LocalIndexHeight + $indexStatsRequest = Invoke-WebRequest -Uri http://localhost:$API/api/BlockStore/addressindexertip -UseBasicParsing + $indexStats = ConvertFrom-Json $indexStatsRequest + $localIndexHeight = $indexStats.tipHeight + $localIndexHeight } function Get-BlockStoreStatus { - $FeatureStatus = Invoke-WebRequest -Uri http://localhost:$API/api/Node/status | ConvertFrom-Json | Select-Object -ExpandProperty featuresData - $BlockStoreStatus = $FeatureStatus | Where-Object { $_.namespace -eq "Stratis.Bitcoin.Features.BlockStore.BlockStoreFeature" } - $BlockStoreStatus.state + $featureStatus = Invoke-WebRequest -Uri http://localhost:$API/api/Node/status -UseBasicParsing | ConvertFrom-Json | Select-Object -ExpandProperty featuresData + $blockStoreStatus = $featureStatus | Where-Object { $_.namespace -eq "Stratis.Bitcoin.Features.BlockStore.BlockStoreFeature" } + $blockStoreStatus.state } #Check for an existing running node @@ -153,16 +150,16 @@ Set-Location $cloneDir\src\Stratis.CirrusMinerD #Start Mainchain Node $API = $mainChainAPIPort Write-Host (Get-TimeStamp) "Starting Mainchain Masternode" -ForegroundColor Cyan -$StartNode = Start-Process dotnet -ArgumentList "run -c Release -- -mainchain -addressindex=1 -apiport=$mainChainAPIPort" -PassThru +$startNode = Start-Process dotnet -ArgumentList "run -c Release -- -mainchain -addressindex=1 -apiport=$mainChainAPIPort" -PassThru #Wait for API While ( -not ( Test-Connection -TargetName 127.0.0.1 -TCPPort $API ) ) { Write-Host (Get-TimeStamp) "Waiting for API..." -ForegroundColor Yellow Start-Sleep 3 - if ( $StartNode.HasExited -eq $true ) + if ( $startNode.HasExited -eq $true ) { - Write-Host (Get-TimeStamp) "ERROR: Something went wrong. Please contact support in Discord" -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: Something went wrong - The Mainchain Node Exited unexpectedly. Please contact support in Discord" -ForegroundColor Red Start-Sleep 30 Exit } @@ -173,9 +170,9 @@ While ( ( Get-BlockStoreStatus ) -ne "Initialized" ) { Write-Host (Get-TimeStamp) "Waiting for BlockStore to Initialize..." -ForegroundColor Yellow Start-Sleep 10 - if ( $StartNode.HasExited -eq $true ) + if ( $startNode.HasExited -eq $true ) { - Write-Host (Get-TimeStamp) "ERROR: Something went wrong. Please contact support in Discord" -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: Something went wrong - The Mainchain Node Exited unexpectedly. Please contact support in Discord" -ForegroundColor Red Start-Sleep 30 Exit } @@ -192,9 +189,9 @@ While ( ( Get-MaxHeight ) -gt ( Get-LocalIndexerHeight ) ) { $a = Get-MaxHeight $b = Get-LocalIndexerHeight - $c = $a - $b + [int]$percentage = $b / $a * 100 "" - Write-Host (Get-TimeStamp) "The Indexed Height is $b" -ForegroundColor Yellow + Write-Host (Get-TimeStamp) "$percentage% Synced" -ForegroundColor Cyan Write-Host (Get-TimeStamp) "The Current Tip is $a" -ForegroundColor Yellow Write-Host (Get-TimeStamp) "$c Blocks Require Indexing..." -ForegroundColor Yellow Start-Sleep 10 @@ -202,23 +199,22 @@ While ( ( Get-MaxHeight ) -gt ( Get-LocalIndexerHeight ) ) } #Clear Variables -if ( Get-Variable a -ErrorAction SilentlyContinue ) { Clear-Variable a } -if ( Get-Variable b -ErrorAction SilentlyContinue ) { Clear-Variable b } -if ( Get-Variable c -ErrorAction SilentlyContinue ) { Clear-Variable c } +$variablesToClear = "a","b","c","startNode","API" +$variablesToClear | ForEach-Object { if ( Get-Variable $_ -ErrorAction SilentlyContinue ) { Clear-Variable $_ } } #Start Sidechain Node $API = $sideChainAPIPort Write-Host (Get-TimeStamp) "Starting Sidechain Masternode" -ForegroundColor Cyan -$StartNode = Start-Process dotnet -ArgumentList "run -c Release -- -sidechain -apiport=$sideChainAPIPort -counterchainapiport=$mainChainAPIPort" -PassThru +$startNode = Start-Process dotnet -ArgumentList "run -c Release -- -sidechain -apiport=$sideChainAPIPort -counterchainapiport=$mainChainAPIPort" -PassThru #Wait for API While ( -not ( Test-Connection -TargetName 127.0.0.1 -TCPPort $API ) ) { Write-Host (Get-TimeStamp) "Waiting for API..." -ForegroundColor Yellow Start-Sleep 3 - if ( $StartNode.HasExited -eq $true ) + if ( $startNode.HasExited -eq $true ) { - Write-Host (Get-TimeStamp) "ERROR: Something went wrong. Please contact support in Discord" -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: Something went wrong - The Sidechain Node Exited unexpectedly. Please contact support in Discord" -ForegroundColor Red Start-Sleep 30 Exit } @@ -229,9 +225,9 @@ While ( ( Get-BlockStoreStatus ) -ne "Initialized" ) { Write-Host (Get-TimeStamp) "Waiting for BlockStore to Initialize..." -ForegroundColor Yellow Start-Sleep 10 - if ( $StartNode.HasExited -eq $true ) + if ( $startNode.HasExited -eq $true ) { - Write-Host (Get-TimeStamp) "ERROR: Something went wrong. Please contact support in Discord" -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: Something went wrong - The Sidechain Node Exited unexpectedly. Please contact support in Discord" -ForegroundColor Red Start-Sleep 30 Exit } @@ -249,8 +245,9 @@ While ( ( Get-MaxHeight ) -gt ( Get-LocalHeight ) ) $a = Get-MaxHeight $b = Get-LocalHeight $c = $a - $b + [int]$percentage = $b / $a * 100 "" - Write-Host (Get-TimeStamp) "The Local Synced Height is $b" -ForegroundColor Yellow + Write-Host (Get-TimeStamp) "$percentage% Synced" -ForegroundColor Cyan Write-Host (Get-TimeStamp) "The Current Tip is $a" -ForegroundColor Yellow Write-Host (Get-TimeStamp) "$c Blocks are Required..." -ForegroundColor Yellow Start-Sleep 10 @@ -259,16 +256,19 @@ While ( ( Get-MaxHeight ) -gt ( Get-LocalHeight ) ) "" Write-Host (Get-TimeStamp) "SUCCESS: STRAX Blockchain and Cirrus Blockchain are now fully synchronised!" -ForegroundColor Green "" +$variablesToClear = "a","b","c","API" +$variablesToClear | ForEach-Object { if ( Get-Variable $_ -ErrorAction SilentlyContinue ) { Clear-Variable $_ } } + #Check Collateral Wallet Existence $API = $mainChainAPIPort Write-Host (Get-TimeStamp) INFO: "Assessing Masternode Requirements" -ForegroundColor Cyan "" -$CollateralWallet = Read-Host "Please Enter the Name of the STRAX Wallet that contains the required collateral of a 100 000 STRAX:" +$collateralWallet = Read-Host "Please Enter the Name of the STRAX Wallet that contains the required collateral of a 100 000 STRAX" "" -$LoadedWallets = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames - -if ( $LoadedWallets -contains $CollateralWallet ) +$loadedWallets = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames + +if ( $loadedWallets -contains $collateralWallet ) { Write-Host (Get-TimeStamp) "SUCCESS: Collateral wallet found!" -ForegroundColor Green } @@ -276,52 +276,51 @@ if ( $LoadedWallets -contains $CollateralWallet ) { Write-Host (Get-TimeStamp) "ERROR: No Wallets could be found.. Please restore a wallet that holds the required collateral" -ForegroundColor Red "" - $RestoreWallet = Read-Host -Prompt 'Would you like to restore the wallet using this script? Enter "Yes" to continue or "No" to exit the script' + $restoreWallet = Read-Host -Prompt 'Would you like to restore the wallet using this script? Enter "Yes" to continue or "No" to exit the script' "" - While ( $RestoreWallet -ne "Yes" -and $RestoreWallet -ne "No" ) + While ( $restoreWallet -ne "Yes" -and $restoreWallet -ne "No" ) { "" - $RestoreWallet = Read-Host -Prompt "Enter 'Yes' to continue or 'No' to exit the script" + $restoreWallet = Read-Host -Prompt "Enter 'Yes' to continue or 'No' to exit the script" "" } - Switch ( $RestoreWallet ) + Switch ( $restoreWallet ) { Yes { - $CollateralWalletMnemonic = Read-Host "Please enter your 12-Words used to recover your wallet" + $collateralWalletMnemonic = Read-Host "Please enter your 12-Words used to recover your wallet" Clear-Host - $CollateralWalletPassphrase = Read-Host "Please enter your Wallet Passphrase" + $collateralWalletPassphrase = Read-Host "Please enter your Wallet Passphrase" Clear-Host - $CollateralWalletPassword = Read-Host "Please enter a password used to encrypt the wallet" + $collateralWalletPassword = Read-Host "Please enter a password used to encrypt the wallet" Clear-Host - if ( -not ( $CollateralWallet ) ) { $ErrorVar = 1 } - if ( -not ( $CollateralWalletMnemonic ) ) { $ErrorVar = 1 } - if ( -not ( $CollateralWalletPassword ) ) { $ErrorVar = 1 } - if ( $ErrorVar ) - { + $validateVariables = $collateralWallet, $collateralWalletMnemonic, $collateralWalletPassword + $validateVariables | ForEach-Object { + if ( $_ -eq $null ) { Write-Host (Get-TimeStamp) "ERROR: There was some missing wallet detail - Please re-run this script" -ForegroundColor Red Start-Sleep 30 Exit + } + } + + $collateralRestoreBody = @{ + mnemonic = $collateralWalletMnemonic + password = $collateralWalletPassword + name = $collateralWallet + creationDate = "2020-11-01T00:00:01.690Z" } - - $Body = @{} - $Body.Add("mnemonic",$CollateralWalletMnemonic) - if ( $CollateralWalletPassphrase ) + if ( $collateralWalletPassphrase ) { - $Body.Add("passphrase",$CollateralWalletPassphrase) + $collateralRestoreBody.Add("passphrase",$collateralWalletPassphrase) } Else { - $Body.Add("passphrase","") + $collateralRestoreBody.Add("passphrase","") } + $collateralRestoreBody = ConvertTo-Json $collateralRestoreBody - $Body.Add("password",$CollateralWalletPassword) - $Body.Add("name",$CollateralWallet) - $Body.Add("creationDate","2020-11-01T00:00:01.690Z") - - $Body = $Body | ConvertTo-Json - $RestoreWallet = Invoke-WebRequest -Uri http://localhost:$API/api/wallet/recover -UseBasicParsing -Method Post -Body $Body -ContentType "application/json" + $restoreWallet = Invoke-WebRequest -Uri http://localhost:$API/api/wallet/recover -UseBasicParsing -Method Post -Body $collateralRestoreBody -ContentType "application/json" if ( (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames) -notcontains $CollateralWallet ) { Write-Host (Get-TimeStamp) "ERROR: There was an error calling the Wallet Recover API - Please re-run this script" -ForegroundColor Red @@ -329,17 +328,18 @@ if ( $LoadedWallets -contains $CollateralWallet ) Exit } - Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/remove-transactions?WalletName=$CollateralWallet"&"all=true"&"ReSync=true -UseBasicParsing -Method Delete + Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/remove-transactions?WalletName=$collateralWallet"&"all=true"&"ReSync=true -UseBasicParsing -Method Delete Clear-Host - Write-Host (Get-TimeStamp) INFO: "Syncing $CollateralWallet - This may take some time and -1 may be dispalyed for some time. The process is wholly dependant on avaialble resource, please do no close this window..." -ForegroundColor Cyan + Write-Host (Get-TimeStamp) INFO: "Syncing $collateralWallet - This may take some time and -1 may be dispalyed for some time. The process is wholly dependant on avaialble resource, please do no close this window..." -ForegroundColor Cyan While ( (GetCollateral-WalletHeight) -ne (Get-LocalHeight) ) { $a = Get-LocalHeight - $b = GetCollateral-WalletHeight + $b = GetCollateral-WalletHeight $c = $a - $b + [int]$percentage = $b / $a * 100 "" - Write-Host (Get-TimeStamp) "The Wallet Synced Height is $b" -ForegroundColor Yellow + Write-Host (Get-TimeStamp) "$percentage% Synced" -ForegroundColor Cyan Write-Host (Get-TimeStamp) "The Current Tip is $a" -ForegroundColor Yellow Write-Host (Get-TimeStamp) "$c Blocks are Required..." -ForegroundColor Yellow Start-Sleep 10 @@ -348,7 +348,7 @@ if ( $LoadedWallets -contains $CollateralWallet ) No { - Write-Host (Get-TimeStamp) "ERROR: There was some missing wallet detail - Please re-run this script" -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: You have chosen not to restore a wallet - Please re-run this script" -ForegroundColor Red Start-Sleep 30 Exit } @@ -356,8 +356,8 @@ if ( $LoadedWallets -contains $CollateralWallet ) } #Check Wallet Balance -$CollateralWalletBalance = (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/balance?WalletName=$CollateralWallet -Method Get | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty balances | Select-Object -ExpandProperty spendableamount) / 100000000 -if ( $CollateralWalletBalance -ge 100000 ) +$collateralWalletBalance = (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/balance?WalletName=$collateralWallet -Method Get -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty balances | Select-Object -ExpandProperty spendableamount) / 100000000 +if ( $collateralWalletBalance -ge 100000 ) { Write-Host (Get-TimeStamp) "SUCCESS: Collateral Wallet contains a balance of over 100,000 STRAX!" -ForegroundColor Green } @@ -368,83 +368,86 @@ if ( $CollateralWalletBalance -ge 100000 ) Exit } +$variablesToClear = "a","b","c","API" +$variablesToClear | ForEach-Object { if ( Get-Variable $_ -ErrorAction SilentlyContinue ) { Clear-Variable $_ } } #Check Cirrus Wallet Existence $API = $sideChainAPIPort "" -$CirrusWallet = Read-Host "Please Enter the Name of the Cirrus Wallet that contains the required balance of 501 CRS to fund the registration fee." +$cirrusWallet = Read-Host "Please Enter the Name of the Cirrus Wallet that contains the required balance of 501 CRS to fund the registration fee." "" -$LoadedWallets = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames +$loadedWallets = Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames -if ( $LoadedWallets -contains $CirrusWallet ) +if ( $loadedWallets -contains $cirrusWallet ) { - Write-Host (Get-TimeStamp) "SUCCESS: $CirrusWallet found!" -ForegroundColor Green + Write-Host (Get-TimeStamp) "SUCCESS: $cirrusWallet found!" -ForegroundColor Green } Else { - Write-Host (Get-TimeStamp) "ERROR: No wallet named $CirrusWallet could be found. Please restore a wallet that holds the required fee." -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: No wallet named $cirrusWallet could be found. Please restore a wallet that holds the required fee." -ForegroundColor Red "" $RestoreWallet = Read-Host -Prompt 'Would you like to restore the wallet using this script? Enter "Yes" to continue or "No" to exit the script' "" - While ( $RestoreWallet -ne "Yes" -and $RestoreWallet -ne "No" ) + While ( $restoreWallet -ne "Yes" -and $restoreWallet -ne "No" ) { "" - $RestoreWallet = Read-Host -Prompt "Enter 'Yes' to continue or 'No' to exit the script" + $restoreWallet = Read-Host -Prompt "Enter 'Yes' to continue or 'No' to exit the script" "" } - Switch ( $RestoreWallet ) + Switch ( $restoreWallet ) { Yes { - $CirrusWalletMnemonic = Read-Host "Please enter your 12-Words used to recover your wallet" + $cirrusWalletMnemonic = Read-Host "Please enter your 12-Words used to recover your wallet" Clear-Host - $CirrusWalletPassphrase = Read-Host "Please enter your Wallet Passphrase" + $cirrusWalletPassphrase = Read-Host "Please enter your Wallet Passphrase" Clear-Host - $CirrusWalletPassword = Read-Host "Please enter a password used to encrypt the wallet" + $cirrusWalletPassword = Read-Host "Please enter a password used to encrypt the wallet" Clear-Host - if ( -not ( $CirrusWallet ) ) { $ErrorVar = 1 } - if ( -not ( $CirrusWalletMnemonic ) ) { $ErrorVar = 1 } - if ( -not ( $CirrusWalletPassword ) ) { $ErrorVar = 1 } - if ( $ErrorVar ) - { + $validateVariables = $cirrusWallet, $cirrusWalletMnemonic, $cirrusWalletPassword + $validateVariables | ForEach-Object { + if ( $_ -eq $null ) { Write-Host (Get-TimeStamp) "ERROR: There was some missing wallet detail - Please re-run this script" -ForegroundColor Red Start-Sleep 30 Exit + } } - $Body = @{} - $Body.Add("mnemonic",$CirrusWalletMnemonic) + $cirrusRestoreBody = @{ + mnemonic = $cirrusWalletMnemonic + password = $cirrusWalletPassword + name = $cirrusWallet + creationDate = "2020-11-01T00:00:01.690Z" + } if ( $CirrusWalletPassphrase ) { - $Body.Add("passphrase",$CirrusWalletPassphrase) + $cirrusRestoreBody.Add("passphrase",$CirrusWalletPassphrase) } Else { - $Body.Add("passphrase","") + $cirrusRestoreBody.Add("passphrase","") } - - $Body.Add("password",$CirrusWalletPassword) - $Body.Add("name",$CirrusWallet) - $Body.Add("creationDate","2020-11-01T00:00:01.690Z") - $Body = $Body | ConvertTo-Json - - $RestoreWallet = Invoke-WebRequest -Uri http://localhost:$API/api/wallet/recover -UseBasicParsing -Method Post -Body $Body -ContentType "application/json" - if ( (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames) -notcontains $CirrusWallet ) + $cirrusRestoreBody = ConvertTo-Json $cirrusRestoreBody + + $restoreCirrusWallet = Invoke-WebRequest -Uri http://localhost:$API/api/wallet/recover -UseBasicParsing -Method Post -Body $cirrusRestoreBody -ContentType "application/json" + if ( (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/list-wallets -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty walletNames) -notcontains $cirrusWallet ) { Write-Host (Get-TimeStamp) "ERROR: There was an error calling the Cirrus Wallet Recover API - Please re-run this script" -ForegroundColor Red Start-Sleep 30 Exit } - Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/remove-transactions?WalletName=$CirrusWallet"&"all=true"&"ReSync=true -UseBasicParsing -Method Delete + Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/remove-transactions?WalletName=$cirrusWallet"&"all=true"&"ReSync=true -UseBasicParsing -Method Delete While ( (GetCirrus-WalletHeight) -ne (Get-LocalHeight) ) { $a = Get-LocalHeight $b = GetCirrus-WalletHeight $c = $a - $b + [int]$percentage = $b / $a * 100 "" + Write-Host (Get-TimeStamp) "$percentage% Synced" -ForegroundColor Cyan Write-Host (Get-TimeStamp) "The Wallet Synced Height is $b" -ForegroundColor Yellow Write-Host (Get-TimeStamp) "The Current Tip is $a" -ForegroundColor Yellow Write-Host (Get-TimeStamp) "$c Blocks are Required..." -ForegroundColor Yellow @@ -463,14 +466,14 @@ if ( $LoadedWallets -contains $CirrusWallet ) #Check Wallet Balance -$CirrusWalletBalance = (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/balance?WalletName=$CirrusWallet -Method Get | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty balances | Select-Object -ExpandProperty spendableamount) / 100000000 -if ( $CirrusWalletBalance -ge 500.01 ) +$cirrusWalletBalance = (Invoke-WebRequest -Uri http://localhost:$API/api/Wallet/balance?WalletName=$cirrusWallet -Method Get -UseBasicParsing | Select-Object -ExpandProperty content | ConvertFrom-Json | Select-Object -ExpandProperty balances | Select-Object -ExpandProperty spendableamount) / 100000000 +if ( $cirrusWalletBalance -ge 500.01 ) { - Write-Host (Get-TimeStamp) "SUCCESS: $CirrusWallet contains a balance of over 501 CRS!" -ForegroundColor Green + Write-Host (Get-TimeStamp) "SUCCESS: $cirrusWallet contains enough CRS to cover the registration cost!" -ForegroundColor Green } Else { - Write-Host (Get-TimeStamp) "ERROR: $CirrusWallet does not contain a balance of over 501 CRS! Please run again and define a wallet that contains the required amount..." -ForegroundColor Red + Write-Host (Get-TimeStamp) "ERROR: $cirrusWallet does not contain a balance of over 501 CRS! Please run again and define a wallet that contains the required amount..." -ForegroundColor Red Start-Sleep 30 Exit } @@ -490,55 +493,84 @@ if ( -not ( Test-Path $sideChainDataDir\federationKey.dat ) ) #Perform Registration +$collateralAddress = Read-Host -Prompt "Please enter your STRAX Address that contains the required collateral amount (the FULL BALANCE of a 100k must be held in ONE address)" "" -$CollateralAddress = Read-Host -Prompt "Please enter your STRAX Address that contains the required collateral amount (the FULL BALANCE of a 100k must be held in ONE address):" -"" -$RegisterMasternode = Read-Host -Prompt 'Would you like to register as a Masternode? Please be aware that this will incur a 500 CRS Fee. Enter "Yes" to continue or "No" to exit the script' -While ( $RegisterMasternode -ne "Yes" -and $RegisterMasternode -ne "No" ) +While ( $CollateralAddress.Trim() -notmatch '^X[a-zA-Z0-9]{26,33}$' ) + { + Write-Host (Get-TimeStamp) "ERROR: $CollateralAddress is not a valid address. Please ensure you're defining a STRAX Address." -ForegroundColor Red + $collateralAddress = Read-Host -Prompt "Please enter your STRAX Address that contains the required collateral amount (the FULL BALANCE of a 100k must be held in ONE address)" "" - $RegisterMasternode = Read-Host 'Enter "Yes" to continue or "No" to exit the script' +} + +$registerMasternode = Read-Host -Prompt 'Would you like to register as a Masternode? Please be aware that this will incur a 500 CRS Fee. Enter "Yes" to continue or "No" to exit the script' +While ( $registerMasternode -ne "Yes" -and $registerMasternode -ne "No" ) +{ + "" + $registerMasternode = Read-Host 'Enter "Yes" to continue or "No" to exit the script' "" } -Switch ( $RegisterMasternode ) +Clear-Host +Switch ( $registerMasternode ) { Yes { - if ( -not ( $CollateralWalletPassword ) ) + if ( -not ( $collateralWalletPassword ) ) { - $CollateralWalletPassword = Read-Host "Please confirm your STRAX (Collateral) wallet password." + $collateralWalletPassword = Read-Host "Please confirm your STRAX (Collateral) wallet password." Clear-Host } - if ( -not ( $CirrusWalletPassword ) ) + if ( -not ( $cirrusWalletPassword ) ) { - $CirrusWalletPassword = Read-Host "Please confirm your Cirrus wallet password." + $cirrusWalletPassword = Read-Host "Please confirm your Cirrus wallet password." Clear-Host } - $Body = @{} - $Body.Add("collateralAddress",$CollateralAddress) - $Body.Add("collateralWalletName",$CollateralWallet) - $Body.Add("collateralWalletPassword",$CollateralWalletPassword) - $Body.Add("walletName",$CirrusWallet) - $Body.Add("walletPassword",$CirrusWalletPassword) - $Body.Add("walletAccount","account 0") - Invoke-WebRequest -Uri http://localhost:$API/api/Collateral/joinfederation -Body $Body -ContentType "application/json-patch+json" -Method Post - Write-Host (Get-TimeStamp) "SUCCESS: Your registration was succesful!! Please follow the STRAX Sidechain Masternode Setup Guide!" -ForegroundColor Green - Start-Sleep 30 + $registerBody = ConvertTo-Json @{ + collateralAddress = $collateralAddress + collateralWalletName = $collateralWallet + collateralWalletPassword = $collateralWalletPassword + walletName = $cirrusWallet + walletPassword = $cirrusWalletPassword + walletAccount = "account 0" + } + $register = Invoke-WebRequest -Uri http://localhost:$API/api/Collateral/joinfederation -Body $registerBody -ContentType "application/json-patch+json" -UseBasicParsing -Method Post | Select + + if ( ($register.content | ConvertFrom-Json | Select-Object -ExpandProperty minerPublicKey) -match '^.{66,66}$' ) + { + Write-Host (Get-TimeStamp) "Your Masternode Public Key is: " ($register.content | ConvertFrom-Json | Select-Object -ExpandProperty minerPublicKey) -ForegroundColor Cyan + Write-Host (Get-TimeStamp) "SUCCESS: Your registration was succesful!! Please follow the STRAX Sidechain Masternode Setup Guide!" -ForegroundColor Green + Start-Sleep 30 + pause + } + Else + { + Write-Host (Get-TimeStamp) "ERROR: Something went wrong when attmepting to register..." -ForegroundColor Red + "" + Write-Host "Cirrus Wallet Name: $cirrusWallet" -ForegroundColor Yellow + Write-Host "STRAX Wallet Name: $collateralWallet" -ForegroundColor Yellow + Write-Host "Collateral Address: $collateralAddress" -ForegroundColor Yellow + "" + Write-Host (Get-TimeStamp) "INFO: Please try again ensuring that the detail is entered correctly, such as Wallet Passowrds. If you continue to experience issues, please contact support via Discord" -ForegroundColor Cyan + Start-Sleep 60 + Exit + } } No { + Write-Host (Get-TimeStamp) "ERROR: You have chosen not to continue with your Masternode registration - Please re-run the registration script to begin the registration process again" -ForegroundColor Red + Start-Sleep 30 } } - + # SIG # Begin signature block # MIIO+wYJKoZIhvcNAQcCoIIO7DCCDugCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR -# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUJz7+xzEP3s6UvyUAY2SzNilC -# sv+gggxDMIIFfzCCBGegAwIBAgIQB+RAO8y2U5CYymWFgvSvNDANBgkqhkiG9w0B +# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUaI73JqpdFrCnxEf+ERUtxeH8 +# lpegggxDMIIFfzCCBGegAwIBAgIQB+RAO8y2U5CYymWFgvSvNDANBgkqhkiG9w0B # AQsFADBsMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD # VQQLExB3d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBFViBDb2Rl # IFNpZ25pbmcgQ0EgKFNIQTIpMB4XDTE4MDcxNzAwMDAwMFoXDTIxMDcyMTEyMDAw @@ -608,11 +640,11 @@ Switch ( $RegisterMasternode ) # Y2VydC5jb20xKzApBgNVBAMTIkRpZ2lDZXJ0IEVWIENvZGUgU2lnbmluZyBDQSAo # U0hBMikCEAfkQDvMtlOQmMplhYL0rzQwCQYFKw4DAhoFAKB4MBgGCisGAQQBgjcC # AQwxCjAIoAKAAKECgAAwGQYJKoZIhvcNAQkDMQwGCisGAQQBgjcCAQQwHAYKKwYB -# BAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYEFFVXdfhr54SU -# NsUqkFvwKbPEM/eEMA0GCSqGSIb3DQEBAQUABIIBADxoiXtgktrhSItBz7JAbit4 -# nKzraFyl+rJ0EBl1aJXrw6Kjna3GKqffgzc/4AmXhPrcby3XcxFrJL61CZymh5Qz -# RLVGFIoTyhVUJESvfSp+/yRWjXprYblaT+/OfsKy/IbthSJ2HkmUM7XrO2cWLWbj -# wEHIph8DLliQV7TEEzOh6/oEApocLp1jZD31B9o0Hmzxftylzrs26ja1jBvCzJKi -# S1qgMMWk0JNM+M2rPa7/lOoHSPPmpB0j+Yp0jyQMbODSHL+M8SXTY9QxgoqLq5aa -# huY3xwKvyKfm20PMbeKSVeZgVY/WTvP928xhy4GBOGPpIBuIyY+nM4xpt66+Fbw= +# BAGCNwIBCzEOMAwGCisGAQQBgjcCARUwIwYJKoZIhvcNAQkEMRYEFDNyjn39gPPC +# J7Z4/e+mAZmCWil9MA0GCSqGSIb3DQEBAQUABIIBAGfEv2mGygtzNxl+6PM3nJDh +# jWdJW6krHbdZhAPoHuOEEBNPSKuw8xB7rxdEl8gKHfW38sHFeL0i91J2wogI7Vpj +# 6Es199NFsh/iU/Mp4el+yLv2t2Q2z/B3kbqg313kNkrmDWA7h6CumoTwvF+zei48 +# dql/ZEHCakLQFefuNiKmR6pog1fEmuCz2QuKN8lCOOy9gKJsXL/kAFUf07NgRtL0 +# rN10OlZ49l8n/GOxGQvP0nb0rtTEgd4Ca00x5LKTKWCCk9Ja/bUZX/dED5Iaoqks +# SBs3+Y5sG0LyLU5R0qMFPO1lry47XJjYvu7XcIoAdJjfPUiodDgIdJ144UJgRnQ= # SIG # End signature block From 24f6bd2dc66467ba3f316584b37f3598ae254d2c Mon Sep 17 00:00:00 2001 From: StratisIain <32906542+StratisIain@users.noreply.github.com> Date: Mon, 21 Dec 2020 15:20:44 +0000 Subject: [PATCH 12/55] Update STRAXSidechainRegistrationScript.ps1 --- Scripts/STRAXSidechainRegistrationScript.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/STRAXSidechainRegistrationScript.ps1 b/Scripts/STRAXSidechainRegistrationScript.ps1 index 424d5856df..7794caecc4 100644 --- a/Scripts/STRAXSidechainRegistrationScript.ps1 +++ b/Scripts/STRAXSidechainRegistrationScript.ps1 @@ -535,9 +535,9 @@ Switch ( $registerMasternode ) walletPassword = $cirrusWalletPassword walletAccount = "account 0" } - $register = Invoke-WebRequest -Uri http://localhost:$API/api/Collateral/joinfederation -Body $registerBody -ContentType "application/json-patch+json" -UseBasicParsing -Method Post | Select + $register = Invoke-WebRequest -Uri http://localhost:$API/api/Collateral/joinfederation -Body $registerBody -ContentType "application/json-patch+json" -UseBasicParsing -Method Post - if ( ($register.content | ConvertFrom-Json | Select-Object -ExpandProperty minerPublicKey) -match '^.{66,66}$' ) + if ( ($register.content | ConvertFrom-Json -ErrorAction SilentlyContinue | Select-Object -ExpandProperty minerPublicKey) -match '^.{66,66}$' ) { Write-Host (Get-TimeStamp) "Your Masternode Public Key is: " ($register.content | ConvertFrom-Json | Select-Object -ExpandProperty minerPublicKey) -ForegroundColor Cyan Write-Host (Get-TimeStamp) "SUCCESS: Your registration was succesful!! Please follow the STRAX Sidechain Masternode Setup Guide!" -ForegroundColor Green From f96941dc59644afba5cbfbda5069d390f53e7358 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 5 Jan 2021 09:06:48 +0000 Subject: [PATCH 13/55] Activate Reward Batching on Mainnet (#333) * Set activation heights * Commit --- src/Stratis.Bitcoin.Networks/StraxMain.cs | 2 ++ src/Stratis.Sidechains.Networks/CirrusMain.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Bitcoin.Networks/StraxMain.cs b/src/Stratis.Bitcoin.Networks/StraxMain.cs index 9a3d126e65..8d3c2735c0 100644 --- a/src/Stratis.Bitcoin.Networks/StraxMain.cs +++ b/src/Stratis.Bitcoin.Networks/StraxMain.cs @@ -34,6 +34,8 @@ public StraxMain() this.DefaultBanTimeSeconds = 11250; // 500 (MaxReorg) * 45 (TargetSpacing) / 2 = 3 hours, 7 minutes and 30 seconds this.CirrusRewardDummyAddress = "CPqxvnzfXngDi75xBJKqi4e6YrFsinrJka"; // Cirrus main address + this.RewardClaimerBatchActivationHeight = 119_185; // Tuesday, 12 January 2021 9:00:00 AM (Estimated) + this.RewardClaimerBlockInterval = 100; // To successfully process the OP_FEDERATION opcode the federations should be known. this.Federations = new Federations(); diff --git a/src/Stratis.Sidechains.Networks/CirrusMain.cs b/src/Stratis.Sidechains.Networks/CirrusMain.cs index 7995ca75de..a807f0bd29 100644 --- a/src/Stratis.Sidechains.Networks/CirrusMain.cs +++ b/src/Stratis.Sidechains.Networks/CirrusMain.cs @@ -178,7 +178,7 @@ public CirrusMain() EnforceMinProtocolVersionAtBlockHeight = 384675, // setting the value to zero makes the functionality inactive EnforcedMinProtocolVersion = ProtocolVersion.CIRRUS_VERSION, // minimum protocol version which will be enforced at block height defined in EnforceMinProtocolVersionAtBlockHeight FederationMemberActivationTime = 1605862800, // Friday, November 20, 2020 9:00:00 AM - VotingManagerV2ActivationHeight = 0 + VotingManagerV2ActivationHeight = 1_683_000 // Tuesday, 12 January 2021 9:00:00 AM (Estimated) }; var buriedDeployments = new BuriedDeploymentsArray From fe4b85bea0e056b124238017037f5ef264e028d6 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 5 Jan 2021 09:49:15 +0000 Subject: [PATCH 14/55] Update WithdrawalTransactionBuilder.cs (#337) --- .../TargetChain/WithdrawalTransactionBuilder.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalTransactionBuilder.cs b/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalTransactionBuilder.cs index cfa95de92c..e7069c514b 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalTransactionBuilder.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalTransactionBuilder.cs @@ -50,7 +50,9 @@ public WithdrawalTransactionBuilder( this.signals = signals; this.distributionManager = distributionManager; - this.cirrusRewardDummyAddressScriptPubKey = BitcoinAddress.Create(this.network.CirrusRewardDummyAddress).ScriptPubKey; + if (!this.federatedPegSettings.IsMainChain) + this.cirrusRewardDummyAddressScriptPubKey = BitcoinAddress.Create(this.network.CirrusRewardDummyAddress).ScriptPubKey; + this.previousDistributionHeight = 0; } From 9cbffdccc4e930a7868d703e71c1b5671a78e1b5 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 5 Jan 2021 15:29:37 +0000 Subject: [PATCH 15/55] Update StraxMain.cs (#338) --- src/Stratis.Bitcoin.Networks/StraxMain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stratis.Bitcoin.Networks/StraxMain.cs b/src/Stratis.Bitcoin.Networks/StraxMain.cs index 8d3c2735c0..c36acee612 100644 --- a/src/Stratis.Bitcoin.Networks/StraxMain.cs +++ b/src/Stratis.Bitcoin.Networks/StraxMain.cs @@ -34,7 +34,7 @@ public StraxMain() this.DefaultBanTimeSeconds = 11250; // 500 (MaxReorg) * 45 (TargetSpacing) / 2 = 3 hours, 7 minutes and 30 seconds this.CirrusRewardDummyAddress = "CPqxvnzfXngDi75xBJKqi4e6YrFsinrJka"; // Cirrus main address - this.RewardClaimerBatchActivationHeight = 119_185; // Tuesday, 12 January 2021 9:00:00 AM (Estimated) + this.RewardClaimerBatchActivationHeight = 119_200; // Tuesday, 12 January 2021 9:00:00 AM (Estimated) this.RewardClaimerBlockInterval = 100; // To successfully process the OP_FEDERATION opcode the federations should be known. From 5d2a8e54749aba8080086487d6352f26001e126f Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 6 Jan 2021 11:02:00 +0000 Subject: [PATCH 16/55] Fixes (#344) --- .../Distribution/RewardDistributionManager.cs | 68 +++++++++++-------- .../TargetChain/CrossChainTransferStore.cs | 31 +++++---- 2 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs index 369b2ed740..1ee1993401 100644 --- a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs +++ b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Microsoft.Extensions.Logging; using NBitcoin; using Stratis.Bitcoin.Consensus; @@ -18,15 +17,16 @@ public sealed class RewardDistributionManager : IRewardDistributionManager { private const int DefaultEpoch = 240; - private readonly Network network; private readonly ChainIndexer chainIndexer; private readonly IConsensusManager consensusManager; - private readonly ILogger logger; - + private readonly CollateralHeightCommitmentEncoder encoder; private readonly int epoch; private readonly int epochWindow; + private readonly ILogger logger; + private readonly Network network; - private readonly Dictionary blocksByHashDictionary = new Dictionary(); + private readonly Dictionary blocksMinedEach = new Dictionary(); + private readonly Dictionary commitmentTransactionByHashDictionary = new Dictionary(); private readonly Dictionary commitmentHeightsByHash = new Dictionary(); // The reward each miner receives upon distribution is computed as a proportion of the overall accumulated reward since the last distribution. @@ -42,6 +42,7 @@ public RewardDistributionManager(Network network, ChainIndexer chainIndexer, ICo this.consensusManager = consensusManager; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); + this.encoder = new CollateralHeightCommitmentEncoder(this.logger); this.epoch = this.network.Consensus.MaxReorgLength == 0 ? DefaultEpoch : (int)this.network.Consensus.MaxReorgLength; this.epochWindow = this.epoch * 2; @@ -59,11 +60,9 @@ public RewardDistributionManager(Network network, ChainIndexer chainIndexer, ICo /// public List Distribute(int heightOfRecordedDistributionDeposit, Money totalReward) { - var encoder = new CollateralHeightCommitmentEncoder(this.logger); - // First determine the main chain blockheight of the recorded deposit less max reorg * 2 (epoch window) var applicableMainChainDepositHeight = heightOfRecordedDistributionDeposit - this.epochWindow; - this.logger.LogDebug($"{nameof(applicableMainChainDepositHeight)} : {applicableMainChainDepositHeight}"); + this.logger.LogDebug("{0} : {1}", nameof(applicableMainChainDepositHeight), applicableMainChainDepositHeight); // Then find the header on the sidechain that contains the applicable commitment height. int sidechainTipHeight = this.chainIndexer.Tip.Height; @@ -72,12 +71,12 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money do { - this.blocksByHashDictionary.TryGetValue(currentHeader.HashBlock, out Block blockToCheck); + this.commitmentTransactionByHashDictionary.TryGetValue(currentHeader.HashBlock, out Transaction transactionToCheck); - if (blockToCheck == null) + if (transactionToCheck == null) { - blockToCheck = this.consensusManager.GetBlockData(currentHeader.HashBlock).Block; - this.blocksByHashDictionary.TryAdd(currentHeader.HashBlock, blockToCheck); + transactionToCheck = this.consensusManager.GetBlockData(currentHeader.HashBlock).Block.Transactions[0]; + this.commitmentTransactionByHashDictionary.TryAdd(currentHeader.HashBlock, transactionToCheck); } // Do we have this commitment height cached already? @@ -85,7 +84,7 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money if (commitmentHeightToCheck == null) { // If not extract from the block. - (int? heightOfMainChainCommitment, _) = encoder.DecodeCommitmentHeight(blockToCheck.Transactions[0]); + (int? heightOfMainChainCommitment, _) = this.encoder.DecodeCommitmentHeight(transactionToCheck); if (heightOfMainChainCommitment != null) { commitmentHeightToCheck = heightOfMainChainCommitment.Value; @@ -95,7 +94,7 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money if (commitmentHeightToCheck != null) { - this.logger.LogDebug($"{currentHeader} : {nameof(commitmentHeightToCheck)}={commitmentHeightToCheck}"); + this.logger.LogDebug("{0} : {1}={2}", currentHeader, nameof(commitmentHeightToCheck), commitmentHeightToCheck); if (commitmentHeightToCheck <= applicableMainChainDepositHeight) break; @@ -108,7 +107,7 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money // Get the set of miners (more specifically, the scriptPubKeys they generated blocks with) to distribute rewards to. // Based on the computed 'common block height' we define the distribution epoch: int sidechainStartHeight = currentHeader.Height; - this.logger.LogDebug($"Initial {nameof(sidechainStartHeight)} : {sidechainStartHeight}"); + this.logger.LogDebug("Initial {0} : {1}", nameof(sidechainStartHeight), sidechainStartHeight); // This is a special case which will not be the case on the live network. if (sidechainStartHeight < this.epoch) @@ -118,16 +117,19 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money if (sidechainStartHeight > this.epoch) sidechainStartHeight -= this.epoch; - this.logger.LogDebug($"Adjusted {nameof(sidechainStartHeight)} : {sidechainStartHeight}"); + this.logger.LogDebug("Adjusted {0} : {1}", nameof(sidechainStartHeight), sidechainStartHeight); - var blocksMinedEach = new Dictionary(); + // Ensure that the dictionary is cleared on every run. + // As this is a static class, new instances of this dictionary will + // only be cleaned up once the node shutsdown. It is therefore better + // to use a single instance to work with. + this.blocksMinedEach.Clear(); - var totalBlocks = CalculateBlocksMinedPerMiner(blocksMinedEach, sidechainStartHeight, currentHeader.Height); - List recipients = ConstructRecipients(heightOfRecordedDistributionDeposit, blocksMinedEach, totalBlocks, totalReward); - return recipients; + var totalBlocks = CalculateBlocksMinedPerMiner(sidechainStartHeight, currentHeader.Height); + return ConstructRecipients(heightOfRecordedDistributionDeposit, totalBlocks, totalReward); } - private long CalculateBlocksMinedPerMiner(Dictionary blocksMinedEach, int sidechainStartHeight, int sidechainEndHeight) + private long CalculateBlocksMinedPerMiner(int sidechainStartHeight, int sidechainEndHeight) { long totalBlocks = 0; @@ -137,7 +139,7 @@ private long CalculateBlocksMinedPerMiner(Dictionary blocksMinedEa if (chainedHeader.Block == null) chainedHeader.Block = this.consensusManager.GetBlockData(chainedHeader.HashBlock).Block; - Transaction coinBase = chainedHeader.Block.Transactions.First(); + Transaction coinBase = chainedHeader.Block.Transactions[0]; // Regard the first 'spendable' scriptPubKey in the coinbase as belonging to the miner's wallet. // This avoids trying to recover the pubkey from the block signature. @@ -147,17 +149,20 @@ private long CalculateBlocksMinedPerMiner(Dictionary blocksMinedEa // In this case the block shouldn't count as it was "not mined by anyone". if (!Script.IsNullOrEmpty(minerScript)) { - if (!blocksMinedEach.TryGetValue(minerScript, out long minerBlockCount)) + if (!this.blocksMinedEach.TryGetValue(minerScript, out long minerBlockCount)) minerBlockCount = 0; - blocksMinedEach[minerScript] = ++minerBlockCount; + this.blocksMinedEach[minerScript] = ++minerBlockCount; totalBlocks++; } else - this.logger.LogDebug($"A block was mined with an empty script at height '{currentHeight}' (the miner probably did not have a wallet at the time."); + this.logger.LogDebug("A block was mined with an empty script at height '{0}' (the miner probably did not have a wallet at the time.", currentHeight); } + /* + * TODO: Uncomment this if debugging is ever required, otherwise implement a IsDebug setting on NodeSettings. + * var minerLog = new StringBuilder(); minerLog.AppendLine($"Total Blocks = {totalBlocks}"); minerLog.AppendLine($"Side Chain Start = {sidechainStartHeight}"); @@ -169,17 +174,18 @@ private long CalculateBlocksMinedPerMiner(Dictionary blocksMinedEa } this.logger.LogDebug(minerLog.ToString()); + */ return totalBlocks; } - private List ConstructRecipients(int heightOfRecordedDistributionDeposit, Dictionary blocksMinedEach, long totalBlocks, Money totalReward) + private List ConstructRecipients(int heightOfRecordedDistributionDeposit, long totalBlocks, Money totalReward) { var recipients = new List(); - foreach (Script scriptPubKey in blocksMinedEach.Keys) + foreach (Script scriptPubKey in this.blocksMinedEach.Keys) { - Money amount = totalReward * blocksMinedEach[scriptPubKey] / totalBlocks; + Money amount = totalReward * this.blocksMinedEach[scriptPubKey] / totalBlocks; // Only convert to P2PKH if it is a pay-to-pubkey script. Leave the other types alone; the mempool should filter out anything that isn't allowed. // Note that the node wallets can detect transactions with a destination of either the P2PK or P2PKH scriptPubKey corresponding to one of their pubkeys. @@ -194,14 +200,18 @@ private List ConstructRecipients(int heightOfRecordedDistributionDepo recipients.Add(new Recipient() { Amount = amount, ScriptPubKey = scriptPubKey }); } + /* + * TODO: Uncomment this if debugging is ever required, otherwise implement a IsDebug setting on NodeSettings. + * var recipientLog = new StringBuilder(); foreach (Recipient recipient in recipients) { recipientLog.AppendLine($"{recipient.ScriptPubKey} - {recipient.Amount}"); } this.logger.LogDebug(recipientLog.ToString()); + */ - this.logger.LogInformation($"Reward distribution at main chain height {heightOfRecordedDistributionDeposit} will distribute {totalReward} STRAX between {recipients.Count} mining keys."); + this.logger.LogInformation("Reward distribution at main chain height {0} will distribute {1} STRAX between {2} mining keys.", heightOfRecordedDistributionDeposit, totalReward, recipients.Count); return recipients; } diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs index 705edd4870..dff7255d9b 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs @@ -214,7 +214,7 @@ private ICrossChainTransfer[] ValidateCrossChainTransfers(ICrossChainTransfer[] List<(Transaction transaction, IWithdrawal withdrawal)> walletData = this.federationWalletManager.FindWithdrawalTransactions(partialTransfer.DepositTransactionId); - this.logger.LogDebug($"DepositTransactionId:{partialTransfer.DepositTransactionId}; {nameof(walletData)}:{walletData.Count}"); + this.logger.LogDebug("DepositTransactionId:{0}; {1}:{}", partialTransfer.DepositTransactionId, nameof(walletData), walletData.Count); if (walletData.Count == 1 && this.ValidateTransaction(walletData[0].transaction)) { @@ -450,8 +450,6 @@ public Task RecordLatestMatureDepositsAsync(IL for (int i = 0; i < deposits.Count; i++) { - this.logger.LogDebug($"{i}={transfers[i]} | {transfers[i]?.Status} || {transfers[i]?.BlockHeight} | {transfers[i]?.DepositTransactionId}"); - if (transfers[i] != null && transfers[i].Status != CrossChainTransferStatus.Suspended) continue; @@ -524,13 +522,13 @@ public Task RecordLatestMatureDepositsAsync(IL { transfers[i] = new CrossChainTransfer(status, deposit.Id, scriptPubKey, deposit.Amount, maturedDeposit.BlockInfo.BlockHeight, transaction, null, null); tracker.SetTransferStatus(transfers[i]); - this.logger.LogDebug($"Set {transfers[i]?.DepositTransactionId} to {status}."); + this.logger.LogDebug("Set {0} to {1}.", transfers[i]?.DepositTransactionId, status); } else { transfers[i].SetPartialTransaction(transaction); tracker.SetTransferStatus(transfers[i], CrossChainTransferStatus.Partial); - this.logger.LogDebug($"Set {transfers[i]?.DepositTransactionId} to Partial."); + this.logger.LogDebug("Set {0} to Partial.", transfers[i]?.DepositTransactionId); } } @@ -625,44 +623,47 @@ public Transaction MergeTransactionSignatures(uint256 depositId, Transaction[] p return transfer.PartialTransaction; } + /* + * // Log this incase we run into issues where the transaction templates doesn't match. + * try { - // Log this incase we run into issues where the transaction templates doesn't match. - this.logger.LogDebug($"Partial Transaction inputs:{partialTransactions[0].Inputs.Count}"); - this.logger.LogDebug($"Partial Transaction outputs:{partialTransactions[0].Outputs.Count}"); + + this.logger.LogDebug("Partial Transaction inputs:{0}", partialTransactions[0].Inputs.Count); + this.logger.LogDebug("Partial Transaction outputs:{1}", partialTransactions[0].Outputs.Count); for (int i = 0; i < partialTransactions[0].Inputs.Count; i++) { TxIn input = partialTransactions[0].Inputs[i]; - this.logger.LogDebug($"Partial Transaction Input N:{input.PrevOut.N} : Hash:{input.PrevOut.Hash}"); + this.logger.LogDebug("Partial Transaction Input N:{0} : Hash:{1}", input.PrevOut.N, input.PrevOut.Hash); } for (int i = 0; i < partialTransactions[0].Outputs.Count; i++) { TxOut output = partialTransactions[0].Outputs[i]; - this.logger.LogDebug($"Partial Transaction Output Value:{output.Value} : ScriptPubKey:{output.ScriptPubKey}"); + this.logger.LogDebug("Partial Transaction Output Value:{0} : ScriptPubKey:{1}", output.Value, output.ScriptPubKey); } - // Log this incase we run into issues where the transaction templates doesn't match. - this.logger.LogDebug($"Transfer Partial Transaction inputs:{transfer.PartialTransaction.Inputs.Count}"); - this.logger.LogDebug($"Transfer Partial Transaction outputs:{transfer.PartialTransaction.Outputs.Count}"); + this.logger.LogDebug("Transfer Partial Transaction inputs:{0}", transfer.PartialTransaction.Inputs.Count); + this.logger.LogDebug("Transfer Partial Transaction outputs:{1}", transfer.PartialTransaction.Outputs.Count); for (int i = 0; i < transfer.PartialTransaction.Inputs.Count; i++) { TxIn transferInput = transfer.PartialTransaction.Inputs[i]; - this.logger.LogDebug($"Transfer Partial Transaction Input N:{transferInput.PrevOut.N} : Hash:{transferInput.PrevOut.Hash}"); + this.logger.LogDebug("Transfer Partial Transaction Input N:{0} : Hash:{1}", transferInput.PrevOut.N, transferInput.PrevOut.Hash); } for (int i = 0; i < transfer.PartialTransaction.Outputs.Count; i++) { TxOut transferOutput = transfer.PartialTransaction.Outputs[i]; - this.logger.LogDebug($"Transfer Partial Transaction Output Value:{transferOutput.Value} : ScriptPubKey:{transferOutput.ScriptPubKey}"); + this.logger.LogDebug("Transfer Partial Transaction Output Value:{0} : ScriptPubKey:{1}", transferOutput.Value, transferOutput.ScriptPubKey); } } catch (Exception err) { this.logger.LogDebug("Failed to log transactions: {0}.", err.Message); } + */ this.logger.LogDebug("Merging signatures for deposit : {0}", depositId); From 435237ca8389489133dc89ccd937c9abe382f48d Mon Sep 17 00:00:00 2001 From: StratisIain <32906542+StratisIain@users.noreply.github.com> Date: Wed, 6 Jan 2021 12:26:48 +0000 Subject: [PATCH 17/55] Additional StraxMain Seeder (#341) * add StraxMain Seeder * fix * doh! * Fix test Co-authored-by: Kevin Loubser --- src/NBitcoin.Tests/NetworkTests.cs | 2 +- src/Stratis.Bitcoin.Networks/StraxMain.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NBitcoin.Tests/NetworkTests.cs b/src/NBitcoin.Tests/NetworkTests.cs index c3320b4fe8..df855af5b2 100644 --- a/src/NBitcoin.Tests/NetworkTests.cs +++ b/src/NBitcoin.Tests/NetworkTests.cs @@ -325,7 +325,7 @@ public void StraxMainIsInitializedCorrectly() Network network = this.straxMain; Assert.Equal(14, network.Checkpoints.Count); - Assert.Single(network.DNSSeeds); + Assert.Equal(2, network.DNSSeeds.Count); Assert.Empty(network.SeedNodes); Assert.Equal("StraxMain", network.Name); diff --git a/src/Stratis.Bitcoin.Networks/StraxMain.cs b/src/Stratis.Bitcoin.Networks/StraxMain.cs index c36acee612..2bdc1e24d4 100644 --- a/src/Stratis.Bitcoin.Networks/StraxMain.cs +++ b/src/Stratis.Bitcoin.Networks/StraxMain.cs @@ -170,7 +170,8 @@ public StraxMain() this.DNSSeeds = new List { - new DNSSeedData("straxmainnet1.stratisnetwork.com", "straxmainnet1.stratisnetwork.com") + new DNSSeedData("straxmainnet1.stratisnetwork.com", "straxmainnet1.stratisnetwork.com"), + new DNSSeedData("straxmainnet2.stratisnetwork.com", "straxmainnet2.stratisnetwork.com") }; this.SeedNodes = new List From 0bf2f268676aace97a6a6f7f97bd3e94139c6ac5 Mon Sep 17 00:00:00 2001 From: quantumagi Date: Wed, 6 Jan 2021 23:28:25 +1100 Subject: [PATCH 18/55] Return SignMessageAsync errors (#343) * Return SignMessageAsync errors * Fix if * Refactor * Refactor * Revert change --- .../Voting/JoinFederationRequestService.cs | 13 +++++++++---- .../Controllers/RestApiClientBase.cs | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs index 1ae8f796cd..0a3edff769 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs @@ -81,11 +81,16 @@ public async Task JoinFederationAsync(JoinFederationRequestModel request }; var walletClient = new WalletClient(this.loggerFactory, this.httpClientFactory, $"http://{this.counterChainSettings.CounterChainApiHost}", this.counterChainSettings.CounterChainApiPort); - string signature = await walletClient.SignMessageAsync(signMessageRequest, cancellationToken); - if (signature == null) - throw new Exception("The call to sign the join federation request failed. It could have timed-out or the counter chain node is offline."); - joinRequest.AddSignature(signature); + try + { + string signature = await walletClient.SignMessageAsync(signMessageRequest, cancellationToken); + joinRequest.AddSignature(signature); + } + catch (Exception err) + { + throw new Exception($"The call to sign the join federation request failed: '{err.Message}'."); + } IWalletTransactionHandler walletTransactionHandler = this.fullNode.NodeService(); var encoder = new JoinFederationRequestEncoder(this.loggerFactory); diff --git a/src/Stratis.Bitcoin/Controllers/RestApiClientBase.cs b/src/Stratis.Bitcoin/Controllers/RestApiClientBase.cs index b533930c16..def9835252 100644 --- a/src/Stratis.Bitcoin/Controllers/RestApiClientBase.cs +++ b/src/Stratis.Bitcoin/Controllers/RestApiClientBase.cs @@ -10,6 +10,7 @@ using Polly; using Polly.Retry; using Stratis.Bitcoin.Utilities; +using Stratis.Bitcoin.Utilities.JsonErrors; namespace Stratis.Bitcoin.Controllers { @@ -109,6 +110,13 @@ protected async Task SendPostRequestAsync(Model reque { HttpResponseMessage response = await this.SendPostRequestAsync(requestModel, apiMethodName, cancellation).ConfigureAwait(false); + if (response != null && !response.IsSuccessStatusCode && response.Content != null) + { + string errorJson = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + var errorResponse = JsonConvert.DeserializeObject(errorJson); + throw new Exception(errorResponse.Errors[0].Message); + } + return await this.ParseHttpResponseMessageAsync(response).ConfigureAwait(false); } From 9989fff3d5441d2745dae1aa477d10778b2c1d0d Mon Sep 17 00:00:00 2001 From: zeptin Date: Wed, 6 Jan 2021 10:00:05 +0000 Subject: [PATCH 19/55] Fix consolidation size estimation logic (#345) * Fix consolidation size estimation logic * Add broadcast flag for convenience --- .../Models/RequestModels.cs | 5 +++++ .../Services/WalletService.cs | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs b/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs index 019ef5f034..f7df9a941a 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Models/RequestModels.cs @@ -1049,5 +1049,10 @@ public ConsolidationRequest() /// [MoneyFormat(isRequired: false, ErrorMessage = "The amount is not in the correct format.")] public string UtxoValueThreshold { get; set; } + + /// + /// For convenience, whether the built consolidated transaction should be automatically broadcast. + /// + public bool Broadcast { get; set; } } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs index bf3678dfc9..ac60266555 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs @@ -1488,6 +1488,11 @@ public async Task Consolidate(ConsolidationRequest request, Cancellation Transaction transaction = this.walletTransactionHandler.BuildTransaction(context); + if (request.Broadcast) + { + this.broadcasterManager.BroadcastTransactionAsync(transaction); + } + return transaction.ToHex(); }, cancellationToken); } @@ -1498,15 +1503,20 @@ private bool SizeAcceptable(int size) return size <= (0.95m * this.network.Consensus.Options.MaxStandardTxWeight); } - private int GetTransactionSizeForUtxoCount(List utxos, int count, WalletAccountReference accountReference, Script destination) + private int GetTransactionSizeForUtxoCount(List utxos, int targetCount, WalletAccountReference accountReference, Script destination) { Money totalToSend = Money.Zero; var outpoints = new List(); - foreach (var utxo in utxos) + int count = 0; + foreach (UnspentOutputReference utxo in utxos) { + if (count >= targetCount) + break; + totalToSend += utxo.Transaction.Amount; outpoints.Add(utxo.ToOutPoint()); + count++; } var context = new TransactionBuildContext(this.network) From da2e24f9e11b7e1a8e43159e8bd2cb1c771398c9 Mon Sep 17 00:00:00 2001 From: StratisIain <32906542+StratisIain@users.noreply.github.com> Date: Tue, 5 Jan 2021 17:12:06 +0000 Subject: [PATCH 20/55] update Dockerfiles (#339) --- Docker/README.md | 2 +- Docker/Stratis.CirrusD.TestNet/Dockerfile | 10 ++ Docker/Stratis.CirrusD.TestNet/cirrus.conf | 130 +++++++++++++++++++++ Docker/Stratis.CirrusD/Dockerfile | 10 ++ Docker/Stratis.CirrusD/cirrus.conf | 119 +++++++++++++++++++ Docker/Stratis.StraxD.TestNet/Dockerfile | 13 +-- Docker/Stratis.StraxD/Dockerfile | 17 +-- 7 files changed, 280 insertions(+), 21 deletions(-) create mode 100644 Docker/Stratis.CirrusD.TestNet/Dockerfile create mode 100644 Docker/Stratis.CirrusD.TestNet/cirrus.conf create mode 100644 Docker/Stratis.CirrusD/Dockerfile create mode 100644 Docker/Stratis.CirrusD/cirrus.conf diff --git a/Docker/README.md b/Docker/README.md index fcda613c6f..094061b8fd 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -6,7 +6,7 @@ Here we have some basic Docker images for StraxD. The images build from the full ``` cd Stratis.StraxD -docker build -t stratisfullnode/straxtest . +docker build -t stratisfullnode/straxmain . ``` # Run the Docker container diff --git a/Docker/Stratis.CirrusD.TestNet/Dockerfile b/Docker/Stratis.CirrusD.TestNet/Dockerfile new file mode 100644 index 0000000000..db549b469d --- /dev/null +++ b/Docker/Stratis.CirrusD.TestNet/Dockerfile @@ -0,0 +1,10 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 + +ARG VERSION=master +ENV VERSION=${VERSION} + +RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.CirrusD && dotnet build +VOLUME /root/.stratisfullnode +WORKDIR /StratisFullNode/src/Stratis.CirrusD +EXPOSE 26179 26175 38223 +CMD ["dotnet", "run", "-testnet"] \ No newline at end of file diff --git a/Docker/Stratis.CirrusD.TestNet/cirrus.conf b/Docker/Stratis.CirrusD.TestNet/cirrus.conf new file mode 100644 index 0000000000..fefbf2a9dc --- /dev/null +++ b/Docker/Stratis.CirrusD.TestNet/cirrus.conf @@ -0,0 +1,130 @@ +####Node Settings#### +#Test network. Defaults to 0. +testnet=1 +#Regression test network. Defaults to 0. +regtest=0 +#Minimum fee rate. Defaults to 10000. +#mintxfee=10000 +#Fallback fee rate. Defaults to 10000. +#fallbackfee=10000 +#Minimum relay fee rate. Defaults to 10000. +#minrelaytxfee=10000 + +####ConnectionManager Settings#### +#The default network port to connect to. Default 26179. +#port=26179 +#Accept connections from the outside. +#listen=<0 or 1> +#This can be used to accept incoming connections when -connect is specified. +#forcelisten=<0 or 1> +#Specified node to connect to. Can be specified multiple times. +#connect= +#Add a node to connect to and attempt to keep the connection open. Can be specified multiple times. +#addnode= +#Bind to given address. Use [host]:port notation for IPv6. Can be specified multiple times. +#bind= +#Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6. Can be specified multiple times. +#whitebind= +#Whitelist peers having the given IP:port address, both inbound or outbound. Can be specified multiple times. +#whitelist= +#Specify your own public address. +#externalip= +#Number of seconds to keep misbehaving peers from reconnecting. Default 1920. +#bantime= +#The maximum number of outbound connections. Default 16. +#maxoutboundconnections= +#The maximum number of inbound connections. Default 109. +#maxinboundconnections= +#The number of connections to be reached before a 1 second connection interval (initally 100ms). Default 1. +#initialconnectiontarget= +#Sync with peers. Default 1. +#synctime=1 +#An optional prefix for the node's user agent shared with peers. Truncated if over 10 characters. +#agentprefix= +#Enable bandwidth saving setting to send and received confirmed blocks only. Defaults to 0. +#blocksonly=0 +#bantime= +#Disallow connection to peers in same IP range. Default is 1 for remote hosts. +#iprangefiltering=<0 or 1> +####BlockStore Settings#### +#Enable to maintain a full transaction index. +#txindex=0 +#Rebuild store with tx index from block data files on disk. +#reindex=0 +#Rebuild the coindb from block data files on disk. +#reindex-chain=0 +#Enable pruning to reduce storage requirements by enabling deleting of old blocks. +#prune=2880 +#The maximum amount of blocks the cache can contain. Default is 5 MB +#maxblkstoremem=5 + +####MemPool Settings#### +#Maximal size of the transaction memory pool in megabytes. Defaults to 300. +#maxmempool=300 +#Maximum number of hours to keep transactions in the mempool. Defaults to 336. +#mempoolexpiry=336 +#Enable high priority for relaying free or low-fee transactions. Defaults to 1. +#relaypriority=1 +#Maximum number of ancestors of a transaction in mempool (including itself). Defaults to 25. +#limitancestorcount=25 +#Maximal size in kB of ancestors of a transaction in mempool (including itself). Defaults to 101. +#limitancestorsize=101 +#Maximum number of descendants any ancestor can have in mempool (including itself). Defaults to 25. +#limitdescendantcount=25 +#Maximum size in kB of descendants any ancestor can have in mempool (including itself). Defaults to 101. +#limitdescendantsize=101. +#Enable transaction replacement in the memory pool. +#mempoolreplacement=0 +#Maximum number of orphan transactions kept in memory. Defaults to 100. +#maxorphantx=100 +#Enable to accept relayed transactions received from whitelisted peers even when not relaying transactions. Defaults to 1. +#whitelistrelay=1 +#Accept non-standard transactions. Default 0. +#acceptnonstdtxn=0 +#Relay non-P2SH multisig. Defaults to True. +#permitbaremultisig=True + +####Consensus Settings#### +#Use checkpoints. Default 1. +#checkpoints=1 +#If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all). Defaults to 57a3119de52cf43b66d6e805a644c20fdee63557038cd68c429d47b21d111084. +#assumevalid=57a3119de52cf43b66d6e805a644c20fdee63557038cd68c429d47b21d111084 +#Max tip age. Default 768. +#maxtipage=768 +#Max memory to use for unconsumed blocks in MB. Default 200. +#maxblkmem=200 +#Max cache memory for the coindb in MB. Default 200. +#dbcache=200 +#How often to flush the cache to disk when in IBD in minutes (min=1min, max=60min). The bigger the number the faster the sync and smaller the db, but shutdown will be longer. +#dbflush=10 + + +####API Settings#### +#URI to node's API interface. Defaults to 'http://localhost'. +#apiuri=http://localhost +#Port of node's API interface. Defaults to 38223. +#apiport=38223 +#Keep Alive interval (set in seconds). Default: 0 (no keep alive). +#keepalive=0 +#Use HTTPS protocol on the API. Default is false. +#usehttps=false +#Path to the file containing the certificate to use for https traffic encryption. Password protected files are not supported. On MacOs, only p12 certificates can be used without password. +#Please refer to .Net Core documentation for usage: 'https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.-ctor?view=netcore-2.1#System_Security_Cryptography_X509Certificates_X509Certificate2__ctor_System_Byte___'. +#certificatefilepath= + +####RPC Settings#### +#Activate RPC Server (default: 0) +#server=0 +#Where the RPC Server binds (default: 127.0.0.1 and ::1) +#rpcbind=127.0.0.1 +#Ip address allowed to connect to RPC (default all: 0.0.0.0 and ::) +#rpcallowip=127.0.0.1 +#Adjust RPC Content Type (default: application/json; charset=utf-8) +#rpccontenttype=application/json; charset=utf-8 + +####API Settings#### +#URI to node's API interface. Defaults to 'http://localhost'. +#signalruri=http://localhost +#Port of node's API interface. Defaults to 38223. +#signalrport=38223 + diff --git a/Docker/Stratis.CirrusD/Dockerfile b/Docker/Stratis.CirrusD/Dockerfile new file mode 100644 index 0000000000..0c4d9ac91a --- /dev/null +++ b/Docker/Stratis.CirrusD/Dockerfile @@ -0,0 +1,10 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 + +ARG VERSION=master +ENV VERSION=${VERSION} + +RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.CirrusD && dotnet build +VOLUME /root/.stratisfullnode +WORKDIR /StratisFullNode/src/Stratis.CirrusD +EXPOSE 16179 16175 37223 +CMD ["dotnet", "run"] \ No newline at end of file diff --git a/Docker/Stratis.CirrusD/cirrus.conf b/Docker/Stratis.CirrusD/cirrus.conf new file mode 100644 index 0000000000..962673a0fb --- /dev/null +++ b/Docker/Stratis.CirrusD/cirrus.conf @@ -0,0 +1,119 @@ +####Node Settings#### +#Test network. Defaults to 0. +testnet=0 +#Regression test network. Defaults to 0. +regtest=0 +#Minimum fee rate. Defaults to 10000. +#mintxfee=10000 +#Fallback fee rate. Defaults to 10000. +#fallbackfee=10000 +#Minimum relay fee rate. Defaults to 10000. +#minrelaytxfee=10000 + +####ConnectionManager Settings#### +#The default network port to connect to. Default 16179. +#port=16179 +#Accept connections from the outside. +#listen=<0 or 1> +#This can be used to accept incoming connections when -connect is specified. +#forcelisten=<0 or 1> +#Specified node to connect to. Can be specified multiple times. +#connect= +#Add a node to connect to and attempt to keep the connection open. Can be specified multiple times. +#addnode= +#Bind to given address. Use [host]:port notation for IPv6. Can be specified multiple times. +#bind= +#Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6. Can be specified multiple times. +#whitebind= +#Whitelist peers having the given IP:port address, both inbound or outbound. Can be specified multiple times. +#whitelist= +#Specify your own public address. +#externalip= +#Number of seconds to keep misbehaving peers from reconnecting. Default 1920. +#bantime= +#The maximum number of outbound connections. Default 16. +#maxoutboundconnections= +#The maximum number of inbound connections. Default 109. +#maxinboundconnections= +#The number of connections to be reached before a 1 second connection interval (initally 100ms). Default 1. +#initialconnectiontarget= +#Sync with peers. Default 1. +#synctime=1 +#An optional prefix for the node's user agent shared with peers. Truncated if over 10 characters. +#agentprefix= +#Enable bandwidth saving setting to send and received confirmed blocks only. Defaults to 0. +#blocksonly=0 +#bantime= +#Disallow connection to peers in same IP range. Default is 1 for remote hosts. +#iprangefiltering=<0 or 1> +####BlockStore Settings#### +#Enable to maintain a full transaction index. +#txindex=0 +#Rebuild chain state and block index from block data files on disk. +#reindex=0 +#Enable pruning to reduce storage requirements by enabling deleting of old blocks. +#prune=2880 +#The maximum amount of blocks the cache can contain. Default is 5 MB +#maxblkstoremem=5 + +####MemPool Settings#### +#Maximal size of the transaction memory pool in megabytes. Defaults to 300. +#maxmempool=300 +#Maximum number of hours to keep transactions in the mempool. Defaults to 336. +#mempoolexpiry=336 +#Enable high priority for relaying free or low-fee transactions. Defaults to 1. +#relaypriority=1 +#Maximum number of ancestors of a transaction in mempool (including itself). Defaults to 25. +#limitancestorcount=25 +#Maximal size in kB of ancestors of a transaction in mempool (including itself). Defaults to 101. +#limitancestorsize=101 +#Maximum number of descendants any ancestor can have in mempool (including itself). Defaults to 25. +#limitdescendantcount=25 +#Maximum size in kB of descendants any ancestor can have in mempool (including itself). Defaults to 101. +#limitdescendantsize=101. +#Enable transaction replacement in the memory pool. +#mempoolreplacement=0 +#Maximum number of orphan transactions kept in memory. Defaults to 100. +#maxorphantx=100 +#Enable to accept relayed transactions received from whitelisted peers even when not relaying transactions. Defaults to 1. +#whitelistrelay=1 +#Accept non-standard transactions. Default 1. +#acceptnonstdtxn=1 + +####Consensus Settings#### +#Use checkpoints. Default 1. +#checkpoints=1 +#If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all). Defaults to . +#assumevalid= +#Max tip age. Default 768. +#maxtipage=768 +#maxblkmem=200 + + +####API Settings#### +#URI to node's API interface. Defaults to 'http://localhost'. +#apiuri=http://localhost +#Port of node's API interface. Defaults to 37223. +#apiport=37223 +#Keep Alive interval (set in seconds). Default: 0 (no keep alive). +#keepalive=0 +#Use HTTPS protocol on the API. Default is false. +#usehttps=false +#Path to the file containing the certificate to use for https traffic encryption. Password protected files are not supported. On MacOs, only p12 certificates can be used without password. +#Please refer to .Net Core documentation for usage: 'https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.-ctor?view=netcore-2.1#System_Security_Cryptography_X509Certificates_X509Certificate2__ctor_System_Byte___'. +#certificatefilepath= + +####RPC Settings#### +#Activate RPC Server (default: 0) +#server=0 +#Where the RPC Server binds (default: 127.0.0.1 and ::1) +#rpcbind=127.0.0.1 +#Ip address allowed to connect to RPC (default all: 0.0.0.0 and ::) +#rpcallowip=127.0.0.1 + +####API Settings#### +#URI to node's API interface. Defaults to 'http://localhost'. +#signalruri=http://localhost +#Port of node's API interface. Defaults to 37223. +#signalrport=37223 + diff --git a/Docker/Stratis.StraxD.TestNet/Dockerfile b/Docker/Stratis.StraxD.TestNet/Dockerfile index 41a411a58f..cab17597e8 100644 --- a/Docker/Stratis.StraxD.TestNet/Dockerfile +++ b/Docker/Stratis.StraxD.TestNet/Dockerfile @@ -1,15 +1,10 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 -RUN git clone https://github.com/stratisproject/StratisFullNode.git \ - && cd /StratisFullNode/src/Stratis.StraxD \ - && dotnet build +ARG VERSION=master +ENV VERSION=${VERSION} +RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.StraxD && dotnet build VOLUME /root/.stratisfullnode - WORKDIR /StratisFullNode/src/Stratis.StraxD - -COPY strax.conf.docker /root/.stratisnode/strax/StraxTest/strax.conf - EXPOSE 27103 27104 27105 - -CMD ["dotnet", "run", "-testnet"] +CMD ["dotnet", "run", "-testnet"] \ No newline at end of file diff --git a/Docker/Stratis.StraxD/Dockerfile b/Docker/Stratis.StraxD/Dockerfile index 6452f06b38..a8c7af1347 100644 --- a/Docker/Stratis.StraxD/Dockerfile +++ b/Docker/Stratis.StraxD/Dockerfile @@ -1,15 +1,10 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 -RUN git clone https://github.com/stratisproject/StratisFullNode.git \ - && cd /StratisFullNode/src/Stratis.StraxD \ - && dotnet build - -VOLUME /root/.stratisfullnode +ARG VERSION=master +ENV VERSION=${VERSION} +RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.StraxD && dotnet build +VOLUME /root/.stratisfullnode WORKDIR /StratisFullNode/src/Stratis.StraxD - -COPY strax.conf.docker /root/.stratisnode/strax/StraxMain/strax.conf - -EXPOSE 17103 17104 17105 - -CMD ["dotnet", "run"] +EXPOSE 17105 17104 17103 +CMD ["dotnet", "run"] \ No newline at end of file From 56ac169e4a0bd110cbf1a96ca39110099dec2d25 Mon Sep 17 00:00:00 2001 From: StratisIain <32906542+StratisIain@users.noreply.github.com> Date: Wed, 6 Jan 2021 11:03:20 +0000 Subject: [PATCH 21/55] update Dockerfiles (#340) --- Docker/Stratis.CirrusD.TestNet/Dockerfile | 3 ++- Docker/Stratis.CirrusD/Dockerfile | 3 ++- Docker/Stratis.StraxD.TestNet/Dockerfile | 3 ++- Docker/Stratis.StraxD/Dockerfile | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Docker/Stratis.CirrusD.TestNet/Dockerfile b/Docker/Stratis.CirrusD.TestNet/Dockerfile index db549b469d..7e8ddc692b 100644 --- a/Docker/Stratis.CirrusD.TestNet/Dockerfile +++ b/Docker/Stratis.CirrusD.TestNet/Dockerfile @@ -3,7 +3,8 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ARG VERSION=master ENV VERSION=${VERSION} -RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.CirrusD && dotnet build +RUN if [ "$VERSION" = "master" ]; then git clone https://github.com/stratisproject/StratisFullNode.git; else git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}"; fi +RUN cd /StratisFullNode/src/Stratis.StraxD && dotnet build VOLUME /root/.stratisfullnode WORKDIR /StratisFullNode/src/Stratis.CirrusD EXPOSE 26179 26175 38223 diff --git a/Docker/Stratis.CirrusD/Dockerfile b/Docker/Stratis.CirrusD/Dockerfile index 0c4d9ac91a..ad18db3d76 100644 --- a/Docker/Stratis.CirrusD/Dockerfile +++ b/Docker/Stratis.CirrusD/Dockerfile @@ -3,7 +3,8 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ARG VERSION=master ENV VERSION=${VERSION} -RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.CirrusD && dotnet build +RUN if [ "$VERSION" = "master" ]; then git clone https://github.com/stratisproject/StratisFullNode.git; else git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}"; fi +RUN cd /StratisFullNode/src/Stratis.StraxD && dotnet build VOLUME /root/.stratisfullnode WORKDIR /StratisFullNode/src/Stratis.CirrusD EXPOSE 16179 16175 37223 diff --git a/Docker/Stratis.StraxD.TestNet/Dockerfile b/Docker/Stratis.StraxD.TestNet/Dockerfile index cab17597e8..e474d62252 100644 --- a/Docker/Stratis.StraxD.TestNet/Dockerfile +++ b/Docker/Stratis.StraxD.TestNet/Dockerfile @@ -3,7 +3,8 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ARG VERSION=master ENV VERSION=${VERSION} -RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.StraxD && dotnet build +RUN if [ "$VERSION" = "master" ]; then git clone https://github.com/stratisproject/StratisFullNode.git; else git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}"; fi +RUN cd /StratisFullNode/src/Stratis.StraxD && dotnet build VOLUME /root/.stratisfullnode WORKDIR /StratisFullNode/src/Stratis.StraxD EXPOSE 27103 27104 27105 diff --git a/Docker/Stratis.StraxD/Dockerfile b/Docker/Stratis.StraxD/Dockerfile index a8c7af1347..496c65a695 100644 --- a/Docker/Stratis.StraxD/Dockerfile +++ b/Docker/Stratis.StraxD/Dockerfile @@ -3,7 +3,8 @@ FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ARG VERSION=master ENV VERSION=${VERSION} -RUN git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}" && cd /StratisFullNode/src/Stratis.StraxD && dotnet build +RUN if [ "$VERSION" = "master" ]; then git clone https://github.com/stratisproject/StratisFullNode.git; else git clone https://github.com/stratisproject/StratisFullNode.git -b "release/${VERSION}"; fi +RUN cd /StratisFullNode/src/Stratis.StraxD && dotnet build VOLUME /root/.stratisfullnode WORKDIR /StratisFullNode/src/Stratis.StraxD EXPOSE 17105 17104 17103 From a72cb92c5881c1400d91745e81d71eec13a92b2a Mon Sep 17 00:00:00 2001 From: zeptin Date: Thu, 7 Jan 2021 07:40:00 +0000 Subject: [PATCH 22/55] Require at least 1 confirmation for consolidation (#347) --- src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs index ac60266555..88dd713124 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Services/WalletService.cs @@ -1389,11 +1389,11 @@ public async Task Consolidate(ConsolidationRequest request, Cancellation if (!string.IsNullOrWhiteSpace(request.SingleAddress)) { - utxos = this.walletManager.GetSpendableTransactionsInWallet(request.WalletName).Where(u => u.Address.Address == request.SingleAddress || u.Address.Address == request.SingleAddress).OrderBy(u2 => u2.Transaction.Amount).ToList(); + utxos = this.walletManager.GetSpendableTransactionsInWallet(request.WalletName, 1).Where(u => u.Address.Address == request.SingleAddress || u.Address.Address == request.SingleAddress).OrderBy(u2 => u2.Transaction.Amount).ToList(); } else { - utxos = this.walletManager.GetSpendableTransactionsInAccount(accountReference).OrderBy(u2 => u2.Transaction.Amount).ToList(); + utxos = this.walletManager.GetSpendableTransactionsInAccount(accountReference, 1).OrderBy(u2 => u2.Transaction.Amount).ToList(); } if (utxos.Count == 0) From ec9981a64d78f112b0ad0778d0c3bdb1718574d5 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 7 Jan 2021 09:28:39 +0000 Subject: [PATCH 23/55] Update WithdrawalTransactionBuilderTests.cs (#351) --- .../WithdrawalTransactionBuilderTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Features.FederatedPeg.Tests/WithdrawalTransactionBuilderTests.cs b/src/Stratis.Features.FederatedPeg.Tests/WithdrawalTransactionBuilderTests.cs index adbd7977f4..57d11dc2ad 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/WithdrawalTransactionBuilderTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/WithdrawalTransactionBuilderTests.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging; using Moq; using NBitcoin; +using NBitcoin.Networks; using Stratis.Bitcoin.Features.Wallet; using Stratis.Bitcoin.Signals; using Stratis.Features.FederatedPeg.Interfaces; @@ -31,7 +32,7 @@ public class WithdrawalTransactionBuilderTests public WithdrawalTransactionBuilderTests() { this.loggerFactory = new Mock(); - this.network = new CirrusRegTest(); + this.network = NetworkRegistration.Register(new CirrusRegTest()); this.federationWalletManager = new Mock(); this.federationWalletTransactionHandler = new Mock(); this.federationGatewaySettings = new Mock(); From 8a9475039bbdb289fdfb83eea5d9a9ebb286f227 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 12 Jan 2021 15:14:06 +0000 Subject: [PATCH 24/55] Sidechain masternode rc (#363) * Fix CCTS Partial Txs logic / Better Console Logging for CCTS (#357) * Fix partial count bug * Move some console logs to CCTS * Fix Build * Fix console output * Update CrossChainTransferStore.cs * Update CrossChainTransferStore.cs * Update MaturedBlocksSyncManager.cs * Remove status count method * Fix federation wallet console stats (#358) * Fix partial count bug * Move some console logs to CCTS * Fix Build * Fix console output * Update CrossChainTransferStore.cs * Update CrossChainTransferStore.cs * Update MaturedBlocksSyncManager.cs * Remove status count method * Move federation wallet stats * Fix Build * Fix (#359) * Fix string interpolation / some logging (#349) * Fix interpolation * Fixes * Update WithdrawalTransactionBuilder.cs * Fix Test * Revert * Bumper version 1.0.6.1 (#361) * Move pending and completed withdrawal stats to CCTS (#360) * Move pending and completed withdrawal stats * Update WithdrawalModel.cs * Update AssemblyInfo.cs (#362) --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- .../Stratis.Bitcoin.Cli.csproj | 2 +- .../LoggingActionFilter.cs | 4 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Pruning/PruneBlockStoreService.cs | 2 +- ...Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- ...tratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../ProvenBlockHeaderStore.cs | 2 +- .../Rules/CommonRules/StraxCoinviewRule.cs | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- ...tratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../MempoolFeature.cs | 2 - .../Rules/StraxCoinViewMempoolRule.cs | 2 +- ...Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- ...atis.Bitcoin.Features.Notifications.csproj | 2 +- .../PoAHeaderSignatureRule.cs | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Broadcasters/BroadcasterBase.cs | 3 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- ...tis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- ...is.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.Networks.csproj | 6 +- .../Properties/AssemblyInfo.cs | 4 +- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- .../Stratis.CirrusDnsD.csproj | 2 +- .../Stratis.CirrusMinerD.csproj | 2 +- .../Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../FederationWalletControllerTests.cs | 10 +- .../CrossChainTestBase.cs | 5 +- .../Wallet/FederationWalletManagerTests.cs | 1 + .../Controllers/FederationWalletController.cs | 37 ++--- .../Distribution/RewardDistributionManager.cs | 2 +- .../FederatedPegFeature.cs | 142 +----------------- .../Interfaces/ICrossChainTransferStore.cs | 15 +- .../Models/WithdrawalModel.cs | 2 +- .../PartialTransactionsBehavior.cs | 10 +- .../SourceChain/MaturedBlocksProvider.cs | 8 +- .../TargetChain/CrossChainTransferStore.cs | 127 ++++++++++++---- .../TargetChain/MaturedBlocksSyncManager.cs | 5 - .../TargetChain/MempoolCleaner.cs | 2 +- .../SignedMultisigTransactionBroadcaster.cs | 2 +- .../TargetChain/WithdrawalHistoryProvider.cs | 35 ++--- .../Wallet/FederationWalletManager.cs | 41 ++++- ...tis.Features.SQLiteWalletRepository.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- .../Stratis.StraxDnsD.csproj | 2 +- 53 files changed, 242 insertions(+), 285 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index eeff31186a..e7e6dee070 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index 13dbcc0bd9..43d8d4b5cd 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 7c0dd4aafd..be9cf911e6 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/LoggingActionFilter.cs b/src/Stratis.Bitcoin.Features.Api/LoggingActionFilter.cs index f0b883f72a..3f9241024f 100644 --- a/src/Stratis.Bitcoin.Features.Api/LoggingActionFilter.cs +++ b/src/Stratis.Bitcoin.Features.Api/LoggingActionFilter.cs @@ -12,7 +12,7 @@ namespace Stratis.Bitcoin.Features.Api /// /// An asynchronous action filter whose role is to log details from the Http requests to the API. /// - /// + /// public class LoggingActionFilter : IAsyncActionFilter { private readonly ILogger logger; @@ -34,7 +34,7 @@ public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionE body = string.Join(Environment.NewLine, arguments.Values); } - this.logger.LogDebug($"Received {request.Method} {request.GetDisplayUrl()}. Body: '{body}'"); + this.logger.LogDebug("Received {0} {1}. Body: '{2}'", request.Method, request.GetDisplayUrl(), body); await next(); } } diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index f036ce073f..9e3bc3f103 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.6.0 + 1.0.6.1 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Pruning/PruneBlockStoreService.cs b/src/Stratis.Bitcoin.Features.BlockStore/Pruning/PruneBlockStoreService.cs index c967c124ce..9cc50aa3f9 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Pruning/PruneBlockStoreService.cs +++ b/src/Stratis.Bitcoin.Features.BlockStore/Pruning/PruneBlockStoreService.cs @@ -97,7 +97,7 @@ public void PruneBlocks() startFrom = startFrom.Previous; } - this.logger.LogDebug($"{chainedHeadersToDelete.Count} blocks will be pruned."); + this.logger.LogDebug("{0} blocks will be pruned.", chainedHeadersToDelete.Count); ChainedHeader prunedTip = chainedHeadersToDelete.First(); diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index 70813edfb0..e86868c1c9 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index 4c098e8da2..93f80d16f0 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/ProvenBlockHeaders/ProvenBlockHeaderStore.cs b/src/Stratis.Bitcoin.Features.Consensus/ProvenBlockHeaders/ProvenBlockHeaderStore.cs index bf82d31ccd..08b77d11b3 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/ProvenBlockHeaders/ProvenBlockHeaderStore.cs +++ b/src/Stratis.Bitcoin.Features.Consensus/ProvenBlockHeaders/ProvenBlockHeaderStore.cs @@ -352,7 +352,7 @@ private void AddComponentStats(StringBuilder log) log.AppendLine("======ProvenBlockHeaderStore======"); log.AppendLine($"Batch Size: {Math.Round(totalBatchInMb, 2)} Mb ({count} headers)"); log.AppendLine($"Cache Size: {Math.Round(totalCacheInMb, 2)}/{Math.Round(totalMaxCacheInMb, 2)} MB"); - + log.AppendLine(); } /// diff --git a/src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/StraxCoinviewRule.cs b/src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/StraxCoinviewRule.cs index 64f91329b8..43dcd257c9 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/StraxCoinviewRule.cs +++ b/src/Stratis.Bitcoin.Features.Consensus/Rules/CommonRules/StraxCoinviewRule.cs @@ -101,7 +101,7 @@ protected override void AllowSpend(TxOut prevOut, Transaction tx) } // TODO: This is the wrong destination message. Should be output.scriptpubkey? - this.Logger.LogDebug($"Reward distribution transaction validated in consensus, spending to '{prevOut.ScriptPubKey}'."); + this.Logger.LogDebug("Reward distribution transaction validated in consensus, spending to '{0}'.", prevOut.ScriptPubKey); } // Otherwise allow the spend (do nothing). diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index 9e3f4eda96..df4c48a244 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index 970501bd2c..0980f0c2c2 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index cbaee9531c..6e4a4393eb 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/MempoolFeature.cs b/src/Stratis.Bitcoin.Features.MemoryPool/MempoolFeature.cs index 4c90431336..d21770e863 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/MempoolFeature.cs +++ b/src/Stratis.Bitcoin.Features.MemoryPool/MempoolFeature.cs @@ -11,7 +11,6 @@ using Stratis.Bitcoin.Features.Consensus; using Stratis.Bitcoin.Features.MemoryPool.Fee; using Stratis.Bitcoin.Features.MemoryPool.Interfaces; -using Stratis.Bitcoin.Features.MemoryPool.Rules; using Stratis.Bitcoin.Interfaces; using Stratis.Bitcoin.Utilities; using TracerAttributes; @@ -77,7 +76,6 @@ private void AddComponentStats(StringBuilder log) { if (this.mempoolManager != null) { - log.AppendLine(); log.AppendLine("=======Mempool======="); log.AppendLine(this.mempoolManager.PerformanceCounter.ToString()); } diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Rules/StraxCoinViewMempoolRule.cs b/src/Stratis.Bitcoin.Features.MemoryPool/Rules/StraxCoinViewMempoolRule.cs index 06b679c7b9..e1cc5e170e 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Rules/StraxCoinViewMempoolRule.cs +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Rules/StraxCoinViewMempoolRule.cs @@ -38,7 +38,7 @@ public override void CheckTransaction(MempoolValidationContext context) if (unspentOutput.Coins.TxOut.ScriptPubKey == StraxCoinstakeRule.CirrusRewardScript) { - this.logger.LogDebug($"Reward distribution transaction seen in mempool, paying to '{unspentOutput.Coins.TxOut.ScriptPubKey}'."); + this.logger.LogDebug("Reward distribution transaction seen in mempool, paying to '{0}'.", unspentOutput.Coins.TxOut.ScriptPubKey); foreach (TxOut output in context.Transaction.Outputs) { diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 30a22e8cd7..0d6250c615 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index c354b61878..c9ec28e30b 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index 770b068d9d..004a786b72 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs index 6e485bb1e4..cfb593bb85 100644 --- a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs +++ b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs @@ -94,7 +94,7 @@ public override async Task RunAsync(RuleContext context) if (this.slotsManager.GetRoundLengthSeconds(this.federationHistory.GetFederationForBlock(prevHeader.Previous).Count) != roundTime) break; - this.Logger.LogDebug($"Block {prevHeader.HashBlock} was mined by the same miner '{pubKey.ToHex()}' as {blockCounter} blocks ({header.Time - prevHeader.Header.Time})s ago and there was no federation change."); + this.Logger.LogDebug("Block {0} was mined by the same miner '{1}' as {2} blocks ({3})s ago and there was no federation change.", prevHeader.HashBlock, pubKey.ToHex(), blockCounter, header.Time - prevHeader.Header.Time); this.Logger.LogTrace("(-)[TIME_TOO_EARLY]"); ConsensusErrors.BlockTimestampTooEarly.Throw(); } diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index 704fd0d596..3c3aa9a409 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 0a2851197c..4aa0ddf9b3 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Broadcasters/BroadcasterBase.cs b/src/Stratis.Bitcoin.Features.SignalR/Broadcasters/BroadcasterBase.cs index 21fa98f4fb..ac93c4ab87 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Broadcasters/BroadcasterBase.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/Broadcasters/BroadcasterBase.cs @@ -33,7 +33,8 @@ protected ClientBroadcasterBase( public void Init(ClientEventBroadcasterSettings broadcasterSettings) { - this.logger.LogDebug($"Initialising SignalR Broadcaster {this.GetType().Name}"); + this.logger.LogDebug("Initialising SignalR Broadcaster {0}", this.GetType().Name); + this.asyncLoop = this.asyncProvider.CreateAndRunAsyncLoop( $"Broadcast {this.GetType().Name}", async token => diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index 2d341c1523..f8e5f4d6dd 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index f4c5006edd..2ebafc00e8 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index c43ce60ea9..04f1c5ef85 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index 48b1f708fb..2efbfa5dbf 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index 6065a6d48d..36ccaabd72 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.6.0 - 1.0.6.0 - 1.0.6.0 + 1.0.6.1 + 1.0.6.1 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 46278e62d0..a6fea09e6c 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.6.0")] -[assembly: AssemblyFileVersion("1.0.6.0")] +[assembly: AssemblyVersion("1.0.6.1")] +[assembly: AssemblyFileVersion("1.0.6.1")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index c49d11a34e..f2056108d0 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False ..\Stratis.ruleset Stratis Group Ltd. diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index 4c7504dea4..e8b5b69246 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index 81e949c763..c8d6290ea3 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.6.0 + 1.0.6.1 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 5dc4acc8fe..ac6e189731 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index 8b222cf5a3..89556e30ca 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 5582b3b858..b824284736 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. diff --git a/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationWalletControllerTests.cs b/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationWalletControllerTests.cs index 7a24249a61..e118ad686b 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationWalletControllerTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationWalletControllerTests.cs @@ -54,7 +54,7 @@ public FederationWalletControllerTests() this.withdrawalHistoryProvider = Substitute.For(); this.controller = new FederationWalletController(this.loggerFactory, this.walletManager, this.walletSyncManager, - this.connectionManager, this.network, this.chainIndexer, this.dateTimeProvider, this.withdrawalHistoryProvider); + this.connectionManager, this.network, this.chainIndexer, Substitute.For()); this.fedWallet = new FederationWallet { @@ -106,7 +106,7 @@ public void GetHistory() { var withdrawals = new List() { new WithdrawalModel(), new WithdrawalModel() }; - this.withdrawalHistoryProvider.GetHistory(0).ReturnsForAnyArgs(withdrawals); + this.withdrawalHistoryProvider.GetHistory(new[] { new CrossChainTransfer() }, 0).ReturnsForAnyArgs(withdrawals); IActionResult result = this.controller.GetHistory(5); List model = this.ActionResultToModel>(result); @@ -141,8 +141,10 @@ public void EnableFederation() [Fact] public void RemoveTransactions() { - var hashSet = new HashSet<(uint256, DateTimeOffset)>(); - hashSet.Add((uint256.One, DateTimeOffset.MinValue)); + var hashSet = new HashSet<(uint256, DateTimeOffset)> + { + (uint256.One, DateTimeOffset.MinValue) + }; this.walletManager.RemoveAllTransactions().Returns(info => hashSet); diff --git a/src/Stratis.Features.FederatedPeg.Tests/CrossChainTestBase.cs b/src/Stratis.Features.FederatedPeg.Tests/CrossChainTestBase.cs index 4380bc9eed..7c6d6584b5 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/CrossChainTestBase.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/CrossChainTestBase.cs @@ -206,6 +206,7 @@ protected void Init(DataFolder dataFolder) this.federationWalletManager = new FederationWalletManager( this.loggerFactory, this.network, + Substitute.For(), this.ChainIndexer, dataFolder, this.walletFeePolicy, @@ -244,8 +245,8 @@ protected void Init(DataFolder dataFolder) protected ICrossChainTransferStore CreateStore() { - return new CrossChainTransferStore(this.network, this.dataFolder, this.ChainIndexer, this.federatedPegSettings, this.dateTimeProvider, - this.loggerFactory, this.withdrawalExtractor, this.blockRepository, this.federationWalletManager, this.withdrawalTransactionBuilder, this.dBreezeSerializer, this.signals, this.stateRepositoryRoot); + return new CrossChainTransferStore(this.network, Substitute.For(), this.dataFolder, this.ChainIndexer, this.federatedPegSettings, this.dateTimeProvider, + this.loggerFactory, this.withdrawalExtractor, Substitute.For(), this.blockRepository, this.federationWalletManager, this.withdrawalTransactionBuilder, this.dBreezeSerializer, this.signals, this.stateRepositoryRoot); } /// diff --git a/src/Stratis.Features.FederatedPeg.Tests/Wallet/FederationWalletManagerTests.cs b/src/Stratis.Features.FederatedPeg.Tests/Wallet/FederationWalletManagerTests.cs index e729062bb8..8bd50296e4 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/Wallet/FederationWalletManagerTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/Wallet/FederationWalletManagerTests.cs @@ -113,6 +113,7 @@ private FederationWalletManager CreateFederationWalletManager() var federationWalletManager = new FederationWalletManager( loggerFactory.Object, this.network, + new Mock().Object, chainIndexer, dataFolder, new Mock().Object, diff --git a/src/Stratis.Features.FederatedPeg/Controllers/FederationWalletController.cs b/src/Stratis.Features.FederatedPeg/Controllers/FederationWalletController.cs index 4c643a63d7..09f5e674db 100644 --- a/src/Stratis.Features.FederatedPeg/Controllers/FederationWalletController.cs +++ b/src/Stratis.Features.FederatedPeg/Controllers/FederationWalletController.cs @@ -15,7 +15,6 @@ using Stratis.Bitcoin.Utilities.ModelStateErrors; using Stratis.Features.FederatedPeg.Interfaces; using Stratis.Features.FederatedPeg.Models; -using Stratis.Features.FederatedPeg.TargetChain; using Stratis.Features.FederatedPeg.Wallet; namespace Stratis.Features.FederatedPeg.Controllers @@ -37,18 +36,13 @@ public static class FederationWalletRouteEndPoint [Route("api/[controller]")] public class FederationWalletController : Controller { + private readonly ICrossChainTransferStore crossChainTransferStore; private readonly IFederationWalletManager federationWalletManager; - + private readonly Network network; private readonly IFederationWalletSyncManager walletSyncManager; - - private readonly CoinType coinType; - private readonly IConnectionManager connectionManager; - private readonly ChainIndexer chainIndexer; - private readonly IWithdrawalHistoryProvider withdrawalHistoryProvider; - /// Instance logger. private readonly ILogger logger; @@ -59,16 +53,15 @@ public FederationWalletController( IConnectionManager connectionManager, Network network, ChainIndexer chainIndexer, - IDateTimeProvider dateTimeProvider, - IWithdrawalHistoryProvider withdrawalHistoryProvider) + ICrossChainTransferStore crossChainTransferStore) { - this.federationWalletManager = walletManager; - this.walletSyncManager = walletSyncManager; this.connectionManager = connectionManager; - this.withdrawalHistoryProvider = withdrawalHistoryProvider; - this.coinType = (CoinType)network.Consensus.CoinType; + this.crossChainTransferStore = crossChainTransferStore; this.chainIndexer = chainIndexer; + this.federationWalletManager = walletManager; + this.network = network; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); + this.walletSyncManager = walletSyncManager; } /// @@ -136,13 +129,13 @@ public IActionResult GetBalance() return this.NotFound("No federation wallet found."); } - (Money ConfirmedAmount, Money UnConfirmedAmount) result = this.federationWalletManager.GetSpendableAmount(); + (Money ConfirmedAmount, Money UnConfirmedAmount) = this.federationWalletManager.GetSpendableAmount(); var balance = new AccountBalanceModel { - CoinType = this.coinType, - AmountConfirmed = result.ConfirmedAmount, - AmountUnconfirmed = result.UnConfirmedAmount, + CoinType = (CoinType)this.network.Consensus.CoinType, + AmountConfirmed = ConfirmedAmount, + AmountUnconfirmed = UnConfirmedAmount, }; var model = new WalletBalanceModel(); @@ -175,11 +168,9 @@ public IActionResult GetHistory([FromQuery] int maxEntriesToReturn) { FederationWallet wallet = this.federationWalletManager.GetWallet(); if (wallet == null) - { return this.NotFound("No federation wallet found."); - } - List result = this.withdrawalHistoryProvider.GetHistory(maxEntriesToReturn); + List result = this.crossChainTransferStore.GetCompletedWithdrawals(maxEntriesToReturn); return this.Json(result); } @@ -235,7 +226,7 @@ public IActionResult Sync([FromBody] HashModel model) [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.InternalServerError)] - public IActionResult EnableFederation([FromBody]EnableFederationRequest request) + public IActionResult EnableFederation([FromBody] EnableFederationRequest request) { Guard.NotNull(request, nameof(request)); @@ -282,7 +273,7 @@ public IActionResult EnableFederation([FromBody]EnableFederationRequest request) [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.InternalServerError)] - public IActionResult RemoveTransactions([FromQuery]RemoveFederationTransactionsModel request) + public IActionResult RemoveTransactions([FromQuery] RemoveFederationTransactionsModel request) { Guard.NotNull(request, nameof(request)); diff --git a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs index 1ee1993401..ff4683e607 100644 --- a/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs +++ b/src/Stratis.Features.FederatedPeg/Distribution/RewardDistributionManager.cs @@ -121,7 +121,7 @@ public List Distribute(int heightOfRecordedDistributionDeposit, Money // Ensure that the dictionary is cleared on every run. // As this is a static class, new instances of this dictionary will - // only be cleaned up once the node shutsdown. It is therefore better + // only be cleaned up once the node shuts down. It is therefore better // to use a single instance to work with. this.blocksMinedEach.Clear(); diff --git a/src/Stratis.Features.FederatedPeg/FederatedPegFeature.cs b/src/Stratis.Features.FederatedPeg/FederatedPegFeature.cs index 3469f522a3..91f48a4ab4 100644 --- a/src/Stratis.Features.FederatedPeg/FederatedPegFeature.cs +++ b/src/Stratis.Features.FederatedPeg/FederatedPegFeature.cs @@ -13,7 +13,6 @@ using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Connection; -using Stratis.Bitcoin.Features.Api; using Stratis.Bitcoin.Features.Miner; using Stratis.Bitcoin.Features.Notifications; using Stratis.Bitcoin.Features.SmartContracts; @@ -26,7 +25,6 @@ using Stratis.Features.FederatedPeg.Distribution; using Stratis.Features.FederatedPeg.InputConsolidation; using Stratis.Features.FederatedPeg.Interfaces; -using Stratis.Features.FederatedPeg.Models; using Stratis.Features.FederatedPeg.Notifications; using Stratis.Features.FederatedPeg.Payloads; using Stratis.Features.FederatedPeg.SourceChain; @@ -41,16 +39,6 @@ namespace Stratis.Features.FederatedPeg { internal class FederatedPegFeature : FullNodeFeature { - /// - /// Given that we can have up to 10 UTXOs going at once. - /// - private const int TransfersToDisplay = 10; - - /// - /// The maximum number of pending transactions to display in the console logging. - /// - private const int PendingToDisplay = 25; - public const string FederationGatewayFeatureNamespace = "federationgateway"; private readonly IConnectionManager connectionManager; @@ -65,8 +53,6 @@ internal class FederatedPegFeature : FullNodeFeature private readonly IFederationWalletSyncManager walletSyncManager; - private readonly ChainIndexer chainIndexer; - private readonly Network network; private readonly ICrossChainTransferStore crossChainTransferStore; @@ -79,8 +65,6 @@ internal class FederatedPegFeature : FullNodeFeature private readonly IMaturedBlocksSyncManager maturedBlocksSyncManager; - private readonly IWithdrawalHistoryProvider withdrawalHistoryProvider; - private readonly IInputConsolidator inputConsolidator; private readonly ILogger logger; @@ -93,14 +77,12 @@ public FederatedPegFeature( IFederationWalletManager federationWalletManager, IFederationWalletSyncManager walletSyncManager, Network network, - ChainIndexer chainIndexer, INodeStats nodeStats, ICrossChainTransferStore crossChainTransferStore, IPartialTransactionRequester partialTransactionRequester, MempoolCleaner mempoolCleaner, ISignedMultisigTransactionBroadcaster signedBroadcaster, IMaturedBlocksSyncManager maturedBlocksSyncManager, - IWithdrawalHistoryProvider withdrawalHistoryProvider, IInputConsolidator inputConsolidator, ICollateralChecker collateralChecker = null) { @@ -108,7 +90,6 @@ public FederatedPegFeature( this.connectionManager = connectionManager; this.federatedPegSettings = federatedPegSettings; this.fullNode = fullNode; - this.chainIndexer = chainIndexer; this.federationWalletManager = federationWalletManager; this.walletSyncManager = walletSyncManager; this.network = network; @@ -116,7 +97,6 @@ public FederatedPegFeature( this.partialTransactionRequester = partialTransactionRequester; this.mempoolCleaner = mempoolCleaner; this.maturedBlocksSyncManager = maturedBlocksSyncManager; - this.withdrawalHistoryProvider = withdrawalHistoryProvider; this.signedBroadcaster = signedBroadcaster; this.inputConsolidator = inputConsolidator; @@ -127,7 +107,6 @@ public FederatedPegFeature( payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload)); nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name); - nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800); } public override async Task InitializeAsync() @@ -196,22 +175,6 @@ public override void Dispose() this.crossChainTransferStore.Dispose(); } - [NoTrace] - private void AddInlineStats(StringBuilder benchLogs) - { - if (this.federationWalletManager == null) - return; - - int height = this.federationWalletManager.LastBlockSyncedHashHeight().Height; - ChainedHeader block = this.chainIndexer.GetHeader(height); - uint256 hashBlock = block == null ? 0 : block.HashBlock; - - FederationWallet federationWallet = this.federationWalletManager.GetWallet(); - benchLogs.AppendLine("Fed.Wallet.Height: ".PadRight(LoggingConfiguration.ColumnLength + 1) + - (federationWallet != null ? height.ToString().PadRight(8) : "No Wallet".PadRight(8)) + - (federationWallet != null ? (" Fed.Wallet.Hash: ".PadRight(LoggingConfiguration.ColumnLength - 1) + hashBlock) : string.Empty)); - } - [NoTrace] private void AddComponentStats(StringBuilder benchLog) { @@ -230,38 +193,14 @@ private void AddComponentStats(StringBuilder benchLog) private string CollectStats() { StringBuilder benchLog = new StringBuilder(); - benchLog.AppendLine(); - benchLog.AppendLine("====== Federation Wallet ======"); - - (Money ConfirmedAmount, Money UnConfirmedAmount) = this.federationWalletManager.GetSpendableAmount(); - - bool isFederationActive = this.federationWalletManager.IsFederationWalletActive(); - - benchLog.AppendLine("Federation Wallet: ".PadRight(LoggingConfiguration.ColumnLength) - + " Confirmed balance: " + ConfirmedAmount.ToString().PadRight(LoggingConfiguration.ColumnLength) - + " Reserved for withdrawals: " + UnConfirmedAmount.ToString().PadRight(LoggingConfiguration.ColumnLength) - + " Federation Status: " + (isFederationActive ? "Active" : "Inactive")); - benchLog.AppendLine(); - - if (!isFederationActive) - { - var apiSettings = (ApiSettings)this.fullNode.Services.ServiceProvider.GetService(typeof(ApiSettings)); - - benchLog.AppendLine("".PadRight(59, '=') + " W A R N I N G " + "".PadRight(59, '=')); - benchLog.AppendLine(); - benchLog.AppendLine("This federation node is not enabled. You will not be able to store or participate in signing of transactions until you enable it."); - benchLog.AppendLine("If not done previously, please enable your federation node using " + $"{apiSettings.ApiUri}/api/FederationWallet/{FederationWalletRouteEndPoint.EnableFederation}."); - benchLog.AppendLine(); - benchLog.AppendLine("".PadRight(133, '=')); - benchLog.AppendLine(); - } List consolidationPartials = this.inputConsolidator.ConsolidationTransactions; if (consolidationPartials != null) { benchLog.AppendLine("--- Consolidation Transactions in Memory ---"); - foreach (ConsolidationTransaction partial in consolidationPartials) + + foreach (ConsolidationTransaction partial in consolidationPartials.Take(20)) { benchLog.AppendLine( string.Format("Tran#={0} TotalOut={1,12} Status={2} Signatures=({3}/{4})", @@ -273,6 +212,10 @@ private string CollectStats() ) ); } + + if (consolidationPartials.Count > 20) + benchLog.AppendLine($"and {consolidationPartials.Count - 20} more..."); + benchLog.AppendLine(); } @@ -296,81 +239,8 @@ private string CollectStats() benchLog.AppendLine(); } - try - { - List pendingWithdrawals = this.withdrawalHistoryProvider.GetPending(); - - if (pendingWithdrawals.Count > 0) - { - benchLog.AppendLine("--- Pending Withdrawals ---"); - foreach (WithdrawalModel withdrawal in pendingWithdrawals.Take(PendingToDisplay)) - benchLog.AppendLine(withdrawal.ToString()); - - if (pendingWithdrawals.Count > PendingToDisplay) - benchLog.AppendLine($"And {pendingWithdrawals.Count - PendingToDisplay} more..."); - - benchLog.AppendLine(); - } - } - catch (Exception exception) - { - benchLog.AppendLine("--- Pending Withdrawals ---"); - benchLog.AppendLine("Failed to retrieve data"); - this.logger.LogError("Exception occurred while getting pending withdrawals: '{0}'.", exception.ToString()); - } - - List completedWithdrawals = this.withdrawalHistoryProvider.GetHistory(TransfersToDisplay); - - if (completedWithdrawals.Count > 0) - { - benchLog.AppendLine("--- Recently Completed Withdrawals ---"); - foreach (WithdrawalModel withdrawal in completedWithdrawals) - benchLog.AppendLine(withdrawal.ToString()); - benchLog.AppendLine(); - } - - benchLog.AppendLine("====== Cross Chain Transfer Store ======"); - this.AddBenchmarkLine(benchLog, new (string, int)[] { - ("Height:", LoggingConfiguration.ColumnLength), - (this.crossChainTransferStore.TipHashAndHeight.Height.ToString(), LoggingConfiguration.ColumnLength), - ("Hash:",LoggingConfiguration.ColumnLength), - (this.crossChainTransferStore.TipHashAndHeight.HashBlock.ToString(), 0), - ("NextDepositHeight:", LoggingConfiguration.ColumnLength), - (this.crossChainTransferStore.NextMatureDepositHeight.ToString(), LoggingConfiguration.ColumnLength), - ("HasSuspended:",LoggingConfiguration.ColumnLength), - (this.crossChainTransferStore.HasSuspended().ToString(), 0) - }, - 4); - - this.AddBenchmarkLine(benchLog, - this.crossChainTransferStore.GetCrossChainTransferStatusCounter().SelectMany(item => new (string, int)[]{ - (item.Key.ToString()+":", LoggingConfiguration.ColumnLength), - (item.Value.ToString(), LoggingConfiguration.ColumnLength) - }).ToArray(), - 4); - return benchLog.ToString(); } - - [NoTrace] - private void AddBenchmarkLine(StringBuilder benchLog, (string Value, int ValuePadding)[] items, int maxItemsPerLine = int.MaxValue) - { - if (items == null) - return; - - int itemsAdded = 0; - foreach ((string Value, int ValuePadding) in items) - { - if (itemsAdded++ >= maxItemsPerLine) - { - benchLog.AppendLine(); - itemsAdded = 1; - } - benchLog.Append(Value.PadRight(ValuePadding)); - } - - benchLog.AppendLine(); - } } /// diff --git a/src/Stratis.Features.FederatedPeg/Interfaces/ICrossChainTransferStore.cs b/src/Stratis.Features.FederatedPeg/Interfaces/ICrossChainTransferStore.cs index 6c1a4fb751..34db6b3cfd 100644 --- a/src/Stratis.Features.FederatedPeg/Interfaces/ICrossChainTransferStore.cs +++ b/src/Stratis.Features.FederatedPeg/Interfaces/ICrossChainTransferStore.cs @@ -91,17 +91,18 @@ public interface ICrossChainTransferStore : IDisposable /// The block height on the counter-chain for which the next list of deposits is expected. int NextMatureDepositHeight { get; } - /// - /// Gets the counter of the cross chain transfer for each available status - /// - /// The counter of the cross chain transfer for each status - Dictionary GetCrossChainTransferStatusCounter(); - /// /// Determines, for a list of input transactions, which of those are completed or unknown withdrawals. /// /// The list of input transactions. /// The list of transactions that are completed (or unknown) wihdrawals. - List CompletedWithdrawals(IEnumerable transactionsToCheck); + List GetCompletedWithdrawalsForTransactions(IEnumerable transactionsToCheck); + + /// + /// Returns a list of completed withdrawals (those that are seen-in-block). + /// + /// The max items to display. + /// The completed withdrawals. + List GetCompletedWithdrawals(int transfersToDisplay); } } diff --git a/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs b/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs index 02e0501d07..cef104f5a3 100644 --- a/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs +++ b/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs @@ -50,7 +50,7 @@ public override string ToString() { var stringBuilder = new StringBuilder(); - stringBuilder.Append(string.Format("Block Height={0,8} Paying={1} Amount={2,12} Status={3}", + stringBuilder.Append(string.Format("Block Height={0,8} Paying={1} Amount={2,14} Status={3}", this.BlockHeight == 0 ? "Unconfirmed" : this.BlockHeight.ToString(), this.PayingTo, this.Amount.ToString(), diff --git a/src/Stratis.Features.FederatedPeg/PartialTransactionsBehavior.cs b/src/Stratis.Features.FederatedPeg/PartialTransactionsBehavior.cs index 4b4e66ad6d..c991e35c7a 100644 --- a/src/Stratis.Features.FederatedPeg/PartialTransactionsBehavior.cs +++ b/src/Stratis.Features.FederatedPeg/PartialTransactionsBehavior.cs @@ -60,13 +60,13 @@ public override object Clone() protected override void AttachCore() { - this.logger.LogDebug($"Attaching behaviour for {this.AttachedPeer.PeerEndPoint.Address}"); + this.logger.LogDebug("Attaching behaviour for {0}", this.AttachedPeer.PeerEndPoint.Address); this.AttachedPeer.MessageReceived.Register(this.OnMessageReceivedAsync, true); } protected override void DetachCore() { - this.logger.LogDebug($"Detaching behaviour for {this.AttachedPeer.PeerEndPoint.Address}"); + this.logger.LogDebug("Detaching behaviour for {0}", this.AttachedPeer.PeerEndPoint.Address); this.AttachedPeer.MessageReceived.Unregister(this.OnMessageReceivedAsync); } @@ -76,7 +76,7 @@ protected override void DetachCore() /// The payload to broadcast. private async Task BroadcastAsync(RequestPartialTransactionPayload payload) { - this.logger.LogDebug($"Broadcasting to {this.AttachedPeer.PeerEndPoint.Address}"); + this.logger.LogDebug("Broadcasting to {0}", this.AttachedPeer.PeerEndPoint.Address); await this.AttachedPeer.SendMessageAsync(payload).ConfigureAwait(false); } @@ -93,7 +93,7 @@ private async Task OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage mes return; } - this.logger.LogDebug($"{nameof(RequestPartialTransactionPayload)} received from '{peer.PeerEndPoint.Address}':'{peer.RemoteSocketEndpoint.Address}'."); + this.logger.LogDebug("{0} received from '{1}':'{2}'.", nameof(RequestPartialTransactionPayload), peer.PeerEndPoint.Address, peer.RemoteSocketEndpoint.Address); ICrossChainTransfer[] transfer = await this.crossChainTransferStore.GetAsync(new[] { payload.DepositId }); @@ -143,7 +143,7 @@ private async Task OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage mes } else { - this.logger.LogDebug($"The old and signed hash matches '{oldHash}'."); + this.logger.LogDebug("The old and signed hash matches '{0}'.", oldHash); } } diff --git a/src/Stratis.Features.FederatedPeg/SourceChain/MaturedBlocksProvider.cs b/src/Stratis.Features.FederatedPeg/SourceChain/MaturedBlocksProvider.cs index 11522097f4..ce16b84277 100644 --- a/src/Stratis.Features.FederatedPeg/SourceChain/MaturedBlocksProvider.cs +++ b/src/Stratis.Features.FederatedPeg/SourceChain/MaturedBlocksProvider.cs @@ -108,7 +108,7 @@ public SerializableResult> RetrieveDeposits(int // Don't process blocks below the requested maturity height. if (chainedHeaderBlock.ChainedHeader.Height < maturityHeight) { - this.logger.LogDebug($"{chainedHeaderBlock.ChainedHeader} below maturity height of {maturityHeight}."); + this.logger.LogDebug("{0} below maturity height of {1}.", chainedHeaderBlock.ChainedHeader, maturityHeight); continue; } @@ -126,7 +126,7 @@ public SerializableResult> RetrieveDeposits(int } } - this.logger.LogDebug($"{maturedDeposits.Count} mature deposits retrieved from block '{chainedHeaderBlock.ChainedHeader}'."); + this.logger.LogDebug("{0} mature deposits retrieved from block '{1}'.", maturedDeposits.Count, chainedHeaderBlock.ChainedHeader); result.Value.Add(new MaturedBlockDepositsModel(new MaturedBlockInfoModel() { @@ -171,13 +171,13 @@ private void RecordBlockDeposits(ChainedHeaderBlock chainedHeaderBlock, DepositR // Already have this recorded? if (this.deposits.TryGetValue(chainedHeaderBlock.ChainedHeader.Height, out BlockDeposits blockDeposits) && blockDeposits.BlockHash == chainedHeaderBlock.ChainedHeader.HashBlock) { - this.logger.LogDebug($"Deposits already recorded for '{chainedHeaderBlock.ChainedHeader}'."); + this.logger.LogDebug("Deposits already recorded for '{0}'.", chainedHeaderBlock.ChainedHeader); return; } IReadOnlyList deposits = this.depositExtractor.ExtractDepositsFromBlock(chainedHeaderBlock.Block, chainedHeaderBlock.ChainedHeader.Height, retrievalTypes); - this.logger.LogDebug($"{deposits.Count} potential deposits extracted from block '{chainedHeaderBlock.ChainedHeader}'."); + this.logger.LogDebug("{0} potential deposits extracted from block '{1}'.", deposits.Count, chainedHeaderBlock.ChainedHeader); this.deposits[chainedHeaderBlock.ChainedHeader.Height] = new BlockDeposits() { diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs index dff7255d9b..fc6a64c57a 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using System.Threading; using System.Threading.Tasks; using DBreeze; @@ -25,6 +26,11 @@ namespace Stratis.Features.FederatedPeg.TargetChain { public class CrossChainTransferStore : ICrossChainTransferStore { + /// + /// Given that we can have up to 10 UTXOs going at once. + /// + private const int TransfersToDisplay = 10; + /// /// Maximum number of partial transactions. /// @@ -66,23 +72,25 @@ public class CrossChainTransferStore : ICrossChainTransferStore /// Access to DBreeze database. private readonly DBreezeEngine DBreeze; - private readonly DBreezeSerializer dBreezeSerializer; - private readonly Network network; - private readonly ChainIndexer chainIndexer; - private readonly IWithdrawalExtractor withdrawalExtractor; private readonly IBlockRepository blockRepository; private readonly CancellationTokenSource cancellation; + private readonly ChainIndexer chainIndexer; + private readonly DBreezeSerializer dBreezeSerializer; private readonly IFederationWalletManager federationWalletManager; - private readonly IWithdrawalTransactionBuilder withdrawalTransactionBuilder; + private readonly Network network; + private readonly INodeStats nodeStats; private readonly IFederatedPegSettings settings; private readonly ISignals signals; private readonly IStateRepositoryRoot stateRepositoryRoot; + private readonly IWithdrawalExtractor withdrawalExtractor; + private readonly IWithdrawalHistoryProvider withdrawalHistoryProvider; + private readonly IWithdrawalTransactionBuilder withdrawalTransactionBuilder; /// Provider of time functions. private readonly object lockObj; - public CrossChainTransferStore(Network network, DataFolder dataFolder, ChainIndexer chainIndexer, IFederatedPegSettings settings, IDateTimeProvider dateTimeProvider, - ILoggerFactory loggerFactory, IWithdrawalExtractor withdrawalExtractor, IBlockRepository blockRepository, IFederationWalletManager federationWalletManager, + public CrossChainTransferStore(Network network, INodeStats nodeStats, DataFolder dataFolder, ChainIndexer chainIndexer, IFederatedPegSettings settings, IDateTimeProvider dateTimeProvider, + ILoggerFactory loggerFactory, IWithdrawalExtractor withdrawalExtractor, IWithdrawalHistoryProvider withdrawalHistoryProvider, IBlockRepository blockRepository, IFederationWalletManager federationWalletManager, IWithdrawalTransactionBuilder withdrawalTransactionBuilder, DBreezeSerializer dBreezeSerializer, ISignals signals, IStateRepositoryRoot stateRepositoryRoot = null) { if (!settings.IsMainChain) @@ -102,11 +110,10 @@ public CrossChainTransferStore(Network network, DataFolder dataFolder, ChainInde Guard.NotNull(withdrawalTransactionBuilder, nameof(withdrawalTransactionBuilder)); this.network = network; + this.nodeStats = nodeStats; this.chainIndexer = chainIndexer; this.blockRepository = blockRepository; this.federationWalletManager = federationWalletManager; - this.withdrawalTransactionBuilder = withdrawalTransactionBuilder; - this.withdrawalExtractor = withdrawalExtractor; this.dBreezeSerializer = dBreezeSerializer; this.lockObj = new object(); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); @@ -116,6 +123,9 @@ public CrossChainTransferStore(Network network, DataFolder dataFolder, ChainInde this.settings = settings; this.signals = signals; this.stateRepositoryRoot = stateRepositoryRoot; + this.withdrawalExtractor = withdrawalExtractor; + this.withdrawalHistoryProvider = withdrawalHistoryProvider; + this.withdrawalTransactionBuilder = withdrawalTransactionBuilder; // Future-proof store name. string depositStoreName = "federatedTransfers" + settings.MultiSigAddress.ToString(); @@ -126,6 +136,8 @@ public CrossChainTransferStore(Network network, DataFolder dataFolder, ChainInde // Initialize tracking deposits by status. foreach (object status in typeof(CrossChainTransferStatus).GetEnumValues()) this.depositsIdsByStatus[(CrossChainTransferStatus)status] = new HashSet(); + + nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name); } /// Performs any needed initialisation for the database. @@ -419,6 +431,7 @@ public Task RecordLatestMatureDepositsAsync(IL return; this.logger.LogInformation($"{maturedBlockDeposits.Count} blocks received, containing a total of {maturedBlockDeposits.SelectMany(d => d.Deposits).Where(a => a.Amount > 0).Count()} deposits."); + this.logger.LogInformation($"Block Range : {maturedBlockDeposits.Min(a => a.BlockInfo.BlockHeight)} to {maturedBlockDeposits.Max(a => a.BlockInfo.BlockHeight)}."); foreach (MaturedBlockDepositsModel maturedDeposit in maturedBlockDeposits) { @@ -483,10 +496,10 @@ public Task RecordLatestMatureDepositsAsync(IL { status = CrossChainTransferStatus.Rejected; } - else if ((tracker.Count(t => t.Value == CrossChainTransferStatus.Partial) - + this.depositsIdsByStatus.Count(t => t.Key == CrossChainTransferStatus.Partial)) >= MaximumPartialTransactions) + else if ((tracker.Count(t => t.Value == CrossChainTransferStatus.Partial) + this.depositsIdsByStatus[CrossChainTransferStatus.Partial].Count) >= MaximumPartialTransactions) { haveSuspendedTransfers = true; + this.logger.LogInformation($"Partial transaction limit reached, processing of deposits will continue once the partial transaction count falls below {MaximumPartialTransactions}."); } else { @@ -619,7 +632,7 @@ public Transaction MergeTransactionSignatures(uint256 depositId, Transaction[] p if (transfer.Status != CrossChainTransferStatus.Partial) { - this.logger.LogDebug($"(-)[MERGE_BAD_STATUS]:{nameof(transfer.Status)}={transfer.Status}"); + this.logger.LogDebug("(-)[MERGE_BAD_STATUS]:{0}={1}", nameof(transfer.Status), transfer.Status); return transfer.PartialTransaction; } @@ -1223,6 +1236,11 @@ public ICrossChainTransfer[] GetTransfersByStatus(CrossChainTransferStatus[] sta } } + private int GetTransfersByStatusCount(CrossChainTransferStatus status) + { + return this.depositsIdsByStatus[status].Count; + } + /// Persist the cross-chain transfer information into the database. /// The DBreeze transaction context to use. /// Cross-chain transfer information to be inserted. @@ -1374,22 +1392,7 @@ public bool ValidateTransaction(Transaction transaction, bool checkSignature = f } /// - public Dictionary GetCrossChainTransferStatusCounter() - { - lock (this.lockObj) - { - Dictionary result = new Dictionary(); - foreach (CrossChainTransferStatus status in Enum.GetValues(typeof(CrossChainTransferStatus)).Cast()) - { - result[status] = this.depositsIdsByStatus.TryGet(status)?.Count ?? 0; - } - - return result; - } - } - - /// - public List CompletedWithdrawals(IEnumerable transactionsToCheck) + public List GetCompletedWithdrawalsForTransactions(IEnumerable transactionsToCheck) { var res = new List(); @@ -1436,6 +1439,74 @@ public static bool IsMempoolErrorRecoverable(MempoolError mempoolError) } } + private void AddComponentStats(StringBuilder benchLog) + { + benchLog.AppendLine("====== Cross Chain Transfer Store ======"); + benchLog.AppendLine("Height:".PadRight(20) + this.TipHashAndHeight.Height + $" [{this.TipHashAndHeight.HashBlock}]"); + benchLog.AppendLine("NextDepositHeight:".PadRight(20) + this.NextMatureDepositHeight); + benchLog.AppendLine("Partial Txs:".PadRight(20) + GetTransfersByStatusCount(CrossChainTransferStatus.Partial)); + benchLog.AppendLine("Suspended Txs:".PadRight(20) + GetTransfersByStatusCount(CrossChainTransferStatus.Suspended)); + benchLog.AppendLine(); + + var depositIds = new HashSet(); + ICrossChainTransfer[] transfers; + + try + { + foreach (CrossChainTransferStatus status in new[] { CrossChainTransferStatus.FullySigned, CrossChainTransferStatus.Partial }) + depositIds.UnionWith(this.depositsIdsByStatus[status]); + + transfers = this.Get(depositIds.ToArray()).Where(t => t != null).ToArray(); + + // When sorting, Suspended transactions will have null PartialTransactions. Always put them last in the order they're in. + IEnumerable inprogress = transfers.Where(x => x.Status != CrossChainTransferStatus.Suspended && x.Status != CrossChainTransferStatus.Rejected); + IEnumerable suspended = transfers.Where(x => x.Status == CrossChainTransferStatus.Suspended || x.Status == CrossChainTransferStatus.Rejected); + + List pendingWithdrawals = this.withdrawalHistoryProvider.GetPendingWithdrawals(inprogress.Concat(suspended)); + + if (pendingWithdrawals.Count > 0) + { + benchLog.AppendLine("--- Pending Withdrawals ---"); + foreach (WithdrawalModel withdrawal in pendingWithdrawals.Take(TransfersToDisplay)) + benchLog.AppendLine(withdrawal.ToString()); + + if (pendingWithdrawals.Count > TransfersToDisplay) + benchLog.AppendLine($"And {pendingWithdrawals.Count - TransfersToDisplay} more..."); + + benchLog.AppendLine(); + } + } + catch (Exception exception) + { + benchLog.AppendLine("--- Pending Withdrawals ---"); + benchLog.AppendLine("Failed to retrieve data"); + this.logger.LogError("Exception occurred while getting pending withdrawals: '{0}'.", exception.ToString()); + } + + List completedWithdrawals = GetCompletedWithdrawals(TransfersToDisplay); + if (completedWithdrawals.Count > 0) + { + benchLog.AppendLine("--- Recently Completed Withdrawals ---"); + + foreach (WithdrawalModel withdrawal in completedWithdrawals) + benchLog.AppendLine(withdrawal.ToString()); + + benchLog.AppendLine(); + } + } + + /// + public List GetCompletedWithdrawals(int transfersToDisplay) + { + var depositIds = new HashSet(); + foreach (CrossChainTransferStatus status in new[] { CrossChainTransferStatus.SeenInBlock }) + depositIds.UnionWith(this.depositsIdsByStatus[status]); + + ICrossChainTransfer[] transfers = this.Get(depositIds.ToArray()).Where(t => t != null).ToArray(); + + return this.withdrawalHistoryProvider.GetHistory(transfers, transfersToDisplay); + } + /// public void Dispose() { diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs b/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs index 18b34d9ff3..e8464daf48 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/MaturedBlocksSyncManager.cs @@ -34,9 +34,6 @@ public class MaturedBlocksSyncManager : IMaturedBlocksSyncManager private IAsyncLoop requestDepositsTask; - /// The maximum amount of blocks to request at a time from alt chain. - public const int MaxBlocksToRequest = 1000; - /// When we are fully synced we stop asking for more blocks for this amount of time. private const int RefreshDelaySeconds = 10; @@ -79,8 +76,6 @@ public async Task StartAsync() /// true if delay between next time we should ask for blocks is required; false otherwise. protected async Task SyncDepositsAsync() { - this.logger.LogInformation($"Fetching deposits from height {this.crossChainTransferStore.NextMatureDepositHeight}"); - SerializableResult> model = await this.federationGatewayClient.GetMaturedBlockDepositsAsync(this.crossChainTransferStore.NextMatureDepositHeight, this.nodeLifetime.ApplicationStopping).ConfigureAwait(false); if (model == null) diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/MempoolCleaner.cs b/src/Stratis.Features.FederatedPeg/TargetChain/MempoolCleaner.cs index 93825f8667..e4b97fd60e 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/MempoolCleaner.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/MempoolCleaner.cs @@ -120,7 +120,7 @@ private async Task CleanMempoolAsync() completedTransactions = this.CompletedTransactions(transactionsToCheck).ToList(); }); - List transactionsToRemove = this.store.CompletedWithdrawals(transactionsToCheck) + List transactionsToRemove = this.store.GetCompletedWithdrawalsForTransactions(transactionsToCheck) .Union(completedTransactions) .ToList(); diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/SignedMultisigTransactionBroadcaster.cs b/src/Stratis.Features.FederatedPeg/TargetChain/SignedMultisigTransactionBroadcaster.cs index 2f4ff2ccf4..80937e710d 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/SignedMultisigTransactionBroadcaster.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/SignedMultisigTransactionBroadcaster.cs @@ -120,7 +120,7 @@ private async Task BroadcastFullyS return transferItem; } - this.logger.LogInformation("Broadcasting deposit '{0}', a signed multisig transaction '{1'} to the network.", crossChainTransfer.DepositTransactionId, crossChainTransfer.PartialTransaction.GetHash()); + this.logger.LogInformation("Broadcasting deposit '{0}', a signed multisig transaction '{1}' to the network.", crossChainTransfer.DepositTransactionId, crossChainTransfer.PartialTransaction.GetHash()); await this.broadcasterManager.BroadcastTransactionAsync(crossChainTransfer.PartialTransaction).ConfigureAwait(false); diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalHistoryProvider.cs b/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalHistoryProvider.cs index 982b2540fa..e6ce3cab39 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalHistoryProvider.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/WithdrawalHistoryProvider.cs @@ -11,56 +11,50 @@ namespace Stratis.Features.FederatedPeg.TargetChain { public interface IWithdrawalHistoryProvider { - List GetHistory(int maximumEntriesToReturn); - List GetPending(); + List GetHistory(IEnumerable crossChainTransfers, int maximumEntriesToReturn); + List GetPendingWithdrawals(IEnumerable crossChainTransfers); } public class WithdrawalHistoryProvider : IWithdrawalHistoryProvider { - private readonly Network network; private readonly IFederatedPegSettings federatedPegSettings; - private readonly ICrossChainTransferStore crossChainTransferStore; - private readonly IWithdrawalExtractor withdrawalExtractor; private readonly MempoolManager mempoolManager; + private readonly Network network; + private readonly IWithdrawalExtractor withdrawalExtractor; /// /// The constructor. /// /// Network we are running on. /// Federation settings providing access to number of signatures required. - /// Store which provides access to the statuses. /// Mempool which provides information about transactions in the mempool. /// Logger factory. /// Counter chain network. + /// public WithdrawalHistoryProvider( Network network, IFederatedPegSettings federatedPegSettings, - ICrossChainTransferStore crossChainTransferStore, MempoolManager mempoolManager, ILoggerFactory loggerFactory, CounterChainNetworkWrapper counterChainNetworkWrapper) { this.network = network; this.federatedPegSettings = federatedPegSettings; - this.crossChainTransferStore = crossChainTransferStore; this.withdrawalExtractor = new WithdrawalExtractor(federatedPegSettings, new OpReturnDataReader(loggerFactory, counterChainNetworkWrapper), network); this.mempoolManager = mempoolManager; } - // TODO: These can be more efficient, i.e. remove the wallet calls from GetHistory - // And use a different model for Withdrawals. It doesn't quite map to the Withdrawal class. - /// /// Get the history of successful withdrawals. /// + /// The list of transfers to report on. /// The maximum number of entries to return. /// A object containing a history of withdrawals. - public List GetHistory(int maximumEntriesToReturn) + public List GetHistory(IEnumerable crossChainTransfers, int maximumEntriesToReturn) { var result = new List(); - ICrossChainTransfer[] transfers = this.crossChainTransferStore.GetTransfersByStatus(new[] { CrossChainTransferStatus.SeenInBlock }); - foreach (ICrossChainTransfer transfer in transfers.OrderByDescending(t => t.BlockHeight)) + foreach (ICrossChainTransfer transfer in crossChainTransfers.OrderByDescending(t => t.BlockHeight)) { if (maximumEntriesToReturn-- <= 0) break; @@ -76,20 +70,13 @@ public List GetHistory(int maximumEntriesToReturn) /// /// Get pending withdrawals. /// + /// The list of transfers to report on. /// A object containing pending withdrawals and statuses. - public List GetPending() + public List GetPendingWithdrawals(IEnumerable crossChainTransfers) { var result = new List(); - // Get all Suspended, all Partial, and all FullySigned transfers. - ICrossChainTransfer[] inProgressTransfers = this.crossChainTransferStore.GetTransfersByStatus(new CrossChainTransferStatus[] - { - CrossChainTransferStatus.Suspended, - CrossChainTransferStatus.Partial, - CrossChainTransferStatus.FullySigned - }, true, false); - - foreach (ICrossChainTransfer transfer in inProgressTransfers) + foreach (ICrossChainTransfer transfer in crossChainTransfers) { var model = new WithdrawalModel(this.network, transfer); string status = transfer?.Status.ToString(); diff --git a/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs b/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs index 0e0fed14d7..a0cf5274df 100644 --- a/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs +++ b/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs @@ -2,16 +2,19 @@ using System.Collections.Generic; using System.Linq; using System.Security; +using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NBitcoin; using NBitcoin.Policy; using Stratis.Bitcoin.AsyncWork; using Stratis.Bitcoin.Configuration; +using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Features.Wallet; using Stratis.Bitcoin.Features.Wallet.Interfaces; using Stratis.Bitcoin.Interfaces; using Stratis.Bitcoin.Utilities; +using Stratis.Features.FederatedPeg.Controllers; using Stratis.Features.FederatedPeg.Interfaces; using Stratis.Features.FederatedPeg.TargetChain; using TracerAttributes; @@ -120,6 +123,7 @@ public class FederationWalletManager : LockProtected, IFederationWalletManager public FederationWalletManager( ILoggerFactory loggerFactory, Network network, + INodeStats nodeStats, ChainIndexer chainIndexer, DataFolder dataFolder, IWalletFeePolicy walletFeePolicy, @@ -155,6 +159,9 @@ public FederationWalletManager( this.withdrawalExtractor = withdrawalExtractor; this.isFederationActive = false; this.blockStore = blockStore; + + nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name); + nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800); } /// @@ -1283,5 +1290,37 @@ private IEnumerable GetSpendableTransactions(int current return (confirmed, total - confirmed); } } + + private void AddInlineStats(StringBuilder benchLogs) + { + string hash = this.Wallet?.LastBlockSyncedHash == null ? "N/A" : this.Wallet.LastBlockSyncedHash.ToString(); + string height = this.Wallet?.LastBlockSyncedHeight == null ? "N/A" : this.Wallet.LastBlockSyncedHeight.ToString(); + + benchLogs.AppendLine("Fed.Wallet.Height: ".PadRight(LoggingConfiguration.ColumnLength + 1) + height.ToString().PadRight(8) + " Fed.Wallet.Hash: ".PadRight(LoggingConfiguration.ColumnLength - 1) + hash); + } + + private void AddComponentStats(StringBuilder benchLog) + { + benchLog.AppendLine("====== Federation Wallet ======"); + + (Money ConfirmedAmount, Money UnConfirmedAmount) = GetSpendableAmount(); + + benchLog.AppendLine("Federation Wallet: ".PadRight(LoggingConfiguration.ColumnLength) + + " Confirmed balance: " + ConfirmedAmount.ToString().PadRight(LoggingConfiguration.ColumnLength) + + " Reserved for withdrawals: " + UnConfirmedAmount.ToString().PadRight(LoggingConfiguration.ColumnLength) + + " Federation Status: " + (this.isFederationActive ? "Active" : "Inactive")); + benchLog.AppendLine(); + + if (!this.isFederationActive) + { + benchLog.AppendLine("".PadRight(59, '=') + " W A R N I N G " + "".PadRight(59, '=')); + benchLog.AppendLine(); + benchLog.AppendLine("This federation node is not enabled. You will not be able to store or participate in signing of transactions until you enable it."); + benchLog.AppendLine("If not done previously, please enable your federation node using " + $"/api/FederationWallet/{FederationWalletRouteEndPoint.EnableFederation}."); + benchLog.AppendLine(); + benchLog.AppendLine("".PadRight(133, '=')); + benchLog.AppendLine(); + } + } } -} +} \ No newline at end of file diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index f3f479ae0d..b6046cfa21 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.0 + 1.0.6.1 False Stratis Group Ltd. diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index ba7d5ad738..eb88886d05 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index e90b01da81..b026544b73 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.6.0 + 1.0.6.1 Stratis Group Ltd. From 469dd32e7c954ce0bcc5961a1835e9a450729ade Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 15 Jan 2021 11:21:02 +0000 Subject: [PATCH 25/55] Add disasble addnode connector setting (#376) --- .../Configuration/Settings/ConnectionManagerSettings.cs | 4 ++++ src/Stratis.Bitcoin/Connection/ConnectionManager.cs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Stratis.Bitcoin/Configuration/Settings/ConnectionManagerSettings.cs b/src/Stratis.Bitcoin/Configuration/Settings/ConnectionManagerSettings.cs index 7cbb28e6c4..e6e828df91 100644 --- a/src/Stratis.Bitcoin/Configuration/Settings/ConnectionManagerSettings.cs +++ b/src/Stratis.Bitcoin/Configuration/Settings/ConnectionManagerSettings.cs @@ -170,6 +170,8 @@ public ConnectionManagerSettings(NodeSettings nodeSettings) this.Agent = string.IsNullOrEmpty(agentPrefix) ? nodeSettings.Agent : $"{agentPrefix}-{nodeSettings.Agent}"; this.logger.LogDebug("Agent set to '{0}'.", this.Agent); + + this.DisableAddNodePeerConnector = config.GetOrDefault("disableaddnodeconnector", false, this.logger); } public void AddAddNode(IPEndPoint addNode) @@ -331,5 +333,7 @@ public static void PrintHelp(Network network) /// List of white listed IP endpoint. The node will flags peers that connects to the node, or that the node connects to, as whitelisted. public List Whitelist { get; set; } + + public bool DisableAddNodePeerConnector { get; set; } } } \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Connection/ConnectionManager.cs b/src/Stratis.Bitcoin/Connection/ConnectionManager.cs index 45ee38685f..f678461087 100644 --- a/src/Stratis.Bitcoin/Connection/ConnectionManager.cs +++ b/src/Stratis.Bitcoin/Connection/ConnectionManager.cs @@ -154,6 +154,9 @@ public void Initialize(IConsensusManager consensusManager) foreach (IPeerConnector peerConnector in this.PeerConnectors) { + if (peerConnector is PeerConnectorAddNode && this.ConnectionSettings.DisableAddNodePeerConnector) + continue; + peerConnector.Initialize(this); peerConnector.StartConnectAsync(); } From efab9debf935022c98189990c6abcbc014214110 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 20 Jan 2021 08:32:36 +0000 Subject: [PATCH 26/55] Add Verify Partial Transaction Endpoint (#387) * Add endpoints to verify partial * Log Partials * Fix Comparer * Fix Deposit Id length * Update FederationGatewayController.cs * Update FederationGatewayController.cs --- .../FederationGatewayController.cs | 62 ++++++++++++++++--- .../Interfaces/IFederationWalletManager.cs | 2 +- .../Models/WithdrawalModel.cs | 13 ++-- .../TargetChain/CrossChainTransferStore.cs | 8 +-- .../Wallet/FederationWalletManager.cs | 16 +++-- .../Wallet/ValidateTransactionResult.cs | 20 ++++++ 6 files changed, 93 insertions(+), 28 deletions(-) create mode 100644 src/Stratis.Features.FederatedPeg/Wallet/ValidateTransactionResult.cs diff --git a/src/Stratis.Features.FederatedPeg/Controllers/FederationGatewayController.cs b/src/Stratis.Features.FederatedPeg/Controllers/FederationGatewayController.cs index 2d3e251b8d..723263ccbd 100644 --- a/src/Stratis.Features.FederatedPeg/Controllers/FederationGatewayController.cs +++ b/src/Stratis.Features.FederatedPeg/Controllers/FederationGatewayController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using NBitcoin; using NLog; @@ -23,8 +24,10 @@ public static class FederationGatewayRouteEndPoint { public const string GetMaturedBlockDeposits = "deposits"; public const string GetFederationInfo = "info"; - public const string GetTransfers = "gettransfers"; + public const string GetTransfersPartialEndpoint = "transfer/pending"; + public const string GetTransfersFullySignedEndpoint = "transfer/fullysigned"; public const string GetFederationMemberInfo = "info/member"; + public const string VerifyPartialTransactionEndpoint = "transfer/verify"; } /// @@ -104,21 +107,16 @@ public IActionResult GetMaturedBlockDeposits([FromQuery(Name = "blockHeight")] i } } - [Route(FederationGatewayRouteEndPoint.GetTransfers)] + [Route(FederationGatewayRouteEndPoint.GetTransfersPartialEndpoint)] [HttpGet] [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] [ProducesResponseType((int)HttpStatusCode.InternalServerError)] - public IActionResult GetTransfers([FromQuery(Name = "depositId")] string depositId = "", [FromQuery(Name = "transactionId")] string transactionId = "", [FromQuery(Name = "amount")] int? amount = 100) + public IActionResult GetTransfersPending([FromQuery(Name = "depositId")] string depositId = "", [FromQuery(Name = "transactionId")] string transactionId = "") { - ICrossChainTransfer[] transfers = this.crossChainTransferStore.GetTransfersByStatus(new[] { - CrossChainTransferStatus.FullySigned, - CrossChainTransferStatus.Partial, - CrossChainTransferStatus.SeenInBlock }) - .ToArray(); + ICrossChainTransfer[] transfers = this.crossChainTransferStore.GetTransfersByStatus(new[] { CrossChainTransferStatus.Partial }, false, false).ToArray(); CrossChainTransferModel[] transactions = transfers - .Where(t => t.PartialTransaction != null) .Where(t => t.DepositTransactionId.ToString().StartsWith(depositId) && (t.PartialTransaction == null || t.PartialTransaction.GetHash().ToString().StartsWith(transactionId))) .Select(t => new CrossChainTransferModel() { @@ -129,7 +127,30 @@ public IActionResult GetTransfers([FromQuery(Name = "depositId")] string deposit TransferStatus = t.Status.ToString(), }).ToArray(); - return this.Json(transactions.OrderByDescending(t => t.Transaction.BlockTime).Take(amount.Value)); + return this.Json(transactions); + } + + [Route(FederationGatewayRouteEndPoint.GetTransfersFullySignedEndpoint)] + [HttpGet] + [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.BadRequest)] + [ProducesResponseType((int)HttpStatusCode.InternalServerError)] + public IActionResult GetTransfers([FromQuery(Name = "depositId")] string depositId = "", [FromQuery(Name = "transactionId")] string transactionId = "") + { + ICrossChainTransfer[] transfers = this.crossChainTransferStore.GetTransfersByStatus(new[] { CrossChainTransferStatus.FullySigned }, false, false).ToArray(); + + CrossChainTransferModel[] transactions = transfers + .Where(t => t.DepositTransactionId.ToString().StartsWith(depositId) && (t.PartialTransaction == null || t.PartialTransaction.GetHash().ToString().StartsWith(transactionId))) + .Select(t => new CrossChainTransferModel() + { + DepositAmount = t.DepositAmount, + DepositId = t.DepositTransactionId, + DepositHeight = t.DepositHeight, + Transaction = new TransactionVerboseModel(t.PartialTransaction, this.network), + TransferStatus = t.Status.ToString(), + }).ToArray(); + + return this.Json(transactions); } /// @@ -224,5 +245,26 @@ public IActionResult GetInfo() return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()); } } + + [Route(FederationGatewayRouteEndPoint.VerifyPartialTransactionEndpoint)] + [HttpGet] + [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.BadRequest)] + [ProducesResponseType((int)HttpStatusCode.InternalServerError)] + public async Task VerifyPartialTransactionAsync([FromQuery(Name = "depositIdTransactionId")] string depositIdTransactionId) + { + if (string.IsNullOrEmpty("depositIdTransactionId")) + return this.Json("Deposit transaction id not specified."); + + if (!uint256.TryParse(depositIdTransactionId, out uint256 id)) + return this.Json("Invalid deposit transaction id"); + + ICrossChainTransfer[] transfers = await this.crossChainTransferStore.GetAsync(new[] { id }, false); + + if (transfers != null && transfers.Any()) + return this.Json(this.federationWalletManager.ValidateTransaction(transfers[0].PartialTransaction, true)); + + return this.Json($"{depositIdTransactionId} does not exist."); + } } } diff --git a/src/Stratis.Features.FederatedPeg/Interfaces/IFederationWalletManager.cs b/src/Stratis.Features.FederatedPeg/Interfaces/IFederationWalletManager.cs index 9019841c81..49a46d2222 100644 --- a/src/Stratis.Features.FederatedPeg/Interfaces/IFederationWalletManager.cs +++ b/src/Stratis.Features.FederatedPeg/Interfaces/IFederationWalletManager.cs @@ -70,7 +70,7 @@ public interface IFederationWalletManager : ILockProtected /// The transaction to check. /// Indicates whether to check the signature. /// True if all's well and false otherwise. - bool ValidateTransaction(Transaction transaction, bool checkSignature = false); + ValidateTransactionResult ValidateTransaction(Transaction transaction, bool checkSignature = false); /// /// Verifies that a transaction's inputs aren't being consumed by any other transactions. diff --git a/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs b/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs index f9d6b9b7aa..92345a863e 100644 --- a/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs +++ b/src/Stratis.Features.FederatedPeg/Models/WithdrawalModel.cs @@ -6,6 +6,8 @@ namespace Stratis.Features.FederatedPeg.Models { public sealed class WithdrawalModel { + private const string RewardsString = "Rewards"; + public WithdrawalModel() { } public WithdrawalModel(Network network, ICrossChainTransfer transfer) @@ -14,7 +16,7 @@ public WithdrawalModel(Network network, ICrossChainTransfer transfer) this.Id = transfer.PartialTransaction?.GetHash(); this.Amount = transfer.DepositAmount; var target = transfer.DepositTargetAddress.GetDestinationAddress(network).ToString(); - this.PayingTo = target == network.CirrusRewardDummyAddress ? "Reward Distribution" : target; + this.PayingTo = target == network.CirrusRewardDummyAddress ? RewardsString : target; this.BlockHeight = transfer.BlockHeight ?? 0; this.BlockHash = transfer.BlockHash; } @@ -26,7 +28,7 @@ public WithdrawalModel(Network network, IWithdrawal withdrawal, ICrossChainTrans this.Amount = withdrawal.Amount; this.BlockHash = withdrawal.BlockHash; this.BlockHeight = withdrawal.BlockNumber; - this.PayingTo = withdrawal.TargetAddress == network.CirrusRewardDummyAddress ? "Reward Distribution" : withdrawal.TargetAddress; + this.PayingTo = withdrawal.TargetAddress == network.CirrusRewardDummyAddress ? RewardsString : withdrawal.TargetAddress; this.TransferStatus = transfer?.Status.ToString(); } @@ -52,11 +54,12 @@ public override string ToString() { var stringBuilder = new StringBuilder(); - stringBuilder.Append(string.Format("Block Height={0,8} Paying={1} Amount={2,14} Status={3}", + stringBuilder.Append(string.Format("Height={0,8} Paying={1} Amount={2,14} Status={3} DepositId={4}", this.BlockHeight == 0 ? "Unconfirmed" : this.BlockHeight.ToString(), - this.PayingTo, + this.PayingTo.Length > RewardsString.Length ? this.PayingTo.Substring(0, RewardsString.Length) : this.PayingTo, this.Amount.ToString(), - this.TransferStatus)); + this.TransferStatus, + this.DepositId.ToString())); if (this.SpendingOutputDetails != null) stringBuilder.Append($" Spending={this.SpendingOutputDetails} "); diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs index efe96ce01e..93e71ab940 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs @@ -635,12 +635,9 @@ public Transaction MergeTransactionSignatures(uint256 depositId, Transaction[] p return transfer.PartialTransaction; } - /* - * // Log this incase we run into issues where the transaction templates doesn't match. - * try { - + this.logger.Debug("Partial Transaction inputs:{0}", partialTransactions[0].Inputs.Count); this.logger.Debug("Partial Transaction outputs:{1}", partialTransactions[0].Outputs.Count); @@ -675,7 +672,6 @@ public Transaction MergeTransactionSignatures(uint256 depositId, Transaction[] p { this.logger.Debug("Failed to log transactions: {0}.", err.Message); } - */ this.logger.Debug("Merging signatures for deposit : {0}", depositId); @@ -1388,7 +1384,7 @@ private void UndoLookups(StatusChangeTracker tracker) public bool ValidateTransaction(Transaction transaction, bool checkSignature = false) { - return this.federationWalletManager.ValidateTransaction(transaction, checkSignature); + return this.federationWalletManager.ValidateTransaction(transaction, checkSignature).IsValid; } /// diff --git a/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs b/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs index 09c0b95cf1..5b113b3b5e 100644 --- a/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs +++ b/src/Stratis.Features.FederatedPeg/Wallet/FederationWalletManager.cs @@ -1036,7 +1036,7 @@ internal int CompareOutpoints(OutPoint outPoint1, OutPoint outPoint2) } /// - public bool ValidateTransaction(Transaction transaction, bool checkSignature = false) + public ValidateTransactionResult ValidateTransaction(Transaction transaction, bool checkSignature = false) { lock (this.lockObject) { @@ -1045,7 +1045,7 @@ public bool ValidateTransaction(Transaction transaction, bool checkSignature = f // Verify that the transaction has valid UTXOs. if (!this.TransactionHasValidUTXOs(transaction, coins)) - return false; + return ValidateTransactionResult.Failed("Transaction does not have valid UTXOs."); // Verify that there are no earlier unspent UTXOs. var comparer = Comparer.Create(DeterministicCoinOrdering.CompareTransactionData); @@ -1058,7 +1058,7 @@ public bool ValidateTransaction(Transaction transaction, bool checkSignature = f .OrderByDescending(t => t, comparer) .FirstOrDefault(); if (oldestInput != null && DeterministicCoinOrdering.CompareTransactionData(earliestUnspent, oldestInput) < 0) - return false; + return ValidateTransactionResult.Failed("Earlier unspent UTXOs exist."); } // Verify that all inputs are signed. @@ -1067,18 +1067,22 @@ public bool ValidateTransaction(Transaction transaction, bool checkSignature = f TransactionBuilder builder = new TransactionBuilder(this.Wallet.Network).AddCoins(coins); if (builder.Verify(transaction, this.federatedPegSettings.GetWithdrawalTransactionFee(coins.Count), out TransactionPolicyError[] errors)) - return true; + return ValidateTransactionResult.Valid(); + + var errorList = new List(); // Trace the reason validation failed. Note that failure here doesn't mean an error necessarily. Just that the transaction is not fully signed. foreach (TransactionPolicyError transactionPolicyError in errors) { this.logger.Debug("{0} FAILED - {1}", nameof(TransactionBuilder.Verify), transactionPolicyError.ToString()); + errorList.Add(transactionPolicyError.ToString()); } - return false; + return ValidateTransactionResult.Failed(errorList.ToArray()); + } - return true; + return ValidateTransactionResult.Valid(); } } diff --git a/src/Stratis.Features.FederatedPeg/Wallet/ValidateTransactionResult.cs b/src/Stratis.Features.FederatedPeg/Wallet/ValidateTransactionResult.cs new file mode 100644 index 0000000000..0562bdfd29 --- /dev/null +++ b/src/Stratis.Features.FederatedPeg/Wallet/ValidateTransactionResult.cs @@ -0,0 +1,20 @@ +namespace Stratis.Features.FederatedPeg.Wallet +{ + public sealed class ValidateTransactionResult + { + public bool IsValid { get; set; } + public string[] Errors { get; set; } + + private ValidateTransactionResult() { } + + public static ValidateTransactionResult Failed(params string[] errors) + { + return new ValidateTransactionResult() { Errors = errors }; + } + + public static ValidateTransactionResult Valid() + { + return new ValidateTransactionResult() { IsValid = true }; + } + } +} \ No newline at end of file From 6d33c0ca4306d8b73b4c9b5eb56352d9c416ea3a Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 20 Jan 2021 13:54:25 +0000 Subject: [PATCH 27/55] Update NBitcoin.csproj (#391) --- src/NBitcoin/NBitcoin.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NBitcoin/NBitcoin.csproj b/src/NBitcoin/NBitcoin.csproj index 0525e7cbf5..2b2be5f7aa 100644 --- a/src/NBitcoin/NBitcoin.csproj +++ b/src/NBitcoin/NBitcoin.csproj @@ -7,7 +7,7 @@ - 4.0.0.78 + 4.0.0.79 From a712b0182807db9ab4d1e2ab80fea4932932be88 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 5 Feb 2021 13:27:36 +0000 Subject: [PATCH 28/55] Update some test projects PackageIds and versions --- ...tratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj | 4 ++-- .../Stratis.Bitcoin.IntegrationTests.Common.csproj | 4 ++-- .../Stratis.Bitcoin.Tests.Common.csproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index 442a7425e3..91aea9c16d 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 Stratis.Bitcoin.Features.PoA.IntegrationTests.Common - Stratis.Bitcoin.Features.PoA.IntegrationTests.Common + Stratis.Features.PoA.IntegrationTests.Common false false false @@ -13,7 +13,7 @@ false false false - 3.0.8.0 + 1.0.6.4 False diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index e814cafad4..701e93077c 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 Stratis.Bitcoin.IntegrationTests.Common - Stratis.Bitcoin.IntegrationTests.Common + Stratis.Features.IntegrationTests.Common false false false @@ -13,7 +13,7 @@ false false false - 3.0.8.0 + 1.0.6.4 False diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index 2dc1f82362..453510d370 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 Stratis.Bitcoin.Tests.Common - Stratis.Bitcoin.Tests.Common + Stratis.Core.Tests.Common false false false @@ -13,7 +13,7 @@ false false false - 3.0.8.0 + 1.0.6.4 False From 4e0d053cc90be8e795be3cdbe9aecc9fdaddc0f5 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 5 Feb 2021 13:29:03 +0000 Subject: [PATCH 29/55] Update PushNuget.ps1 --- PushNuget.ps1 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PushNuget.ps1 b/PushNuget.ps1 index 046337567d..23741ba092 100644 --- a/PushNuget.ps1 +++ b/PushNuget.ps1 @@ -73,6 +73,20 @@ rm "src\Stratis.Features.SQLiteWalletRepository\bin\Release\" -Recurse -Force dotnet pack src\Stratis.Features.SQLiteWalletRepository --configuration Release --include-source --include-symbols dotnet nuget push "src\Stratis.Features.SQLiteWalletRepository\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json" +# TEST PROJECTS + +rm "src\Stratis.Bitcoin.Tests.Common\bin\Release\" -Recurse -Force +dotnet pack src\Stratis.Bitcoin.Tests.Common --configuration Release --include-source --include-symbols +dotnet nuget push "src\Stratis.Bitcoin.Tests.Common\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json" + +rm "src\Stratis.Bitcoin.IntegrationTests.Common\bin\Release\" -Recurse -Force +dotnet pack src\Stratis.Bitcoin.IntegrationTests.Common --configuration Release --include-source --include-symbols +dotnet nuget push "src\Stratis.Bitcoin.IntegrationTests.Common\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json" + +rm "src\Stratis.Bitcoin.Features.PoA.IntegrationTests.Common\bin\Release\" -Recurse -Force +dotnet pack src\Stratis.Bitcoin.Features.PoA.IntegrationTests.Common --configuration Release --include-source --include-symbols +dotnet nuget push "src\Stratis.Bitcoin.Features.PoA.IntegrationTests.Common\bin\Release\*.symbols.nupkg" -k "" --source "https://api.nuget.org/v3/index.json" + # TOOLS PROJECTS rm "src\FodyNlogAdapter\bin\Release\" -Recurse -Force From 62de4877e13cf4183ca007fd62c6016ffbcaf692 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 5 Feb 2021 16:08:05 +0000 Subject: [PATCH 30/55] Update MaxStandardSigOpsCost and CCTS Max Partials Txs (#404) --- src/Stratis.Bitcoin.Networks/StraxMain.cs | 2 +- src/Stratis.Bitcoin.Networks/StraxRegTest.cs | 2 +- src/Stratis.Bitcoin.Networks/StraxTest.cs | 2 +- .../TargetChain/CrossChainTransferStore.cs | 31 +++++-------------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/Stratis.Bitcoin.Networks/StraxMain.cs b/src/Stratis.Bitcoin.Networks/StraxMain.cs index 2bdc1e24d4..afe98c7f1c 100644 --- a/src/Stratis.Bitcoin.Networks/StraxMain.cs +++ b/src/Stratis.Bitcoin.Networks/StraxMain.cs @@ -76,7 +76,7 @@ public StraxMain() maxStandardVersion: 2, maxStandardTxWeight: 150_000, maxBlockSigopsCost: 20_000, - maxStandardTxSigopsCost: 20_000 / 5, + maxStandardTxSigopsCost: 20_000 / 2, witnessScaleFactor: 4 ); diff --git a/src/Stratis.Bitcoin.Networks/StraxRegTest.cs b/src/Stratis.Bitcoin.Networks/StraxRegTest.cs index cc2104ec1b..11a98234d0 100644 --- a/src/Stratis.Bitcoin.Networks/StraxRegTest.cs +++ b/src/Stratis.Bitcoin.Networks/StraxRegTest.cs @@ -57,7 +57,7 @@ public StraxRegTest() maxStandardVersion: 2, maxStandardTxWeight: 150_000, maxBlockSigopsCost: 20_000, - maxStandardTxSigopsCost: 20_000 / 5, + maxStandardTxSigopsCost: 20_000 / 2, witnessScaleFactor: 4 ); diff --git a/src/Stratis.Bitcoin.Networks/StraxTest.cs b/src/Stratis.Bitcoin.Networks/StraxTest.cs index 73494bdd79..b84b631b8f 100644 --- a/src/Stratis.Bitcoin.Networks/StraxTest.cs +++ b/src/Stratis.Bitcoin.Networks/StraxTest.cs @@ -57,7 +57,7 @@ public StraxTest() maxStandardVersion: 2, maxStandardTxWeight: 150_000, maxBlockSigopsCost: 20_000, - maxStandardTxSigopsCost: 20_000 / 5, + maxStandardTxSigopsCost: 20_000 / 2, witnessScaleFactor: 4 ); diff --git a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs index 5d7aafa961..fc5f089902 100644 --- a/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs +++ b/src/Stratis.Features.FederatedPeg/TargetChain/CrossChainTransferStore.cs @@ -11,6 +11,7 @@ using NBitcoin; using NLog; using Stratis.Bitcoin.Configuration; +using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Features.BlockStore; using Stratis.Bitcoin.Features.MemoryPool; using Stratis.Bitcoin.Signals; @@ -29,12 +30,12 @@ public sealed class CrossChainTransferStore : ICrossChainTransferStore /// /// Given that we can have up to 10 UTXOs going at once. /// - private const int TransfersToDisplay = 20; + private const int TransfersToDisplay = 10; /// /// Maximum number of partial transactions. /// - public const int MaximumPartialTransactions = 20; + public const int MaximumPartialTransactions = 5; /// This table contains the cross-chain transfer information. private const string transferTableName = "Transfers"; @@ -1436,10 +1437,10 @@ public static bool IsMempoolErrorRecoverable(MempoolError mempoolError) private void AddComponentStats(StringBuilder benchLog) { benchLog.AppendLine("====== Cross Chain Transfer Store ======"); - benchLog.AppendLine("Height:".PadRight(20) + this.TipHashAndHeight.Height + $" [{this.TipHashAndHeight.HashBlock}]"); - benchLog.AppendLine("NextDepositHeight:".PadRight(20) + this.NextMatureDepositHeight); - benchLog.AppendLine("Partial Txs:".PadRight(20) + GetTransferCountByStatus(CrossChainTransferStatus.Partial)); - benchLog.AppendLine("Suspended Txs:".PadRight(20) + GetTransferCountByStatus(CrossChainTransferStatus.Suspended)); + benchLog.AppendLine("Height".PadRight(LoggingConfiguration.ColumnLength) + $": {this.TipHashAndHeight.Height} [{this.TipHashAndHeight.HashBlock}]"); + benchLog.AppendLine("NextDepositHeight".PadRight(LoggingConfiguration.ColumnLength) + $": {this.NextMatureDepositHeight}"); + benchLog.AppendLine("Partial Txs".PadRight(LoggingConfiguration.ColumnLength) + $": {GetTransferCountByStatus(CrossChainTransferStatus.Partial)}"); + benchLog.AppendLine("Suspended Txs".PadRight(LoggingConfiguration.ColumnLength) + $": {GetTransferCountByStatus(CrossChainTransferStatus.Suspended)}"); benchLog.AppendLine(); var depositIds = new HashSet(); @@ -1476,25 +1477,9 @@ private void AddComponentStats(StringBuilder benchLog) benchLog.AppendLine("Failed to retrieve data"); this.logger.Error("Exception occurred while getting pending withdrawals: '{0}'.", exception.ToString()); } - - // Only display this on the mainchain for now as the sidechain has too many SeenInBlock - // deposits making the query exectute too long. - // TODO: We need to look at including the block height in the dictionary perhaps. - if (this.settings.IsMainChain) - { - List completedWithdrawals = GetCompletedWithdrawals(10); - if (completedWithdrawals.Count > 0) - { - benchLog.AppendLine("--- Recently Completed Withdrawals ---"); - - foreach (WithdrawalModel withdrawal in completedWithdrawals) - benchLog.AppendLine(withdrawal.ToString()); - - benchLog.AppendLine(); - } - } } + /// public List GetCompletedWithdrawals(int transfersToDisplay) { From b111c9a48886e6e873509600cf657183151df9ee Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Fri, 5 Feb 2021 16:25:46 +0000 Subject: [PATCH 31/55] Bump Version to 1.0.6.5 --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- .../Stratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- .../Stratis.Bitcoin.Features.Notifications.csproj | 2 +- ...atis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Networks.csproj | 6 +++--- .../Stratis.Bitcoin.Tests.Common.csproj | 2 +- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 6 +++--- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Features.SQLiteWalletRepository.csproj | 2 +- .../Stratis.Sidechains.Networks.csproj | 2 +- .../Stratis.SmartContracts.CLR.Validation.csproj | 2 +- .../Stratis.SmartContracts.CLR.csproj | 6 +++--- .../Stratis.SmartContracts.Core.csproj | 2 +- .../Stratis.SmartContracts.Networks.csproj | 2 +- .../Stratis.SmartContracts.RuntimeObserver.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 38 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index 7527aa8747..212db66033 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index df1e335940..94356c8cac 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 3082278529..257908382b 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index d162141d7e..a075fb2d76 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.6.4 + 1.0.6.5 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index e1e7830d7a..60926bead7 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index 430a2ce297..532c61f5a1 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index 21ebf41278..de98d20e7c 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index 3ee9b28f0f..9328feedfa 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index 8211cb2e8e..b478fffd26 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 1a2a690b20..892839c060 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 10ec0eb677..17e5e516a0 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index 7ccc7abc36..5b2ba01082 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index 91aea9c16d..99a583b31f 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index e6552e2dcc..abeba4bed2 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 4b8c9123bd..ded265b91d 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index 4638b90adc..daae890f72 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 3aca55b28a..166c056664 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index 657c1aab03..ded7948505 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index b1f056a79d..72b6b43db6 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index 701e93077c..55601475a5 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index ec6b7b3c71..1a0886af0f 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.6.4 - 1.0.6.4 - 1.0.6.4 + 1.0.6.5 + 1.0.6.5 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index 453510d370..35e32f0586 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index f7b2832e10..15f0cdc4a8 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Stratis Group Ltd.")] [assembly: AssemblyProduct("Stratis Full Node")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.6.4")] -[assembly: AssemblyFileVersion("1.0.6.4")] +[assembly: AssemblyVersion("1.0.6.5")] +[assembly: AssemblyFileVersion("1.0.6.5")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 9c99220d31..fd235308a3 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False ..\Stratis.ruleset Stratis Group Ltd. diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index 614bc8773c..0f980cd2c7 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index daae6209f7..24426f5d71 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.6.4 + 1.0.6.5 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 0232d5e696..8c19d4b66e 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index 63688ace65..eb1a3d4c12 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 8708e75b13..8198d7b3ca 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index ef391ecb85..f17a7ac140 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.6.4 + 1.0.6.5 False Stratis Group Ltd. diff --git a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj index cccfce685a..e6c1015e04 100644 --- a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj +++ b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj @@ -5,7 +5,7 @@ Full ..\None.ruleset - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis.Sidechains.Networks diff --git a/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj b/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj index 8683c7b2bd..8894f8271b 100644 --- a/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj +++ b/src/Stratis.SmartContracts.CLR.Validation/Stratis.SmartContracts.CLR.Validation.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj b/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj index b63d6ab694..b1e3231d9e 100644 --- a/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj +++ b/src/Stratis.SmartContracts.CLR/Stratis.SmartContracts.CLR.csproj @@ -3,9 +3,9 @@ netcoreapp3.1 - 1.0.6.4 - 1.0.6.4 - 1.0.6.4 + 1.0.6.5 + 1.0.6.5 + 1.0.6.5 Stratis Group Ltd. Stratis.SmartContracts.CLR diff --git a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj index 2a9f6194ae..d46030117d 100644 --- a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj +++ b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj index e820167f68..3bb24f3483 100644 --- a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj +++ b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj b/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj index 3c5e897b88..07dcdaa4e9 100644 --- a/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj +++ b/src/Stratis.SmartContracts.RuntimeObserver/Stratis.SmartContracts.RuntimeObserver.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index 4a5eb3832a..6bf5c84b85 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index 3b6ca63a71..4d34876849 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.6.4 + 1.0.6.5 Stratis Group Ltd. From 488685903ec3bcfeaa4028a8b162a3bec63adab2 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 2 Feb 2021 13:27:51 +0000 Subject: [PATCH 32/55] Add mainnet check points (#400) * Add MainNet check points * Fix Tests --- src/NBitcoin.Tests/NetworkTests.cs | 2 +- src/Stratis.Bitcoin.Networks/StraxMain.cs | 3 ++- src/Stratis.Bitcoin.Tests/Consensus/CheckpointsTest.cs | 2 +- src/Stratis.Sidechains.Networks/CirrusMain.cs | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/NBitcoin.Tests/NetworkTests.cs b/src/NBitcoin.Tests/NetworkTests.cs index df855af5b2..5d748f26ce 100644 --- a/src/NBitcoin.Tests/NetworkTests.cs +++ b/src/NBitcoin.Tests/NetworkTests.cs @@ -324,7 +324,7 @@ public void StraxMainIsInitializedCorrectly() { Network network = this.straxMain; - Assert.Equal(14, network.Checkpoints.Count); + Assert.Equal(15, network.Checkpoints.Count); Assert.Equal(2, network.DNSSeeds.Count); Assert.Empty(network.SeedNodes); diff --git a/src/Stratis.Bitcoin.Networks/StraxMain.cs b/src/Stratis.Bitcoin.Networks/StraxMain.cs index afe98c7f1c..e9e9b8d71d 100644 --- a/src/Stratis.Bitcoin.Networks/StraxMain.cs +++ b/src/Stratis.Bitcoin.Networks/StraxMain.cs @@ -160,7 +160,8 @@ public StraxMain() { 30000, new CheckpointInfo(new uint256("0x4d0f2a809ef915721ced21f5ec51b6177b684eee06cadd49bcedc57daa243b8b"), new uint256("0xd9b7f8c92f289d66cb35a517e0b5c11c3e7e23a6507ce8ba2f042642849dcba0")) }, { 40000, new CheckpointInfo(new uint256("0xdc10671e67350eda9518b220e329ca9f661cd98c0e12d246471f8ec4f8a81c71"), new uint256("0xeb13622df7b0fc95068c0146d718bb2eaf2fd8943b3bea89396d8d58f5af8c15")) }, { 50000, new CheckpointInfo(new uint256("0xe3398765bc0da5b481a5dfe60f0acf14f4b1fc8582bab8f7a166317aea9aa026"), new uint256("0x350db25ca3ff01ec589681c94c325f619e5013bdc06efcbefa981776f4dcca4f")) }, - { 60000, new CheckpointInfo(new uint256("0x9cbc20fd1720529c59073ade6f5511ab5c2cf168556c9a10cb41ff9d8dac724f"), new uint256("0xe363394313d2e1af248a1c0d18b79e6074a08884dddbebfca90e8ae716edb645")) } + { 60000, new CheckpointInfo(new uint256("0x9cbc20fd1720529c59073ade6f5511ab5c2cf168556c9a10cb41ff9d8dac724f"), new uint256("0xe363394313d2e1af248a1c0d18b79e6074a08884dddbebfca90e8ae716edb645")) }, + { 150000, new CheckpointInfo(new uint256("0x48bb4c2f08088da9990e23f19cb4b9a094bdf7791f86f77a98d08e5d2b06c1ce"), new uint256("0x14f80d627e7727f4da4a5945ddb77e2821369246c72f1c6ca754c6509a4eef60")) } }; this.Bech32Encoders = new Bech32Encoder[2]; diff --git a/src/Stratis.Bitcoin.Tests/Consensus/CheckpointsTest.cs b/src/Stratis.Bitcoin.Tests/Consensus/CheckpointsTest.cs index 10e61038ad..12e71a04ac 100644 --- a/src/Stratis.Bitcoin.Tests/Consensus/CheckpointsTest.cs +++ b/src/Stratis.Bitcoin.Tests/Consensus/CheckpointsTest.cs @@ -74,7 +74,7 @@ public void GetLastCheckPointHeight_StraxMainnet_ReturnsLastCheckPointHeight() int result = checkpoints.GetLastCheckpointHeight(); - Assert.Equal(60000, result); + Assert.Equal(150000, result); } [Fact] diff --git a/src/Stratis.Sidechains.Networks/CirrusMain.cs b/src/Stratis.Sidechains.Networks/CirrusMain.cs index a807f0bd29..d37603dfea 100644 --- a/src/Stratis.Sidechains.Networks/CirrusMain.cs +++ b/src/Stratis.Sidechains.Networks/CirrusMain.cs @@ -266,7 +266,8 @@ public CirrusMain() { 1200000, new CheckpointInfo(new uint256("0x8411b830270cc9d6c2e28de1c2e8025c57a5673835f63e30708967adfee5a92c")) }, { 1300000, new CheckpointInfo(new uint256("0x512c19a8245316b4d3b13513c7901f41842846f539f668ca4ac349daaab6dc20")) }, { 1400000, new CheckpointInfo(new uint256("0xbfd4a96a6c5250f18bf7c586761256fa5f8753ffa10b24160f0648a452823a95")) }, - { 1500000, new CheckpointInfo(new uint256("0x2a1602877a5231997654bae975223762ee636be2f371cb444b2d3fb564e6989e")) } + { 1500000, new CheckpointInfo(new uint256("0x2a1602877a5231997654bae975223762ee636be2f371cb444b2d3fb564e6989e")) }, + { 1750000, new CheckpointInfo(new uint256("0x58c96a878efeeffea1b1924b61eed627687900e01588ffaa2f4a161973f01abf")) } }; this.DNSSeeds = new List From aba3b966db0d567e44926c7691421135edeafb05 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 15 Feb 2021 10:04:55 +0000 Subject: [PATCH 33/55] Fix Seeder (#425) --- src/Stratis.CirrusDnsD/Program.cs | 23 +++++++++++++------ .../Stratis.CirrusDnsD.csproj | 1 + 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Stratis.CirrusDnsD/Program.cs b/src/Stratis.CirrusDnsD/Program.cs index 4ec582b0f1..b3a5fc1d2f 100644 --- a/src/Stratis.CirrusDnsD/Program.cs +++ b/src/Stratis.CirrusDnsD/Program.cs @@ -4,6 +4,7 @@ using Stratis.Bitcoin; using Stratis.Bitcoin.Builder; using Stratis.Bitcoin.Configuration; +using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Features.Api; using Stratis.Bitcoin.Features.BlockStore; using Stratis.Bitcoin.Features.Dns; @@ -12,8 +13,10 @@ using Stratis.Bitcoin.Features.SmartContracts; using Stratis.Bitcoin.Features.SmartContracts.PoA; using Stratis.Bitcoin.Features.SmartContracts.Wallet; +using Stratis.Bitcoin.Networks; using Stratis.Bitcoin.Utilities; using Stratis.Features.Collateral; +using Stratis.Features.Collateral.CounterChain; using Stratis.Features.SQLiteWalletRepository; using Stratis.Sidechains.Networks; @@ -67,9 +70,11 @@ public static async Task Main(string[] args) private static IFullNode GetSideChainFullNode(NodeSettings nodeSettings) { - IFullNode node = new FullNodeBuilder() - .UseNodeSettings(nodeSettings) - .UseBlockStore() + DbType dbType = nodeSettings.GetDbType(); + + IFullNodeBuilder nodeBuilder = new FullNodeBuilder() + .UseNodeSettings(nodeSettings, dbType) + .UseBlockStore(dbType) .UseMempool() .AddSmartContracts(options => { @@ -77,16 +82,20 @@ private static IFullNode GetSideChainFullNode(NodeSettings nodeSettings) options.UsePoAWhitelistedContracts(); }) .AddPoAFeature() - .UsePoAConsensus() + .UsePoAConsensus(dbType) .CheckCollateralCommitment() + + // This needs to be set so that we can check the magic bytes during the Strat to Strax changeover. + // Perhaps we can introduce a block height check rather? + .SetCounterChainNetwork(StraxNetwork.MainChainNetworks[nodeSettings.Network.NetworkType]()) + .UseSmartContractWallet() .AddSQLiteWalletRepository() .UseApi() .AddRPC() - .UseDns() - .Build(); + .UseDns(); - return node; + return nodeBuilder.Build(); } private static IFullNode GetDnsNode(NodeSettings nodeSettings) diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index fd8778f4db..dc3e303e15 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -23,6 +23,7 @@ + From d446432c305c9d65ffdbc029cc8d61598f895c74 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 15 Feb 2021 10:15:39 +0000 Subject: [PATCH 34/55] Fix AddressIndexer Console (#426) --- .../AddressIndexing/AddressIndexer.cs | 4 ++-- src/Stratis.Bitcoin.Features.Wallet/WalletFeature.cs | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.BlockStore/AddressIndexing/AddressIndexer.cs b/src/Stratis.Bitcoin.Features.BlockStore/AddressIndexing/AddressIndexer.cs index cb9d4da768..0faabfba2d 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/AddressIndexing/AddressIndexer.cs +++ b/src/Stratis.Bitcoin.Features.BlockStore/AddressIndexing/AddressIndexer.cs @@ -389,7 +389,7 @@ private void SaveAll() private void AddInlineStats(StringBuilder benchLog) { - benchLog.AppendLine("AddressIndexer.Height: ".PadRight(LoggingConfiguration.ColumnLength + 1) + this.IndexerTip.Height.ToString().PadRight(9) + + benchLog.AppendLine("AddressIndexer Height".PadRight(LoggingConfiguration.ColumnLength) + $": {this.IndexerTip.Height}".PadRight(9) + "AddressCache%: " + this.addressIndexRepository.GetLoadPercentage().ToString().PadRight(8) + "OutPointCache%: " + this.outpointsRepository.GetLoadPercentage().ToString().PadRight(8) + $"Ms/block: {Math.Round(this.averageTimePerBlock.Average, 2)}"); @@ -673,7 +673,7 @@ public LastBalanceDecreaseTransactionModel GetLastBalanceDecreaseTransaction(str // Height 0 is used as a placeholder height for compacted address balance records, so ignore them if they are the only record. if (lastBalanceHeight == 0) return null; - + ChainedHeader header = this.chainIndexer.GetHeader(lastBalanceHeight); if (header == null) diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletFeature.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletFeature.cs index cce70ce1a3..3fa56db638 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletFeature.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletFeature.cs @@ -100,8 +100,6 @@ private void AddInlineStats(StringBuilder log) log.AppendLine("Wallet Height".PadRight(LoggingConfiguration.ColumnLength) + $": {this.walletManager.WalletTipHeight}".PadRight(10) + $"(Hash: {this.walletManager.WalletTipHash})"); else log.AppendLine("Wallet Height".PadRight(LoggingConfiguration.ColumnLength) + ": No Wallet"); - - log.AppendLine(); } private void AddComponentStats(StringBuilder log) From a57bf78f73e246014da1b6d2cf92b05eee1147c5 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 15 Feb 2021 10:20:33 +0000 Subject: [PATCH 35/55] Update ConnectionManager.cs (#427) --- src/Stratis.Bitcoin/Connection/ConnectionManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Stratis.Bitcoin/Connection/ConnectionManager.cs b/src/Stratis.Bitcoin/Connection/ConnectionManager.cs index 5ece69e57e..bc0d6021c3 100644 --- a/src/Stratis.Bitcoin/Connection/ConnectionManager.cs +++ b/src/Stratis.Bitcoin/Connection/ConnectionManager.cs @@ -316,6 +316,7 @@ void AddPeerInfo(StringBuilder peerBuilder, INetworkPeer peer) int inbound = this.ConnectedPeers.Count(x => x.Inbound); + builder.AppendLine(); builder.AppendLine($">> Connections (In:{inbound}) (Out:{this.ConnectedPeers.Count() - inbound})"); builder.AppendLine("Data Transfer".PadRight(LoggingConfiguration.ColumnLength, ' ') + $": Received: {totalRead.BytesToMegaBytes()} MB Sent: {totalWritten.BytesToMegaBytes()} MB"); From 9c75e249f7c65650ecc87051edc0ba561db136c2 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 11 Mar 2021 11:50:32 +0000 Subject: [PATCH 36/55] Fix Project Versions --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj | 4 ++-- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Sidechains.Networks.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index f791a5725b..18824c7165 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index e50dc34b42..cbe4ffec69 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.7.0 + 1.0.7.2 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 8ff90da17c..11a8c0b0ad 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index eac6ba364d..bd6ec6ffe9 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.7.0 + 1.0.7.2 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index c34a20fd17..b7764c508b 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.7.0 + 1.0.7.2 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index c17fb2c541..e57d025190 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index fb30e691f3..a3208b0bcd 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.7.0 + 1.0.7.2 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index c2fa5cc617..4a79cf6277 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,8 +14,8 @@ false false false - 1.0.7.0 - 1.0.7.0 + 1.0.7.2 + 1.0.7.2 1.0.7.2 False Stratis Group Ltd. diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index f1801121f6..ed31a0d787 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index dc3e303e15..07e4cc68c2 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.7.0 + 1.0.7.2 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 2ebf1f5fba..4db7f3c50f 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index 0b80e0e8c4..a4031deaef 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 7a2462d662..e10a72e32e 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. diff --git a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj index eca3609d84..4d4ed94118 100644 --- a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj +++ b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj @@ -5,7 +5,7 @@ Full ..\None.ruleset - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. Stratis.Sidechains.Networks diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index f61eb9e137..21f5e720d5 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index 65be90c391..1294f020cb 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.7.0 + 1.0.7.2 Stratis Group Ltd. From 685250bff0902375464056586c771daf9ebbdd4a Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sat, 21 Aug 2021 12:22:17 +0100 Subject: [PATCH 37/55] Better collateral address checking (#670) --- .../PoATestsBase.cs | 8 +-- .../PollsRepositoryTests.cs | 2 +- .../PoAVotingCoinbaseOutputFormatRuleTests.cs | 2 +- .../VotingDataEncoderTests.cs | 2 +- .../VotingManagerTests.cs | 2 +- .../FederationManager.cs | 25 +++++-- src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs | 2 +- .../PoAVotingCoinbaseOutputFormatRule.cs | 2 +- .../Voting/JoinFederationRequestService.cs | 16 +++-- .../Voting/PollsRepository.cs | 12 ++-- .../Voting/VotingDataEncoder.cs | 14 ++-- .../Voting/VotingManager.cs | 68 ++++++++++--------- .../Controllers/WalletClient.cs | 3 +- .../MandatoryCollateralMemberVotingRule.cs | 2 +- .../CheckCollateralFullValidationRuleTests.cs | 2 +- .../CollateralCheckerTests.cs | 2 +- .../FederationGatewayControllerTests.cs | 2 +- 17 files changed, 95 insertions(+), 71 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs index c973e9d041..78296ab9d0 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/PoATestsBase.cs @@ -74,8 +74,8 @@ public PoATestsBase(TestPoANetwork network = null) this.resultExecutorMock = new Mock(); - this.votingManager = new VotingManager(this.federationManager, this.loggerFactory, this.resultExecutorMock.Object, new NodeStats(dateTimeProvider, NodeSettings.Default(this.network), new Mock().Object), - dataFolder, this.dBreezeSerializer, this.signals, finalizedBlockRepo, this.network); + this.votingManager = new VotingManager(this.federationManager, this.resultExecutorMock.Object, new NodeStats(dateTimeProvider, NodeSettings.Default(this.network), new Mock().Object), dataFolder, + this.dBreezeSerializer, this.signals, finalizedBlockRepo, this.network); this.votingManager.Initialize(this.federationHistory); @@ -118,8 +118,8 @@ public static (IFederationManager federationManager, IFederationHistory federati var chainIndexerMock = new Mock(); var header = new BlockHeader(); chainIndexerMock.Setup(x => x.Tip).Returns(new ChainedHeader(header, header.GetHash(), 0)); - var votingManager = new VotingManager(federationManager, loggerFactory, - new Mock().Object, new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, signals, finalizedBlockRepo, network); + var votingManager = new VotingManager(federationManager, new Mock().Object, + new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, signals, finalizedBlockRepo, network); var federationHistory = new Mock(); federationHistory.Setup(x => x.GetFederationMemberForBlock(It.IsAny())).Returns((chainedHeader) => diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/PollsRepositoryTests.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/PollsRepositoryTests.cs index 9228a246de..7c3e4f1196 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/PollsRepositoryTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/PollsRepositoryTests.cs @@ -16,7 +16,7 @@ public PollsRepositoryTests() { string dir = TestBase.CreateTestDir(this); - this.repository = new PollsRepository(dir, new ExtendedLoggerFactory(), new DBreezeSerializer(new TestPoANetwork().Consensus.ConsensusFactory)); + this.repository = new PollsRepository(dir, new DBreezeSerializer(new TestPoANetwork().Consensus.ConsensusFactory)); this.repository.Initialize(); } diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/Rules/PoAVotingCoinbaseOutputFormatRuleTests.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/Rules/PoAVotingCoinbaseOutputFormatRuleTests.cs index 6c26ee25af..2c1b9fb729 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/Rules/PoAVotingCoinbaseOutputFormatRuleTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/Rules/PoAVotingCoinbaseOutputFormatRuleTests.cs @@ -49,7 +49,7 @@ public void ThrowsIfCantEncode() [Fact] public void ThrowsIfEmptyList() { - var encoder = new VotingDataEncoder(new ExtendedLoggerFactory()); + var encoder = new VotingDataEncoder(); byte[] bytes = encoder.Encode(new List()); List votingData = new List(VotingDataEncoder.VotingOutputPrefixBytes); diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/VotingDataEncoderTests.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/VotingDataEncoderTests.cs index 6bf68509eb..a628902223 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/VotingDataEncoderTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/VotingDataEncoderTests.cs @@ -15,7 +15,7 @@ public class VotingDataEncoderTests public VotingDataEncoderTests() { - this.encoder = new VotingDataEncoder(new ExtendedLoggerFactory()); + this.encoder = new VotingDataEncoder(); } [Fact] diff --git a/src/Stratis.Bitcoin.Features.PoA.Tests/VotingManagerTests.cs b/src/Stratis.Bitcoin.Features.PoA.Tests/VotingManagerTests.cs index c62ec3c102..c7a620432f 100644 --- a/src/Stratis.Bitcoin.Features.PoA.Tests/VotingManagerTests.cs +++ b/src/Stratis.Bitcoin.Features.PoA.Tests/VotingManagerTests.cs @@ -19,7 +19,7 @@ public class VotingManagerTests : PoATestsBase public VotingManagerTests() { - this.encoder = new VotingDataEncoder(this.loggerFactory); + this.encoder = new VotingDataEncoder(); this.changesApplied = new List(); this.changesReverted = new List(); diff --git a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs index 43776ffa04..d24a5373b0 100644 --- a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs @@ -291,11 +291,8 @@ private void AddFederationMemberLocked(IFederationMember federationMember) { if (federationMember is CollateralFederationMember collateralFederationMember) { - if (this.federationMembers.Cast().Any(x => x.CollateralMainchainAddress == collateralFederationMember.CollateralMainchainAddress)) - { - this.logger.Trace("(-)[DUPLICATED_COLLATERAL_ADDR]"); + if (this.federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) return; - } if (this.federationMembers.Contains(federationMember)) { @@ -375,4 +372,24 @@ public bool IsMultisigMember(PubKey pubKey) return this.GetFederationMembers().Any(m => m.PubKey == pubKey && m is CollateralFederationMember member && member.IsMultisigMember); } } + + public static class FederationExtensions + { + /// + /// Checks to see if a particular collateral address is already present in the current set of + /// federation members. + /// + /// The collateral address to verify. + /// true if present, false otherwise. + public static bool IsCollateralAddressRegistered(this List federationMembers, ILogger logger, string collateralAddress) + { + if (federationMembers.Cast().Any(x => x.CollateralMainchainAddress == collateralAddress)) + { + logger.Warn($"Federation member with address '{collateralAddress}' already exists."); + return true; + } + + return false; + } + } } diff --git a/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs b/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs index 328c047028..d0d0e99934 100644 --- a/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs +++ b/src/Stratis.Bitcoin.Features.PoA/PoAMiner.cs @@ -126,7 +126,7 @@ public PoAMiner( this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.cancellation = CancellationTokenSource.CreateLinkedTokenSource(new[] { nodeLifetime.ApplicationStopping }); - this.votingDataEncoder = new VotingDataEncoder(loggerFactory); + this.votingDataEncoder = new VotingDataEncoder(); this.nodeSettings = nodeSettings; nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name); diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/ConsensusRules/PoAVotingCoinbaseOutputFormatRule.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/ConsensusRules/PoAVotingCoinbaseOutputFormatRule.cs index c6834385fb..35ddefe863 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/ConsensusRules/PoAVotingCoinbaseOutputFormatRule.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/ConsensusRules/PoAVotingCoinbaseOutputFormatRule.cs @@ -15,7 +15,7 @@ public class PoAVotingCoinbaseOutputFormatRule : PartialValidationConsensusRule [NoTrace] public override void Initialize() { - this.votingDataEncoder = new VotingDataEncoder(this.Parent.LoggerFactory); + this.votingDataEncoder = new VotingDataEncoder(); base.Initialize(); } diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs index 69854df766..9a21fd329e 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs @@ -3,8 +3,8 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using NBitcoin; +using NLog; using Stratis.Bitcoin; using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Features.PoA; @@ -26,19 +26,21 @@ public interface IJoinFederationRequestService public sealed class JoinFederationRequestService : IJoinFederationRequestService { private readonly ICounterChainSettings counterChainSettings; + private readonly IFederationManager federationManager; private readonly IFullNode fullNode; private readonly IHttpClientFactory httpClientFactory; - private readonly ILoggerFactory loggerFactory; + private readonly ILogger logger; private readonly PoANetwork network; private readonly NodeSettings nodeSettings; private readonly VotingManager votingManager; - public JoinFederationRequestService(ICounterChainSettings counterChainSettings, IFullNode fullNode, IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, Network network, NodeSettings nodeSettings, VotingManager votingManager) + public JoinFederationRequestService(ICounterChainSettings counterChainSettings, IFederationManager federationManager, IFullNode fullNode, IHttpClientFactory httpClientFactory, Network network, NodeSettings nodeSettings, VotingManager votingManager) { this.counterChainSettings = counterChainSettings; + this.federationManager = federationManager; this.fullNode = fullNode; this.httpClientFactory = httpClientFactory; - this.loggerFactory = loggerFactory; + this.logger = LogManager.GetCurrentClassLogger(); this.network = network as PoANetwork; this.nodeSettings = nodeSettings; this.votingManager = votingManager; @@ -46,6 +48,10 @@ public JoinFederationRequestService(ICounterChainSettings counterChainSettings, public async Task JoinFederationAsync(JoinFederationRequestModel request, CancellationToken cancellationToken) { + // First ensure that this collateral address isnt already present in the federation. + if (this.federationManager.GetFederationMembers().IsCollateralAddressRegistered(this.logger, request.CollateralAddress)) + throw new Exception($"The provided collateral address '{request.CollateralAddress}' is already present in the federation."); + // Get the address pub key hash. BitcoinAddress address = BitcoinAddress.Create(request.CollateralAddress, this.counterChainSettings.CounterChainNetwork); KeyId addressKey = PayToPubkeyHashTemplate.Instance.ExtractScriptPubKeyParameters(address.ScriptPubKey); @@ -80,7 +86,7 @@ public async Task JoinFederationAsync(JoinFederationRequestModel request ExternalAddress = request.CollateralAddress }; - var walletClient = new WalletClient(this.loggerFactory, this.httpClientFactory, $"http://{this.counterChainSettings.CounterChainApiHost}", this.counterChainSettings.CounterChainApiPort); + var walletClient = new WalletClient(this.httpClientFactory, $"http://{this.counterChainSettings.CounterChainApiHost}", this.counterChainSettings.CounterChainApiPort); try { diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs index 5a1b7d7a7f..99f51ad313 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/PollsRepository.cs @@ -5,7 +5,7 @@ using DBreeze; using DBreeze.DataTypes; using DBreeze.Utils; -using Microsoft.Extensions.Logging; +using NLog; using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Utilities; @@ -27,19 +27,19 @@ public class PollsRepository : IDisposable private int highestPollId; - public PollsRepository(DataFolder dataFolder, ILoggerFactory loggerFactory, DBreezeSerializer dBreezeSerializer) - : this(dataFolder.PollsPath, loggerFactory, dBreezeSerializer) + public PollsRepository(DataFolder dataFolder, DBreezeSerializer dBreezeSerializer) + : this(dataFolder.PollsPath, dBreezeSerializer) { } - public PollsRepository(string folder, ILoggerFactory loggerFactory, DBreezeSerializer dBreezeSerializer) + public PollsRepository(string folder, DBreezeSerializer dBreezeSerializer) { Guard.NotEmpty(folder, nameof(folder)); Directory.CreateDirectory(folder); this.dbreeze = new DBreezeEngine(folder); - this.logger = loggerFactory.CreateLogger(this.GetType().FullName); + this.logger = LogManager.GetCurrentClassLogger(); this.dBreezeSerializer = dBreezeSerializer; } @@ -59,7 +59,7 @@ public void Initialize() } } - this.logger.LogDebug("Polls repo initialized with highest id: {0}.", this.highestPollId); + this.logger.Debug("Polls repo initialized with highest id: {0}.", this.highestPollId); } /// Provides Id of the most recently added poll. diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingDataEncoder.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingDataEncoder.cs index 7b5e9ce866..3f5e26e72e 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingDataEncoder.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingDataEncoder.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.Extensions.Logging; using NBitcoin; +using NLog; namespace Stratis.Bitcoin.Features.PoA.Voting { @@ -16,9 +16,9 @@ public class VotingDataEncoder private readonly ILogger logger; - public VotingDataEncoder(ILoggerFactory loggerFactory) + public VotingDataEncoder() { - this.logger = loggerFactory.CreateLogger(this.GetType().FullName); + this.logger = LogManager.GetCurrentClassLogger(); } /// Decodes raw voting data. @@ -29,7 +29,7 @@ public List Decode(byte[] votingDataBytes) { if (votingDataBytes.Length > VotingDataMaxSerializedSize) { - this.logger.LogTrace("(-)[INVALID_SIZE]"); + this.logger.Trace("(-)[INVALID_SIZE]"); PoAConsensusErrors.VotingDataInvalidFormat.Throw(); } @@ -46,8 +46,8 @@ public List Decode(byte[] votingDataBytes) } catch (Exception e) { - this.logger.LogDebug("Exception during deserialization: '{0}'.", e.ToString()); - this.logger.LogTrace("(-)[DESERIALIZING_EXCEPTION]"); + this.logger.Debug("Exception during deserialization: '{0}'.", e.ToString()); + this.logger.Trace("(-)[DESERIALIZING_EXCEPTION]"); PoAConsensusErrors.VotingDataInvalidFormat.Throw(); return null; @@ -93,7 +93,7 @@ public byte[] ExtractRawVotingData(Transaction tx) if (votingData != null) { - this.logger.LogTrace("(-)[TOO_MANY_VOTING_OUTPUTS]"); + this.logger.Trace("(-)[TOO_MANY_VOTING_OUTPUTS]"); PoAConsensusErrors.TooManyVotingOutputs.Throw(); } diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs index fdcc20875d..bdfd48bf9f 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs @@ -3,8 +3,8 @@ using System.Linq; using System.Text; using ConcurrentCollections; -using Microsoft.Extensions.Logging; using NBitcoin; +using NLog; using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Configuration.Logging; using Stratis.Bitcoin.Consensus; @@ -63,9 +63,8 @@ public sealed class VotingManager : IDisposable private bool isInitialized; private bool isBusyReconstructing; - public VotingManager(IFederationManager federationManager, ILoggerFactory loggerFactory, IPollResultExecutor pollResultExecutor, - INodeStats nodeStats, DataFolder dataFolder, DBreezeSerializer dBreezeSerializer, ISignals signals, - IFinalizedBlockInfoRepository finalizedBlockInfo, + public VotingManager(IFederationManager federationManager, IPollResultExecutor pollResultExecutor, INodeStats nodeStats, + DataFolder dataFolder, DBreezeSerializer dBreezeSerializer, ISignals signals, IFinalizedBlockInfoRepository finalizedBlockInfo, Network network, IBlockRepository blockRepository = null, ChainIndexer chainIndexer = null) @@ -77,10 +76,10 @@ public VotingManager(IFederationManager federationManager, ILoggerFactory logger this.finalizedBlockInfo = Guard.NotNull(finalizedBlockInfo, nameof(finalizedBlockInfo)); this.locker = new object(); - this.votingDataEncoder = new VotingDataEncoder(loggerFactory); + this.votingDataEncoder = new VotingDataEncoder(); this.scheduledVotingData = new List(); - this.pollsRepository = new PollsRepository(dataFolder, loggerFactory, dBreezeSerializer); - this.logger = loggerFactory.CreateLogger(this.GetType().FullName); + this.pollsRepository = new PollsRepository(dataFolder, dBreezeSerializer); + this.logger = LogManager.GetCurrentClassLogger(); this.network = network; this.poaConsensusOptions = (PoAConsensusOptions)this.network.Consensus.Options; @@ -106,14 +105,14 @@ public void Initialize(IFederationHistory federationHistory, IIdleFederationMemb this.isInitialized = true; - this.logger.LogDebug("VotingManager initialized."); + this.logger.Debug("VotingManager initialized."); } /// Remove all polls that started on or after the given height. /// The height to clean polls from. public void DeletePollsAfterHeight(int height) { - this.logger.LogInformation($"Cleaning poll data from height {height}."); + this.logger.Info($"Cleaning poll data from height {height}."); var idsToRemove = new List(); @@ -141,7 +140,7 @@ public void ReconstructVotingDataFromHeightLocked(int height) var currentHeight = height; var progress = $"Reconstructing voting poll data from height {currentHeight}."; - this.logger.LogInformation(progress); + this.logger.Info(progress); this.signals.Publish(new RecontructFederationProgressEvent() { Progress = progress }); do @@ -165,7 +164,7 @@ public void ReconstructVotingDataFromHeightLocked(int height) if (currentHeight % 10000 == 0) { progress = $"Reconstructing voting data at height {currentHeight}"; - this.logger.LogInformation(progress); + this.logger.Info(progress); this.signals.Publish(new RecontructFederationProgressEvent() { Progress = progress }); } } while (true); @@ -184,7 +183,7 @@ public void ScheduleVote(VotingData votingData) if (!this.federationManager.IsFederationMember) { - this.logger.LogTrace("(-)[NOT_FED_MEMBER]"); + this.logger.Trace("(-)[NOT_FED_MEMBER]"); throw new InvalidOperationException("Not a federation member!"); } @@ -196,7 +195,7 @@ public void ScheduleVote(VotingData votingData) this.CleanFinishedPollsLocked(); } - this.logger.LogDebug("Vote was scheduled with key: {0}.", votingData.Key); + this.logger.Debug("Vote was scheduled with key: {0}.", votingData.Key); } /// Provides a copy of scheduled voting data. @@ -227,7 +226,7 @@ public List GetAndCleanScheduledVotes() this.scheduledVotingData = new List(); if (votingData.Count > 0) - this.logger.LogDebug("{0} scheduled votes were taken.", votingData.Count); + this.logger.Debug("{0} scheduled votes were taken.", votingData.Count); return votingData; } @@ -334,20 +333,23 @@ public List GetFederationFromExecutedPolls() { lock (this.locker) { - var federation = new List(this.poaConsensusOptions.GenesisFederationMembers); + var federationMembers = new List(this.poaConsensusOptions.GenesisFederationMembers); IEnumerable executedPolls = this.GetExecutedPolls().MemberPolls(); foreach (Poll poll in executedPolls.OrderBy(a => a.PollExecutedBlockData.Height)) { - IFederationMember federationMember = ((PoAConsensusFactory)(this.network.Consensus.ConsensusFactory)).DeserializeFederationMember(poll.VotingData.Data); + IFederationMember federationMember = ((PoAConsensusFactory)this.network.Consensus.ConsensusFactory).DeserializeFederationMember(poll.VotingData.Data); if (poll.VotingData.Key == VoteKey.AddFederationMember) - federation.Add(federationMember); + { + if (federationMember is CollateralFederationMember collateralFederationMember && !federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + federationMembers.Add(federationMember); + } else if (poll.VotingData.Key == VoteKey.KickFederationMember) - federation.Remove(federationMember); + federationMembers.Remove(federationMember); } - return federation; + return federationMembers; } } @@ -435,7 +437,7 @@ private void OnBlockConnected(BlockConnected blockConnected) { if (blockConnected.ConnectedBlock.ChainedHeader.Height - poll.PollVotedInFavorBlockData.Height == this.network.Consensus.MaxReorgLength) { - this.logger.LogDebug("Applying poll '{0}'.", poll); + this.logger.Debug("Applying poll '{0}'.", poll); this.pollResultExecutor.ApplyChange(poll.VotingData); poll.PollExecutedBlockData = new HashHeightPair(chBlock.ChainedHeader); @@ -447,7 +449,7 @@ private void OnBlockConnected(BlockConnected blockConnected) { foreach (Poll poll in this.GetApprovedPolls().Where(x => x.PollVotedInFavorBlockData.Hash == newFinalizedHash.Hash).ToList()) { - this.logger.LogDebug("Applying poll '{0}'.", poll); + this.logger.Debug("Applying poll '{0}'.", poll); this.pollResultExecutor.ApplyChange(poll.VotingData); poll.PollExecutedBlockData = new HashHeightPair(chBlock.ChainedHeader); @@ -460,7 +462,7 @@ private void OnBlockConnected(BlockConnected blockConnected) if (rawVotingData == null) { - this.logger.LogTrace("(-)[NO_VOTING_DATA]"); + this.logger.Trace("(-)[NO_VOTING_DATA]"); return; } @@ -475,7 +477,7 @@ private void OnBlockConnected(BlockConnected blockConnected) List votingDataList = this.votingDataEncoder.Decode(rawVotingData); - this.logger.LogDebug("Applying {0} voting data items included in a block by '{1}'.", votingDataList.Count, fedMemberKeyHex); + this.logger.Debug("Applying {0} voting data items included in a block by '{1}'.", votingDataList.Count, fedMemberKeyHex); lock (this.locker) { @@ -512,7 +514,7 @@ private void OnBlockConnected(BlockConnected blockConnected) this.polls.Add(poll); this.pollsRepository.AddPolls(poll); - this.logger.LogDebug("New poll was created: '{0}'.", poll); + this.logger.Debug("New poll was created: '{0}'.", poll); }); } else if (!poll.PubKeysHexVotedInFavor.Contains(fedMemberKeyHex)) @@ -520,11 +522,11 @@ private void OnBlockConnected(BlockConnected blockConnected) poll.PubKeysHexVotedInFavor.Add(fedMemberKeyHex); this.pollsRepository.UpdatePoll(poll); - this.logger.LogDebug("Voted on existing poll: '{0}'.", poll); + this.logger.Debug("Voted on existing poll: '{0}'.", poll); } else { - this.logger.LogDebug("Fed member '{0}' already voted for this poll. Ignoring his vote. Poll: '{1}'.", fedMemberKeyHex, poll); + this.logger.Debug("Fed member '{0}' already voted for this poll. Ignoring his vote. Poll: '{1}'.", fedMemberKeyHex, poll); } var fedMembersHex = new ConcurrentHashSet(this.federationManager.GetFederationMembers().Select(x => x.PubKey.ToHex())); @@ -536,7 +538,7 @@ private void OnBlockConnected(BlockConnected blockConnected) if (chainedHeader?.Header == null) { - this.logger.LogWarning("Couldn't retrieve header for block at height-hash: {0}-{1}.", poll.PollStartBlockData.Height, poll.PollStartBlockData.Hash?.ToString()); + this.logger.Warn("Couldn't retrieve header for block at height-hash: {0}-{1}.", poll.PollStartBlockData.Height, poll.PollStartBlockData.Hash?.ToString()); Guard.NotNull(chainedHeader, nameof(chainedHeader)); Guard.NotNull(chainedHeader.Header, nameof(chainedHeader.Header)); @@ -557,7 +559,7 @@ private void OnBlockConnected(BlockConnected blockConnected) int requiredVotesCount = (fedMembersHex.Count / 2) + 1; - this.logger.LogDebug("Fed members count: {0}, valid votes count: {1}, required votes count: {2}.", fedMembersHex.Count, validVotesCount, requiredVotesCount); + this.logger.Debug("Fed members count: {0}, valid votes count: {1}, required votes count: {2}.", fedMembersHex.Count, validVotesCount, requiredVotesCount); if (validVotesCount < requiredVotesCount) continue; @@ -569,7 +571,7 @@ private void OnBlockConnected(BlockConnected blockConnected) } catch (Exception ex) { - this.logger.LogError(ex, ex.ToString()); + this.logger.Error(ex, ex.ToString()); throw; } } @@ -582,7 +584,7 @@ private void OnBlockDisconnected(BlockDisconnected blockDisconnected) { foreach (Poll poll in this.polls.Where(x => !x.IsPending && x.PollExecutedBlockData?.Hash == chBlock.ChainedHeader.HashBlock).ToList()) { - this.logger.LogDebug("Reverting poll execution '{0}'.", poll); + this.logger.Debug("Reverting poll execution '{0}'.", poll); this.pollResultExecutor.RevertChange(poll.VotingData); poll.PollExecutedBlockData = null; @@ -594,7 +596,7 @@ private void OnBlockDisconnected(BlockDisconnected blockDisconnected) if (rawVotingData == null) { - this.logger.LogTrace("(-)[NO_VOTING_DATA]"); + this.logger.Trace("(-)[NO_VOTING_DATA]"); return; } @@ -617,7 +619,7 @@ private void OnBlockDisconnected(BlockDisconnected blockDisconnected) targetPoll = this.polls.Last(x => x.VotingData == votingData); } - this.logger.LogDebug("Reverting poll voting in favor: '{0}'.", targetPoll); + this.logger.Debug("Reverting poll voting in favor: '{0}'.", targetPoll); if (targetPoll.PollVotedInFavorBlockData == new HashHeightPair(chBlock.ChainedHeader)) { @@ -636,7 +638,7 @@ private void OnBlockDisconnected(BlockDisconnected blockDisconnected) this.polls.Remove(targetPoll); this.pollsRepository.RemovePolls(targetPoll.Id); - this.logger.LogDebug("Poll with Id {0} was removed.", targetPoll.Id); + this.logger.Debug("Poll with Id {0} was removed.", targetPoll.Id); } } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletClient.cs b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletClient.cs index 7023beac90..06aecbf1a6 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletClient.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Controllers/WalletClient.cs @@ -1,7 +1,6 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using Stratis.Bitcoin.Controllers; using Stratis.Bitcoin.Features.Wallet.Models; @@ -23,7 +22,7 @@ public class WalletClient : RestApiClientBase, IWalletClient /// In a production/live scenario the sidechain and mainnet federation nodes should run on the same machine. /// /// - public WalletClient(ILoggerFactory loggerFactory, IHttpClientFactory httpClientFactory, string url, int port) + public WalletClient(IHttpClientFactory httpClientFactory, string url, int port) : base(httpClientFactory, port, "Wallet", url) { } diff --git a/src/Stratis.Features.Collateral/ConsensusRules/MandatoryCollateralMemberVotingRule.cs b/src/Stratis.Features.Collateral/ConsensusRules/MandatoryCollateralMemberVotingRule.cs index 42b3c1c48e..a26380ce7b 100644 --- a/src/Stratis.Features.Collateral/ConsensusRules/MandatoryCollateralMemberVotingRule.cs +++ b/src/Stratis.Features.Collateral/ConsensusRules/MandatoryCollateralMemberVotingRule.cs @@ -21,7 +21,7 @@ public class MandatoryCollateralMemberVotingRule : FullValidationConsensusRule [NoTrace] public override void Initialize() { - this.votingDataEncoder = new VotingDataEncoder(this.Parent.LoggerFactory); + this.votingDataEncoder = new VotingDataEncoder(); this.ruleEngine = (PoAConsensusRuleEngine)this.Parent; this.federationManager = this.ruleEngine.FederationManager; this.federationHistory = this.ruleEngine.FederationHistory; diff --git a/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs b/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs index e3a1706a48..1507c92a6c 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/CheckCollateralFullValidationRuleTests.cs @@ -46,7 +46,7 @@ public CheckCollateralFullValidationRuleTests() var loggerFactory = new ExtendedLoggerFactory(); ILogger logger = loggerFactory.CreateLogger(this.GetType().FullName); - var votingDataEncoder = new VotingDataEncoder(loggerFactory); + var votingDataEncoder = new VotingDataEncoder(); var votes = new List { new VotingData() diff --git a/src/Stratis.Features.FederatedPeg.Tests/CollateralCheckerTests.cs b/src/Stratis.Features.FederatedPeg.Tests/CollateralCheckerTests.cs index 2ddc97e156..dd30307da9 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/CollateralCheckerTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/CollateralCheckerTests.cs @@ -72,7 +72,7 @@ private void InitializeCollateralChecker([CallerMemberName] string callingMethod var fullNode = new Mock(); IFederationManager federationManager = new FederationManager(fullNode.Object, network, nodeSettings, signals, counterChainSettings); - var votingManager = new VotingManager(federationManager, loggerFactory, new Mock().Object, new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, signals, finalizedBlockRepo, network); + var votingManager = new VotingManager(federationManager, new Mock().Object, new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, signals, finalizedBlockRepo, network); var federationHistory = new FederationHistory(federationManager, votingManager); votingManager.Initialize(federationHistory); diff --git a/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationGatewayControllerTests.cs b/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationGatewayControllerTests.cs index 6d4084b394..646d45a37b 100644 --- a/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationGatewayControllerTests.cs +++ b/src/Stratis.Features.FederatedPeg.Tests/ControllersTests/FederationGatewayControllerTests.cs @@ -264,7 +264,7 @@ private VotingManager InitializeVotingManager(NodeSettings nodeSettings) var header = new BlockHeader(); chainIndexerMock.Setup(x => x.Tip).Returns(new ChainedHeader(header, header.GetHash(), 0)); - var votingManager = new VotingManager(this.federationManager, this.loggerFactory, new Mock().Object, new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, this.signals, finalizedBlockRepo, this.network); + var votingManager = new VotingManager(this.federationManager, new Mock().Object, new Mock().Object, nodeSettings.DataFolder, dbreezeSerializer, this.signals, finalizedBlockRepo, this.network); var federationHistory = new FederationHistory(this.federationManager, votingManager); votingManager.Initialize(federationHistory); From d8322777772d018b4ae6cf9edf6b70e6fea26ae5 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sat, 21 Aug 2021 12:26:16 +0100 Subject: [PATCH 38/55] Bump Version to 1.0.9.3 --- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 4 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 8f16ed57d3..0bcc2145f2 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.9.2")] -[assembly: AssemblyFileVersion("1.0.9.2")] +[assembly: AssemblyVersion("1.0.9.3")] +[assembly: AssemblyFileVersion("1.0.9.3")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 868ec35e0d..80e5a0ba07 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.2 + 1.0.9.3 False ..\Stratis.ruleset Stratis Group Ltd. From c500af2cdef56b587e969bb787e63b934d47c970 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sat, 21 Aug 2021 13:13:38 +0100 Subject: [PATCH 39/55] Add collateral address check to GetModifiedFederation (#671) --- src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs index bdfd48bf9f..a8e4dc9612 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs @@ -374,7 +374,10 @@ public List GetModifiedFederation(ChainedHeader chainedHeader // Addition/removal. if (poll.VotingData.Key == VoteKey.AddFederationMember) - modifiedFederation.Add(federationMember); + { + if (federationMember is CollateralFederationMember collateralFederationMember && !modifiedFederation.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + modifiedFederation.Add(federationMember); + } else if (poll.VotingData.Key == VoteKey.KickFederationMember) modifiedFederation.Remove(federationMember); } From b7b0b56c9b84d8b9b48a2a562b177a5fc97071d3 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sat, 21 Aug 2021 14:01:10 +0100 Subject: [PATCH 40/55] Remove logging from federation build logic --- src/Stratis.Bitcoin.Features.PoA/FederationManager.cs | 11 ++++++----- .../Voting/JoinFederationRequestService.cs | 2 +- .../Voting/VotingManager.cs | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs index d24a5373b0..73d6852224 100644 --- a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs @@ -291,8 +291,11 @@ private void AddFederationMemberLocked(IFederationMember federationMember) { if (federationMember is CollateralFederationMember collateralFederationMember) { - if (this.federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (this.federationMembers.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) + { + this.logger.Warn($"Federation member with address '{collateralFederationMember.CollateralMainchainAddress}' already exists."); return; + } if (this.federationMembers.Contains(federationMember)) { @@ -379,15 +382,13 @@ public static class FederationExtensions /// Checks to see if a particular collateral address is already present in the current set of /// federation members. /// + /// The list of federation members to check against. /// The collateral address to verify. /// true if present, false otherwise. - public static bool IsCollateralAddressRegistered(this List federationMembers, ILogger logger, string collateralAddress) + public static bool IsCollateralAddressRegistered(this List federationMembers, string collateralAddress) { if (federationMembers.Cast().Any(x => x.CollateralMainchainAddress == collateralAddress)) - { - logger.Warn($"Federation member with address '{collateralAddress}' already exists."); return true; - } return false; } diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs index 9a21fd329e..f638d6e3eb 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs @@ -49,7 +49,7 @@ public JoinFederationRequestService(ICounterChainSettings counterChainSettings, public async Task JoinFederationAsync(JoinFederationRequestModel request, CancellationToken cancellationToken) { // First ensure that this collateral address isnt already present in the federation. - if (this.federationManager.GetFederationMembers().IsCollateralAddressRegistered(this.logger, request.CollateralAddress)) + if (this.federationManager.GetFederationMembers().IsCollateralAddressRegistered(request.CollateralAddress)) throw new Exception($"The provided collateral address '{request.CollateralAddress}' is already present in the federation."); // Get the address pub key hash. diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs index a8e4dc9612..c13f40eb65 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs @@ -342,7 +342,7 @@ public List GetFederationFromExecutedPolls() if (poll.VotingData.Key == VoteKey.AddFederationMember) { - if (federationMember is CollateralFederationMember collateralFederationMember && !federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (federationMember is CollateralFederationMember collateralFederationMember && !federationMembers.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) federationMembers.Add(federationMember); } else if (poll.VotingData.Key == VoteKey.KickFederationMember) @@ -375,7 +375,7 @@ public List GetModifiedFederation(ChainedHeader chainedHeader // Addition/removal. if (poll.VotingData.Key == VoteKey.AddFederationMember) { - if (federationMember is CollateralFederationMember collateralFederationMember && !modifiedFederation.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (federationMember is CollateralFederationMember collateralFederationMember && !modifiedFederation.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) modifiedFederation.Add(federationMember); } else if (poll.VotingData.Key == VoteKey.KickFederationMember) From 77836567662309f6b24e1015bcde6a40dcfc8597 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sat, 21 Aug 2021 14:01:10 +0100 Subject: [PATCH 41/55] Remove logging from federation build logic --- src/Stratis.Bitcoin.Features.PoA/FederationManager.cs | 11 ++++++----- .../Voting/JoinFederationRequestService.cs | 2 +- .../Voting/VotingManager.cs | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs index d24a5373b0..73d6852224 100644 --- a/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/FederationManager.cs @@ -291,8 +291,11 @@ private void AddFederationMemberLocked(IFederationMember federationMember) { if (federationMember is CollateralFederationMember collateralFederationMember) { - if (this.federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (this.federationMembers.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) + { + this.logger.Warn($"Federation member with address '{collateralFederationMember.CollateralMainchainAddress}' already exists."); return; + } if (this.federationMembers.Contains(federationMember)) { @@ -379,15 +382,13 @@ public static class FederationExtensions /// Checks to see if a particular collateral address is already present in the current set of /// federation members. /// + /// The list of federation members to check against. /// The collateral address to verify. /// true if present, false otherwise. - public static bool IsCollateralAddressRegistered(this List federationMembers, ILogger logger, string collateralAddress) + public static bool IsCollateralAddressRegistered(this List federationMembers, string collateralAddress) { if (federationMembers.Cast().Any(x => x.CollateralMainchainAddress == collateralAddress)) - { - logger.Warn($"Federation member with address '{collateralAddress}' already exists."); return true; - } return false; } diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs index 9a21fd329e..f638d6e3eb 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/JoinFederationRequestService.cs @@ -49,7 +49,7 @@ public JoinFederationRequestService(ICounterChainSettings counterChainSettings, public async Task JoinFederationAsync(JoinFederationRequestModel request, CancellationToken cancellationToken) { // First ensure that this collateral address isnt already present in the federation. - if (this.federationManager.GetFederationMembers().IsCollateralAddressRegistered(this.logger, request.CollateralAddress)) + if (this.federationManager.GetFederationMembers().IsCollateralAddressRegistered(request.CollateralAddress)) throw new Exception($"The provided collateral address '{request.CollateralAddress}' is already present in the federation."); // Get the address pub key hash. diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs index a8e4dc9612..c13f40eb65 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/VotingManager.cs @@ -342,7 +342,7 @@ public List GetFederationFromExecutedPolls() if (poll.VotingData.Key == VoteKey.AddFederationMember) { - if (federationMember is CollateralFederationMember collateralFederationMember && !federationMembers.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (federationMember is CollateralFederationMember collateralFederationMember && !federationMembers.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) federationMembers.Add(federationMember); } else if (poll.VotingData.Key == VoteKey.KickFederationMember) @@ -375,7 +375,7 @@ public List GetModifiedFederation(ChainedHeader chainedHeader // Addition/removal. if (poll.VotingData.Key == VoteKey.AddFederationMember) { - if (federationMember is CollateralFederationMember collateralFederationMember && !modifiedFederation.IsCollateralAddressRegistered(this.logger, collateralFederationMember.CollateralMainchainAddress)) + if (federationMember is CollateralFederationMember collateralFederationMember && !modifiedFederation.IsCollateralAddressRegistered(collateralFederationMember.CollateralMainchainAddress)) modifiedFederation.Add(federationMember); } else if (poll.VotingData.Key == VoteKey.KickFederationMember) From 2e2132ca7923bc5549c531dd717702a1d5ca661d Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sun, 22 Aug 2021 11:43:34 +0100 Subject: [PATCH 42/55] Update all versions to 1.0.9.3 --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/NBitcoin/NBitcoin.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- .../Stratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.Interop.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- .../Stratis.Bitcoin.Features.Notifications.csproj | 2 +- ...atis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Networks.csproj | 6 +++--- .../Stratis.Bitcoin.Tests.Common.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Collateral.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Features.FederatedPeg.csproj | 2 +- .../Stratis.Features.SQLiteWalletRepository.csproj | 2 +- .../Stratis.Sidechains.Networks.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 35 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index f791a5725b..13970c63c6 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index e50dc34b42..1f5704f014 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.7.0 + 1.0.9.3 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/NBitcoin/NBitcoin.csproj b/src/NBitcoin/NBitcoin.csproj index 360631cae1..c4bf23121a 100644 --- a/src/NBitcoin/NBitcoin.csproj +++ b/src/NBitcoin/NBitcoin.csproj @@ -7,7 +7,7 @@ - 4.0.0.81 + 4.0.0.82 diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 9ba09316bd..121866a093 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index f55ffab7f4..a907e6ffbd 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.9.0 + 1.0.9.3 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index 7d390aaee7..918a4b94e7 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index 6211506257..07604979f8 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index 4855707279..9151c3a7c0 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index fd7dd4ba85..460ee16d07 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj index eafcd307fd..6232de80e3 100644 --- a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj +++ b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.0 + 1.0.9.3 Stratis Group Ltd. Stratis.Features.Interop Stratis.Features.Interop diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index fbb223252f..96c4c96345 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index a6f014b9b8..703d02d3dd 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 6910530703..128c858794 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index 0d7c6d5814..a43d8a00b6 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index 23c484f5c9..374c7dde8e 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index c7ae1b8ef9..a6cac5017c 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 39a5af5470..018a2da99a 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index ca4179f18f..650e49581e 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.9.0 + 1.0.9.3 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 5df6fc35f1..995b269ba5 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.0 + 1.0.9.3 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index 8ed6295963..1f977dc27c 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index 5fba3ca6fd..73178d1c7a 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index 23bdded8d1..caf1b7eda1 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index 4aa33c68f8..72f4af612e 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.7.0 - 1.0.7.0 - 1.0.9.0 + 1.0.9.3 + 1.0.9.3 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index 5171db905b..9bcc2d42b3 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index 3f635ff87c..c3d41ae258 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index dc3e303e15..a60ee203bb 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.7.0 + 1.0.9.3 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 2ebf1f5fba..64dca8e0fa 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index c22f630cf0..43abb164c5 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. diff --git a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj index 7fbfe851c0..23fa63875c 100644 --- a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj +++ b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 4.0.1.0 + 4.0.2.0 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 712e7fda46..89c5b7abb4 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.9.0 + 1.0.9.3 Stratis Group Ltd. diff --git a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj index 0533d830c7..004dfce442 100644 --- a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj +++ b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj @@ -12,7 +12,7 @@ Full ..\None.ruleset Stratis Group Ltd. - 4.0.1.0 + 4.0.2.0 diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index f4bd0541e8..e97d9d7cf4 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.0 + 1.0.9.3 False Stratis Group Ltd. diff --git a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj index 7e5174018a..e06f658a05 100644 --- a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj +++ b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj @@ -5,7 +5,7 @@ Full ..\None.ruleset - 1.0.9.0 + 1.0.9.3 Stratis Group Ltd. Stratis.Sidechains.Networks diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index 73f9d1e1ec..fb2a4c3cc6 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index 65be90c391..9ba0ccc3f2 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.7.0 + 1.0.9.3 Stratis Group Ltd. From ce58e1f6dea11e5ed2a183634ac4660e0ee0047b Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sun, 22 Aug 2021 20:30:27 +0100 Subject: [PATCH 43/55] Add null check in IdleMemberKicker (#673) * Add null check in IdleMemberKicker * Update IdleFederationMembersKicker.cs --- .../Voting/IdleFederationMembersKicker.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs index 1fdd922e61..ca9aefe90d 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs @@ -193,12 +193,19 @@ public void Execute(ChainedHeader consensusTip) this.SaveMembersByLastActiveTime(); // Check if any fed member was idle for too long. Use the timestamp of the mined block. - foreach (KeyValuePair fedMemberToActiveTime in this.fedPubKeysByLastActiveTime) + foreach (KeyValuePair fedMemberToActiveTime in this.fedPubKeysByLastActiveTime.ToList()) { if (this.ShouldMemberBeKicked(fedMemberToActiveTime.Key, consensusTip.Header.Time, out uint inactiveForSeconds)) { IFederationMember memberToKick = this.federationManager.GetFederationMembers().SingleOrDefault(x => x.PubKey == fedMemberToActiveTime.Key); + // If the federation member is not present in the federation, remove it and continue. + if (memberToKick == null) + { + this.fedPubKeysByLastActiveTime.Remove(fedMemberToActiveTime.Key, out _); + continue; + } + byte[] federationMemberBytes = this.consensusFactory.SerializeFederationMember(memberToKick); bool alreadyKicking = this.votingManager.AlreadyVotingFor(VoteKey.KickFederationMember, federationMemberBytes); From 82d537367c57273a9bcfbf4edb99c445896f0d01 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sun, 22 Aug 2021 20:32:43 +0100 Subject: [PATCH 44/55] Bump version --- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 4 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 0bcc2145f2..29221d9419 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.9.3")] -[assembly: AssemblyFileVersion("1.0.9.3")] +[assembly: AssemblyVersion("1.0.9.4")] +[assembly: AssemblyFileVersion("1.0.9.4")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 80e5a0ba07..959ba38c65 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False ..\Stratis.ruleset Stratis Group Ltd. From a3bf61c063aca36068bbe1fbe7b9b5184e7549f3 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sun, 22 Aug 2021 20:30:27 +0100 Subject: [PATCH 45/55] Add null check in IdleMemberKicker (#673) * Add null check in IdleMemberKicker * Update IdleFederationMembersKicker.cs --- .../Voting/IdleFederationMembersKicker.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs b/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs index 1fdd922e61..ca9aefe90d 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs +++ b/src/Stratis.Bitcoin.Features.PoA/Voting/IdleFederationMembersKicker.cs @@ -193,12 +193,19 @@ public void Execute(ChainedHeader consensusTip) this.SaveMembersByLastActiveTime(); // Check if any fed member was idle for too long. Use the timestamp of the mined block. - foreach (KeyValuePair fedMemberToActiveTime in this.fedPubKeysByLastActiveTime) + foreach (KeyValuePair fedMemberToActiveTime in this.fedPubKeysByLastActiveTime.ToList()) { if (this.ShouldMemberBeKicked(fedMemberToActiveTime.Key, consensusTip.Header.Time, out uint inactiveForSeconds)) { IFederationMember memberToKick = this.federationManager.GetFederationMembers().SingleOrDefault(x => x.PubKey == fedMemberToActiveTime.Key); + // If the federation member is not present in the federation, remove it and continue. + if (memberToKick == null) + { + this.fedPubKeysByLastActiveTime.Remove(fedMemberToActiveTime.Key, out _); + continue; + } + byte[] federationMemberBytes = this.consensusFactory.SerializeFederationMember(memberToKick); bool alreadyKicking = this.votingManager.AlreadyVotingFor(VoteKey.KickFederationMember, federationMemberBytes); From ed826e058e7de8a78140f1a41d7ff66308c50421 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Sun, 22 Aug 2021 20:32:43 +0100 Subject: [PATCH 46/55] Bump version --- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 4 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 0bcc2145f2..29221d9419 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.9.3")] -[assembly: AssemblyFileVersion("1.0.9.3")] +[assembly: AssemblyVersion("1.0.9.4")] +[assembly: AssemblyFileVersion("1.0.9.4")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 80e5a0ba07..959ba38c65 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False ..\Stratis.ruleset Stratis Group Ltd. From cb7759971e1820ff97c27d0fa259a3eb04b8f55a Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 23 Aug 2021 10:43:26 +0100 Subject: [PATCH 47/55] Update all project versions to 1.0.9.4 --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- .../Stratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.Interop.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- .../Stratis.Bitcoin.Features.Notifications.csproj | 2 +- ...atis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Networks.csproj | 6 +++--- .../Stratis.Bitcoin.Tests.Common.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Collateral.csproj | 2 +- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Features.FederatedPeg.csproj | 2 +- .../Stratis.Features.SQLiteWalletRepository.csproj | 2 +- .../Stratis.Sidechains.Networks.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 34 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index 13970c63c6..8a99449676 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index 1f5704f014..c170873a76 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 121866a093..0a98506414 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index a907e6ffbd..4298c8014f 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.9.3 + 1.0.9.4 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index 918a4b94e7..24b4fbb6d0 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index 07604979f8..d3fda23724 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index 9151c3a7c0..add8119808 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index 460ee16d07..e9375679cd 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj index 6232de80e3..4ef4ac7ca1 100644 --- a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj +++ b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis.Features.Interop Stratis.Features.Interop diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index 96c4c96345..d2fd1a4780 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 703d02d3dd..1a63662b19 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 128c858794..9cf61ff269 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index a43d8a00b6..8798669ae1 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index 374c7dde8e..fe9320f91b 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index a6cac5017c..c1f1506f2b 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index 018a2da99a..cca62d77b4 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index 650e49581e..6ae3104a4a 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 995b269ba5..1f5434f3c1 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index 1f977dc27c..b692f5ccb0 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index 73178d1c7a..3aa77791f8 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index caf1b7eda1..6ab2b824c4 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index 72f4af612e..d997a6b287 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.9.3 - 1.0.9.3 - 1.0.9.3 + 1.0.9.4 + 1.0.9.4 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index 9bcc2d42b3..b68c03a998 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index c3d41ae258..d2a861dd90 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index a60ee203bb..3ac3f4b76c 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.9.3 + 1.0.9.4 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index 64dca8e0fa..e3aba576fb 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index 43abb164c5..c2f65685d1 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. diff --git a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj index 23fa63875c..cccf336b86 100644 --- a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj +++ b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 4.0.2.0 + 4.0.3.0 Stratis Group Ltd. diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 89c5b7abb4..17500a3c5e 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. diff --git a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj index 004dfce442..b90904fa2d 100644 --- a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj +++ b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj @@ -12,7 +12,7 @@ Full ..\None.ruleset Stratis Group Ltd. - 4.0.2.0 + 4.0.3.0 diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index e97d9d7cf4..b601030dcb 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.3 + 1.0.9.4 False Stratis Group Ltd. diff --git a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj index e06f658a05..f9b17507f8 100644 --- a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj +++ b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj @@ -5,7 +5,7 @@ Full ..\None.ruleset - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. Stratis.Sidechains.Networks diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index fb2a4c3cc6..0dad1d8c76 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index 9ba0ccc3f2..b7c838e980 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.9.3 + 1.0.9.4 Stratis Group Ltd. From 0c52c7a5221afcda6a1acdc4b6ef8d7e4844be3f Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Mon, 23 Aug 2021 15:14:13 +0100 Subject: [PATCH 48/55] Bump SC versions --- .../Stratis.SmartContracts.Core.csproj | 2 +- .../Stratis.SmartContracts.Networks.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj index c29d7cef28..0f9b5ea440 100644 --- a/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj +++ b/src/Stratis.SmartContracts.Core/Stratis.SmartContracts.Core.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 2.0.1.0 + 2.0.3.0 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj index 3ec5aaaf66..fcdff29339 100644 --- a/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj +++ b/src/Stratis.SmartContracts.Networks/Stratis.SmartContracts.Networks.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 - 2.0.1.0 + 2.0.3.0 Stratis Group Ltd. From 93a1a5cd46c538e2399a9df8ff99d89dc06b6e98 Mon Sep 17 00:00:00 2001 From: quantumagi Date: Fri, 23 Jul 2021 18:03:36 +1000 Subject: [PATCH 49/55] Validate ChainStore tip on load (#600) * Validate ChainStore tip on load * Change comment * Update tests * Dispose IChainStore * Bump version --- src/NBitcoin/ChainStore.cs | 6 ++++- .../ApiSettingsTest.cs | 18 ++++++++++----- .../CoinViewTests.cs | 6 ++++- .../Base/ChainRepositoryTest.cs | 7 +++++- src/Stratis.Bitcoin/Base/BaseFeature.cs | 22 +++++++++++++------ src/Stratis.Bitcoin/Base/ChainRepository.cs | 5 +++++ .../ChainStores/LevelDbChainStore.cs | 2 +- .../ChainStores/RocksDbChainStore.cs | 2 +- 8 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/NBitcoin/ChainStore.cs b/src/NBitcoin/ChainStore.cs index 677ab38e17..17b0ec09ea 100644 --- a/src/NBitcoin/ChainStore.cs +++ b/src/NBitcoin/ChainStore.cs @@ -4,7 +4,7 @@ namespace NBitcoin { - public interface IChainStore + public interface IChainStore : IDisposable { BlockHeader GetHeader(ChainedHeader chainedHeader, uint256 hash); @@ -90,5 +90,9 @@ public void PutChainData(IEnumerable items) foreach (ChainDataItem item in items) this.chainData.TryAdd(item.Height, item.Data); } + + public void Dispose() + { + } } } diff --git a/src/Stratis.Bitcoin.Api.Tests/ApiSettingsTest.cs b/src/Stratis.Bitcoin.Api.Tests/ApiSettingsTest.cs index 9282939dad..68e35b79a9 100644 --- a/src/Stratis.Bitcoin.Api.Tests/ApiSettingsTest.cs +++ b/src/Stratis.Bitcoin.Api.Tests/ApiSettingsTest.cs @@ -14,8 +14,10 @@ namespace Stratis.Bitcoin.Api.Tests /// /// Tests the settings for the API features. /// - public class ApiSettingsTest : TestBase + public class ApiSettingsTest : TestBase, IDisposable { + private IFullNode fullNode; + public ApiSettingsTest() : base(KnownNetworks.Main) { } @@ -266,14 +268,20 @@ public void GivenUseHttpsAndNoCertificateFilePath_ThenShouldThrowConfigurationEx settingsAction.Should().Throw(); } - private static ApiSettings FullNodeSetup(NodeSettings nodeSettings) + private ApiSettings FullNodeSetup(NodeSettings nodeSettings) { - return new FullNodeBuilder() + this.fullNode = new FullNodeBuilder() .UseNodeSettings(nodeSettings) .UseApi() .UsePowConsensus() - .Build() - .NodeService(); + .Build(); + + return this.fullNode.NodeService(); + } + + public void Dispose() + { + this.fullNode.NodeService().Dispose(); } } } diff --git a/src/Stratis.Bitcoin.IntegrationTests/CoinViewTests.cs b/src/Stratis.Bitcoin.IntegrationTests/CoinViewTests.cs index bc559604f1..5fbafe8ba2 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/CoinViewTests.cs +++ b/src/Stratis.Bitcoin.IntegrationTests/CoinViewTests.cs @@ -282,11 +282,15 @@ public void CanSaveChainIncrementally() var chain = new ChainIndexer(this.regTest); var data = new DataFolder(TestBase.CreateTestDir(this)); - using (var repo = new ChainRepository(new LevelDbChainStore(this.network, data, chain))) + var chainStore = new LevelDbChainStore(this.network, data, chain); + chain[0].SetChainStore(chainStore); + + using (var repo = new ChainRepository(chainStore)) { chain.SetTip(repo.LoadAsync(chain.Genesis).GetAwaiter().GetResult()); Assert.True(chain.Tip == chain.Genesis); chain = new ChainIndexer(this.regTest); + chain[0].SetChainStore(chainStore); ChainedHeader tip = this.AppendBlock(chain); repo.SaveAsync(chain).GetAwaiter().GetResult(); var newChain = new ChainIndexer(this.regTest); diff --git a/src/Stratis.Bitcoin.Tests/Base/ChainRepositoryTest.cs b/src/Stratis.Bitcoin.Tests/Base/ChainRepositoryTest.cs index f16c407824..26a3c968b2 100644 --- a/src/Stratis.Bitcoin.Tests/Base/ChainRepositoryTest.cs +++ b/src/Stratis.Bitcoin.Tests/Base/ChainRepositoryTest.cs @@ -77,15 +77,20 @@ public void LoadChainFromDisk() new ChainRepository.ChainRepositoryData() { Hash = block.HashBlock, Work = block.ChainWorkBytes } .ToBytes(this.Network.Consensus.ConsensusFactory)); + + ConsensusFactory consensusFactory = KnownNetworks.StraxRegTest.Consensus.ConsensusFactory; + batch.Put(2, block.Header.GetHash().ToBytes(), block.Header.ToBytes(consensusFactory)); } engine.Write(batch); } } - using (var repo = new ChainRepository(new LevelDbChainStore(chain.Network, new DataFolder(dir), chain))) + var chainStore = new LevelDbChainStore(chain.Network, new DataFolder(dir), chain); + using (var repo = new ChainRepository(chainStore)) { var testChain = new ChainIndexer(KnownNetworks.StraxRegTest); + testChain[0].SetChainStore(chainStore); testChain.SetTip(repo.LoadAsync(testChain.Genesis).GetAwaiter().GetResult()); Assert.Equal(tip, testChain.Tip); } diff --git a/src/Stratis.Bitcoin/Base/BaseFeature.cs b/src/Stratis.Bitcoin/Base/BaseFeature.cs index ab220c696c..06aa92bb8b 100644 --- a/src/Stratis.Bitcoin/Base/BaseFeature.cs +++ b/src/Stratis.Bitcoin/Base/BaseFeature.cs @@ -390,24 +390,32 @@ public static IFullNodeBuilder UseBaseFeature(this IFullNodeBuilder fullNodeBuil services.AddSingleton(); services.AddSingleton(); services.AddSingleton().AddSingleton((provider) => { return provider.GetService() as IFullNode; }); - services.AddSingleton(new ChainIndexer(fullNodeBuilder.Network)); - services.AddSingleton(DateTimeProvider.Default); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + + ChainIndexer chainIndexer = new ChainIndexer(fullNodeBuilder.Network); + IChainStore chainStore = null; if (dbType == DbType.Leveldb) { - services.AddSingleton(); + chainStore = new LevelDbChainStore(fullNodeBuilder.Network, fullNodeBuilder.NodeSettings.DataFolder, chainIndexer); services.AddSingleton(); } if (dbType == DbType.RocksDb) { - services.AddSingleton(); + chainStore = new RocksDbChainStore(fullNodeBuilder.Network, fullNodeBuilder.NodeSettings.DataFolder, chainIndexer); services.AddSingleton(); } + chainIndexer[0].SetChainStore(chainStore); + + services.AddSingleton(chainStore); + services.AddSingleton(chainIndexer); + + services.AddSingleton(DateTimeProvider.Default); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/src/Stratis.Bitcoin/Base/ChainRepository.cs b/src/Stratis.Bitcoin/Base/ChainRepository.cs index 43a5c9eb4e..24cfb4a387 100644 --- a/src/Stratis.Bitcoin/Base/ChainRepository.cs +++ b/src/Stratis.Bitcoin/Base/ChainRepository.cs @@ -82,6 +82,11 @@ public Task LoadAsync(ChainedHeader genesisHeader) genesisHeader.SetChainStore(this.chainStore); tip = genesisHeader; } + else + { + // Confirm that the chain tip exists in the headers table. + this.chainStore.GetHeader(tip, tip.HashBlock); + } this.locator = tip.GetLocator(); return tip; diff --git a/src/Stratis.Bitcoin/Persistence/ChainStores/LevelDbChainStore.cs b/src/Stratis.Bitcoin/Persistence/ChainStores/LevelDbChainStore.cs index 00633b7e19..e038293326 100644 --- a/src/Stratis.Bitcoin/Persistence/ChainStores/LevelDbChainStore.cs +++ b/src/Stratis.Bitcoin/Persistence/ChainStores/LevelDbChainStore.cs @@ -7,7 +7,7 @@ namespace Stratis.Bitcoin.Persistence.ChainStores { - public class LevelDbChainStore : IChainStore, IDisposable + public class LevelDbChainStore : IChainStore { private readonly Network network; diff --git a/src/Stratis.Bitcoin/Persistence/ChainStores/RocksDbChainStore.cs b/src/Stratis.Bitcoin/Persistence/ChainStores/RocksDbChainStore.cs index f47751b068..44f6da3c23 100644 --- a/src/Stratis.Bitcoin/Persistence/ChainStores/RocksDbChainStore.cs +++ b/src/Stratis.Bitcoin/Persistence/ChainStores/RocksDbChainStore.cs @@ -10,7 +10,7 @@ namespace Stratis.Bitcoin.Persistence.ChainStores /// /// Rocksdb implementation of the chain storage /// - public sealed class RocksDbChainStore : IChainStore, IDisposable + public sealed class RocksDbChainStore : IChainStore { internal static readonly byte ChainTableName = 1; internal static readonly byte HeaderTableName = 2; From 09730c9aedaf638399fcba559c1c1d551880f0e9 Mon Sep 17 00:00:00 2001 From: quantumagi Date: Thu, 26 Aug 2021 17:01:04 +1000 Subject: [PATCH 50/55] CirrusMain checkpoint 2_827_550 (#680) --- src/Stratis.Sidechains.Networks/CirrusMain.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Stratis.Sidechains.Networks/CirrusMain.cs b/src/Stratis.Sidechains.Networks/CirrusMain.cs index 813ca8bb01..1305f7c9e7 100644 --- a/src/Stratis.Sidechains.Networks/CirrusMain.cs +++ b/src/Stratis.Sidechains.Networks/CirrusMain.cs @@ -263,6 +263,8 @@ public CirrusMain() { 1_750_000, new CheckpointInfo(new uint256("0x58c96a878efeeffea1b1924b61eed627687900e01588ffaa2f4a161973f01abf")) }, { 1_850_000, new CheckpointInfo(new uint256("0x6e2590bd9a8eaab25b236c0c9ac314abec70b18aa053b96c9257f2356dec8314")) }, { 2_150_000, new CheckpointInfo(new uint256("0x4c65f29b5098479cab275afd77d302ebe5ed8d8ef33e02ae54bf185865763f18")) }, + { 2_500_000, new CheckpointInfo(new uint256("0x2853be7b7224840d3d4b60427ea832e9bd67d8fc6bfcd4956b8c6b2414cf8fc2")) }, + { 2_827_550, new CheckpointInfo(new uint256("0xcf0ebdd99ec04ef260d22befe70ef7b948e50b5fcc18d9d37376d49e872372a0")) } }; this.DNSSeeds = new List From fc3e0885f9497802c89ebdcd435d3d37c74fb5c4 Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Thu, 26 Aug 2021 11:47:13 +0100 Subject: [PATCH 51/55] Bump version to 1.0.9.5 --- src/Stratis.Bitcoin/Properties/AssemblyInfo.cs | 4 ++-- src/Stratis.Bitcoin/Stratis.Bitcoin.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs index 29221d9419..b5aece1f47 100644 --- a/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs +++ b/src/Stratis.Bitcoin/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.9.4")] -[assembly: AssemblyFileVersion("1.0.9.4")] +[assembly: AssemblyVersion("1.0.9.5")] +[assembly: AssemblyFileVersion("1.0.9.5")] [assembly: InternalsVisibleTo("Stratis.Bitcoin.Tests")] \ No newline at end of file diff --git a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj index 959ba38c65..53262f9916 100644 --- a/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj +++ b/src/Stratis.Bitcoin/Stratis.Bitcoin.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False ..\Stratis.ruleset Stratis Group Ltd. From 6ed367954e98cbd489e619caab80219fd6f45f5a Mon Sep 17 00:00:00 2001 From: quantumagi Date: Fri, 18 Jun 2021 13:06:16 +1000 Subject: [PATCH 52/55] Merge Disable signature rule in IBD #579 from release/1.1.0.0 --- .../PoAHeaderSignatureRule.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs index 463120c42d..5ca5e216b7 100644 --- a/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs +++ b/src/Stratis.Bitcoin.Features.PoA/BasePoAFeatureConsensusRules/PoAHeaderSignatureRule.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NBitcoin; using Stratis.Bitcoin.Base; using Stratis.Bitcoin.Consensus; using Stratis.Bitcoin.Consensus.Rules; +using Stratis.Bitcoin.Utilities; namespace Stratis.Bitcoin.Features.PoA.BasePoAFeatureConsensusRules { @@ -26,6 +28,8 @@ public class PoAHeaderSignatureRule : FullValidationConsensusRule private Network network; + private HashHeightPair lastCheckPoint; + /// public override void Initialize() { @@ -41,10 +45,17 @@ public override void Initialize() this.network = this.Parent.Network; this.maxReorg = this.network.Consensus.MaxReorgLength; + + KeyValuePair lastCheckPoint = engine.Network.Checkpoints.LastOrDefault(); + this.lastCheckPoint = (lastCheckPoint.Value != null) ? new HashHeightPair(lastCheckPoint.Value.Hash, lastCheckPoint.Key) : null; } public override async Task RunAsync(RuleContext context) { + // Only start validating at the last checkpoint block. + if (context.ValidationContext.ChainedHeaderToValidate.Height < (this.lastCheckPoint?.Height ?? 0)) + return; + ChainedHeader chainedHeader = context.ValidationContext.ChainedHeaderToValidate; var header = chainedHeader.Header as PoABlockHeader; From 062acfd664f13a83bc293e12fafb85833df947de Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Tue, 31 Aug 2021 10:46:51 +0100 Subject: [PATCH 53/55] UI SignalR improvements / Move UI notification outside of loop blocks (#686) --- .../EventSubscriptionService.cs | 32 ++++++-------- ...ocessedTransactionOfInterestClientEvent.cs | 7 ++- .../EventsHub.cs | 7 +-- ...lletProcessedTransactionOfInterestEvent.cs | 1 + src/Stratis.Bitcoin/EventBus/IEventBus.cs | 11 ++++- .../EventBus/InMemoryEventBus.cs | 21 +++++++++ src/Stratis.Bitcoin/EventBus/Subscription.cs | 28 ++++++++++++ .../SQLiteWalletRepository.cs | 44 +++++++++++++------ 8 files changed, 114 insertions(+), 37 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.SignalR/EventSubscriptionService.cs b/src/Stratis.Bitcoin.Features.SignalR/EventSubscriptionService.cs index 22900b18dd..cd984367bd 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/EventSubscriptionService.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/EventSubscriptionService.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; +using System.Threading.Tasks; using NLog; using Stratis.Bitcoin.EventBus; using Stratis.Bitcoin.Signals; @@ -33,31 +33,25 @@ public EventSubscriptionService( public void Init() { - MethodInfo subscribeMethod = this.signals.GetType().GetMethod("Subscribe"); - MethodInfo onEventCallbackMethod = typeof(EventSubscriptionService).GetMethod("OnEvent"); foreach (IClientEvent eventToHandle in this.options.EventsToHandle) { this.logger.Debug("Create subscription for {0}", eventToHandle.NodeEventType); - MethodInfo subscribeMethodInfo = subscribeMethod.MakeGenericMethod(eventToHandle.NodeEventType); - Type callbackType = typeof(Action<>).MakeGenericType(eventToHandle.NodeEventType); - Delegate onEventDelegate = Delegate.CreateDelegate(callbackType, this, onEventCallbackMethod); - var token = (SubscriptionToken)subscribeMethodInfo.Invoke(this.signals, new object[] { onEventDelegate }); - this.subscriptions.Add(token); - } - } + async Task callback(EventBase eventBase) + { + Type childType = eventBase.GetType(); - /// This is invoked through reflection. - public void OnEvent(EventBase @event) - { - Type childType = @event.GetType(); + IClientEvent clientEvent = this.options.EventsToHandle.FirstOrDefault(ev => ev.NodeEventType == childType); + if (clientEvent == null) + return; - IClientEvent clientEvent = this.options.EventsToHandle.FirstOrDefault(ev => ev.NodeEventType == childType); - if (clientEvent == null) - return; + clientEvent.BuildFrom(eventBase); - clientEvent.BuildFrom(@event); - this.eventsHub.SendToClientsAsync(clientEvent).ConfigureAwait(false).GetAwaiter().GetResult(); + await this.eventsHub.SendToClientsAsync(clientEvent).ConfigureAwait(false); + } + + this.signals.Subscribe(eventToHandle.NodeEventType, callback); + } } public void Dispose() diff --git a/src/Stratis.Bitcoin.Features.SignalR/Events/WalletProcessedTransactionOfInterestClientEvent.cs b/src/Stratis.Bitcoin.Features.SignalR/Events/WalletProcessedTransactionOfInterestClientEvent.cs index 1973a380de..770e421fc0 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Events/WalletProcessedTransactionOfInterestClientEvent.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/Events/WalletProcessedTransactionOfInterestClientEvent.cs @@ -6,12 +6,17 @@ namespace Stratis.Bitcoin.Features.SignalR.Events { public sealed class WalletProcessedTransactionOfInterestClientEvent : IClientEvent { + public string Source { get; set; } + public Type NodeEventType { get; } = typeof(WalletProcessedTransactionOfInterestEvent); public void BuildFrom(EventBase @event) { - if (@event is WalletProcessedTransactionOfInterestEvent progressEvent) + if (@event is WalletProcessedTransactionOfInterestEvent txEvent) + { + this.Source = txEvent.Source; return; + } throw new ArgumentException(); } diff --git a/src/Stratis.Bitcoin.Features.SignalR/EventsHub.cs b/src/Stratis.Bitcoin.Features.SignalR/EventsHub.cs index ef56750b5a..3d3bc07c3a 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/EventsHub.cs +++ b/src/Stratis.Bitcoin.Features.SignalR/EventsHub.cs @@ -79,12 +79,13 @@ public void UnSubscribeToIncomingSignalRMessages(string target) public async Task SendToClientsAsync(IClientEvent @event) { - // Check if any there are any connected clients - if (this.Clients == null) return; + // Check if any there are any connected clients. + if (this.Clients == null) + return; try { - await this.Clients.All.SendAsync("receiveEvent", @event); + await this.Clients.All.SendAsync("receiveEvent", @event).ConfigureAwait(false); } catch (Exception ex) { diff --git a/src/Stratis.Bitcoin.Features.Wallet/Events/WalletProcessedTransactionOfInterestEvent.cs b/src/Stratis.Bitcoin.Features.Wallet/Events/WalletProcessedTransactionOfInterestEvent.cs index c9077917f5..a52ab15d85 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Events/WalletProcessedTransactionOfInterestEvent.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/Events/WalletProcessedTransactionOfInterestEvent.cs @@ -14,5 +14,6 @@ namespace Stratis.Bitcoin.Features.Wallet.Events /// public sealed class WalletProcessedTransactionOfInterestEvent : EventBase { + public string Source { get; set; } } } diff --git a/src/Stratis.Bitcoin/EventBus/IEventBus.cs b/src/Stratis.Bitcoin/EventBus/IEventBus.cs index 5c9074e471..20cb9823ba 100644 --- a/src/Stratis.Bitcoin/EventBus/IEventBus.cs +++ b/src/Stratis.Bitcoin/EventBus/IEventBus.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; namespace Stratis.Bitcoin.EventBus { @@ -8,13 +9,21 @@ namespace Stratis.Bitcoin.EventBus public interface IEventBus { /// - /// Subscribes to the specified event type with the specified action + /// Subscribes to the specified event type with the specified action. /// /// The type of event /// The Action to invoke when an event of this type is published /// A to be used when calling SubscriptionToken Subscribe(Action action) where TEventBase : EventBase; + /// + /// Subscribes to the specified event type with the specified function. + /// + /// The type of event + /// The Function to invoke when an event of this type is published + /// A to be used when calling + SubscriptionToken Subscribe(Type eventType, Func handler); + /// /// Unsubscribe from the Event type related to the specified /// diff --git a/src/Stratis.Bitcoin/EventBus/InMemoryEventBus.cs b/src/Stratis.Bitcoin/EventBus/InMemoryEventBus.cs index 540b2875ae..d0e4c1a17e 100644 --- a/src/Stratis.Bitcoin/EventBus/InMemoryEventBus.cs +++ b/src/Stratis.Bitcoin/EventBus/InMemoryEventBus.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Stratis.Bitcoin.Utilities; @@ -40,6 +41,26 @@ public InMemoryEventBus(ILoggerFactory loggerFactory, ISubscriptionErrorHandler this.subscriptions = new Dictionary>(); } + /// + public SubscriptionToken Subscribe(Type eventType, Func handler) + { + if (handler == null) + throw new ArgumentNullException(nameof(handler)); + + lock (this.subscriptionsLock) + { + if (!this.subscriptions.ContainsKey(eventType)) + { + this.subscriptions.Add(eventType, new List()); + } + + var subscriptionToken = new SubscriptionToken(this, eventType); + this.subscriptions[eventType].Add(new Subscription(handler, subscriptionToken)); + + return subscriptionToken; + } + } + /// public SubscriptionToken Subscribe(Action handler) where TEvent : EventBase { diff --git a/src/Stratis.Bitcoin/EventBus/Subscription.cs b/src/Stratis.Bitcoin/EventBus/Subscription.cs index d70ddabb44..e931c8005e 100644 --- a/src/Stratis.Bitcoin/EventBus/Subscription.cs +++ b/src/Stratis.Bitcoin/EventBus/Subscription.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; namespace Stratis.Bitcoin.EventBus { @@ -28,4 +29,31 @@ public void Publish(EventBase eventItem) this.action.Invoke(eventItem as TEventBase); } } + + internal class Subscription : ISubscription + { + /// + /// Token returned to the subscriber + /// + public SubscriptionToken SubscriptionToken { get; } + + /// + /// The action to invoke when a subscripted event type is published. + /// + private readonly Func action; + + public Subscription(Func del, SubscriptionToken token) + { + this.action = del ?? throw new ArgumentNullException(nameof(del)); + this.SubscriptionToken = token ?? throw new ArgumentNullException(nameof(token)); + } + + public void Publish(EventBase eventItem) + { + if (!(eventItem is EventBase)) + throw new ArgumentException("Event Item is not the correct type."); + + this.action.Invoke(eventItem); + } + } } diff --git a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs index ea9a17e154..829f5453a9 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs +++ b/src/Stratis.Features.SQLiteWalletRepository/SQLiteWalletRepository.cs @@ -857,7 +857,7 @@ public void ProcessBlocks(IEnumerable<(ChainedHeader header, Block block)> block Parallel.ForEach(rounds, round => { - if (!ParallelProcessBlock(round, block, chainedHeader)) + if (!ParallelProcessBlock(round, block, chainedHeader, out bool _)) done = true; }); @@ -871,18 +871,34 @@ public void ProcessBlocks(IEnumerable<(ChainedHeader header, Block block)> block ProcessBlocksInfo round = (walletName != null) ? this.Wallets[walletName] : this.processBlocksInfo; if (this.StartBatch(round, blocks.First().header)) + { + bool signalUI = false; + foreach ((ChainedHeader chainedHeader, Block block) in blocks.Append((null, null))) { this.logger.LogDebug("Processing '{0}'.", chainedHeader); - if (!ParallelProcessBlock(round, block, chainedHeader)) + if (!ParallelProcessBlock(round, block, chainedHeader, out bool transactionOfInterestProcessed)) break; + + if (transactionOfInterestProcessed) + signalUI = true; } + + if (signalUI) + { + // We only want to raise events for the UI (via SignalR) to query the wallet balance if a transaction pertaining to the wallet + // was processed. + this.signals?.Publish(new WalletProcessedTransactionOfInterestEvent() { Source = "processblock" }); + } + } } } - private bool ParallelProcessBlock(ProcessBlocksInfo round, Block block, ChainedHeader chainedHeader) + private bool ParallelProcessBlock(ProcessBlocksInfo round, Block block, ChainedHeader chainedHeader, out bool transactionOfInterestProcessed) { + transactionOfInterestProcessed = false; + try { HDWallet wallet = round.Wallet; @@ -1004,10 +1020,7 @@ private bool ParallelProcessBlock(ProcessBlocksInfo round, Block block, ChainedH ITransactionsToLists transactionsToLists = new TransactionsToLists(this.Network, this.ScriptAddressReader, round, this.dateTimeProvider); if (transactionsToLists.ProcessTransactions(block.Transactions, new HashHeightPair(chainedHeader), blockTime: block.Header.BlockTime.ToUnixTimeSeconds())) { - // We only want to raise events for the UI (via SignalR) to query the wallet balance if a transaction pertaining to the wallet - // was processed. - this.signals?.Publish(new WalletProcessedTransactionOfInterestEvent()); - + transactionOfInterestProcessed = true; this.Metrics.ProcessCount++; } @@ -1210,17 +1223,15 @@ public void ProcessTransaction(string walletName, Transaction transaction, uint2 ProcessBlocksInfo processBlocksInfo = walletContainer; + bool notifyWallet = false; + try { IEnumerable> txToScript; { var transactionsToLists = new TransactionsToLists(this.Network, this.ScriptAddressReader, processBlocksInfo, this.dateTimeProvider); if (transactionsToLists.ProcessTransactions(new[] { transaction }, null, fixedTxId)) - { - // We only want to raise events for the UI (via SignalR) to query the wallet balance if a transaction pertaining to the wallet - // was processed. - this.signals?.Publish(new WalletProcessedTransactionOfInterestEvent()); - } + notifyWallet = true; txToScript = (new[] { processBlocksInfo.Outputs, processBlocksInfo.PrevOuts }).Select(list => list.CreateScript()); } @@ -1264,6 +1275,13 @@ public void ProcessTransaction(string walletName, Transaction transaction, uint2 walletContainer.LockProcessBlocks.Release(); walletContainer.WriteLockRelease(); } + + if (notifyWallet) + { + // We only want to raise events for the UI (via SignalR) to query the wallet balance if a transaction pertaining to the wallet + // was processed. + this.signals?.Publish(new WalletProcessedTransactionOfInterestEvent() { Source = "processtx" }); + } } /// @@ -1499,7 +1517,7 @@ public AccountHistory GetHistory(HdAccount account, int limit, int offset, strin (HDWallet HDWallet, DBConnection conn) = (walletContainer.Wallet, walletContainer.Conn); var result = HDTransactionData.GetHistory(conn, HDWallet.WalletId, account.Index, limit, offset, txId, accountAddress, forSmartContracts, this.Network.Name.Contains("Cirrus")); - + // Filter ColdstakeUtxos result = result.Where(r => { From 7bac9807a9294c6bff90d9faf38b38281fa0ddf6 Mon Sep 17 00:00:00 2001 From: zeptin Date: Wed, 25 Aug 2021 08:57:42 +0200 Subject: [PATCH 54/55] [ColdStaking] Add retrieval endpoint for incorrectly sent coldstaking transactions (#678) * Add retrieval endpoint for incorrectly sent coldstaking transactions --- .../ColdStakingControllerTest.cs | 7 +-- .../ColdStakingManager.cs | 46 ++++++++++++++++ .../Controllers/ColdStakingController.cs | 52 ++++++++++++++++++- .../Models/ColdStakingModels.cs | 34 ++++++++++++ .../WalletManager.cs | 1 - .../Wallet/ColdWalletTests.cs | 52 +++++++++++++++++++ 6 files changed, 186 insertions(+), 6 deletions(-) diff --git a/src/Stratis.Bitcoin.Features.ColdStaking.Tests/ColdStakingControllerTest.cs b/src/Stratis.Bitcoin.Features.ColdStaking.Tests/ColdStakingControllerTest.cs index 308b6d73a0..3bb7994cc2 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking.Tests/ColdStakingControllerTest.cs +++ b/src/Stratis.Bitcoin.Features.ColdStaking.Tests/ColdStakingControllerTest.cs @@ -234,10 +234,11 @@ private void Initialize([System.Runtime.CompilerServices.CallerMemberName] strin this.loggerFactory, DateTimeProvider.Default, walletRepository); var reserveUtxoService = new ReserveUtxoService(this.loggerFactory, new Mock().Object); + var walletFeePolicy = new Mock().Object; + var broadcasterManager = new Mock().Object; + var walletTransactionHandler = new WalletTransactionHandler(this.loggerFactory, this.coldStakingManager, walletFeePolicy, this.Network, new StandardTransactionPolicy(this.Network), reserveUtxoService); - var walletTransactionHandler = new WalletTransactionHandler(this.loggerFactory, this.coldStakingManager, new Mock().Object, this.Network, new StandardTransactionPolicy(this.Network), reserveUtxoService); - - this.coldStakingController = new ColdStakingController(this.loggerFactory, this.coldStakingManager, walletTransactionHandler); + this.coldStakingController = new ColdStakingController(this.loggerFactory, this.coldStakingManager, walletTransactionHandler, walletFeePolicy, broadcasterManager); this.asyncProvider = new AsyncProvider(this.loggerFactory, new Mock().Object); diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/ColdStakingManager.cs b/src/Stratis.Bitcoin.Features.ColdStaking/ColdStakingManager.cs index 490f284f49..b82bbe1d67 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/ColdStakingManager.cs +++ b/src/Stratis.Bitcoin.Features.ColdStaking/ColdStakingManager.cs @@ -692,5 +692,51 @@ public IEnumerable GetSpendableTransactionsInColdWallet( this.logger.LogTrace("(-):*.Count={0}", res.Count()); return res; } + + public List RetrieveFilteredUtxos(string walletName, string walletPassword, string transactionHex, FeeRate feeRate, string walletAccount = null) + { + var retrievalTransactions = new List(); + + Transaction transactionToReclaim = this.network.Consensus.ConsensusFactory.CreateTransaction(transactionHex); + + foreach (TxOut output in transactionToReclaim.Outputs) + { + Wallet.Wallet wallet = this.GetWallet(walletName); + + HdAddress address = wallet.GetAllAddresses(Wallet.Wallet.AllAccounts).FirstOrDefault(a => a.ScriptPubKey == output.ScriptPubKey); + + // The address is not in the wallet so ignore this output. + if (address == null) + continue; + + HdAccount destinationAccount = wallet.GetAccounts(Wallet.Wallet.NormalAccounts).First(); + + // This shouldn't really happen unless the user has no proper accounts in the wallet. + if (destinationAccount == null) + continue; + + Script destination = destinationAccount.GetFirstUnusedReceivingAddress().ScriptPubKey; + + ISecret extendedPrivateKey = wallet.GetExtendedPrivateKeyForAddress(walletPassword, address); + + Key privateKey = extendedPrivateKey.PrivateKey; + + var builder = new TransactionBuilder(this.network); + + var coin = new Coin(transactionToReclaim, output); + + builder.AddCoins(coin); + builder.AddKeys(privateKey); + builder.Send(destination, output.Value); + builder.SubtractFees(); + builder.SendEstimatedFees(feeRate); + + Transaction builtTransaction = builder.BuildTransaction(true); + + retrievalTransactions.Add(builtTransaction); + } + + return retrievalTransactions; + } } } diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingController.cs b/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingController.cs index 213fafeb07..c65c9565f4 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingController.cs +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Controllers/ColdStakingController.cs @@ -23,25 +23,33 @@ namespace Stratis.Bitcoin.Features.ColdStaking.Controllers public class ColdStakingController : Controller { public ColdStakingManager ColdStakingManager { get; private set; } + private readonly IWalletTransactionHandler walletTransactionHandler; + private readonly IWalletFeePolicy walletFeePolicy; + private readonly IBroadcasterManager broadcasterManager; - /// Instance logger. private readonly ILogger logger; public ColdStakingController( ILoggerFactory loggerFactory, IWalletManager walletManager, - IWalletTransactionHandler walletTransactionHandler) + IWalletTransactionHandler walletTransactionHandler, + IWalletFeePolicy walletFeePolicy, + IBroadcasterManager broadcasterManager) { Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(walletManager, nameof(walletManager)); Guard.NotNull(walletTransactionHandler, nameof(walletTransactionHandler)); + Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy)); + Guard.NotNull(broadcasterManager, nameof(broadcasterManager)); this.ColdStakingManager = walletManager as ColdStakingManager; Guard.NotNull(this.ColdStakingManager, nameof(this.ColdStakingManager)); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.walletTransactionHandler = walletTransactionHandler; + this.walletFeePolicy = walletFeePolicy; + this.broadcasterManager = broadcasterManager; } /// @@ -589,5 +597,45 @@ public IActionResult EstimateColdStakingWithdrawalFee([FromBody] ColdStakingWith return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()); } } + + [Route("retrieve-filtered-utxos")] + [HttpPost] + [ProducesResponseType((int)HttpStatusCode.OK)] + [ProducesResponseType((int)HttpStatusCode.BadRequest)] + [ProducesResponseType((int)HttpStatusCode.InternalServerError)] + public IActionResult RetrieveFilteredUtxos([FromBody] RetrieveFilteredUtxosRequest request) + { + Guard.NotNull(request, nameof(request)); + + // Checks the request is valid. + if (!this.ModelState.IsValid) + { + this.logger.LogTrace("(-)[MODEL_STATE_INVALID]"); + return ModelStateErrors.BuildErrorResponse(this.ModelState); + } + + try + { + FeeRate feeRate = this.walletFeePolicy.GetFeeRate(FeeType.High.ToConfirmations()); + + List retrievalTransactions = this.ColdStakingManager.RetrieveFilteredUtxos(request.WalletName, request.WalletPassword, request.Hex, feeRate, request.WalletAccount); + + if (request.Broadcast) + { + foreach (Transaction transaction in retrievalTransactions) + { + this.broadcasterManager.BroadcastTransactionAsync(transaction); + } + } + + return this.Json(retrievalTransactions.Select(t => t.ToHex())); + } + catch (Exception e) + { + this.logger.LogError("Exception occurred: {0}", e.ToString()); + this.logger.LogTrace("(-)[ERROR]"); + return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()); + } + } } } diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Models/ColdStakingModels.cs b/src/Stratis.Bitcoin.Features.ColdStaking/Models/ColdStakingModels.cs index 40606b7d4f..9cf43418ed 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Models/ColdStakingModels.cs +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Models/ColdStakingModels.cs @@ -315,4 +315,38 @@ public override string ToString() return $"{nameof(this.TransactionHex)}={this.TransactionHex}"; } } + + public class RetrieveFilteredUtxosRequest + { + /// The wallet name. + [Required] + [JsonProperty(PropertyName = "walletName")] + public string WalletName { get; set; } + + /// The wallet password. + [Required] + [JsonProperty(PropertyName = "walletPassword")] + public string WalletPassword { get; set; } + + /// + /// The (optional) account for the retrieved UTXOs to be sent back to. + /// If this is not specified, the first available non-coldstaking account will be used. + /// + [JsonProperty(PropertyName = "walletAccount")] + public string WalletAccount { get; set; } + + /// + /// The hex of the transaction to retrieve the UTXOs for. + /// Only UTXOs sent to addresses within the supplied wallet can be reclaimed. + /// + [Required] + [JsonProperty(PropertyName = "hex")] + public string Hex { get; set; } + + /// + /// Indicate whether the built transactions should be sent to the network immediately after being built. + /// + [JsonProperty(PropertyName = "broadcast")] + public bool Broadcast { get; set; } + } } diff --git a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs index 4c7e908e93..1bbf0362fa 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs +++ b/src/Stratis.Bitcoin.Features.Wallet/WalletManager.cs @@ -10,7 +10,6 @@ using NBitcoin.BuilderExtensions; using Stratis.Bitcoin.Configuration; using Stratis.Bitcoin.Features.Wallet.Interfaces; -using Stratis.Bitcoin.Features.Wallet.Models; using Stratis.Bitcoin.Utilities; using Stratis.Bitcoin.Utilities.Extensions; using TracerAttributes; diff --git a/src/Stratis.Bitcoin.IntegrationTests/Wallet/ColdWalletTests.cs b/src/Stratis.Bitcoin.IntegrationTests/Wallet/ColdWalletTests.cs index a3e64cd763..ae6c9a6196 100644 --- a/src/Stratis.Bitcoin.IntegrationTests/Wallet/ColdWalletTests.cs +++ b/src/Stratis.Bitcoin.IntegrationTests/Wallet/ColdWalletTests.cs @@ -8,6 +8,8 @@ using Stratis.Bitcoin.Features.Api; using Stratis.Bitcoin.Features.BlockStore; using Stratis.Bitcoin.Features.ColdStaking; +using Stratis.Bitcoin.Features.ColdStaking.Controllers; +using Stratis.Bitcoin.Features.ColdStaking.Models; using Stratis.Bitcoin.Features.Consensus; using Stratis.Bitcoin.Features.MemoryPool; using Stratis.Bitcoin.Features.Miner; @@ -199,5 +201,55 @@ public async Task WalletCanMineWithColdWalletCoinsAsync() }, cancellationToken: cancellationToken); } } + + [Fact] + [Trait("Unstable", "True")] + public async Task CanRetrieveFilteredUtxosAsync() + { + using (var builder = NodeBuilder.Create(this)) + { + var network = new StraxRegTest(); + + CoreNode stratisSender = CreatePowPosMiningNode(builder, network, TestBase.CreateTestDir(this), coldStakeNode: false); + CoreNode stratisColdStake = CreatePowPosMiningNode(builder, network, TestBase.CreateTestDir(this), coldStakeNode: true); + + stratisSender.WithReadyBlockchainData(ReadyBlockchain.StraxRegTest150Miner).Start(); + stratisColdStake.WithWallet().Start(); + + var coldWalletManager = stratisColdStake.FullNode.WalletManager() as ColdStakingManager; + + // Set up cold staking account on cold wallet. + coldWalletManager.GetOrCreateColdStakingAccount(WalletName, true, Password, null); + HdAddress coldWalletAddress = coldWalletManager.GetFirstUnusedColdStakingAddress(WalletName, true); + + var walletAccountReference = new WalletAccountReference(WalletName, Account); + long total2 = stratisSender.FullNode.WalletManager().GetSpendableTransactionsInAccount(walletAccountReference, 1).Sum(s => s.Transaction.Amount); + + // Sync nodes. + TestHelper.Connect(stratisSender, stratisColdStake); + + // Send coins to cold address. + Money amountToSend = total2 - network.Consensus.ProofOfWorkReward; + Transaction transaction1 = stratisSender.FullNode.WalletTransactionHandler().BuildTransaction(CreateContext(stratisSender.FullNode.Network, new WalletAccountReference(WalletName, Account), Password, coldWalletAddress.ScriptPubKey, amountToSend, FeeType.Medium, 1)); + + // Broadcast to the other nodes. + await stratisSender.FullNode.NodeController().SendTransaction(new SendTransactionRequest(transaction1.ToHex())); + + // Wait for the transaction to arrive. + TestBase.WaitLoop(() => stratisColdStake.CreateRPCClient().GetRawMempool().Length > 0); + + // Despite the funds being sent to an address in the cold account, the wallet does not recognise the output as funds belonging to it. + Assert.True(stratisColdStake.FullNode.WalletManager().GetBalances(WalletName, Account).Sum(a => a.AmountUnconfirmed + a.AmountUnconfirmed) == 0); + + uint256[] mempoolTransactionId = stratisColdStake.CreateRPCClient().GetRawMempool(); + + Transaction misspentTransaction = stratisColdStake.CreateRPCClient().GetRawTransaction(mempoolTransactionId[0]); + + // Now retrieve the UTXO sent to the cold address. The funds will reappear in a normal account on the cold staking node. + stratisColdStake.FullNode.NodeController().RetrieveFilteredUtxos(new RetrieveFilteredUtxosRequest() { WalletName = stratisColdStake.WalletName, WalletPassword = stratisColdStake.WalletPassword, Hex = misspentTransaction.ToHex(), WalletAccount = null, Broadcast = true}); + + TestBase.WaitLoop(() => stratisColdStake.FullNode.WalletManager().GetBalances(WalletName, Account).Sum(a => a.AmountUnconfirmed + a.AmountUnconfirmed) > 0); + } + } } } From 555470a581e05b9abad7c09b6ec9f62ae6207bfa Mon Sep 17 00:00:00 2001 From: Francois de la Rouviere Date: Wed, 1 Sep 2021 15:05:04 +0100 Subject: [PATCH 55/55] Bump all versions to 1.0.9.5 --- src/FederationSetup/FederationSetup.csproj | 2 +- src/FodyNlogAdapter/FodyNlogAdapter.csproj | 2 +- src/NBitcoin/NBitcoin.csproj | 2 +- src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj | 2 +- .../Stratis.Bitcoin.Features.Api.csproj | 2 +- .../Stratis.Bitcoin.Features.BlockStore.csproj | 2 +- .../Stratis.Bitcoin.Features.ColdStaking.csproj | 2 +- .../Stratis.Bitcoin.Features.Consensus.csproj | 2 +- .../Stratis.Bitcoin.Features.Dns.csproj | 2 +- .../Stratis.Bitcoin.Features.Interop.csproj | 2 +- .../Stratis.Bitcoin.Features.LightWallet.csproj | 2 +- .../Stratis.Bitcoin.Features.MemoryPool.csproj | 2 +- .../Stratis.Bitcoin.Features.Miner.csproj | 2 +- .../Stratis.Bitcoin.Features.Notifications.csproj | 2 +- ...Bitcoin.Features.PoA.IntegrationTests.Common.csproj | 2 +- .../Stratis.Bitcoin.Features.PoA.csproj | 2 +- .../Stratis.Bitcoin.Features.RPC.csproj | 2 +- .../Stratis.Bitcoin.Features.SignalR.csproj | 2 +- .../Stratis.Bitcoin.Features.SmartContracts.csproj | 2 +- .../Stratis.Bitcoin.Features.Wallet.csproj | 2 +- .../Stratis.Bitcoin.Features.WatchOnlyWallet.csproj | 2 +- .../Stratis.Bitcoin.IntegrationTests.Common.csproj | 10 +--------- .../Stratis.Bitcoin.Networks.csproj | 6 +++--- .../Stratis.Bitcoin.Tests.Common.csproj | 2 +- src/Stratis.CirrusD/Stratis.CirrusD.csproj | 2 +- src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj | 2 +- src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj | 2 +- src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj | 2 +- .../Stratis.Features.Collateral.csproj | 3 ++- .../Stratis.Features.Diagnostic.csproj | 2 +- .../Stratis.Features.FederatedPeg.csproj | 3 ++- .../Stratis.Features.SQLiteWalletRepository.csproj | 2 +- .../Stratis.Sidechains.Networks.csproj | 2 +- src/Stratis.StraxD/Stratis.StraxD.csproj | 2 +- src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj | 2 +- 35 files changed, 39 insertions(+), 45 deletions(-) diff --git a/src/FederationSetup/FederationSetup.csproj b/src/FederationSetup/FederationSetup.csproj index 8a99449676..ac631636b7 100644 --- a/src/FederationSetup/FederationSetup.csproj +++ b/src/FederationSetup/FederationSetup.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. diff --git a/src/FodyNlogAdapter/FodyNlogAdapter.csproj b/src/FodyNlogAdapter/FodyNlogAdapter.csproj index c170873a76..893f3579c8 100644 --- a/src/FodyNlogAdapter/FodyNlogAdapter.csproj +++ b/src/FodyNlogAdapter/FodyNlogAdapter.csproj @@ -3,7 +3,7 @@ netcoreapp3.1 FodyNlogAdapter - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. Stratis.Utils.FodyNlogAdapter diff --git a/src/NBitcoin/NBitcoin.csproj b/src/NBitcoin/NBitcoin.csproj index c4bf23121a..73d01a5145 100644 --- a/src/NBitcoin/NBitcoin.csproj +++ b/src/NBitcoin/NBitcoin.csproj @@ -7,7 +7,7 @@ - 4.0.0.82 + 4.0.0.83 diff --git a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj index 0a98506414..193a026a9d 100644 --- a/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj +++ b/src/Stratis.Bitcoin.Cli/Stratis.Bitcoin.Cli.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj index 4298c8014f..1a05eb107b 100644 --- a/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj +++ b/src/Stratis.Bitcoin.Features.Api/Stratis.Bitcoin.Features.Api.csproj @@ -6,7 +6,7 @@ Stratis.Bitcoin.Features.Api Library Stratis.Features.Api - 1.0.9.4 + 1.0.9.5 False library diff --git a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj index 24b4fbb6d0..08ed3d7062 100644 --- a/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj +++ b/src/Stratis.Bitcoin.Features.BlockStore/Stratis.Bitcoin.Features.BlockStore.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj index d3fda23724..524bd233f4 100644 --- a/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj +++ b/src/Stratis.Bitcoin.Features.ColdStaking/Stratis.Bitcoin.Features.ColdStaking.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj index add8119808..cf110b1b79 100644 --- a/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj +++ b/src/Stratis.Bitcoin.Features.Consensus/Stratis.Bitcoin.Features.Consensus.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj index e9375679cd..0d6e517354 100644 --- a/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj +++ b/src/Stratis.Bitcoin.Features.Dns/Stratis.Bitcoin.Features.Dns.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj index 4ef4ac7ca1..145320b92c 100644 --- a/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj +++ b/src/Stratis.Bitcoin.Features.Interop/Stratis.Bitcoin.Features.Interop.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis.Features.Interop Stratis.Features.Interop diff --git a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj index d2fd1a4780..d79bb6c14e 100644 --- a/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj +++ b/src/Stratis.Bitcoin.Features.LightWallet/Stratis.Bitcoin.Features.LightWallet.csproj @@ -7,7 +7,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj index 1a63662b19..84c7d02f71 100644 --- a/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj +++ b/src/Stratis.Bitcoin.Features.MemoryPool/Stratis.Bitcoin.Features.MemoryPool.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False library Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj index 9cf61ff269..6116d78a55 100644 --- a/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj +++ b/src/Stratis.Bitcoin.Features.Miner/Stratis.Bitcoin.Features.Miner.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj index 8798669ae1..47b2d43e62 100644 --- a/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj +++ b/src/Stratis.Bitcoin.Features.Notifications/Stratis.Bitcoin.Features.Notifications.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj index fe9320f91b..84e5264c91 100644 --- a/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common/Stratis.Bitcoin.Features.PoA.IntegrationTests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False diff --git a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj index c1f1506f2b..e4e3c39e9a 100644 --- a/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj +++ b/src/Stratis.Bitcoin.Features.PoA/Stratis.Bitcoin.Features.PoA.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj index cca62d77b4..21a9d12768 100644 --- a/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj +++ b/src/Stratis.Bitcoin.Features.RPC/Stratis.Bitcoin.Features.RPC.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj index 6ae3104a4a..2de071a5d7 100644 --- a/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj +++ b/src/Stratis.Bitcoin.Features.SignalR/Stratis.Bitcoin.Features.SignalR.csproj @@ -1,7 +1,7 @@  netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis.Features.SignalR Stratis.Features.SignalR Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj index 1f5434f3c1..ea20c88d99 100644 --- a/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj +++ b/src/Stratis.Bitcoin.Features.SmartContracts/Stratis.Bitcoin.Features.SmartContracts.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis.Features.SmartContracts Stratis.Features.SmartContracts diff --git a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj index b692f5ccb0..de12880e66 100644 --- a/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj +++ b/src/Stratis.Bitcoin.Features.Wallet/Stratis.Bitcoin.Features.Wallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj index 3aa77791f8..752c7abb98 100644 --- a/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj +++ b/src/Stratis.Bitcoin.Features.WatchOnlyWallet/Stratis.Bitcoin.Features.WatchOnlyWallet.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj index 6ab2b824c4..82e44cb530 100644 --- a/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj +++ b/src/Stratis.Bitcoin.IntegrationTests.Common/Stratis.Bitcoin.IntegrationTests.Common.csproj @@ -5,15 +5,7 @@ Stratis.Bitcoin.IntegrationTests.Common Stratis.Features.IntegrationTests.Common - false - false - false - false - false - false - false - false - 1.0.9.4 + 1.0.9.5 False diff --git a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj index d997a6b287..7a70ec7888 100644 --- a/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj +++ b/src/Stratis.Bitcoin.Networks/Stratis.Bitcoin.Networks.csproj @@ -14,9 +14,9 @@ false false false - 1.0.9.4 - 1.0.9.4 - 1.0.9.4 + 1.0.9.5 + 1.0.9.5 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj index b68c03a998..ce9317003f 100644 --- a/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj +++ b/src/Stratis.Bitcoin.Tests.Common/Stratis.Bitcoin.Tests.Common.csproj @@ -13,7 +13,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False diff --git a/src/Stratis.CirrusD/Stratis.CirrusD.csproj b/src/Stratis.CirrusD/Stratis.CirrusD.csproj index d2a861dd90..e75b1ce99c 100644 --- a/src/Stratis.CirrusD/Stratis.CirrusD.csproj +++ b/src/Stratis.CirrusD/Stratis.CirrusD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj index 3ac3f4b76c..bcaa4dc4c5 100644 --- a/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj +++ b/src/Stratis.CirrusDnsD/Stratis.CirrusDnsD.csproj @@ -17,7 +17,7 @@ latest Stratis Group Ltd. - 1.0.9.4 + 1.0.9.5 diff --git a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj index e3aba576fb..44a2f0f6d1 100644 --- a/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj +++ b/src/Stratis.CirrusMinerD/Stratis.CirrusMinerD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis Group Ltd. diff --git a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj index c2f65685d1..404521fc39 100644 --- a/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj +++ b/src/Stratis.CirrusPegD/Stratis.CirrusPegD.csproj @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. diff --git a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj index cccf336b86..8ff29cbc2b 100644 --- a/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj +++ b/src/Stratis.Features.Collateral/Stratis.Features.Collateral.csproj @@ -2,8 +2,9 @@ netcoreapp3.1 - 4.0.3.0 + 4.0.4.0 Stratis Group Ltd. + Stratis.Features.Collateral diff --git a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj index 17500a3c5e..aa2c4aa10f 100644 --- a/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj +++ b/src/Stratis.Features.Diagnostic/Stratis.Features.Diagnostic.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 ..\None.ruleset true - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. diff --git a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj index b90904fa2d..63c414c4b8 100644 --- a/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj +++ b/src/Stratis.Features.FederatedPeg/Stratis.Features.FederatedPeg.csproj @@ -12,7 +12,8 @@ Full ..\None.ruleset Stratis Group Ltd. - 4.0.3.0 + 4.0.4.0 + Stratis.Features.FederatedPeg diff --git a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj index b601030dcb..c1c6aeb48e 100644 --- a/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj +++ b/src/Stratis.Features.SQLiteWalletRepository/Stratis.Features.SQLiteWalletRepository.csproj @@ -14,7 +14,7 @@ false false false - 1.0.9.4 + 1.0.9.5 False Stratis Group Ltd. diff --git a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj index f9b17507f8..95a23ecc1b 100644 --- a/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj +++ b/src/Stratis.Sidechains.Networks/Stratis.Sidechains.Networks.csproj @@ -5,7 +5,7 @@ Full ..\None.ruleset - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. Stratis.Sidechains.Networks diff --git a/src/Stratis.StraxD/Stratis.StraxD.csproj b/src/Stratis.StraxD/Stratis.StraxD.csproj index 0dad1d8c76..e0d608152c 100644 --- a/src/Stratis.StraxD/Stratis.StraxD.csproj +++ b/src/Stratis.StraxD/Stratis.StraxD.csproj @@ -16,7 +16,7 @@ latest - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd. diff --git a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj index b7c838e980..f51be549cc 100644 --- a/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj +++ b/src/Stratis.StraxDnsD/Stratis.StraxDnsD.csproj @@ -16,7 +16,7 @@ latest - 1.0.9.4 + 1.0.9.5 Stratis Group Ltd.