Git Product home page Git Product logo

node-webdollar's Introduction

Node-WebDollar Build Status

Webstorm ES6

Settings => Languages & Frameworks => JavaScript language version and choose ECMAScript 6

JS Version

Docker (No skills, only docker)

1. Install Docker

https://docs.docker.com/install/

2. Run prebuilt Container (automated build https://hub.docker.com/r/webdollar/node/)

AutoSSL

docker run -d --restart=always -v /webdollar/ssl:/etc/letsencrypt/live -v /webdollar/data:/blockchainDB3 -e DOMAIN=<ENTER DOMAIN HERE> -e EMAIL=<ENTER EMAIL HERE> --name webdollar -p 80:80 -p 443:443 webdollar/node

NoSSL

docker run -d --restart=always -v /webdollar/data:/blockchainDB3 -e NOSSL=true -e SERVER_PORT=80 --name webdollar -p 80:80 webdollar/node

Installing (Non-techie skills required)

Installing (High tech skills required)

0. Node.js

Required: v16.x

nvm is the recommended tooling to get the right version. Simply run nvm use from the root of this project.

Windows: You can download Node.js from this URL: https://nodejs.org/en/download/

Linux: It's reccomended you install Node.js using NVM

1. Cloning Repository

git clone https://github.com/WebDollar/Node-WebDollar.git Node-WebDollar

2. Installing modules

cd Node-WebDollar to enter in the directory of the repository

npm install

If you get errors in step 2:

3. node-gyp

In case you get errors from node-gyp, especially for Argon2 or webrtc

3.1 node-gyp on Windows

open a Command Prompt with Administrator rights

cd C:\Path\To\Node-WebDollar\
npm install --global --production windows-build-tools
npm install

3.2 Error for updating to 1.3.21

Tutorial based on ranisalt/node-argon2#29

Install node v16 via nvm nvm install 16 nvm use 16 nvm use default 16

4. SSL (Secure Socket Layer) Certificate

WebDollar uses SSL (Secured Socket Layer) and in order to generate your SSL Certificate you need a Domain or to generate your own SSL Certificate for your IP

4.1. No-IP solution for Free Domain

This is required to get a SSL certificate. If you already have a domain, skip this step.

Follow the tutorial: Install No-Ip using ddns.net

4.2. Generate your SSL certificate

Port 80 must not be in use prior to running LetsEncrypt SSL generator!

Inside Node-WebDollar folder, run:

sudo bash start-node-letsencrypt.sh

Firewall acceptable

Unix

sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT

If you are under a router/firewall, you need to port forward the port used by the Nodes: 80,443 or whatever port they use.

5. Console commands

5.1 Run terminal interactive menu

npm run commands

5.2 Run terminal non-interactive menu

After building the terminal project

npm run build_terminal_menu
npm run build_terminal_worker

it is possible to run the terminal project as a non-interactive script:

node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js -- --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here

the first part of the command (node --max_old_space_size=10240 dist_bundle/terminal-menu-bundle.js) launches the terminal project.

The next portion of the command (--) starts it in non-interactive mode. Without --, the terminal menu defaults to interactive.

The next parts are the commands to run in order.

Alternatively, you can use the ./webd command in the root of this project. The cli must be built first. ./webd assumes non-interactive, so -- can be omitted from the command. To run interactively npm run commands works best.

./webd --import-address wallet.json --list-addresses --mining-address 0 --mine-in-pool https://webdollar.io/pool/url/here --set-password 'my 12 word password'

To display the list of commands, run:

./webd (-h|--help)

5.3 Running Full Node

Install pm2.

npm install pm2 -g --unsafe-perm
Linux

Run pm2:

chmod +x start.sh
./start.sh

or bash node-start.sh

To kill pm2 process, use pm2 stop id- get id by running pm2 list

Windows

start.sh ???

5.2 Run Mocha Tests (optional)

npm run test

5.3 Missing Packages or Errors

Obs. In case there you get an error message about some missing packages like the following one:

Error: Cannot find module 'name_missing_package'

just, run npm install name_missing_package

5.4 Building Dist for Browser (webpack)

npm run build_browser

5.5 Building Dist for Browser TEST (dist_bundle/browser/browser.html)

npm run test_browser

5.6 Building Dist for User-Interface

npm run build_browser_user_interface

open web page dist_bundle/browser/browser.html

5.7 Running Server in Node.js

npm run commands
npm run start

5.8 PM2 to run the Node run indefinitely

Follow the tutorial: PM2 to run the Node Indefinitely

Development Environment

Dockerized

It is possible to run the development environment in a docker container. This is useful if you are unable to configure and install the custom argon2 flavor required by this project. The docker container has this project set up to be built in it, and comes pre-installed with the tools you need for this project.

Building

Run docker-compose build to build the workspace container.

To force a rebuild, you can either remove the previous workspace (docker rm webdollar-dev-env) or you can run docker-compose build --no-cache.

Running

Once you've build the workspace container, simply run it to launch an interactive shell with all the tools you need to develop.

docker-compose run webdollar-dev-env

This entire folder is mounted into the container, so any files you change in the workspace will be available to the container immediately.

To do:

  1. Pool Mining
  2. Multi-sig with Schnorr Signatures

Resources to learn

7 Ethereum https://medium.com/@preethikasireddy/how-does-ethereum-work-anyway-22d1df506369

Mining Bitcoin

  1. http://blog.jameslarisch.com/mining-bitcoin-blocks-yourself-for-fun-and-no-profit
  2. http://www.righto.com/2014/02/bitcoin-mining-hard-way-algorithms.html
  3. https://steemit.com/blockchain/@verifyas/what-you-should-know-about-nonces-and-difficulty

Join WebDollar community

node-webdollar's People

Contributors

ader1990 avatar adrianmai avatar alex4688 avatar amit794 avatar bwvolleyball avatar cbusuioceanu avatar cryptocoingb avatar du08yb avatar ez-george avatar gymrewards avatar ibudisteanu avatar igneom avatar intpg avatar ionutalexandrupanait avatar laurentenhoor avatar lazyprogrammerio avatar mariusg91 avatar martincanto avatar morion4000 avatar opreacosmind avatar s1lviu avatar spirilis avatar syvb avatar tomonetml avatar valentinvladimir avatar volvox93 avatar webdmine avatar whistlewhileyouwork avatar xkidro avatar xterr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-webdollar's Issues

Cannot read property 'length' of undefined

0|WebD     |  ✘   ERROR serializing block:  TypeError: Cannot read property 'length' of undefined
0|WebD     |     at MiniBlockchainTransactionFrom.serializeFrom (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:15429:132)
0|WebD     |     at MiniBlockchainTransaction._serializeTransaction (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:10001:23)
0|WebD     |     at MiniBlockchainTransaction.serializeTransaction (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:9982:21)
0|WebD     |     at InterfaceBlockchainBlockDataTransactions.serializeTransactions (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:23542:48)
0|WebD     |     at MiniBlockchainBlockData._computeBlockDataHeaderPrefix (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:10574:31)
0|WebD     |     at MiniBlockchainBlockData._computeBlockDataHeaderPrefix (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:27340:74)
0|WebD     |     at MiniBlockchainBlockData.serializeData (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:10589:18)
0|WebD     |     at MiniBlockchainBlock._computeBlockHeaderPrefix (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:6070:64)
0|WebD     |     at MiniBlockchainBlock._computeBlockHeaderPrefix (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:27025:171)
0|WebD     |     at MiniBlockchainBlock.serializeBlock (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:6138:14) 

tx mining

A implementation of a protocol for miners that mine on consensus (not a pool) to process transfer tx set by a % by the user.

PouchDB freezes in Terminal (backbone) on Unix

When I run npm run start_mining in Terminal tested on Unix

The Wallet loadAddresses freezes and never gets a resolved Promise. It always shows me the error message in terminal from the 10 second timeout.

            //timeout, max 10 seconds to load the database
            setTimeout(()=>{
                console.log(colors.red("LOAD ADDRESSES FROZE AND FAILED !!"));
                resolve(false);
            }, 10000);

            let buffer = await this.db.get(this.walletFileName);        // never gets resolved

Any Idea? @s1lviu @opreacosmind

image

LE: In Browser it works perfectly!!!

Auto export new created wallet and at first time visit

Hi,
Could be easy to implement this?

looking into src/main-blockchain/wallet/Main-Blockchain-Wallet.js

await this.createNewAddress(); //it will save automatically

the comment states about auto saving the wallet.

Can
https://github.com/WebDollar/User-Interface-WebDollar/blob/df82421f4dc37fb58e45c987799ec52fa2b8037e/src/components/Wallet/Address/Address.vue#L137
function be called from there to auto download wallets ?

Creating a new mining pool uses an inactive domain

So, it looks like at one point webdollar.ddns.net:9094 was running, and that is where new mining pools default to. Looks like it hasn't been running for years though, and this isn't mentioned at all in the documentation or fixed. Just curious how I can get around this?

Number primitive has more than 15 significant digits

0|WebD     |  ⚠   ---------------------------------------------------------------------------- 
0|WebD     |  ⚠   WebDollar Block was mined  286853  nonce ( 2151404650) 00000000519de640197b339687e4db296ee5efc6ca5b3d588aeb1d68d3b59b7b  reward 6000 WEBD 3564a019aaf0306d5b5a76d9251cec8e84604d33 
0|WebD     |  ⚠   ---------------------------------------------------------------------------- 
0|WebD     |  ✘   MiniBlockchain simulateNewBlock 1 raised an exception at blockHeight 286853 Error: [BigNumber Error] Number primitive has more than 15 significant digits: 336.34999999962747
0|WebD     |     at new BigNumber (/home/ubuntu/webdollar/node_modules/bignumber.js/bignumber.js:312:27)
0|WebD     |     at BigNumber.P.dividedToIntegerBy.P.idiv (/home/ubuntu/webdollar/node_modules/bignumber.js/bignumber.js:1569:31)
0|WebD     |     at InterfaceBlockchainBlocks.recalculateNetworkHashRate (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:23388:30)
0|WebD     |     at MainBlockchain._onBlockCreated (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:14184:25)
0|WebD     |     at MainBlockchain._onBlockCreated (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:13653:107)
0|WebD     |     at MainBlockchain.includeBlockchainBlock (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:14163:20)
0|WebD     |     at <anonymous> { height: 286853,

No incoming connections for terminal nodes created after 1.133.1 commit 644b3a3

Changes in commit 644b3a3 cause new nodes on previously unused ports to not receive any incoming connections. Nodes using commit 94e7fb0 and prior versions do receive incoming connections. I have tested a node on each commit and 94e7fb0 has 10 connections to other nodes but 0 connections from other nodes after 8 hours. All versions since commit 94e7fb0 exhibit this behavior.

It is important to understand that any node that has recently run a version prior to 94e7fb0 and since upgraded to a newer version will have incoming connections because it's address has already propagated from the working version. But a new node on a new port with version 94e7fb0 or later will not have incoming connections. Nodes listed on the fallback list are an exception since they are discovered by default.

To reproduce:
npm install using commit 644b3a3. Start mining using a previously unused port (do NOT use a standard port: 80, 443 etc).

Error on worker restart

There seems to be some kind of issue on the following code, which seems to not be restarting the worker correctly.

async _makeUnresponsiveThreads(){
try {
let date = new Date().getTime();
if (consts.TERMINAL_WORKERS.TYPE === "cpu-cpp" || consts.TERMINAL_WORKERS.TYPE === "gpu")
for (let i = this.workers_list.length - 1; i >= 0; i--)
if ((date - this.workers_list[i].date ) > 60 * 1000) {
await this.workers_list[i].restartWorker();
this.workers_list[i].date = new Date().getTime();
// await this.workers_list[i].kill();
// this.workers_list.splice(i, 1);
Log.info("Restarting Worker", Log.LOG_TYPE.default);
}
// if ( this._current >= this._current_max )
// this._stopAndResolve();
} catch (exception){
}
this.makeUnresponsiveThreadsTimeout = setTimeout( this._makeUnresponsiveThreads.bind(this), 5000 );
}

Whenever there is a POW round, and the computer has another program running at the same time, the worker stops generating hashes, it hangs for a while, then it shows the message that it's "Restarting Worker". Sometimes it shows one hash, and then hangs again, or it just hangs, generating no hashes at all, only to be restarted again, and the cycle repeats.

I know, the issue may be caused by using resources at the same time as the miner is trying to use them, causing a racing condition, which would be my fault, and that's a fair point. But, even if I free the cpu by closing everything, and keeping the miner open, the issue persists, failing to restart again, which at that point, makes it an issue with the miner, since the resources are available, it's just refusing to use them for some reason, possibly not restarting properly.

What I believe may be a solution to this, is using the code I changed on #348 , to stop mining completely, and then initialize the workers again, which would be a proper restart in my opinion, but since I'm not entirely familiar with the miner, and even less so with the inner workings of node.js, I'm not sure if that would solve it, or cause even more issues, heck, I'm not also entirely sure if #348 may have caused this or if I only started noticing this now, since I'm paying more attention now to the miner

Due to that, i'm just creating this issue for the time being, waiting for a opinion from someone who has more understanding on the matter.

Importing address function is browser dependent

Test steps:

1
open http://webdollar.io/ in Firefox 58.0.2 (64-bit)
open http://webdollar.io/ in Google Chrome 64.0.3282.140 (64-bit)
2
Wait 1-5 minutes in order to mine a few units.
3
Check each wallet's amount.
4
Use download wallet functions to save each browser's wallet(walletFirefox and walletChrome)
Delete wallets from each browser.
5
Import walletFirefox in Firefox
Import walletChrome in Google Chrome
6
Check each wallet's amount.
Expected : same as step 3.
Obtained: same as step 3.
7
Stop mining to wallets tested
8
Import walletFirefox in Google Chrome
Import walletChrome in Firefox
9
Check each wallet's amount.
Expected : same as step 3.
Obtained: zero(0) !!!

It looks that the wallet is browser dependent. When imported in same browser from where it was created, the synchronizing with the network is done.
When changing browser for a wallet, the amount of units is set to zero. It's just like the imported address is a new one. May be a formatting issue with the address, I think. I haven't checked the code, is just an assumption.

Express server starts on different ports

Replication steps:

  • run npm run commands, select 8, the express server starts on port 3333
  • run npm run start_mining, the express server starts on port 80

I believe this is inconsistent.

Time it took to mine last 10 blocks is incorectly calculated

Issue is is function static getDifficultyMean( getDifficultyCallback, getTimeStampCallback, blockTimestamp, blockNumber)

The formula for calculating total time it took to mine last 10 blocks doesn't consider the timestamp of (firstblock -1)
. e.g, for calculating time it took to mine first block it would need to subtract timestamp of previous block from the timestamp of first block.
Even more , adding all the timestamps(firstblock to blocknumber(or firstblock+9)) and than subtrating 10x timestamp of firstblock is not a correct formula for getting the time it took to mine all the blocks.
img_20180329_102314

A more direct formula would only include timestamps of previous block before firstblock and blocknumber(last block generated before hitting next%10==0). It is enough to just subtract these 2 timestamps in order to get the time that passed in between.
img_20180329_102641

Duplicate resolver information in the block structure

There is a duplicate of information in the PoS block structure:
{ $where : "this.algorithm == 'pos' && this.resolver != '' && this.resolver2 != '' &&this.resolver2 != this.resolver" } --> this query always returns empty set of results.

resolver !="" on PoS blocks
when resolver2 != "", resolver == resolver2

argon2-browser Unexpected Character in wasm

Hi, I haven't been able to get anything related to the browser building to work like:
npm run build_browser

I keep getting this error related to argon2

ERROR in ./node_modules/argon2-browser/dist/argon2.wasm Module parse failed: Unexpected character '' (1:0) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file) @ ./node_modules/argon2-browser/lib/argon2.js 82:35-65 @ ./src/common/crypto/Argon2/Argon2.js @ ./src/tests/crypto/Argon2.test.js @ ./src/tests/main.test.js

I am on Centos7, all of my development tools are up to date. I tried redownloading the package and even trying different versions and I get the same thing. Wasn't able to build argon2 from the source because for some reason my environmental variables CMAKE_MAKE_PROGRAM , CMAKE_C_COMPILER , CMAKE_CXX_COMPILER aren't set for some reason.

Thanks!

wallet problem

after 200-300 transactions with a walletu wallet are blocked and no longer traded

Hash Rate on Nodes

I installed the Node on a few units. A) Celleron CPU, Ryzen 5, AMD i5
No Matter what processor I only get approx 500-600 H/s.
The Browser based on the Ryzen5 and I 5 get about 1800H/s

I cant find any parameter for the node to increase the "power" usage of the CPUs to get a better node perfomance

Any suggestions, please would be appreciated

Cannot read property 'length' of undefined at MiniBlockchainTransactionFrom.calculateInputSum

this prevents miner from swtiching to the outer fork

0|WebD     | TypeError: Cannot read property 'length' of undefined
0|WebD     |     at MiniBlockchainTransactionFrom.calculateInputSum (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:15350:44)
0|WebD     |     at MiniBlockchainTransaction._processTransactionFees (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:9666:34)
0|WebD     |     at MiniBlockchainTransaction.processTransaction (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:10097:22)
0|WebD     |     at MiniBlockchainFork.preFork (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:12373:57)
0|WebD     |     at Object.success.blockchain.semaphoreProcessing.processSempahoreCallback [as callback] (/home/ubuntu/webdollar/dist_bundle/terminal-bundle.js:6786:26)
0|WebD     |     at <anonymous>
0|WebD     |     at process._tickCallback (internal/process/next_tick.js:188:7)
0|WebD     | blockchainForks  preFork raised an error 

Wrong POS hash calculation

the conversion of Number to Buffer doesn't always work the way you expect thus giving you the wrong hash

https://github.com/WebDollar/Node-WebDollar/blob/PoS/src/common/blockchain/mini-blockchain/blocks/Mini-Blockchain-Block.js#L133

> Buffer.from((0xAB).toString(16), 'hex').toString('hex');
'ab'
> Buffer.from((0xABC).toString(16), 'hex').toString('hex');
'ab'
> Buffer.from((0xABCD).toString(16), 'hex').toString('hex');
'abcd'
> Buffer.from((0xABCDE).toString(16), 'hex').toString('hex');
'abcd'

read this nodejs/node#21242 for details

block was incorrectly mined

 �   Pool Work Management raised an error { message: 'block was incorrectly mined',
  work: 
   { result: false,
     hash: <Buffer 00 00 1a 25 a2 31 c1 ce ec ec 21 0c de 5d 8a 54 ba 4e 50 38 bb ed 4d e3 50 45 ea ec ea 14 ee 9d>,
     nonce: 1018608,
     id: 31 } } 

Average block time is not 40s as advertised in the whitepaper

Before the PoS fork, the average block time was ~ 42s.
After the PoS fork, the average block time is ~45s.

Show me the math:

// Before PoS fork:
new Date("Wed, 30 Jan 2019 05:40:35 GMT")-new Date(1524743407 * 1000))/1000/(567810
// 42.4 s

// After PoS fork:
(new Date() - new Date("Wed, 30 Jan 2019 05:40:35 GMT"))/1000/(608372-567810)
// 45.3 seconds

Bug 0

I am very disappointed with the general coding and development direction of this project.

My two cents on what has to be done so that webdollar becomes coding friendly:

  1. Create a wiki document where it's explained what webdollar is and what is not
  2. Create a wiki document of the webdollar architecture and general workflow
  3. Update the technical details of the blockchain written by me here: https://github.com/WebDollar/Node-WebDollar/blob/master/docs/Blockchain.md
  4. Create a wiki document of the webdollar future technical changes and workflows before it will be implemented
  5. Split the code into modules that can run independently
  6. Create and document a JSON-RPC interface
  7. Every module should have unit tests, with at least 50% coverage
  8. Write relevant commit message in the commits
  9. Never push to a branch, only PRs should be made and accepted if at least two core code reviewers sign off
  10. Define those core reviewers, a minimum of 3-5 should be enough.
  11. Implement automated test gateways that vote for the code quality.
  12. Never accept PRs that break the testing gates like wercker or travis.

Please add more to the list, if you consider so.
Personally, I will not contribute to the webdollar project if the above are not done ASAP, as I consider it a waste of time and resources.

Thanks.

Node Private API is not working

Changes made with this commit imply that named path parameters are always used:

https://github.com/WebDollar/Node-WebDollar/blob/MiningPools/src/node/sockets/node-server/express/Node-Express.js#L197

on the other hand private API routing does not defined any named parameters:

https://github.com/WebDollar/Node-WebDollar/blob/MiningPools/src/node/sockets/node-server/API-router/Node-API-Router.js#L23

so there is no way to pass URL parameters to the private API methods which makes them unusable.

P.S. Just my five cents - REST methods like wallets/create-transaction or wallets/import are typically called using POST.

Transactions are invalidated by TransactionsPendingQueue._removeOldTransactions shortly after they were created.

A bunch of new transactions is created via API and added to the miner pending queue. Shorty after that they either silently disappear like that

⚠   -------------------------------- 
⚠   pendingQueue 25 
⚠   Transactions selected for mining:  25 
⚠   -------------------------------- 

....

✘   block  296284  was not mined... 
⚠   -------------------------------- 
⚠   pendingQueue 0 
⚠   Transactions selected for mining:  0 
⚠   -------------------------------- 

or in 10% cases the error is shown (honestly, the random logging approach just makes issue tracking unnecessary complicated)

⚠   Old Transaction removed because of exception  { message: 'Nonce is not right',
   myNonce: 1,
   nonce: 2,
   txId: 'a43354340e27773141f5145aeaa4476b7f2de03e6e45645d8a8ac33548372497' } 

but I'm quite sure transactions were valid upon creation and inclusion to the pending queue a minute before which means there must be some mistake in the nonce calculation/validation logic.

can it be somehow connected to the nonce computation logic in MiniBlockchainTransaction ?

Help with the block deserialization off-chain

Hello,

I do not want to run the WebDollar code, as I would like to refactor this part, as this code is core to what happens in the blockchain and it should be kept as loosely coupled as possible.

I have run the following and got the attachment data for block01 of webdollar blockchain

blockchainDB.get("block0", {attachments: true, include_docs: true}, function (err,doc) {data = doc._attachments.key.data})

Variable data looks like this:

data
'MDAwMDdlMzAxMzcxMWJjMTI2YTg3MDhhMzI0NDcyZmRmY2Y2ODU1Y2VmMWY5NzliMGRmNDM0NzVjOTU2OGUzMzAwMDBlNzI0MDAwMTczMWQ0NmMxMzFlYjZkZDQ2NjdhOTZiZGMyN2JhZjkyMjNiZWM3MmMzNDY4ZGZiNmJhNTJjNDYwZTc2NDIzYTQwMDAwMDQ0NzZjMWQzNTViMDMyMDU0MTIyMDQ4MDRlNDI3ZjlhNTZkZTE1ZjEwZjBjODBmYzUzMGZlY2RlOWE0OGFlNmFlZGU4NjFlOTkwM2U1NDIyZjdjMTExMzU4MDMyZGZlNmNhMzdhYWQ4YmRkNWRmNmUwZTI3NjEzNTlkMzBhODI3NTA1OGUyOTlmY2MwMzgxNTM0NTQ1ZjU1Y2Y0M2U0MTk4M2Y1ZDRjOTQ1NjAwMDAwMDAwMGExY2ZjZWIyMTVhZWFjNDZjMGI3ZWVhMGQ1ZGE5ZGVmZDkyN2UyNDUwNGI3NTdlNmMzZDM3MDI4NTNjOWM5OTAxMDAwMDAxNzMxZDQ2YzEzMWViNmRkNDY2N2E5NmJkYzI3YmFmOTIyM2JlYzcyYzM0NjhkZmI2YmE1MmM0NjBlNzY0MjNhNA=='

I would like now to deserialize it using the minimum noncluttered nodejs code and obtain the timestamp and previous hash, for example.
Got the code from:

deserializeNumber(buffer){

function deserializeNumber(buffer){

    if(buffer.length === 1) return buffer[0]; else

    if (buffer.length === 2) return buffer[1] | (buffer[0] << 8); else

    if (buffer.length === 3) return buffer[2] | (buffer[1] << 8) | (buffer[0] << 16); else

    if (buffer.length === 4) return buffer[3] | (buffer[2] << 8) | (buffer[1] << 16) | (buffer[0] << 24); else

    if (buffer.length === 6) return buffer[5] | (buffer[4] << 8) | (buffer[3] << 16) | (buffer[2] << 24) | (buffer[1] << 32) | (buffer[0] << 40);

}

function substr(buffer, index, count){

    if (count === undefined)
        count = buffer.length;

    let length = Math.min(index + count, buffer.length);

    if (length-index <= 0)
        throw {message: "length-index <= 0...", buffer: buffer.toString("hex"), index:index, length:length, count: count};

    let buf = new Buffer(length-index);
    buffer.copy(buf, 0, index, length);

    return buf;

}

And now I would like to know if I am doing stuff right to get the previousHash and timestamp

buffer = Buffer.from(data, 'base64')

According to

this.hash = BufferExtended.substr(buffer, offset, consts.BLOCKCHAIN.BLOCKS_POW_LENGTH);

hashPrev should be at an offset of BLOCKCHAIN.BLOCKS_POW_LENGTH + NONCE + 2

I got a value but it is definitely not the one I am looking for:

substr(buffer, 0 + 32 + 4 +2, 32).toString("hex")
'3563656631663937396230646634333437356339353638653333303030306537'

I also get a very bad timestamp:

deserializeNumber(substr(buffer, 0 + 32 + 4 +2+32, 4))
842281008

Any help would be appreciated.

Thanks.

couldn't get level TypeError

This keeps coming up while solo mining WebDollar on Linux Ubuntu 18, in terminal.

couldn't get level TypeError: Cannot read property 'difficultyTarget' of undefined
After this exception, the hashrate goes down to 0 hashes/s.

Also: BAAAAAANNNNS and BAAAAAAAAAAAN keeps coming up.

Nonce is not right 2

What does this mean?

 ⚠   Error Including Transaction { message: 'Nonce is not right 2',
  myNonce: 3,
  nonce: null,
  txId: '4301b0b2d2d2be1e7bedc4fce6d9ca0e2ac82ee7e15359d0969e2d1d4bed0f49' } 
 ⚠   Error Including Transaction TypeError: Cannot read property 'node' of undefined
    at Function.broadcastRequest (/home/webd/MiningPool1/dist_bundle/terminal-menu-bundle.js:6663:40)
    at InterfaceBlockchainTransactionsProtocol.propagateNewMissingNonce (/home/webd/MiningPool1/dist_bundle/terminal-menu-bundle.js:24454:110)
    at TransactionsPendingQueue.propagateMissingNonce (/home/webd/MiningPool1/dist_bundle/terminal-menu-bundle.js:24161:39)
    at MiningTransactionsSelector.selectNextTransactions (/home/webd/MiningPool1/dist_bundle/terminal-menu-bundle.js:31600:79)
    at <anonymous> 
4301b0b2d2d2be1e7bedc4fce6d9ca0e2ac82ee7e15359d0969e2d1d4bed0f49 WEBD$gC4vLB$Y0S0KrBCUMhqbot10$27xi46dqz$
4301b0b2d2d2be1e7bedc4fce6d9ca0e2ac82ee7e15359d0969e2d1d4bed0f49 ------- GOOD tx

Isn't process.env object and not array?

This is unreachable code since process.env is an object.

for (let i=0; i<process.env.length; i++)
if (typeof process.env[i] === 'string')
if (process.env[i].toLowerCase() === 'true') process.env[i] = true;
else if (process.env[i].toLowerCase() === 'false') process.env[i] = false;

mine WebDollar in a Linux terminal. rgon2-bench2 process was lost after a few hours. pow is 0H/s

mine WebDollar in a Linux terminal. but . I found out that argon2-bench2 process was lost after a few hours. pow is 0H/s .
why argon2-bench2 process lost ?

TOP

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND

1082774 root 20 0 453448 2716 1268 S 84.1 0.0 235:45.47 argon2-bench2
2191669 konds 20 0 1184284 192124 121484 S 1.3 1.2 21:29.18 chrome
2191706 konds 20 0 558636 117640 72284 S 1.0 0.7 36:34.18 chrome
3137 konds 20 0 2309476 192560 63828 S 0.7 1.2 17:12.53 gnome-shell
1080877 root 20 0 2177296 667544 38404 S 0.7 4.1 1:51.21 node

root@konds:# ps auxf | grep -i argon2-bench2
root 1091216 0.0 0.0 14532 956 pts/2 S+ 18:57 0:00 _ grep -i argon2-bench2
root 1082773 0.0 0.0 4292 748 pts/1 S+ 17:36 0:00 | _ /bin/sh -c ./dist_bundle/CPU/argon2-bench2 -d 0 -c 6 -b 30000 -f ./dist_bundle/CPU/input.txt0.78002621121191450
root 1082774 291 0.0 453448 2716 pts/1 Rl+ 17:36 236:53 | _ ./dist_bundle/CPU/argon2-bench2 -d 0 -c 6 -b 30000 -f ./dist_bundle/CPU/input.txt0.78002621121191450
root@konds:
#

rgon2-bench2 process was lost after a few hours. pow is 0H/s

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND

1008884 konds 20 0 2165720 712864 204700 S 11.0 4.4 20:32.99 chrome
2191706 konds 20 0 589664 138948 86748 S 8.0 0.9 49:19.99 chrome
2975 konds 20 0 294360 44048 19200 S 3.3 0.3 22:22.60 Xorg
3137 konds 20 0 2335560 219188 82692 S 3.3 1.3 22:06.67 gnome-shell
1080877 root 20 0 2203352 709044 36848 S 2.3 4.3 6:28.96 node
3148 konds 9 -11 1702492 12708 9456 S 1.7 0.1 1:49.77 pulseaudio
2191669 konds 20 0 1574048 214316 122344 S 1.7 1.3 23:12.76 chrome
2445 root 20 0 515168 79048 10772 S 1.0 0.5 6:17.34 pvestatd
2191714 konds 20 0 554332 91524 59540 S 1.0 0.6 2:12.71 chrome
2191906 konds 20 0 831352 138396 62180 S 0.7 0.8 7:23.14 chrome
490 root -2 0 0 0 0 S 0.3 0.0 0:41.77 i915/signal:0
1736 debian-+ 20 0 188340 7280 6064 S 0.3 0.0 0:26.38 transmission-da
2453 root 20 0 517052 80816 10644 S 0.3 0.5 2:14.86 pve-firewall
1107116 root 20 0 46948 3776 3104 R 0.3 0.0 0:00.02 top
2437322 root 20 0 46916 4116 3136 S 0.3 0.0 7:44.65 top
1 root 20 0 205060 7500 5396 S 0.0 0.0 0:28.31 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.16 kthreadd

root@konds:# ps auxf | grep -i argon2-bench2
root 1108018 0.0 0.0 14532 1028 pts/2 S+ 21:10 0:00 _ grep -i argon2-bench2
root@konds:
#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.