Ejemplo n.º 1
0
        public void Load_StakingDisabled_DoesNotLoadWalletDetails()
        {
            bool callbackCalled             = false;
            Action <MinerSettings> callback = (MinerSettings settings) =>
            {
                callbackCalled = true;
            };

            var minersettings = new MinerSettings(callback);

            var nodeSettings = new NodeSettings(args: new string[] {
                "-mine=true",
                "-stake=false",
                "-walletname=mytestwallet",
                "-walletpassword=test",
                "-mineaddress=TFE7R2FSAgAeJxt1fgW2YVCh9Zc448f3ms"
            });

            minersettings.Load(nodeSettings);

            Assert.True(minersettings.Mine);
            Assert.False(minersettings.Stake);
            Assert.Null(minersettings.WalletName);
            Assert.Null(minersettings.WalletPassword);
            Assert.Equal("TFE7R2FSAgAeJxt1fgW2YVCh9Zc448f3ms", minersettings.MineAddress);
            Assert.True(callbackCalled);
        }
        public PosMintingTest()
        {
            this.consensusManager          = new Mock <IConsensusManager>();
            this.network                   = KnownNetworks.StratisTest;
            this.network.Consensus.Options = new ConsensusOptions();
            this.chain                     = new ConcurrentChain(this.network);
            this.dateTimeProvider          = new Mock <IDateTimeProvider>();
            this.initialBlockDownloadState = new Mock <IInitialBlockDownloadState>();
            this.nodeLifetime              = new Mock <INodeLifetime>();
            this.coinView                  = new Mock <ICoinView>();
            this.stakeChain                = new Mock <IStakeChain>();
            this.powBlocks                 = new List <uint256>();
            this.SetupStakeChain();
            this.stakeValidator        = new Mock <IStakeValidator>();
            this.mempoolSchedulerLock  = new MempoolSchedulerLock();
            this.minerSettings         = new MinerSettings(NodeSettings.Default(this.network));
            this.txMempool             = new Mock <ITxMempool>();
            this.walletManager         = new Mock <IWalletManager>();
            this.asyncLoopFactory      = new Mock <IAsyncLoopFactory>();
            this.timeSyncBehaviorState = new Mock <ITimeSyncBehaviorState>();

            this.cancellationTokenSource = new CancellationTokenSource();
            this.nodeLifetime.Setup(n => n.ApplicationStopping).Returns(this.cancellationTokenSource.Token);

            this.posMinting = this.InitializePosMinting();
        }
        public PowMiningTest(PowMiningTestFixture fixture)
        {
            this.fixture = fixture;
            this.network = fixture.Network;

            this.initialNetworkOptions = this.network.Consensus.Options;
            if (this.initialNetworkOptions == null)
            {
                this.network.Consensus.Options = new ConsensusOptions();
            }

            this.asyncProvider = new Mock <IAsyncProvider>();

            this.consensusManager = new Mock <IConsensusManager>();
            this.consensusManager.SetupGet(c => c.Tip).Returns(() => this.chainIndexer.Tip);
            this.consensusRules = new Mock <IConsensusRuleEngine>();

            this.mempool = new Mock <ITxMempool>();
            this.mempool.SetupGet(mp => mp.MapTx).Returns(new TxMempool.IndexedTransactionSet());

            this.minerSettings = new MinerSettings(NodeSettings.Default(this.network));

            this.chainIndexer = fixture.ChainIndexer;

            this.nodeLifetime = new Mock <INodeLifetime>();
            this.nodeLifetime.Setup(n => n.ApplicationStopping).Returns(new CancellationToken()).Verifiable();

            this.initialBlockDownloadState = new Mock <IInitialBlockDownloadState>();
            this.initialBlockDownloadState.Setup(s => s.IsInitialBlockDownload()).Returns(false);

            this.mempoolLock = new MempoolSchedulerLock();
        }
Ejemplo n.º 4
0
 public X1PowMining(
     IAsyncProvider asyncProvider,
     IBlockProvider blockProvider,
     IConsensusManager consensusManager,
     ChainIndexer chainIndexer,
     IDateTimeProvider dateTimeProvider,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     INodeLifetime nodeLifetime,
     ILoggerFactory loggerFactory,
     IInitialBlockDownloadState initialBlockDownloadState,
     MinerSettings minerSettings)
 {
     this.asyncProvider             = asyncProvider;
     this.blockProvider             = blockProvider;
     this.chainIndexer              = chainIndexer;
     this.consensusManager          = consensusManager;
     this.dateTimeProvider          = dateTimeProvider;
     this.loggerFactory             = loggerFactory;
     this.initialBlockDownloadState = initialBlockDownloadState;
     this.logger       = loggerFactory.CreateLogger(this.GetType().FullName);
     this.mempool      = mempool;
     this.mempoolLock  = mempoolLock;
     this.network      = network;
     this.nodeLifetime = nodeLifetime;
     this.miningCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(new[] { this.nodeLifetime.ApplicationStopping });
     this.minerSettings = (X1MinerSettings)minerSettings;
     if (this.minerSettings.UseOpenCL)
     {
         this.openCLMiner = new OpenCLMiner(this.minerSettings, loggerFactory);
     }
 }
Ejemplo n.º 5
0
        public SmartContractPosPowBlockDefinition(
            IBlockBufferGenerator blockBufferGenerator,
            ICoinView coinView,
            IConsensusLoop consensusLoop,
            IDateTimeProvider dateTimeProvider,
            ISmartContractExecutorFactory executorFactory,
            ILoggerFactory loggerFactory,
            ITxMempool mempool,
            MempoolSchedulerLock mempoolLock,
            MinerSettings minerSettings,
            Network network,
            ISenderRetriever senderRetriever,
            IStakeChain stakeChain,
            IStakeValidator stakeValidator,
            IContractStateRoot stateRoot)
            : base(consensusLoop, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
        {
            this.coinView        = coinView;
            this.executorFactory = executorFactory;
            this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);
            this.senderRetriever = senderRetriever;
            this.stakeChain      = stakeChain;
            this.stakeValidator  = stakeValidator;
            this.stateRoot       = stateRoot;

            // When building smart contract blocks, we will be generating and adding both transactions to the block and txouts to the coinbase.
            // At the moment, these generated objects aren't accounted for in the block size and weight accounting.
            // This means that if blocks started getting full, this miner could start generating blocks greater than the max consensus block size.
            // To avoid this without significantly overhauling the BlockDefinition, for now we just lower the block size by a percentage buffer.
            // If in the future blocks are being built over the size limit and you need an easy fix, just increase the size of this buffer.
            this.Options = blockBufferGenerator.GetOptionsWithBuffer(this.Options);
        }
        public SmartContractBlockDefinition(
            IBlockBufferGenerator blockBufferGenerator,
            ICoinView coinView,
            IConsensusManager consensusManager,
            IDateTimeProvider dateTimeProvider,
            IContractExecutorFactory executorFactory,
            ILoggerFactory loggerFactory,
            ITxMempool mempool,
            MempoolSchedulerLock mempoolLock,
            MinerSettings minerSettings,
            Network network,
            ISenderRetriever senderRetriever,
            IStateRepositoryRoot stateRoot,
            IBlockExecutionResultCache executionCache,
            ICallDataSerializer callDataSerializer,
            NodeDeployments nodeDeployments)
            : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, nodeDeployments)
        {
            this.coinView           = coinView;
            this.executorFactory    = executorFactory;
            this.logger             = loggerFactory.CreateLogger(this.GetType());
            this.senderRetriever    = senderRetriever;
            this.stateRoot          = stateRoot;
            this.callDataSerializer = callDataSerializer;
            this.executionCache     = executionCache;
            this.refundOutputs      = new List <TxOut>();
            this.receipts           = new List <Receipt>();

            // When building smart contract blocks, we will be generating and adding both transactions to the block and txouts to the coinbase.
            // At the moment, these generated objects aren't accounted for in the block size and weight accounting.
            // This means that if blocks started getting full, this miner could start generating blocks greater than the max consensus block size.
            // To avoid this without significantly overhauling the BlockDefinition, for now we just lower the block size by a percentage buffer.
            // If in the future blocks are being built over the size limit and you need an easy fix, just increase the size of this buffer.
            this.Options = blockBufferGenerator.GetOptionsWithBuffer(this.Options);
        }
Ejemplo n.º 7
0
        public void Load_GivenNodeSettings_LoadsSettingsFromNodeSettings()
        {
            bool callbackCalled             = false;
            Action <MinerSettings> callback = (MinerSettings settings) =>
            {
                callbackCalled = true;
            };

            var minersettings = new MinerSettings(callback);

            var nodeSettings = NodeSettings.Default();

            nodeSettings.LoadArguments(new string[] {
                "-mine=true",
                "-stake=true",
                "-walletname=mytestwallet",
                "-walletpassword=test",
                "-mineaddress=TFE7R2FSAgAeJxt1fgW2YVCh9Zc448f3ms"
            });

            minersettings.Load(nodeSettings);

            Assert.True(minersettings.Mine);
            Assert.True(minersettings.Stake);
            Assert.Equal("mytestwallet", minersettings.WalletName);
            Assert.Equal("test", minersettings.WalletPassword);
            Assert.Equal("TFE7R2FSAgAeJxt1fgW2YVCh9Zc448f3ms", minersettings.MineAddress);
            Assert.True(callbackCalled);
        }
Ejemplo n.º 8
0
        private static bool LoadSettings(string path)
        {
            try
            {
                gameSettings = GameSettings.Load(path);
            }
            catch (Exception ex)
            {
                LogSystem.Error("Error load settings " + path, ex);

                if (MessageBox.Show(@"Создать настройки по умолчанию?
Yes -создадуться настройки поумолчанию. После создания  проверьте пожалуйста настройки.
No - подправить настройки в ручную и запустить заново бота (Для продвинутых пользователей).",
                                    "Незагрузился файл настроек" + path, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    gameSettings = GameSettings.Create(path);
                    GameSettings.Save();
                }
                else
                {
                    return(false);
                }
            }

            botvaSettings      = gameSettings.BotvaSettings;
            accountantSettings = botvaSettings.AccountantSettings;
            minerSettings      = botvaSettings.MinerSettings;
            attackSettings     = botvaSettings.AttackSettings;
            acountSettings     = botvaSettings.AcountSettings;
            return(true);
        }
        /// <summary>
        /// Constructor for an graph node object
        /// </summary>
        /// <param name="name">associated event</param>
        ///  <author>Bernd Nottbeck</author>
        public InductiveMinerGraphNode(Event name)
        {
            threshHold = MinerSettings.GetAsDouble("InductiveThresholdSlider");

            Name                 = name;
            FollowerList         = new List <InductiveMinerRow>();
            EventualFollowerList = new List <InductiveMinerRow>();
        }
Ejemplo n.º 10
0
        public void Buffer_50Kb_For_1MB_BlockSize()
        {
            BlockDefinitionOptions optionsFromNetwork = new MinerSettings(new NodeSettings(new SmartContractsTest())).BlockDefinitionOptions;
            BlockDefinitionOptions newOptions         = this.bufferGenerator.GetOptionsWithBuffer(optionsFromNetwork);

            Assert.Equal((uint)950_000, newOptions.BlockMaxWeight);
            Assert.Equal((uint)950_000, newOptions.BlockMaxSize);
        }
Ejemplo n.º 11
0
        public static MinerInfo GetStatsFromEthermine(MinerInfo minerInfo)
        {
            try
            {
                var timeSpan = DateTime.Now - StatsDate;
                if (timeSpan.Minutes > STATS_TIME)
                {
                    // Đặt lại thời gian
                    StatsDate = DateTime.Now;

                    // History
                    string url          = $"/miner/{minerInfo.Wallet}/history";
                    var    data         = GetApiData("https://api.ethermine.org" + url);
                    var    historyStats = JsonConvert.DeserializeObject <HistoryReturnData>(data);
                    minerInfo.History = historyStats.data.ToArray();

                    // currentStats
                    url  = $"/miner/{minerInfo.Wallet}/currentStats";
                    data = GetApiData("https://api.ethermine.org" + url);
                    var minerStats = JsonConvert.DeserializeObject <StatsReturnData>(data);
                    minerInfo.Stats = minerStats.data;

                    // Rounds
                    url  = $"/miner/{minerInfo.Wallet}/rounds";
                    data = GetApiData("https://api.ethermine.org" + url);
                    var rounds = JsonConvert.DeserializeObject <RoundReturnData>(data);
                    minerInfo.Rounds = rounds.data.ToArray();

                    // Payouts
                    url  = $"/miner/{minerInfo.Wallet}/payouts";
                    data = GetApiData("https://api.ethermine.org" + url);
                    var payouts = JsonConvert.DeserializeObject <PayoutReturnData>(data);
                    minerInfo.Payouts = payouts.data.ToArray();

                    // Settings
                    url  = $"/miner/{minerInfo.Wallet}/settings";
                    data = GetApiData("https://api.ethermine.org" + url);
                    MinerSettings settings;
                    if (!data.Contains("NO DATA"))
                    {
                        settings = JsonConvert.DeserializeObject <SettingsReturnData>(data).data;
                    }
                    else
                    {
                        settings = new MinerSettings
                        {
                            minPayout = 1,
                        };
                    }
                    minerInfo.Settings = settings;
                }
            }
            catch
            {
            }

            return(minerInfo);
        }
Ejemplo n.º 12
0
        public void Load_MinimumStakingCoinValue_Should_Be_Strictly_Above_Zero()
        {
            var nodeSettings = new NodeSettings(args: new string[] {
                "-minimumstakingcoinvalue=0",
            });

            var minerSettings = new MinerSettings(nodeSettings);

            minerSettings.MinimumStakingCoinValue.Should().Be(1);
        }
Ejemplo n.º 13
0
    public Task UpdateSettingsAsync(IDbConnection con, IDbTransaction tx, MinerSettings settings)
    {
        const string query = @"INSERT INTO miner_settings(poolid, address, paymentthreshold, created, updated)
            VALUES(@poolid, @address, @paymentthreshold, now(), now())
            ON CONFLICT ON CONSTRAINT miner_settings_pkey DO UPDATE
            SET paymentthreshold = @paymentthreshold, updated = now()
            WHERE miner_settings.poolid = @poolid AND miner_settings.address = @address";

        return(con.ExecuteAsync(query, settings, tx));
    }
Ejemplo n.º 14
0
        public void MinerSettingsGetValueAsInt()
        {
            MinerSettings.AddOrUpdateKey("Test", 42);

            var actual = MinerSettings.GetAsInt("Test");

            Assert.AreEqual(42, actual);

            actual = MinerSettings.GetAsInt("Does not exist");
            Assert.AreEqual(-1, actual);
        }
Ejemplo n.º 15
0
 public PoABlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     Network network,
     MinerSettings minerSettings)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network)
 {
 }
 public PosBlockAssemblerTest() : base(new StraxTest())
 {
     this.consensusManager = new Mock <IConsensusManager>();
     this.mempool          = new Mock <ITxMempool>();
     this.dateTimeProvider = new Mock <IDateTimeProvider>();
     this.stakeValidator   = new Mock <IStakeValidator>();
     this.stakeChain       = new Mock <IStakeChain>();
     this.key           = new Key();
     this.minerSettings = new MinerSettings(NodeSettings.Default(this.Network));
     SetupConsensusManager();
 }
Ejemplo n.º 17
0
 protected x42BlockDefinition(
     IConsensusManager consensusManager,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     NodeDeployments nodeDeployments) : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, nodeDeployments)
 {
     this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Ejemplo n.º 18
0
 void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     if (InductiveminerRadioButton.IsChecked == true)
     {
         MinerSettings.AddOrUpdateKey("InductiveMiner", "InductiveMiner");
     }
     else if (InductiveminerInfrequentRadioButton.IsChecked == true)
     {
         MinerSettings.AddOrUpdateKey("InductiveMiner", "InductiveMinerInfrequent");
         MinerSettings.AddOrUpdateKey("InductiveThresholdSlider", InductiveThresholdSlider.Value);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the object.
        /// </summary>
        public StakingController(IFullNode fullNode, ILoggerFactory loggerFactory, IWalletManager walletManager, MinerSettings minerSettings, IPosMinting posMinting = null)
        {
            Guard.NotNull(fullNode, nameof(fullNode));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(walletManager, nameof(walletManager));

            this.fullNode      = fullNode;
            this.logger        = loggerFactory.CreateLogger(this.GetType().FullName);
            this.walletManager = walletManager;
            this.minerSettings = minerSettings;
            this.posMinting    = posMinting;
        }
Ejemplo n.º 20
0
        public void Defaults_EnableCoinStakeSplitting_MinimumStakingCoinValue_And_MinimumSplitCoinValue()
        {
            var nodeSettings = new NodeSettings(args: new string[] {
                "-stake=1",
            });

            var minerSettings = new MinerSettings(nodeSettings);

            minerSettings.EnableCoinStakeSplitting.Should().BeTrue();
            minerSettings.MinimumStakingCoinValue.Should().Be(10000000);
            minerSettings.MinimumSplitCoinValue.Should().Be(10000000000);
        }
Ejemplo n.º 21
0
        public void MinerSettingsGetValueAsObject()
        {
            var myObject = new Object();

            MinerSettings.AddOrUpdateKey("Test", myObject);

            var actual = MinerSettings.Get("Test");

            Assert.AreEqual(myObject, actual);

            actual = MinerSettings.Get("Does not exist");
            Assert.IsNull(actual);
        }
 public PosBlockAssemblerTest()
 {
     this.consensusManager = new Mock <IConsensusManager>();
     this.mempool          = new Mock <ITxMempool>();
     this.dateTimeProvider = new Mock <IDateTimeProvider>();
     this.stakeValidator   = new Mock <IStakeValidator>();
     this.stakeChain       = new Mock <IStakeChain>();
     this.stratisTest      = KnownNetworks.StratisTest;
     new FullNodeBuilderConsensusExtension.PosConsensusRulesRegistration().RegisterRules(this.stratisTest.Consensus);
     this.key           = new Key();
     this.minerSettings = new MinerSettings(NodeSettings.Default(this.Network));
     SetupConsensusManager();
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Shows the specified settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        public void Show(MinerSettings settings)
        {
            boxUseMine.Checked        = settings.VisitMine;
            boxUseGlasses.Checked     = settings.UseGlasses;
            boxUseHelmet.Checked      = settings.UseHelmet;
            boxSearchUntilTry.Checked = settings.SearchUntilTry;

            smallTicketAction.Show(settings.GetTicketAction(Ticket.Small));
            bigTicketAction.Show(settings.GetTicketAction(Ticket.Big));

            data = settings.SearchCrystalLimits.ToList();
            gridLimits.DataSource = new BindingList <Range <int> >(data);
        }
Ejemplo n.º 24
0
 public PowTestBlockDefinition(
     IConsensusManager consensusLoop,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     ITxMempool mempool,
     MempoolSchedulerLock mempoolLock,
     MinerSettings minerSettings,
     Network network,
     IConsensusRuleEngine consensusRules,
     BlockDefinitionOptions options = null)
     : base(consensusLoop, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, consensusRules)
 {
     this.block = this.BlockTemplate.Block;
 }
Ejemplo n.º 25
0
        public void Load_EnableCoinStakeSplitting_MinimumStakingCoinValue_And_MinimumSplitCoinValue()
        {
            var nodeSettings = new NodeSettings(args: new string[] {
                "-enablecoinstakesplitting=false",
                "-minimumstakingcoinvalue=50000",
                "-minimumsplitcoinvalue=50000000"
            });

            var minerSettings = new MinerSettings(nodeSettings);

            minerSettings.EnableCoinStakeSplitting.Should().BeFalse();
            minerSettings.MinimumStakingCoinValue.Should().Be(50000);
            minerSettings.MinimumSplitCoinValue.Should().Be(50000000);
        }
Ejemplo n.º 26
0
        public PowBlockAssemblerTest()
        {
            this.consensusManager = new Mock <IConsensusManager>();
            this.consensusRules   = new Mock <IConsensusRuleEngine>();
            this.txMempool        = new Mock <ITxMempool>();
            this.dateTimeProvider = new Mock <IDateTimeProvider>();
            this.powReward        = Money.Coins(50);
            this.testNet          = KnownNetworks.TestNet;
            new FullNodeBuilderConsensusExtension.PowConsensusRulesRegistration().RegisterRules(this.testNet.Consensus);
            this.minerSettings = new MinerSettings(NodeSettings.Default(this.Network));
            this.key           = new Key();

            this.SetupConsensusManager();
        }
 public PosTestBlockAssembler(
     IConsensusManager consensusManager,
     Network network,
     MempoolSchedulerLock mempoolLock,
     ITxMempool mempool,
     MinerSettings minerSettings,
     IDateTimeProvider dateTimeProvider,
     IStakeChain stakeChain,
     IStakeValidator stakeValidator,
     ILoggerFactory loggerFactory)
     : base(consensusManager, dateTimeProvider, loggerFactory, mempool, mempoolLock, minerSettings, network, stakeChain, stakeValidator)
 {
     base.block = this.BlockTemplate.Block;
 }
        public void MineTest2()
        {
            MinerSettings.AddOrUpdateKey("AdjacencyThresholdSlider", 51);
            MinerSettings.AddOrUpdateKey("MaximumRecursionDepthSlider", 10);
            var field = new Field {
                EventLog = EventLogExample.ComplexEventLogVanDerAalst()
            };
            var      miner  = new HeuristicMiner(field);
            PetriNet actual = (PetriNet)miner.Mine();

            Assert.AreEqual(33, actual.Transitions.Count);
            Assert.AreEqual("D", actual.Transitions[2].Name);
            Assert.AreEqual(44, actual.Places.Count);
            //   Assert.AreEqual("End", actual.Places[].Name);
        }
 public void MineTestFail2()
 {
     try
     {
         MinerSettings.AddOrUpdateKey("AdjacencyThresholdSlider", 51);
         var field = new Field();
         var miner = new HeuristicMiner(field);
         miner.Mine();
         Assert.Fail();
     }
     catch (Exception exception)
     {
         Assert.IsInstanceOfType(exception, typeof(Exception));
     }
 }
 /// <summary>
 /// Sets the AlphamMiner Type
 /// </summary>
 /// <param name="e"></param>
 void IContent.OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     if (AlphaMinerRadioButton.IsChecked == true)
     {
         MinerSettings.AddOrUpdateKey("Alphaminer", AlphaMinerRadioButton.Name);
     }
     else if (AlphaMinerPlusRadioButton.IsChecked == true)
     {
         MinerSettings.AddOrUpdateKey("AlphaMiner", AlphaMinerPlusRadioButton.Name);
     }
     else if (AlphaMinerPlusPlusRadioButton.IsChecked == true)
     {
         MinerSettings.AddOrUpdateKey("AlphaMiner", AlphaMinerPlusPlusRadioButton.Name);
     }
 }