good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
2be8ee29
Commit
2be8ee29
authored
Apr 1, 2020
by
atvanguard
Browse files
Options
Downloads
Patches
Plain Diff
fix: Start Ethereum service in a manner such that ethApi is instantiated for bor while import
parent
a14bfacf
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/bor/chaincmd.go
+6
-5
6 additions, 5 deletions
cmd/bor/chaincmd.go
cmd/utils/flags.go
+58
-3
58 additions, 3 deletions
cmd/utils/flags.go
eth/backend.go
+4
-0
4 additions, 0 deletions
eth/backend.go
with
68 additions
and
8 deletions
cmd/bor/chaincmd.go
+
6
−
5
View file @
2be8ee29
...
@@ -61,7 +61,7 @@ It expects the genesis file as argument.`,
...
@@ -61,7 +61,7 @@ It expects the genesis file as argument.`,
Action
:
utils
.
MigrateFlags
(
importChain
),
Action
:
utils
.
MigrateFlags
(
importChain
),
Name
:
"import"
,
Name
:
"import"
,
Usage
:
"Import a blockchain file"
,
Usage
:
"Import a blockchain file"
,
ArgsUsage
:
"<filename> (<filename 2> ... <filename N>) "
,
ArgsUsage
:
"<filename> (<filename 2> ... <filename N>)
<genesisPath>
"
,
Flags
:
[]
cli
.
Flag
{
Flags
:
[]
cli
.
Flag
{
utils
.
DataDirFlag
,
utils
.
DataDirFlag
,
utils
.
CacheFlag
,
utils
.
CacheFlag
,
...
@@ -228,8 +228,8 @@ func initGenesis(ctx *cli.Context) error {
...
@@ -228,8 +228,8 @@ func initGenesis(ctx *cli.Context) error {
}
}
func
importChain
(
ctx
*
cli
.
Context
)
error
{
func
importChain
(
ctx
*
cli
.
Context
)
error
{
if
len
(
ctx
.
Args
())
<
1
{
if
len
(
ctx
.
Args
())
<
2
{
utils
.
Fatalf
(
"This command requires a
n
argument."
)
utils
.
Fatalf
(
"This command requires a
tleast 2
argument
s
."
)
}
}
stack
:=
makeFullNode
(
ctx
)
stack
:=
makeFullNode
(
ctx
)
defer
stack
.
Close
()
defer
stack
.
Close
()
...
@@ -255,12 +255,13 @@ func importChain(ctx *cli.Context) error {
...
@@ -255,12 +255,13 @@ func importChain(ctx *cli.Context) error {
// Import the chain
// Import the chain
start
:=
time
.
Now
()
start
:=
time
.
Now
()
if
len
(
ctx
.
Args
())
==
1
{
// ArgsUsage: "<filename> (<filename 2> ... <filename N>) <genesisPath>",
if
len
(
ctx
.
Args
())
==
2
{
if
err
:=
utils
.
ImportChain
(
chain
,
ctx
.
Args
()
.
First
());
err
!=
nil
{
if
err
:=
utils
.
ImportChain
(
chain
,
ctx
.
Args
()
.
First
());
err
!=
nil
{
log
.
Error
(
"Import error"
,
"err"
,
err
)
log
.
Error
(
"Import error"
,
"err"
,
err
)
}
}
}
else
{
}
else
{
for
_
,
arg
:=
range
ctx
.
Args
()
{
for
_
,
arg
:=
range
ctx
.
Args
()
[
:
len
(
ctx
.
Args
())
-
1
]
{
if
err
:=
utils
.
ImportChain
(
chain
,
arg
);
err
!=
nil
{
if
err
:=
utils
.
ImportChain
(
chain
,
arg
);
err
!=
nil
{
log
.
Error
(
"Import error"
,
"file"
,
arg
,
"err"
,
err
)
log
.
Error
(
"Import error"
,
"file"
,
arg
,
"err"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
cmd/utils/flags.go
+
58
−
3
View file @
2be8ee29
...
@@ -19,6 +19,7 @@ package utils
...
@@ -19,6 +19,7 @@ package utils
import
(
import
(
"crypto/ecdsa"
"crypto/ecdsa"
"encoding/json"
"errors"
"errors"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
...
@@ -34,6 +35,7 @@ import (
...
@@ -34,6 +35,7 @@ import (
"github.com/maticnetwork/bor/common"
"github.com/maticnetwork/bor/common"
"github.com/maticnetwork/bor/common/fdlimit"
"github.com/maticnetwork/bor/common/fdlimit"
"github.com/maticnetwork/bor/consensus"
"github.com/maticnetwork/bor/consensus"
"github.com/maticnetwork/bor/consensus/bor"
"github.com/maticnetwork/bor/consensus/bor"
"github.com/maticnetwork/bor/consensus/clique"
"github.com/maticnetwork/bor/consensus/clique"
"github.com/maticnetwork/bor/consensus/ethash"
"github.com/maticnetwork/bor/consensus/ethash"
...
@@ -47,6 +49,8 @@ import (
...
@@ -47,6 +49,8 @@ import (
"github.com/maticnetwork/bor/ethdb"
"github.com/maticnetwork/bor/ethdb"
"github.com/maticnetwork/bor/ethstats"
"github.com/maticnetwork/bor/ethstats"
"github.com/maticnetwork/bor/graphql"
"github.com/maticnetwork/bor/graphql"
pcsclite
"github.com/gballet/go-libpcsclite"
"github.com/maticnetwork/bor/les"
"github.com/maticnetwork/bor/les"
"github.com/maticnetwork/bor/log"
"github.com/maticnetwork/bor/log"
"github.com/maticnetwork/bor/metrics"
"github.com/maticnetwork/bor/metrics"
...
@@ -61,7 +65,6 @@ import (
...
@@ -61,7 +65,6 @@ import (
"github.com/maticnetwork/bor/params"
"github.com/maticnetwork/bor/params"
"github.com/maticnetwork/bor/rpc"
"github.com/maticnetwork/bor/rpc"
whisper
"github.com/maticnetwork/bor/whisper/whisperv6"
whisper
"github.com/maticnetwork/bor/whisper/whisperv6"
pcsclite
"github.com/gballet/go-libpcsclite"
cli
"gopkg.in/urfave/cli.v1"
cli
"gopkg.in/urfave/cli.v1"
)
)
...
@@ -1658,19 +1661,68 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
...
@@ -1658,19 +1661,68 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
return
genesis
return
genesis
}
}
func
getGenesis
(
ctx
*
cli
.
Context
)
*
core
.
Genesis
{
genesisPath
:=
ctx
.
Args
()
.
Get
(
len
(
ctx
.
Args
())
-
1
)
if
genesisPath
==
""
{
return
nil
}
file
,
_
:=
os
.
Open
(
genesisPath
)
defer
file
.
Close
()
genesis
:=
new
(
core
.
Genesis
)
json
.
NewDecoder
(
file
)
.
Decode
(
genesis
)
return
genesis
}
// MakeChain creates a chain manager from set command line flags.
// MakeChain creates a chain manager from set command line flags.
func
MakeChain
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
)
(
chain
*
core
.
BlockChain
,
chainDb
ethdb
.
Database
)
{
func
MakeChain
(
ctx
*
cli
.
Context
,
stack
*
node
.
Node
)
(
chain
*
core
.
BlockChain
,
chainDb
ethdb
.
Database
)
{
genesis
:=
getGenesis
(
ctx
)
if
genesis
==
nil
{
genesis
=
MakeGenesis
(
ctx
)
}
var
err
error
var
err
error
chainDb
=
MakeChainDatabase
(
ctx
,
stack
)
chainDb
=
MakeChainDatabase
(
ctx
,
stack
)
config
,
_
,
err
:=
core
.
SetupGenesisBlock
(
chainDb
,
MakeG
enesis
(
ctx
)
)
config
,
_
,
err
:=
core
.
SetupGenesisBlock
(
chainDb
,
g
enesis
)
if
err
!=
nil
{
if
err
!=
nil
{
Fatalf
(
"%v"
,
err
)
Fatalf
(
"%v"
,
err
)
}
}
var
engine
consensus
.
Engine
var
engine
consensus
.
Engine
var
ethereum
*
eth
.
Ethereum
if
config
.
Clique
!=
nil
{
if
config
.
Clique
!=
nil
{
engine
=
clique
.
New
(
config
.
Clique
,
chainDb
)
engine
=
clique
.
New
(
config
.
Clique
,
chainDb
)
}
else
if
config
.
Bor
!=
nil
{
}
else
if
config
.
Bor
!=
nil
{
engine
=
bor
.
New
(
config
,
chainDb
,
nil
)
cfg
:=
&
eth
.
Config
{
Genesis
:
genesis
}
workspace
,
err
:=
ioutil
.
TempDir
(
""
,
"console-tester-"
)
if
err
!=
nil
{
Fatalf
(
"failed to create temporary keystore: %v"
,
err
)
}
// Create a networkless protocol stack and start an Ethereum service within
stack
,
err
:=
node
.
New
(
&
node
.
Config
{
DataDir
:
workspace
,
UseLightweightKDF
:
true
,
Name
:
"console-tester"
})
if
err
!=
nil
{
Fatalf
(
"failed to create node: %v"
,
err
)
}
err
=
stack
.
Register
(
func
(
ctx
*
node
.
ServiceContext
)
(
node
.
Service
,
error
)
{
s
,
err
:=
eth
.
New
(
ctx
,
cfg
)
return
s
,
err
})
if
err
!=
nil
{
Fatalf
(
"failed to register Ethereum protocol: %v"
,
err
)
}
// Start the node and assemble the JavaScript console around it
if
err
=
stack
.
Start
();
err
!=
nil
{
Fatalf
(
"failed to start test stack: %v"
,
err
)
}
_
,
err
=
stack
.
Attach
()
if
err
!=
nil
{
Fatalf
(
"failed to attach to node: %v"
,
err
)
}
stack
.
Service
(
&
ethereum
)
engine
=
ethereum
.
Engine
()
.
(
*
bor
.
Bor
)
}
else
{
}
else
{
engine
=
ethash
.
NewFaker
()
engine
=
ethash
.
NewFaker
()
if
!
ctx
.
GlobalBool
(
FakePoWFlag
.
Name
)
{
if
!
ctx
.
GlobalBool
(
FakePoWFlag
.
Name
)
{
...
@@ -1702,6 +1754,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
...
@@ -1702,6 +1754,9 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
}
}
vmcfg
:=
vm
.
Config
{
EnablePreimageRecording
:
ctx
.
GlobalBool
(
VMEnableDebugFlag
.
Name
)}
vmcfg
:=
vm
.
Config
{
EnablePreimageRecording
:
ctx
.
GlobalBool
(
VMEnableDebugFlag
.
Name
)}
chain
,
err
=
core
.
NewBlockChain
(
chainDb
,
cache
,
config
,
engine
,
vmcfg
,
nil
)
chain
,
err
=
core
.
NewBlockChain
(
chainDb
,
cache
,
config
,
engine
,
vmcfg
,
nil
)
if
ethereum
!=
nil
{
ethereum
.
SetBlockchain
(
chain
)
}
if
err
!=
nil
{
if
err
!=
nil
{
Fatalf
(
"Can't create BlockChain: %v"
,
err
)
Fatalf
(
"Can't create BlockChain: %v"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
eth/backend.go
+
4
−
0
View file @
2be8ee29
...
@@ -231,6 +231,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
...
@@ -231,6 +231,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
return
eth
,
nil
return
eth
,
nil
}
}
func
(
s
*
Ethereum
)
SetBlockchain
(
blockchain
*
core
.
BlockChain
)
{
s
.
blockchain
=
blockchain
}
func
makeExtraData
(
extra
[]
byte
)
[]
byte
{
func
makeExtraData
(
extra
[]
byte
)
[]
byte
{
if
len
(
extra
)
==
0
{
if
len
(
extra
)
==
0
{
// create default extradata
// create default extradata
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment