Skip to content

Commit 685f59f

Browse files
committed
Merge branch 'master' of github.com:jpmorganchase/quorum
2 parents 27bfed7 + 9111ffd commit 685f59f

File tree

4 files changed

+89
-16
lines changed

4 files changed

+89
-16
lines changed

cmd/geth/chaincmd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ be gzipped.`,
109109
},
110110
Category: "BLOCKCHAIN COMMANDS",
111111
Description: `
112-
The import-preimages command imports hash preimages from an RLP encoded stream.`,
112+
The import-preimages command imports hash preimages from an RLP encoded stream.`,
113113
}
114114
exportPreimagesCommand = cli.Command{
115115
Action: utils.MigrateFlags(exportPreimages),
@@ -232,7 +232,7 @@ func importChain(ctx *cli.Context) error {
232232
utils.Fatalf("This command requires an argument.")
233233
}
234234
stack := makeFullNode(ctx)
235-
chain, chainDb := utils.MakeChain(ctx, stack)
235+
chain, chainDb := utils.MakeChain(ctx, stack, true)
236236
defer chainDb.Close()
237237

238238
// Start periodically gathering memory profiles
@@ -326,7 +326,7 @@ func exportChain(ctx *cli.Context) error {
326326
utils.Fatalf("This command requires an argument.")
327327
}
328328
stack := makeFullNode(ctx)
329-
chain, _ := utils.MakeChain(ctx, stack)
329+
chain, _ := utils.MakeChain(ctx, stack, true)
330330
start := time.Now()
331331

332332
var err error
@@ -392,7 +392,7 @@ func copyDb(ctx *cli.Context) error {
392392
}
393393
// Initialize a new chain for the running node to sync into
394394
stack := makeFullNode(ctx)
395-
chain, chainDb := utils.MakeChain(ctx, stack)
395+
chain, chainDb := utils.MakeChain(ctx, stack, false)
396396

397397
syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
398398
dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil)
@@ -464,7 +464,7 @@ func removeDB(ctx *cli.Context) error {
464464

465465
func dump(ctx *cli.Context) error {
466466
stack := makeFullNode(ctx)
467-
chain, chainDb := utils.MakeChain(ctx, stack)
467+
chain, chainDb := utils.MakeChain(ctx, stack, false)
468468
for _, arg := range ctx.Args() {
469469
var block *types.Block
470470
if hashish(arg) {

cmd/utils/flags.go

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ import (
2929
"path/filepath"
3030
"strconv"
3131
"strings"
32-
33-
"github.com/ethereum/go-ethereum/permission"
34-
"github.com/ethereum/go-ethereum/plugin"
35-
3632
"time"
3733

3834
"github.com/ethereum/go-ethereum/accounts"
@@ -42,7 +38,10 @@ import (
4238
"github.com/ethereum/go-ethereum/consensus"
4339
"github.com/ethereum/go-ethereum/consensus/clique"
4440
"github.com/ethereum/go-ethereum/consensus/ethash"
41+
"github.com/ethereum/go-ethereum/consensus/istanbul"
42+
istanbulBackend "github.com/ethereum/go-ethereum/consensus/istanbul/backend"
4543
"github.com/ethereum/go-ethereum/core"
44+
"github.com/ethereum/go-ethereum/core/rawdb"
4645
"github.com/ethereum/go-ethereum/core/state"
4746
"github.com/ethereum/go-ethereum/core/vm"
4847
"github.com/ethereum/go-ethereum/crypto"
@@ -63,6 +62,8 @@ import (
6362
"github.com/ethereum/go-ethereum/p2p/nat"
6463
"github.com/ethereum/go-ethereum/p2p/netutil"
6564
"github.com/ethereum/go-ethereum/params"
65+
"github.com/ethereum/go-ethereum/permission"
66+
"github.com/ethereum/go-ethereum/plugin"
6667
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
6768
"gopkg.in/urfave/cli.v1"
6869
)
@@ -609,7 +610,7 @@ var (
609610
Value: 50400,
610611
}
611612
RaftDNSEnabledFlag = cli.BoolFlag{
612-
Name: "raftdnsenable",
613+
Name: "raftdnsenable",
613614
Usage: "Enable DNS resolution of peers",
614615
}
615616

@@ -1292,7 +1293,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
12921293
}
12931294
cfg.NoPruning = ctx.GlobalString(GCModeFlag.Name) == "archive"
12941295

1295-
12961296
if ctx.GlobalIsSet(CacheFlag.Name) || ctx.GlobalIsSet(CacheGCFlag.Name) {
12971297
cfg.TrieCache = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100
12981298
}
@@ -1545,17 +1545,41 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
15451545
}
15461546

15471547
// MakeChain creates a chain manager from set command line flags.
1548-
func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
1549-
var err error
1548+
func MakeChain(ctx *cli.Context, stack *node.Node, useExist bool) (chain *core.BlockChain, chainDb ethdb.Database) {
1549+
var (
1550+
config *params.ChainConfig
1551+
err error
1552+
)
15501553
chainDb = MakeChainDatabase(ctx, stack)
15511554

1552-
config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx))
1553-
if err != nil {
1554-
Fatalf("%v", err)
1555+
if useExist {
1556+
stored := rawdb.ReadCanonicalHash(chainDb, 0)
1557+
if (stored == common.Hash{}) {
1558+
Fatalf("No existing genesis")
1559+
}
1560+
config = rawdb.ReadChainConfig(chainDb, stored)
1561+
} else {
1562+
config, _, err = core.SetupGenesisBlock(chainDb, MakeGenesis(ctx))
1563+
if err != nil {
1564+
Fatalf("%v", err)
1565+
}
15551566
}
1567+
15561568
var engine consensus.Engine
15571569
if config.Clique != nil {
15581570
engine = clique.New(config.Clique, chainDb)
1571+
} else if config.Istanbul != nil {
1572+
// for IBFT
1573+
istanbulConfig := istanbul.DefaultConfig
1574+
if config.Istanbul.Epoch != 0 {
1575+
istanbulConfig.Epoch = config.Istanbul.Epoch
1576+
}
1577+
istanbulConfig.ProposerPolicy = istanbul.ProposerPolicy(config.Istanbul.ProposerPolicy)
1578+
istanbulConfig.Ceil2Nby3Block = config.Istanbul.Ceil2Nby3Block
1579+
engine = istanbulBackend.New(istanbulConfig, stack.GetNodeKey(), chainDb)
1580+
} else if config.IsQuorum {
1581+
// for Raft
1582+
engine = ethash.NewFullFaker()
15591583
} else {
15601584
engine = ethash.NewFaker()
15611585
if !ctx.GlobalBool(FakePoWFlag.Name) {

docs/Features/import-export.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Backup & Restore of Quorum Nodes
2+
3+
Quorum supports export and import of chain data with built in tooling. This is an effective node backup mechanism
4+
adapted for the specific needs of Quorum such as private transactions, permissioning, and supported consensus
5+
algorithms.
6+
7+
8+
!!! note
9+
Quorum chain data import and export must run after `geth` process is stopped.
10+
11+
### Node Backup (Export)
12+
13+
Backup functionality mimics original `geth export` command. Quorum export accepts 3 arguments:
14+
15+
1. Export file name **required**
16+
3. First block
17+
4. Last block *are optional but must be provided together when used*
18+
19+
##### Sample command
20+
21+
`geth export <export file name> --datadir <geth data dir>`
22+
23+
### Node Restore (Import)
24+
25+
Restore functionality mimics original `geth import` command but requires transaction manager environment variable.
26+
Quorum import must run on a new node with an initialized `--datadir` after `geth init` has been executed. Restore
27+
supports arbitrary number of import files (at least 1).
28+
29+
!!! warning
30+
If private transactions are used in the chain data, Private Transaction Manager process for the original exported
31+
node must be running on the PTM ipc endpoint during import chain. Otherwise, nil pointer exceptions will be raised.
32+
33+
##### Sample command
34+
35+
`PRIVATE_CONFIG=<PTM ipc endpoint> geth import <import file names...> --datadir <geth data dir>`
36+
37+
### Special Consensus Considerations
38+
39+
##### IBFT
40+
41+
IBFT block data contains sealer information in the header, to restore a copy of exported chain data, the new node must
42+
be initialized use an IBFT genesis file with exact same validator set encoded in extra data field as original exported
43+
node's genesis.
44+
45+
##### Raft
46+
47+
Raft backup do not account for current Raft state. An exported chain data from a Raft cluster can only be used by
48+
new nodes being added to that same cluster only.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ nav:
9696
- How-To Guides:
9797
- Adding new nodes: How-To-Guides/adding_nodes.md
9898
- Adding IBFT validators: How-To-Guides/add_ibft_validator.md
99+
- Backup & Restore: Features/import-export.md
99100
- Product Roadmap: roadmap.md
100101
- FAQ: FAQ.md
101102

0 commit comments

Comments
 (0)