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

Commit dc3bbbf

Browse files
Merge pull request #184 from ethereumjs/rename-fast-to-full
Rename fast sync to full sync
2 parents 51f9513 + 6062525 commit dc3bbbf

File tree

18 files changed

+70
-73
lines changed

18 files changed

+70
-73
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Output:
177177

178178
### Example 1: Light sync
179179

180-
In this example, we will run two ethereumjs-clients. The first will be a fast sync client that
180+
In this example, we will run two ethereumjs-clients. The first will be a full sync client that
181181
will connect to the rinkeby network and start downloading the blockchain. The second will be a
182182
light client that connects to the first client and syncs headers as they are downloaded.
183183

@@ -187,7 +187,7 @@ listener. The second client will use libp2p to connect to the first client.
187187
Run the first client and start downloading blocks:
188188

189189
```
190-
ethereumjs --syncmode fast --lightserv true --datadir first --network rinkeby --transports rlpx libp2p:multiaddrs=/ip4/127.0.0.1/tcp/50505/ws
190+
ethereumjs --syncmode full --lightserv true --datadir first --network rinkeby --transports rlpx libp2p:multiaddrs=/ip4/127.0.0.1/tcp/50505/ws
191191
```
192192

193193
Output:
@@ -272,7 +272,7 @@ to help contributors better understand how the project is organized.
272272
- `/docs` Contains auto-generated API docs.
273273
- `/lib/blockchain` Contains the `Chain` class.
274274
- `/lib/net` Contains all of the network layer classes including `Peer`, `Protocol` and its subclasses, `Server` and its subclasses, and `PeerPool`.
275-
- `/lib/service` Contains the main Ethereum services (`FastEthereumService` and `LightEthereumService`).
275+
- `/lib/service` Contains the main Ethereum services (`FullEthereumService` and `LightEthereumService`).
276276
- `/lib/rpc` Contains the RPC server (optionally) embedded in the client.
277277
- `/lib/sync` Contains the various chain synchronizers and `Fetcher` helpers.
278278
- `/test` Contains test cases, testing helper functions, mocks and test data.
@@ -297,12 +297,12 @@ to help contributors better understand how the project is organized.
297297
and `removed` events when new peers are added and removed and also emit the `message` event whenever
298298
any of the peers in the pool emit a message. Each `Service` has an associated `PeerPool` and they are used primarily by `Synchronizer`s to help with blockchain synchronization.
299299
- `Synchronizer` Subclasses of this class implements a specific blockchain synchronization strategy. They
300-
also make use of subclasses of the `Fetcher` class that help fetch headers and bodies from pool peers. The fetchers internally make use of streams to handle things like queuing and backpressure. - `FastSynchronizer` [**In Progress**] Implements fast syncing of the blockchain - `LightSynchronizer` [**In Progress**] Implements light syncing of the blockchain
300+
also make use of subclasses of the `Fetcher` class that help fetch headers and bodies from pool peers. The fetchers internally make use of streams to handle things like queuing and backpressure. - `FullSynchronizer` [**In Progress**] Implements full syncing of the blockchain - `LightSynchronizer` [**In Progress**] Implements light syncing of the blockchain
301301
- `Handler` Subclasses of this class implements a protocol message handler. Handlers respond to incoming requests from peers.
302302
- `EthHandler` [**In Progress**] Handles incoming ETH requests
303303
- `LesHandler` [**In Progress**] Handles incoming LES requests
304-
- `Service` Subclasses of `Service` will implement specific functionality of a `Node`. For example, the `EthereumService` subclasses will synchronize the blockchain using the fast or light sync protocols. Each service must specify which protocols it needs and define a `start()` and `stop()` function.
305-
- `FastEthereumService` [**In Progress**] Implementation of ethereum fast sync.
304+
- `Service` Subclasses of `Service` will implement specific functionality of a `Node`. For example, the `EthereumService` subclasses will synchronize the blockchain using the full or light sync protocols. Each service must specify which protocols it needs and define a `start()` and `stop()` function.
305+
- `FullEthereumService` [**In Progress**] Implementation of ethereum full sync.
306306
- `LightEthereumService` [**In Progress**] Implementation of ethereum light sync.
307307
- `WhisperService` [**Not Started**] Implementation of an ethereum whisper node.
308308
- `Node` [**In Progress**] Represents the top-level ethereum node, and is responsible for managing the lifecycle of included services.

bin/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const args = require('yargs')
2828
},
2929
syncmode: {
3030
describe: 'Blockchain sync mode',
31-
choices: ['light', 'fast'],
31+
choices: ['light', 'full'],
3232
default: Config.SYNCMODE_DEFAULT,
3333
},
3434
lightserv: {

browser/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export * from '../lib/node'
2727

2828
// Service
2929
export * from '../lib/service/service'
30-
export * from '../lib/service/fastethereumservice'
30+
export * from '../lib/service/fullethereumservice'
3131
export * from '../lib/service/lightethereumservice'
3232

3333
// Synchronizer
3434
export * from '../lib/sync/sync'
35-
export * from '../lib/sync/fastsync'
35+
export * from '../lib/sync/fullsync'
3636
export * from '../lib/sync/lightsync'
3737

3838
// Utilities
@@ -47,7 +47,7 @@ export function createNode(args: any) {
4747
const options = {
4848
common: new Common({ chain: args.network ?? 'mainnet' }),
4949
servers: [new exports.Libp2pServer({ multiaddrs: [], ...args })],
50-
syncmode: args.syncmode ?? 'fast',
50+
syncmode: args.syncmode ?? 'full',
5151
db: level(args.db ?? 'ethereumjs'),
5252
logger: logger,
5353
}

lib/blockchain/chain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,6 @@ export class Chain extends EventEmitter {
324324
*/
325325
async getTd(hash: Buffer, num: BN): Promise<BN> {
326326
await this.open()
327-
return (this.blockchain as any)._getTd(hash, num)
327+
return this.blockchain.getTotalDifficulty(hash, num)
328328
}
329329
}

lib/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export interface ConfigOptions {
1313
common?: Common
1414

1515
/**
16-
* Synchronization mode ('fast' or 'light')
16+
* Synchronization mode ('full' or 'light')
1717
*
18-
* Default: 'fast'
18+
* Default: 'full'
1919
*/
2020
syncmode?: string
2121

@@ -101,7 +101,7 @@ export class Config {
101101
// hardfork awareness is implemented within the library
102102
// Also a fix for https://github.com/ethereumjs/ethereumjs-vm/issues/757
103103
public static readonly COMMON_DEFAULT = new Common({ chain: 'mainnet', hardfork: 'chainstart' })
104-
public static readonly SYNCMODE_DEFAULT = 'fast'
104+
public static readonly SYNCMODE_DEFAULT = 'full'
105105
public static readonly LIGHTSERV_DEFAULT = false
106106
public static readonly DATADIR_DEFAULT = `${os.homedir()}/Library/Ethereum`
107107
public static readonly TRANSPORTS_DEFAULT = ['rlpx:port=30303', 'libp2p']

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ exports.define('EthereumService', './service/ethereumservice')
6363
// Synchronizer
6464
exports.define('sync', './sync')
6565
exports.define('Synchronizer', './sync/sync')
66-
exports.define('FastSynchronizer', './sync/fastsync')
66+
exports.define('FullSynchronizer', './sync/fullsync')
6767
exports.define('LightSynchronizer', './sync/lightsync')
6868

6969
// Utilities

lib/node.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import events from 'events'
22
import { LevelUp } from 'levelup'
33
import { BootnodeLike } from './types'
44
import { Config } from './config'
5-
import { FastEthereumService, LightEthereumService } from './service'
5+
import { FullEthereumService, LightEthereumService } from './service'
66

77
export interface NodeOptions {
88
/* Client configuration */
@@ -29,7 +29,7 @@ export interface NodeOptions {
2929
export default class Node extends events.EventEmitter {
3030
public config: Config
3131

32-
public services: (FastEthereumService | LightEthereumService)[]
32+
public services: (FullEthereumService | LightEthereumService)[]
3333

3434
public opened: boolean
3535
public started: boolean
@@ -44,8 +44,8 @@ export default class Node extends events.EventEmitter {
4444
this.config = options.config
4545

4646
this.services = [
47-
this.config.syncmode === 'fast'
48-
? new FastEthereumService({
47+
this.config.syncmode === 'full'
48+
? new FullEthereumService({
4949
config: this.config,
5050
db: options.db,
5151
})
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { EthereumService, EthereumServiceOptions } from './ethereumservice'
2-
import { FastSynchronizer } from '../sync/fastsync'
2+
import { FullSynchronizer } from '../sync/fullsync'
33
import { EthProtocol } from '../net/protocol/ethprotocol'
44
import { LesProtocol } from '../net/protocol/lesprotocol'
55
import { Peer } from '../net/peer/peer'
66
import { Protocol, BoundProtocol } from '../net/protocol'
77

8-
interface FastEthereumServiceOptions extends EthereumServiceOptions {
8+
interface FullEthereumServiceOptions extends EthereumServiceOptions {
99
/* Serve LES requests (default: false) */
1010
lightserv?: boolean
1111
}
@@ -14,20 +14,20 @@ interface FastEthereumServiceOptions extends EthereumServiceOptions {
1414
* Ethereum service
1515
* @memberof module:service
1616
*/
17-
export class FastEthereumService extends EthereumService {
18-
public synchronizer: FastSynchronizer
17+
export class FullEthereumService extends EthereumService {
18+
public synchronizer: FullSynchronizer
1919
public lightserv: boolean
2020
/**
2121
* Create new ETH service
22-
* @param {FastEthereumServiceOptions}
22+
* @param {FullEthereumServiceOptions}
2323
*/
24-
constructor(options: FastEthereumServiceOptions) {
24+
constructor(options: FullEthereumServiceOptions) {
2525
super(options)
2626

2727
this.lightserv = options.lightserv ?? false
2828

29-
this.config.logger.info('Fast sync mode')
30-
this.synchronizer = new FastSynchronizer({
29+
this.config.logger.info('Full sync mode')
30+
this.synchronizer = new FullSynchronizer({
3131
config: this.config,
3232
pool: this.pool,
3333
chain: this.chain,

lib/service/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
export * from './service'
66
export * from './ethereumservice'
7-
export * from './fastethereumservice'
7+
export * from './fullethereumservice'
88
export * from './lightethereumservice'
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { Synchronizer, SynchronizerOptions } from './sync'
66
import { BlockFetcher } from './fetcher'
77

88
/**
9-
* Implements an ethereum fast sync synchronizer
9+
* Implements an ethereum full sync synchronizer
1010
* @memberof module:sync
1111
*/
12-
export class FastSynchronizer extends Synchronizer {
12+
export class FullSynchronizer extends Synchronizer {
1313
private blockFetcher: BlockFetcher | null
1414

1515
constructor(options: SynchronizerOptions) {
@@ -22,7 +22,7 @@ export class FastSynchronizer extends Synchronizer {
2222
* @return {string} type
2323
*/
2424
get type(): string {
25-
return 'fast'
25+
return 'full'
2626
}
2727

2828
/**
@@ -113,13 +113,10 @@ export class FastSynchronizer extends Synchronizer {
113113
// @ts-ignore: error: The operand of a 'delete' operator must be optional
114114
delete this.blockFetcher
115115
return true
116-
117-
// TO DO: Fetch state trie as well
118116
}
119117

120118
/**
121-
* Fetch all blocks from current height up to highest found amongst peers and
122-
* fetch entire recent state trie
119+
* Fetch all blocks from current height up to highest found amongst peers
123120
* @return Resolves with true if sync successful
124121
*/
125122
async sync(): Promise<boolean> {

0 commit comments

Comments
 (0)