Skip to content

Commit 87c0ae6

Browse files
authored
Merge branch 'master' into fix-tx-isSigned-fromValuesArray
2 parents 1c6aee1 + 22c8a4a commit 87c0ae6

37 files changed

+687
-619
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
},
1313
"scripts": {
1414
"postinstall": "npm run bootstrap",
15-
"bootstrap": "lerna bootstrap --ignore-scripts --include-dependencies --no-ci --hoist && npm run build",
15+
"bootstrap": "lerna bootstrap --ignore-scripts --include-dependencies --no-ci --hoist && npm run temporaryClientFixes && npm run build",
16+
"temporaryClientFixes": "cp node_modules/interface-datastore/dist/src/key.d.ts node_modules/interface-datastore/src && cd node_modules/bcrypto && npm i",
1617
"bootstrap:block": "npm run bootstrap -- --scope @ethereumjs/block",
1718
"bootstrap:blockchain": "npm run bootstrap -- --scope @ethereumjs/blockchain",
1819
"bootstrap:client": "npm run bootstrap -- --scope @ethereumjs/client",

packages/client/CHANGELOG.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
56
(modification: no type change headlines) and this project adheres to
67
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
78

9+
## [UNRELEASED]
10+
11+
- `libp2p` modules upgraded to latest, PR [#1027](https://github.com/ethereumjs/ethereumjs-vm/pull/1027)
12+
813
## [0.0.6] - 2020-06-19
914

1015
### Revival Release 🌻
@@ -26,6 +31,7 @@ showing the relations between the main components as well as the initialization
2631
## Changes
2732

2833
**Dependencies, CI and Docs**
34+
2935
- Added Node 12, removed Node 8 on CI runs, updated `level` and `ethereumjs-common` dependency,
3036
PR [#111](https://github.com/ethereumjs/ethereumjs-client/pull/111)
3137
- Upgraded CI provider to GitHub actions,
@@ -40,17 +46,19 @@ showing the relations between the main components as well as the initialization
4046
PR [#134](https://github.com/ethereumjs/ethereumjs-client/pull/134)
4147

4248
**Bug Fixes and Maintenance**
49+
4350
- Fixed tx initialization bug, PR [#113](https://github.com/ethereumjs/ethereumjs-client/pull/113)
4451
- fix(rpc): Handle rpc request with empty params,
4552
PR [#122](https://github.com/ethereumjs/ethereumjs-client/pull/122)
4653
- Fixed light sync block init bug,
4754
PR [#127](https://github.com/ethereumjs/ethereumjs-client/pull/127)
4855
- `RPC` test method cleanup,
4956
PR [#126](https://github.com/ethereumjs/ethereumjs-client/pull/126)
50-
- Removed old fields `consensus` and `finality`,
57+
- Removed old fields `consensus` and `finality`,
5158
PR [#120](https://github.com/ethereumjs/ethereumjs-client/pull/120)
5259

5360
**New Features**
61+
5462
- Improved sync reliability,
5563
PR [#133](https://github.com/ethereumjs/ethereumjs-client/pull/133)
5664
- Added `eth_blockNumber` RPC method,
@@ -61,36 +69,41 @@ showing the relations between the main components as well as the initialization
6169
[0.0.6]: https://github.com/ethereumjs/ethereumjs-client/compare/v0.0.5...v0.0.6
6270

6371
## [0.0.5] - 2019-02-12
72+
6473
- Add support for final [Goerli](https://github.com/goerli/testnet) testnet,
6574
PR [#89](https://github.com/ethereumjs/ethereumjs-client/pull/89)
6675

6776
[0.0.5]: https://github.com/ethereumjs/ethereumjs-client/compare/v0.0.4...v0.0.5
6877

6978
## [0.0.4] - 2018-12-30
79+
7080
- Add more RPC endpoints, PR [#65](https://github.com/ethereumjs/ethereumjs-client/pull/65), [#69](https://github.com/ethereumjs/ethereumjs-client/pull/69), [#75](https://github.com/ethereumjs/ethereumjs-client/pull/75), [#81](https://github.com/ethereumjs/ethereumjs-client/pull/81)
7181
- Add unit tests, PR [#70](https://github.com/ethereumjs/ethereumjs-client/pull/70)
7282
- Fix error with geth genesis file parser, PR [#71](https://github.com/ethereumjs/ethereumjs-client/pull/71)
73-
- Update ``ethereumjs-common`` to 0.6.1, PR [#72](https://github.com/ethereumjs/ethereumjs-client/pull/72)
83+
- Update `ethereumjs-common` to 0.6.1, PR [#72](https://github.com/ethereumjs/ethereumjs-client/pull/72)
7484
- Fix bug with sender status, PR [#74](https://github.com/ethereumjs/ethereumjs-client/pull/74)
7585
- Add documentation and strict mode to RPC modules, PR [#76](https://github.com/ethereumjs/ethereumjs-client/pull/76)
7686
- Shutdown gracefully on SIGINT, PR [#79](https://github.com/ethereumjs/ethereumjs-client/pull/79)
7787
- Add integration tests, PR [#82](https://github.com/ethereumjs/ethereumjs-client/pull/82)
78-
- Update ``ethereumjs-devp2p`` to 2.5.1, PR [#84](https://github.com/ethereumjs/ethereumjs-client/pull/84)
88+
- Update `ethereumjs-devp2p` to 2.5.1, PR [#84](https://github.com/ethereumjs/ethereumjs-client/pull/84)
7989
- Refactor syncing to use streams, PR [#85](https://github.com/ethereumjs/ethereumjs-client/pull/85)
8090

8191
[0.0.4]: https://github.com/ethereumjs/ethereumjs-client/compare/v0.0.3...v0.0.4
8292

8393
## [0.0.3] - 2018-10-30
94+
8495
- Update libp2p defaults, PR [#63](https://github.com/ethereumjs/ethereumjs-client/pull/63)
8596

8697
[0.0.3]: https://github.com/ethereumjs/ethereumjs-client/compare/v0.0.2...v0.0.3
8798

8899
## [0.0.2] - 2018-10-26
89-
- Update ``ethereumjs-blockchain`` to 3.3.1, PR [#61](https://github.com/ethereumjs/ethereumjs-client/pull/61)
100+
101+
- Update `ethereumjs-blockchain` to 3.3.1, PR [#61](https://github.com/ethereumjs/ethereumjs-client/pull/61)
90102

91103
[0.0.2]: https://github.com/ethereumjs/ethereumjs-client/compare/v0.0.1...v0.0.2
92104

93105
## [0.0.1] - 2018-10-26
106+
94107
- Initial development release
95108

96109
[0.0.1]: https://github.com/ethereumjs/ethereumjs-client/tree/v0.0.1

packages/client/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Code Coverage][client-coverage-badge]][client-coverage-link]
77
[![Discord][discord-badge]][discord-link]
88

9-
This is the work repository for the EthereumJS client project targeting both Node.js and the browser as a platform.
9+
This is the work repository for the EthereumJS client project targeting both Node.js and the browser.
1010

1111
See [Technical Guidelines](#technical-guidelines) to dive directly into development info.
1212

@@ -32,8 +32,7 @@ For the `ethereumjs` CLI command to work run:
3232
npm link
3333
```
3434

35-
Note: for development purposes you can invoke the client by build with `npm run build:node` and
36-
then run `node ./dist/bin/cli.js`.
35+
Note: for development purposes you can invoke the client with `npm run client:start`
3736

3837
### Running the Client
3938

@@ -222,16 +221,16 @@ Output:
222221
<pre>
223222
...
224223
INFO [10-24|11:42:26] Listener up transport=rlpx url=enode://1c3a3d70e9fb7c274355b7ffbbb34465576ecec7ab275947fd4bdc7ddcd19320dfb61b210cbacc0702011aea6971204d4309cf9cc1856fce4887145962281907@[::]:30303
225-
INFO [10-24|11:37:48] Listener up transport=libp2p url=<b>/ip4/127.0.0.1/tcp/50505/ws/ipfs/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa</b>
224+
INFO [10-24|11:37:48] Listener up transport=libp2p url=<b>/ip4/127.0.0.1/tcp/50505/ws/p2p/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa</b>
226225
...
227226
</pre>
228227

229-
Copy the libp2p URL from the output. In this example, the url is `/ip4/127.0.0.1/tcp/50505/ws/ipfs/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa` but it will be different in your case.
228+
Copy the libp2p URL from the output. In this example, the url is `/ip4/127.0.0.1/tcp/50505/ws/p2p/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa` but it will be different in your case.
230229

231230
Wait until a few thousand blocks are downloaded and then run the second client in a new terminal, using the url above to connect to the first client:
232231

233232
<pre>
234-
ethereumjs --syncmode light --network rinkeby --datadir second --transports libp2p:multiaddrs=/ip4/0.0.0.0/tcp/50506,bootnodes=<b>/ip4/127.0.0.1/tcp/50505/ws/ipfs/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa</b>
233+
ethereumjs --syncmode light --network rinkeby --datadir second --transports libp2p:multiaddrs=/ip4/0.0.0.0/tcp/50506,bootnodes=<b>/ip4/127.0.0.1/tcp/50505/ws/p2p/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa</b>
235234
</pre>
236235

237236
Notice that we have to run the second client on port 50506 using the `multiaddrs=/ip4/0.0.0.0/tcp/50506` libp2p option to avoid port conflicts.
@@ -261,7 +260,7 @@ http-server
261260
Now, open a new browser window and navigate to `http://localhost:8080`. Open the developer console in your browser and run the following command to start syncing to the first client. Again, remember to change the value of bootnodes to match the url of the first client from above:
262261

263262
```
264-
ethereumjs.run({ network: 'rinkeby', syncmode: 'light', bootnodes: '/ip4/127.0.0.1/tcp/50505/ws/ipfs/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa' })
263+
ethereumjs.run({ network: 'rinkeby', syncmode: 'light', bootnodes: '/ip4/127.0.0.1/tcp/50505/ws/p2p/QmYAuYxw6QX1x5aafs6g3bUrPbMDifP5pDun3N9zbVLpEa' })
265264
```
266265

267266
That's it! Now, you should start seeing headers being downloaded to the local storage of your browser. Since IndexDB is being used, even if you close and re-open the browser window, the headers you've downloaded will be saved.

packages/client/bin/cli.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const args = require('yargs')
3939
},
4040
datadir: {
4141
describe: 'Data directory for the blockchain',
42-
default: Config.DATADIR_DEFAULT,
42+
default: `${os.homedir()}/Library/Ethereum/ethereumjs`,
4343
},
4444
transports: {
4545
describe: 'Network transports',
@@ -93,6 +93,14 @@ const args = require('yargs')
9393
boolean: true,
9494
default: Config.DEBUGCODE_DEFAULT,
9595
},
96+
discDns: {
97+
describe: 'Query EIP-1459 DNS TXT records for peer discovery',
98+
boolean: true,
99+
},
100+
discV4: {
101+
describe: 'Use v4 ("findneighbour" node requests) for peer discovery',
102+
boolean: true,
103+
},
96104
})
97105
.locale('en_EN').argv
98106

@@ -163,7 +171,7 @@ async function run() {
163171
common,
164172
syncmode: args.syncmode,
165173
lightserv: args.lightserv,
166-
datadir: `${os.homedir()}/Library/Ethereum/ethereumjs`,
174+
datadir: args.datadir,
167175
transports: args.transports,
168176
rpc: args.rpc,
169177
rpcport: args.rpcport,
@@ -174,6 +182,8 @@ async function run() {
174182
dnsAddr: args.dnsAddr,
175183
dnsNetworks: args.dnsNetworks,
176184
debugCode: args.debugCode,
185+
discDns: args.discDns,
186+
discV4: args.discV4,
177187
})
178188
logger = config.logger
179189

packages/client/browser/index.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Common from '@ethereumjs/common'
2-
const level = require('level')
32

43
// Blockchain
54
export * from '../lib/blockchain/chain'
@@ -21,9 +20,11 @@ export * from '../lib/net/protocol/flowcontrol'
2120
// Server
2221
export * from '../lib/net/server/server'
2322
export * from '../lib/net/server/libp2pserver'
23+
import { Libp2pServer } from '../lib/net/server/libp2pserver'
2424

2525
// EthereumClient
2626
export * from '../lib/client'
27+
import EthereumClient from '../lib/client'
2728

2829
// Service
2930
export * from '../lib/service/service'
@@ -37,38 +38,37 @@ export * from '../lib/sync/lightsync'
3738

3839
// Utilities
3940
export * from '../lib/util'
41+
import { Config } from '../lib/config'
4042

4143
// Logging
4244
export * from './logging'
4345
import { getLogger } from './logging'
4446

4547
export function createClient(args: any) {
46-
const logger = getLogger({ loglevel: args.loglevel })
47-
const options = {
48+
const logger = getLogger({ loglevel: args.loglevel ?? 'info' })
49+
const config = new Config({
4850
common: new Common({ chain: args.network ?? 'mainnet' }),
49-
servers: [new exports.Libp2pServer({ multiaddrs: [], ...args })],
51+
servers: [new Libp2pServer({ multiaddrs: [], config: new Config({ logger }), ...args })],
5052
syncmode: args.syncmode ?? 'full',
51-
db: level(args.db ?? 'ethereumjs'),
52-
logger: logger,
53-
}
54-
return new exports.EthereumClient(options)
53+
logger,
54+
})
55+
return new EthereumClient({ config })
5556
}
5657

57-
export function run(args: any) {
58+
export async function run(args: any) {
5859
const client = createClient(args)
59-
const logger = client.logger
60+
const { logger, chainCommon: common } = client.config
6061
logger.info('Initializing Ethereumjs client...')
61-
logger.info(`Connecting to network: ${client.common.chainName()}`)
62+
logger.info(`Connecting to network: ${common.chainName()}`)
6263
client.on('error', (err: any) => logger.error(err))
6364
client.on('listening', (details: any) => {
6465
logger.info(`Listener up transport=${details.transport} url=${details.url}`)
6566
})
6667
client.on('synchronized', () => {
6768
logger.info('Synchronized')
6869
})
69-
client.open().then(() => {
70-
logger.info('Synchronizing blockchain...')
71-
client.start()
72-
})
70+
await client.open()
71+
logger.info('Synchronizing blockchain...')
72+
await client.start()
7373
return client
7474
}

packages/client/browser/libp2pnode.ts

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,60 @@
33
* @memberof module:net/peer
44
*/
55

6-
import LibP2pWebsockets from 'libp2p-websockets'
7-
import LibP2pBootstrap from 'libp2p-bootstrap'
8-
import mplex from 'libp2p-mplex'
9-
import secio from 'libp2p-secio'
6+
import LibP2p from 'libp2p'
7+
import { NOISE } from 'libp2p-noise'
8+
import PeerId from 'peer-id'
9+
import multiaddr from 'multiaddr'
10+
// types currently unavailable for below libp2p deps,
11+
// tracking issue: https://github.com/libp2p/js-libp2p/issues/659
12+
const LibP2pWebsockets = require('libp2p-websockets')
13+
const filters = require('libp2p-websockets/src/filters')
14+
const LibP2pBootstrap = require('libp2p-bootstrap')
15+
const mplex = require('libp2p-mplex')
1016

11-
const libp2p = require('libp2p')
12-
const promisify = require('util-promisify')
17+
export interface Libp2pNodeOptions {
18+
/* Peer id */
19+
peerId: PeerId
1320

14-
export class Libp2pNode extends libp2p {
15-
constructor(options: any) {
21+
/* Addresses */
22+
addresses?: {
23+
listen?: string[]
24+
announce?: string[]
25+
announceFilter?: (ma: multiaddr[]) => multiaddr[]
26+
}
27+
28+
/* Bootnodes */
29+
bootnodes?: multiaddr[]
30+
}
31+
32+
export class Libp2pNode extends LibP2p {
33+
constructor(options: Libp2pNodeOptions) {
34+
const wsTransportKey = LibP2pWebsockets.prototype[Symbol.toStringTag]
35+
options.bootnodes = options.bootnodes ?? []
1636
super({
17-
peerInfo: options.peerInfo,
37+
peerId: options.peerId,
38+
addresses: options.addresses,
1839
modules: {
1940
transport: [LibP2pWebsockets],
2041
streamMuxer: [mplex],
21-
connEncryption: [secio],
22-
peerDiscovery: [LibP2pBootstrap],
42+
connEncryption: [NOISE],
43+
[<any>'peerDiscovery']: [LibP2pBootstrap],
2344
},
2445
config: {
46+
transport: {
47+
[wsTransportKey]: {
48+
filter: filters.all,
49+
},
50+
},
2551
peerDiscovery: {
26-
bootstrap: {
52+
autoDial: false,
53+
[LibP2pBootstrap.tag]: {
2754
interval: 2000,
28-
enabled: options.bootnodes !== undefined,
29-
list: options.bootnodes ?? [],
55+
enabled: options.bootnodes.length > 0,
56+
list: options.bootnodes,
3057
},
3158
},
32-
EXPERIMENTAL: {
33-
dht: false,
34-
pubsub: false,
35-
},
3659
},
3760
})
38-
39-
this.asyncStart = promisify(this.start.bind(this))
40-
this.asyncStop = promisify(this.stop.bind(this))
41-
this.asyncDial = promisify(this.dial.bind(this))
42-
this.asyncDialProtocol = promisify(this.dialProtocol.bind(this))
4361
}
4462
}

packages/client/lib/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import events from 'events'
22
import { LevelUp } from 'levelup'
3-
import { BootnodeLike } from './types'
3+
import { MultiaddrLike } from './types'
44
import { Config } from './config'
55
import { FullEthereumService, LightEthereumService } from './service'
66

@@ -23,7 +23,7 @@ export interface EthereumClientOptions {
2323
stateDB?: LevelUp
2424

2525
/* List of bootnodes to use for discovery */
26-
bootnodes?: BootnodeLike[]
26+
bootnodes?: MultiaddrLike[]
2727

2828
/* List of supported clients */
2929
clientFilter?: string[]

0 commit comments

Comments
 (0)