From c51c89285473d2190d178a6a801b8a543b4f1eac Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:15:16 +0300 Subject: [PATCH 1/7] Default consensus DLCPoA Remove all coins functionality --- Blockchain.js | 37 ------------------------------------- main.js | 10 +++------- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/Blockchain.js b/Blockchain.js index 50b26b6..fce3abb 100644 --- a/Blockchain.js +++ b/Blockchain.js @@ -1697,7 +1697,6 @@ function Blockchain(config) { config.validators[0].generateNextBlock(blockData, function (generatedBlock) { addBlock(generatedBlock); broadcastLastBlock(); - setTimeout(coinEmission, 2000); cb(generatedBlock); }); }, function () { @@ -1708,41 +1707,6 @@ function Blockchain(config) { } } - /** - * Первичный выпуск монет - * Заложенно config.initialEmission * precision - * где precision это максимальная точность при операциях с не дробными монетами - */ - function coinEmission() { - if(config.disableInternalToken) { - return; - } - if(!blockHandler.isKeyFromKeyring(wallet.keysPair.public)) { - logger.error("The selected key does not belong to the keychain! Emission corrupted."); - return; - } - - logger.info('Starting coin emission ' + (config.initialEmission)); - - wallet.transanctions = []; - wallet.transact(wallet.id, config.initialEmission * config.precision, null, true); - let blockData = wallet.transanctions.pop(); - - transactor.transact(blockData, function (blockData, cb) { - config.validators[0].generateNextBlock(blockData, function (generatedBlock) { - addBlock(generatedBlock); - broadcastLastBlock(); - setTimeout(function () { - config.validators[0].generateEmptyBlock(true); - }, 1000); - cb(generatedBlock); - - }); - }, function () { - console.log('Emission: Emission accepted'); - blockHandler.resync(); - }); - } /** @@ -1923,7 +1887,6 @@ function Blockchain(config) { broadcastMessage: broadcastMessage, createWalletIfNotExsists: createWalletIfNotExsists, keyringEmission: keyringEmission, - coinEmission: coinEmission, genesisTiemstamp: genesisTiemstamp, wallet: wallet, app: app, diff --git a/main.js b/main.js index 2997c27..714c107 100644 --- a/main.js +++ b/main.js @@ -88,19 +88,15 @@ const config = { newNetwork: false, //Если будет обнаружен запуск новой сети блокчейн, будет произведена автоматическая эмиссия ключей и денег lcpoaVariantTime: 1, //Количество милилсекунд, требуемое на генерацию одного хеша блока validators: [ //"Валидаторы" - дополнительные проверяющие блоков, для введения дополнительных консенсусов, кроме LCPoA - 'lcpoa', //БЕЗ КОНСЕНСУСА БЕЗ КЛЮЧЕЙ АВТОМАТИЧЕСКАЯ ЭМИССИЯ НЕВОЗМОЖНА - 'thrusted' + 'dlcpoa', + //'lcpoa', //БЕЗ КОНСЕНСУСА БЕЗ КЛЮЧЕЙ АВТОМАТИЧЕСКАЯ ЭМИССИЯ НЕВОЗМОЖНА + //'thrusted' ], emptyBlockInterval: 10000, //Интервал проверки необходимости выпуска пустого блока blacklisting: false, maxTransactionAtempts: 5, //Сколько попыток добавить блок мы предпренимаем keyringKeysCount: 5, //Сколько генерировать ключей в связку при старте сети. Используется в Trusted консенсусе и других checkExternalConnectionData: false, //Проверять внешние данные на соответствие - disableInternalToken: false, //выключить выпуск старых денег(false - разрешено выпускать старые деньги, true - запрет на выпуск) - - //Tokens - precision: 10000000000, //Точность вычислений для кошелька - initialEmission: 100000000, //Сумма первоначальной эмиссии (нужна только при эмиссии) //Messaging Bus enableMessaging: false, //Разрешить использование шины сообщений (необходима для некоторых консенсусов) From 5a270e6930a5744511f5cb25e36b5dd64ad39a85 Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:21:03 +0300 Subject: [PATCH 2/7] Clean up --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 714c107..e57f76d 100644 --- a/main.js +++ b/main.js @@ -35,7 +35,7 @@ program .option('--work-dir [path]', 'Working directory', false) .option('--keyring-emission', 'Generate and deploy keyring', false) .option('--generate-wallets [keyring path]', 'Generate wallets from keyring file', false) - .option('--new-chain', 'Generates keyring and token emission if possible', false) + .option('--new-chain', 'Starts new chain', false) .option('--fall-on-errors', 'Allow stop node on uncaught exceptions', false) .option('--block-accept-count [count]', 'Number of blocks to confirm transaction') .option('--http-port [port]', 'Interface and RPC binding port') From 5796798a1a3bdba31ad528032f7d25f6728569d8 Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:23:07 +0300 Subject: [PATCH 3/7] Clean up --- main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index e57f76d..d72d9c9 100644 --- a/main.js +++ b/main.js @@ -36,12 +36,12 @@ program .option('--keyring-emission', 'Generate and deploy keyring', false) .option('--generate-wallets [keyring path]', 'Generate wallets from keyring file', false) .option('--new-chain', 'Starts new chain', false) - .option('--fall-on-errors', 'Allow stop node on uncaught exceptions', false) + .option('--fall-on-errors', 'Stops node with error code on uncaught exceptions', false) .option('--block-accept-count [count]', 'Number of blocks to confirm transaction') .option('--http-port [port]', 'Interface and RPC binding port') .option('--disable-rpc-password', 'Disable RPC password', false) .option('--disable-mining', 'Completely disables mining', false) - .option('--fast-load', 'Don\'t checking databased on startup', false) + .option('--fast-load', 'Don\'t checking saved blocks database on startup', false) .option('--verbose', 'More logging info', false) .option('--enable-address-rotation', 'Activates the rotation of the addresses', false) .option('--no-splash', 'Disable splash screen', false) From b05a3011b168d46dba7871f02b63a349b81a1955 Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:28:12 +0300 Subject: [PATCH 4/7] remove deprecated wallet balance message --- modules/wallet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wallet.js b/modules/wallet.js index 2167b41..dff3229 100644 --- a/modules/wallet.js +++ b/modules/wallet.js @@ -270,7 +270,7 @@ let Wallet = function (walletFile, config) { wallet.update = function () { - wallet.log('Info: Wallet balance: ' + formatToken(wallet.balance, config.precision)); + //wallet.log('Info: Wallet balance: ' + formatToken(wallet.balance, config.precision)); wallet.save(); }; From 4b5490e82868159b7d54e84b256922fec462ff7d Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:37:39 +0300 Subject: [PATCH 5/7] Change sign function --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index d72d9c9..4bd6822 100644 --- a/main.js +++ b/main.js @@ -133,7 +133,7 @@ const config = { //Cryptography hashFunction: 'SHA256', //функция вычисления хэша - signFunction: '', //Функция вычисления цифровой подписи и генерации паролей(пустая-значит, по умолчанию используется), 'GOST' 'GOST256' 'NEWRSA' + signFunction: 'NEWRSA', //Функция вычисления цифровой подписи и генерации паролей(пустая-значит, по умолчанию используется), 'GOST' 'GOST256' 'NEWRSA' keyLength: 2048, //Key length for some algorithms generatorFunction: 'NEWRSA', //Key generator function From ca91e89ef9e1a45cd9649def52c6eeb39e53980c Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 14:44:49 +0300 Subject: [PATCH 6/7] Config write func --- main.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index 4bd6822..d31e998 100644 --- a/main.js +++ b/main.js @@ -32,6 +32,7 @@ program .option('--clear', 'Clear all saved chain and deletes wallet. WARNING: You can lose important data') .option('--clear-db', 'Clear all saved chain and calculated wallets.') .option('-c, --config [path]', 'Core config path', 'config.json') + .option('--write-config [path]', 'Save config in [path] file', false) .option('--work-dir [path]', 'Working directory', false) .option('--keyring-emission', 'Generate and deploy keyring', false) .option('--generate-wallets [keyring path]', 'Generate wallets from keyring file', false) @@ -170,14 +171,17 @@ try { } } - - /* try { - fs.writeFileSync('config.json', JSON.stringify(config)); - } catch (e) { - console.log('Info: Can\'t save config'); - }*/ } catch (e) { - logger.info('No configure found. Using standard configuration.'); + logger.warning('No configure found. Using standard configuration.'); +} + + +if(program.writeConfig) { + try { + fs.writeFileSync(program.writeConfig, JSON.stringify(config)); + } catch (e) { + logger.warning('Can\'t save config'); + } } config.program = program; From 326812906d2a6c4295b223931c27eef90ddccc03 Mon Sep 17 00:00:00 2001 From: Andrey Nedobylsky Date: Wed, 19 Feb 2020 15:03:50 +0300 Subject: [PATCH 7/7] Change tests validators --- .tabnineignore | 6 ++++++ BigNet/test/config.json | 8 +++++++- Tests/CustomDB/test/config.json | 4 ++++ Tests/HardSyncTest/test/config.json | 4 ++++ Tests/HardSyncTest/test/config2.json | 4 ++++ Tests/Network/test/config.json | 4 ++++ Tests/Network/test/config2.json | 4 ++++ Tests/PluginsTest/test/config.json | 4 ++++ Tests/WaterfallSpeedTest/test/config.json | 4 ++++ 9 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .tabnineignore diff --git a/.tabnineignore b/.tabnineignore new file mode 100644 index 0000000..60643db --- /dev/null +++ b/.tabnineignore @@ -0,0 +1,6 @@ +runtime +blocks +EcmaContracts +contractsRuntime +BigNet/test +Tests/* \ No newline at end of file diff --git a/BigNet/test/config.json b/BigNet/test/config.json index 4a6a932..8290c46 100644 --- a/BigNet/test/config.json +++ b/BigNet/test/config.json @@ -5,6 +5,10 @@ "initialPeers": [ ], "recieverAddress": "nodeOne", + "validators": [ + "lcpoa", + "thrusted" + ], "blockHashFilter": { "blockEndls": [ "f3c3", @@ -32,5 +36,7 @@ "masterContract": 5 }, "signFunction": "NEWRSA", - "plugins": [ "iz3-basic-crypto" ] + "plugins": [ + "iz3-basic-crypto" + ] } \ No newline at end of file diff --git a/Tests/CustomDB/test/config.json b/Tests/CustomDB/test/config.json index 88f0618..c2b1c2a 100644 --- a/Tests/CustomDB/test/config.json +++ b/Tests/CustomDB/test/config.json @@ -4,6 +4,10 @@ "httpPort": 3015, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeOne", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/HardSyncTest/test/config.json b/Tests/HardSyncTest/test/config.json index 36c8766..971eb9f 100644 --- a/Tests/HardSyncTest/test/config.json +++ b/Tests/HardSyncTest/test/config.json @@ -4,6 +4,10 @@ "httpPort": 3015, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeOne", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/HardSyncTest/test/config2.json b/Tests/HardSyncTest/test/config2.json index 7820135..2a75af9 100644 --- a/Tests/HardSyncTest/test/config2.json +++ b/Tests/HardSyncTest/test/config2.json @@ -4,6 +4,10 @@ "httpPort": 3016, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeTwo", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/Network/test/config.json b/Tests/Network/test/config.json index ccb2c09..925f1da 100644 --- a/Tests/Network/test/config.json +++ b/Tests/Network/test/config.json @@ -4,6 +4,10 @@ "httpPort": 3015, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeOne", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/Network/test/config2.json b/Tests/Network/test/config2.json index 125e8b7..ed04203 100644 --- a/Tests/Network/test/config2.json +++ b/Tests/Network/test/config2.json @@ -4,6 +4,10 @@ "httpPort": 3016, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeTwo", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/PluginsTest/test/config.json b/Tests/PluginsTest/test/config.json index fa797d8..abfc309 100644 --- a/Tests/PluginsTest/test/config.json +++ b/Tests/PluginsTest/test/config.json @@ -4,6 +4,10 @@ "httpPort": 3015, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeOne", "blockHashFilter": { "blockEndls": [ diff --git a/Tests/WaterfallSpeedTest/test/config.json b/Tests/WaterfallSpeedTest/test/config.json index 49e2e24..114bc24 100644 --- a/Tests/WaterfallSpeedTest/test/config.json +++ b/Tests/WaterfallSpeedTest/test/config.json @@ -4,6 +4,10 @@ "httpPort": 3017, "initialPeers": [ ], + "validators": [ + "lcpoa", + "thrusted" + ], "recieverAddress": "nodeOne", "blockHashFilter": { "blockEndls": [