Skip to content
This repository was archived by the owner on Dec 10, 2020. It is now read-only.

Commit 06b031e

Browse files
authored
Merge pull request #23 from ethereumjs/upgrade-ci-to-gh-actions
Upgrade CI to GH Actions
2 parents df2644b + aee38f4 commit 06b031e

File tree

13 files changed

+256
-141
lines changed

13 files changed

+256
-141
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
tags:
7+
- '*'
8+
pull_request:
9+
types: [opened, reopened, synchronize]
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/setup-node@v1
15+
- uses: actions/checkout@v1
16+
- run: npm install
17+
- run: npm run lint
18+
19+
coverage:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/setup-node@v1
23+
- uses: actions/checkout@v1
24+
- run: npm install
25+
- run: npm run coverage
26+
- name: Upload coverage to Coveralls
27+
uses: coverallsapp/github-action@master
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
matrix:
35+
node-version: [10.x, 12.x, 13.x, 14.x]
36+
steps:
37+
- name: Use Node.js ${{ matrix.node-version }}
38+
uses: actions/setup-node@v1
39+
with:
40+
node-version: ${{ matrix.node-version }}
41+
- uses: actions/checkout@v1
42+
- run: npm install
43+
- run: npm run test

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
package-lock.json
2+
package-lock.json
3+
.nyc_output
4+
coverage

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
semi: false
2+
singleQuote: true
3+
trailingComma: none

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

README.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# SYNOPSIS
2-
[![NPM Package](https://img.shields.io/npm/v/ethashjs.svg?style=flat-square)](https://www.npmjs.org/package/ethashjs)
3-
[![Build Status](https://travis-ci.org/ethereumjs/ethashjs.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereumjs/ethashjs)
4-
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethashjs.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethashjs)
5-
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode
62

7-
Implements [Ethash](https://github.com/ethereum/wiki/wiki/Ethash)
3+
[![NPM Package](https://img.shields.io/npm/v/ethashjs.svg)](https://www.npmjs.org/package/ethashjs)
4+
[![Actions Status](https://github.com/ethereumjs/ethashjs/workflows/Build/badge.svg)](https://github.com/ethereumjs/ethashjs/actions)
5+
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethashjs.svg)](https://coveralls.io/r/ethereumjs/ethashjs)
6+
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg)](https://gitter.im/ethereum/ethereumjs-lib)
87

9-
# CONTACT
10-
[Scrollback](https://scrollback.io/ethereumjs/all/all-messages) or #ethereumjs on freenode
8+
Implements [Ethash](https://github.com/ethereum/wiki/wiki/Ethash).
119

1210
# INSTALL
11+
1312
`npm install ethashjs`
1413

1514
# USAGE
15+
1616
```javascript
1717
const Ethash = require('ethashjs')
1818
const Block = require('ethereumjs-block')
@@ -23,61 +23,75 @@ var cacheDB = levelup('', {
2323
db: memdown
2424
})
2525

26-
var ethash = new Ethash(cacheDB);
27-
var validblockRlp = "f90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910111213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0"
26+
var ethash = new Ethash(cacheDB)
27+
var validblockRlp =
28+
'f90667f905fba0a8d5b7a4793baaede98b5236954f634a0051842df6a252f6a80492fd888678bda01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0f93c8db1e931daa2e22e39b5d2da6fb4074e3d544094857608536155e3521bc1a0bb7495628f9160ddbcf6354380ee32c300d594e833caec3a428041a66e7bade1a0c7778a7376099ee2e5c455791c1885b5c361b95713fddcbe32d97fd01334d296b90100000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000400000000000000000000000000000000000000000000000000000008302000001832fefd882560b84559c17b9b9040001020304050607080910111213141516171819202122232410000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000100000000000000000002000000000000000000030000000000000000000400000000000000000005000000000000000000060000000000000000000700000000000000000008000000000000000000090000000000000000000100000000000000000001000000000000000000020000000000000000000300000000000000000004000000000000000000050000000000000000000600000000000000000007000000000000000000080000000000000000000900000000000000000001000000000000000000010000000000000000000200000000000000000003000000000000000000040000000000000000000500000000000000000006000000000000000000070000000000000000000800000000000000000009000000000000000000010000000000000000000a09c7b47112a3afb385c12924bf6280d273c106eea7caeaf5131d8776f61056c148876ae05d46b58d1fff866f864800a82c35094095e7baea6a6c7c4c2dfeb977efac326af552d8785012a05f200801ba01d2c92cfaeb04e53acdff2b5d42005ff6aacdb0105e64eb8c30c273f445d2782a01e7d50ffce57840360c57d94977b8cdebde614da23e8d1e77dc07928763cfe21c0'
2829

29-
var validblock = new Block(new Buffer(validblockRlp, 'hex'))
30+
var validblock = new Block(Buffer.from(validblockRlp, 'hex'))
3031

3132
ethash.verifyPOW(validblock, function (result) {
3233
console.log(result)
3334
})
3435
```
3536

36-
# BROWSER
37-
Yep, You can [browserify](http://browserify.org/) it.
37+
# BROWSER
38+
39+
Yep, you can [browserify](http://browserify.org/) it.
3840

3941
# API
42+
4043
- [`new Ethash([cacheDB])`](#newethashcachedb)
4144
- [`ethash.verifyPOW(block, cb)`](#ethashverifypowblock-cb)
4245
- [`ethash.mkcache(cacheSize, seed)`](#ethashmkcachecachesize-seed)
4346
- [`ethash.run(val, nonce, fullsize)`](#ethashrunval-nonce-fullsize)
4447

4548
### `new Ethash([cacheDB])`
49+
4650
Creates a new instance of `Ethash`.
4751

4852
**Parameters**
53+
4954
- `cacheDB` - an instance of a levelup db which is used to store the cache(s)
5055

5156
### `ethash.verifyPOW(block, cb)`
57+
5258
Verifies the POW on a block and its uncles
5359

54-
**Parameters**
60+
**Parameters**
61+
5562
- `block` - the [block](https://github.com/ethereum/ethereumjs-block) to verify
56-
- `cb` - the callback which is given a `Boolean` determining the validaty of the block
63+
- `cb` - the callback which is given a `Boolean` determining the validaty of the block
5764

5865
### `ethash.mkcache(cacheSize, seed)`
59-
Creates a cache. NOTE: this is automatically done for in - [`ethash.verifyPOW(block, cb)`](#ethashverifypowblock-cb) so you do not need to use this function if you are just validating blocks
6066

61-
**Parameters**
67+
Creates a cache. NOTE: this is automatically done for in - [`ethash.verifyPOW(block, cb)`](#ethashverifypowblock-cb) so you do not need to use this function if you are just validating blocks
68+
69+
**Parameters**
70+
6271
- `cachSize` - the size of the cach
6372
- `seed` - the seed as a `Buffer`
6473

65-
6674
### `ethash.run(val, nonce, fullsize)`
75+
6776
Runs ethash on a give val/nonce pair. NOTE: you need to run [`ethash.mkcache(cacheSize, seed)`](#ethashverifypowcachesize-seed) first before using this function.
6877

69-
**Parameters**
78+
**Parameters**
79+
7080
- `val` - value to run ethash on e.g. the header hash
7181
- `nonce` - the nonce used for this hash attempt
7282
- `fullsize` - the fullsize of the cache.
7383

74-
**Return**
75-
and `Object` containing
76-
- `hash` - the hash of the value
84+
**Returns**
85+
86+
An `Object` containing:
87+
88+
- `hash` - the hash of the value
7789
- `mix` - the mis result
7890

7991
# TESTS
92+
8093
`npm test`
8194

8295
# LICENSE
96+
8397
[MPL-2.0](https://www.mozilla.org/MPL/2.0/)

example/example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const Ethash = require('../index.js')
22

33
var ethash = new Ethash()
44
// make the 1000 cache items with a seed of 0 * 32
5-
ethash.mkcache(1000, new Buffer(32).fill(0))
5+
ethash.mkcache(1000, Buffer.alloc(32).fill(0))
66

7-
var result = ethash.run(new Buffer('test'), new Buffer([0]), 1000)
7+
var result = ethash.run(Buffer.from('test'), Buffer.from([0]), 1000)
88
console.log(result.hash.toString('hex'))

example/rawExample.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Ethash.prototype.verifySubmit = function (number, headerHash, nonce, cb) {
88
this.loadEpoc(number, function () {
99
console.log('EPOC set')
1010
console.log(self.seed.toString('hex'))
11-
var a = self.run(headerHash, new Buffer(nonce, 'hex'))
11+
var a = self.run(headerHash, Buffer.from(nonce, 'hex'))
1212
cb(a.hash)
1313
})
1414
}
@@ -19,7 +19,10 @@ var cacheDB = levelup('', {
1919

2020
var ethash = new Ethash(cacheDB)
2121

22-
var header = Buffer('0e2887aa1a0668bf8254d1a6ae518927de99e3e5d7f30fd1f16096e2608fe05e', 'hex')
22+
var header = Buffer.from(
23+
'0e2887aa1a0668bf8254d1a6ae518927de99e3e5d7f30fd1f16096e2608fe05e',
24+
'hex'
25+
)
2326

2427
ethash.verifySubmit(35414, header, 'e360b6170c229d15', function (result) {
2528
console.log(result.toString('hex'))

0 commit comments

Comments
 (0)