Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Upgrade from Travis to GH Actions #105

Merged
merged 3 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build
on:
push:
branches:
- master
tags:
- '*'
pull_request:
types: [opened, reopened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 13.x]

steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- uses: actions/checkout@v1
- run: npm install
- run: npm run lint
- run: npm run coverage
- run: npm run test:browser

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 0 additions & 10 deletions .nycrc

This file was deleted.

34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# SYNOPSIS

[![NPM Package](https://img.shields.io/npm/v/merkle-patricia-tree)](https://www.npmjs.org/package/merkle-patricia-tree)
[![Build Status](https://img.shields.io/travis/ethereumjs/merkle-patricia-tree/master)](https://travis-ci.org/ethereumjs/merkle-patricia-tree)
[![Actions Status](https://github.com/ethereumjs/ethereumjs-util/workflows/Build/badge.svg)](https://github.com/ethereumjs/merkle-patricia-tree/actions)
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/merkle-patricia-tree.svg)](https://coveralls.io/r/ethereumjs/merkle-patricia-tree)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg)](https://gitter.im/ethereum/ethereumjs-lib)

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

This is an implementation of the modified merkle patricia tree as specified in the [Ethereum's yellow paper](http://gavwood.com/Paper.pdf).
This is an implementation of the modified merkle patricia tree as specified in the [Ethereum's Yellow Paper](http://gavwood.com/Paper.pdf):

> The modified Merkle Patricia tree (trie) provides a persistent data structure to map between arbitrary-length binary data (byte arrays). It is defined in terms of a mutable data structure to map between 256-bit binary fragments and arbitrary-length binary data. The core of the trie, and its sole requirement in terms of the protocol specification is to provide a single 32-byte value that identifies a given set of key-value pairs.
> \- Ethereum's yellow paper
> The modified Merkle Patricia tree (trie) provides a persistent data structure to map between arbitrary-length binary data (byte arrays). It is defined in terms of a mutable data structure to map between 256-bit binary fragments and arbitrary-length binary data. The core of the trie, and its sole requirement in terms of the protocol specification is to provide a single 32-byte value that identifies a given set of key-value pairs.

The only backing store supported is LevelDB through the `levelup` module.

Expand All @@ -30,8 +29,8 @@ const Trie = require('merkle-patricia-tree').BaseTrie,
db = level('./testdb'),
trie = new Trie(db)

trie.put(Buffer.from('test'), Buffer.from('one'), function() {
trie.get(Buffer.from('test'), function(err, value) {
trie.put(Buffer.from('test'), Buffer.from('one'), function () {
trie.get(Buffer.from('test'), function (err, value) {
if (value) console.log(value.toString())
})
})
Expand All @@ -40,9 +39,9 @@ trie.put(Buffer.from('test'), Buffer.from('one'), function() {
## Merkle Proofs

```javascript
Trie.prove(trie, Buffer.from('test'), function(err, prove) {
Trie.prove(trie, Buffer.from('test'), function (err, prove) {
if (err) return cb(err)
Trie.verifyProof(trie.root, Buffer.from('test'), prove, function(err, value) {
Trie.verifyProof(trie.root, Buffer.from('test'), prove, function (err, value) {
if (err) return cb(err)
console.log(value.toString())
cb()
Expand All @@ -63,10 +62,10 @@ var trie = new Trie(db, stateRoot)

trie
.createReadStream()
.on('data', function(data) {
.on('data', function (data) {
console.log(data)
})
.on('end', function() {
.on('end', function () {
console.log('End.')
})
```
Expand All @@ -89,7 +88,7 @@ var trie = new Trie(db, stateRoot)

var address = 'AN_ETHEREUM_ACCOUNT_ADDRESS'

trie.get(address, function(err, data) {
trie.get(address, function (err, data) {
if (err) return cb(err)

var acc = new Account(data)
Expand All @@ -105,11 +104,11 @@ trie.get(address, function(err, data) {
console.log('------Storage------')
var stream = storageTrie.createReadStream()
stream
.on('data', function(data) {
.on('data', function (data) {
console.log(`key: ${ethutil.bufferToHex(data.key)}`)
console.log(`Value: ${ethutil.bufferToHex(rlp.decode(data.value))}`)
})
.on('end', function() {
.on('end', function () {
console.log('Finished reading storage.')
})
})
Expand Down
17 changes: 7 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
module.exports = function(config) {
config.set({
browserNoActivityTimeout: 60000,
frameworks: ['browserify', 'detectBrowsers', 'tap'],
browserDisconnectTimeout: 100000,
browserNoActivityTimeout: 100000,
frameworks: ['browserify', 'tap'],
plugins: ['karma-browserify', 'karma-tap', 'karma-chrome-launcher', 'karma-firefox-launcher'],
files: ['./test/*.js'],
preprocessors: {
'./dist/**/*.js': ['browserify'],
'./test/**/*.js': ['browserify']
'./test/**/*.js': ['browserify'],
},
colors: true,
browsers: ['FirefoxHeadless', 'ChromeHeadless'],
singleRun: true,
detectBrowsers: {
enabled: true,
usePhantomJS: false,
postDetection: function(availableBrowsers) {
return ['Firefox']
},
}
})
}
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"scripts": {
"build": "ethereumjs-config-build",
"prepublishOnly": "npm run test && npm run build",
"coverage": "nyc npm run test:node && nyc report --reporter=text-lcov > .nyc_output/lcov.info",
"coveralls": "npm run coverage && coveralls < .nyc_output/lcov.info",
"coverage": "nyc --reporter=lcov npm run test:node",
"docs:build": "npx typedoc",
"tslint": "ethereumjs-config-tslint",
"tslint:fix": "ethereumjs-config-tslint-fix",
Expand All @@ -21,9 +20,9 @@
"format:fix": "ethereumjs-config-format-fix",
"formatTest": "node ./scripts/formatTest",
"tsc": "ethereumjs-config-tsc",
"test": "npm run build && npm run test:node && npm run test:browser",
"test": "npm run test:node && npm run test:browser",
"test:browser": "npm run build && karma start karma.conf.js",
"test:node": "npm run build && tape ./test/*.js"
"test:node": "npm run build && tape test/*.js | tap-prettify -"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -64,17 +63,17 @@
"@ethereumjs/config-tslint": "^1.1.1",
"@types/bn.js": "^4.11.5",
"@types/levelup": "^3.1.1",
"browserify": "^13.0.0",
"coveralls": "^3.0.5",
"husky": "^2.1.0",
"karma": "^1.7.1",
"karma-browserify": "^5.0.0",
"karma-detect-browsers": "^2.0.2",
"karma-firefox-launcher": "^1.0.1",
"karma-tap": "^1.0.3",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"tape": "^4.10.1",
"browserify": "^16.5.0",
"husky": "^4.2.3",
"karma": "^4.4.1",
"karma-browserify": "^7.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^1.3.0",
"karma-tap": "^4.2.0",
"nyc": "^15.0.0",
"prettier": "^2.0.2",
"tap-prettify": "^0.0.2",
"tape": "^4.13.0",
"tslint": "^5.18.0",
"typedoc": "next",
"typedoc-plugin-markdown": "^2.2.16",
Expand Down
18 changes: 9 additions & 9 deletions src/baseTrie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Trie {
}

static fromProof(proofNodes: Buffer[], cb: Function, proofTrie?: Trie) {
let opStack = proofNodes.map(nodeValue => {
let opStack = proofNodes.map((nodeValue) => {
return {
type: 'put',
key: ethUtil.keccak(nodeValue),
Expand All @@ -68,14 +68,14 @@ export class Trie {
}

static prove(trie: Trie, key: Buffer, cb: Function) {
trie.findPath(key, function(
trie.findPath(key, function (
err: Error,
node: TrieNode,
remaining: number[],
stack: TrieNode[],
) {
if (err) return cb(err)
let p = stack.map(stackElem => {
let p = stack.map((stackElem) => {
return stackElem.serialize()
})
cb(null, p)
Expand Down Expand Up @@ -473,7 +473,7 @@ export class Trie {
_walkTrie(root: Buffer, onNode: Function, onDone: Function) {
const self = this
root = root || this.root
onDone = onDone || function() {}
onDone = onDone || function () {}
let aborted = false
let returnValues: any = []

Expand Down Expand Up @@ -507,17 +507,17 @@ export class Trie {
let stopped = false

const walkController = {
stop: function() {
stop: function () {
stopped = true
cb()
},
// end all traversal and return values to the onDone cb
return: function(...args: any) {
return: function (...args: any) {
aborted = true
returnValues = args
cb()
},
next: function() {
next: function () {
if (aborted || stopped) {
return cb()
}
Expand All @@ -530,7 +530,7 @@ export class Trie {
if (node instanceof ExtensionNode) {
children = [[node.key, node.value]]
} else if (node instanceof BranchNode) {
children = node.getChildren().map(b => [[b[0]], b[1]])
children = node.getChildren().map((b) => [[b[0]], b[1]])
}
async.forEachOf(
children,
Expand All @@ -552,7 +552,7 @@ export class Trie {
cb,
)
},
only: function(childIndex: number) {
only: function (childIndex: number) {
if (!(node instanceof BranchNode)) {
return cb(new Error('Expected branch node'))
}
Expand Down
4 changes: 1 addition & 3 deletions src/checkpointTrie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ export class CheckpointTrie extends BaseTrie {
this.db = this._mainDB

if (commitState) {
this._createScratchReadStream(scratch)
.pipe(WriteStream(this.db._leveldb))
.on('close', cb)
this._createScratchReadStream(scratch).pipe(WriteStream(this.db._leveldb)).on('close', cb)
} else {
async.nextTick(cb)
}
Expand Down
10 changes: 5 additions & 5 deletions src/util/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export function callTogether(...funcs: Function[]) {
const index = length

if (!length) {
return function() {}
return function () {}
}

return function(this: any, ...args: any) {
return function (this: any, ...args: any) {
length = index

while (length--) {
Expand All @@ -33,17 +33,17 @@ export function asyncFirstSeries(array: any[], iterator: Function, cb: Function)
var didComplete = false
async.eachSeries(
array,
function(item: any, next: Function) {
function (item: any, next: Function) {
if (didComplete) return next
iterator(item, function(err: Error, result: any) {
iterator(item, function (err: Error, result: any) {
if (result) {
didComplete = true
process.nextTick(cb.bind(null, null, result))
}
next(err)
})
},
function() {
function () {
if (!didComplete) {
cb()
}
Expand Down