Git Product home page Git Product logo

ethashjs's People

Contributors

alcuadrado avatar axic avatar evertonfraga avatar greenkeeperio-bot avatar holgerd77 avatar kumavis avatar panispani avatar perl5577 avatar ryanio avatar wanderer 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

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

ethashjs's Issues

Maintenance

Hmm, this library got a bit forgotten (last release 4 (!) years ago sigh), but it is actually actively used as a dependency within the blockchain library to verify POW for a block.

Not sure if it is worth to port to TypeScript (but on the other hand: why not?) but we should at least give this some maintenance love and update dependencies.

@ryanio Can you do a CI update here?

Eventually the library is also a candidate for a monorepo integration, the blockchain library is actually the only consumer with the EthereumJS ecosystem.

verify from RPC

Why is this block not verifying using ethhash

var Promise= require('bluebird');
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
const ethUtil = require('ethereumjs-util')
const Ethash = require('ethashjs')
const Block = require('ethereumjs-block')
const levelup = require('levelup')
const memdown = require('memdown')
const rlp = require('rlp')
const fromrpc=require('./from-rpc.js')
var cacheDB = levelup('', {
  db: memdown
})


var ethash = new Ethash(cacheDB);

  web3.eth.getBlock(220).then(function(data) {

		  	console.log(data)

		        var validblock = new fromrpc(data)
		ethash.verifyPOW(validblock, function (result) {
		  console.log(result)
		})
});

publish 0.0.4

published version contains console.logs, please bump to 0.0.4

Usage guide

Hi Ethereum Javascripters,

I'm a web developer who's interested in ethereum in javascript and am very interested in mining with javascript (I know it'll be slower).
While I've read Dagger-hashimoto and a lot of blockchain material, I'm confused with how to use ethashjs.

I see that it says it can be browserified but I have no idea how to actually use it.

I have geth running with jsonrpc enabled and working with curl requests. But I can't figure out what I need from geth in order to run ethashjs.

Perhaps someone here could help me, what should I be doing to try and mine in the browser using ethashjs?

Monorepo integration?

After having slept a night on this I think it would actually a lot of sense to add this to the monorepo.

@evertonfraga What do you think? Would this be a substantial additional integration effort or is this relatively easily doable now?

Follow-up on #20

Upgrade official Ethash tests / Remove ethereumjs-testing dependency

Tests should be upgraded to the latest test state from the ethereum/tests repository (not sure if necessary though since tests are not updated there for quite some time as well).

Along the ethereumjs-testing dependency should be removed analogue to e.g. ethereumjs/ethereumjs-block#61, since the dependency is super-heavy (several 100 MBs) and the tests rarely change.

This would be a pre-requisite for #20 (the monorepo part), since we don't want to draw in this dependency within the monorepo.

Ethash.prototype.calcDatasetItem not work

For debuging
console.log('Ethash.prototype.calcDatasetItem 1');
console.log(mix);
console.log('i:' + i + ' n:' + n + ' r:' + r);
mix.writeInt32LE(mix.readUInt32LE(0) ^ i)

Ethash.prototype.calcDatasetItem 1
<Buffer 62 8e 0a 0d e9 eb 22 c1 0a b0 d7 b3 29 e0 ae f4 f0 b9 f2 5e ef da c5 9d b8 e3 a7 ee 7c 08 66 8a f8 c2 1c 1e b0 13 34 61 4f b9 5a 43 27 24 6d af 1c 86 5c ...>
i:12511692 n:264179 r:16

buffer.js:786
throw TypeError('offset is not uint');
^

ethashjs/index.js - Array.fill() does not exist

Hi,

I'm getting the following error from ethashjs/index.js. The text fullSize, n, w, s and mixhashes are just my additional debugging logs. The problem occurred before I added the debugging information.

block number (hex) 0x1199e1
fullSize : 1392507008
n : 21757922
w : 32
s : ?1w�V��FJ��Ey��[��fj�#�׋�V.
g�)����Bm��eU\y��cB3�?�f�[�� �i�ٗ
mixhashes: 2

/home/beef/BeefPool/node_modules/ethashjs/index.js:60
var mix = Buffer.concat(Array(mixhashes).fill(s))
^
TypeError: Object , has no method 'fill'
at Ethash.run (/home/beef/BeefPool/node_modules/ethashjs/index.js:60:44)
at /home/beef/BeefPool/shareHandler.js:43:19
at Object._onImmediate (/home/beef/BeefPool/node_modules/ethashjs/node_modules/levelup/lib/levelup.js:258:9)
at processImmediate as _immediateCallback

The snippet from ethashjs/index.js modified with my debugging information:
Ethash.prototype.run = function (val, nonce, fullSize) {
fullSize = fullSize || this.fullSize
console.log("fullSize : " + fullSize);
const n = Math.floor(fullSize / ethHashUtil.params.HASH_BYTES)
console.log("n : " + n);
const w = Math.floor(ethHashUtil.params.MIX_BYTES / ethHashUtil.params.WORD_BYTES)
console.log("w : " + w);
const s = ethUtil.sha3(Buffer.concat([val, ethHashUtil.bufReverse(nonce)]), 512)
console.log("s : " + s);
const mixhashes = Math.floor(ethHashUtil.params.MIX_BYTES / ethHashUtil.params.HASH_BYTES)
console.log("mixhashes: " + mixhashes);
var mix = Buffer.concat(Array(mixhashes).fill(s))

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.