Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
b17e4a87
Unverified
Commit
b17e4a87
authored
Mar 27, 2019
by
Péter Szilágyi
Committed by
GitHub
Mar 27, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19344 from karalabe/eth-remove-redundant-chainconfig
eth: remove redundant chain config fields
parents
dba336e6
ac3e7c9b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
25 deletions
+21
-25
api.go
eth/api.go
+4
-6
api_backend.go
eth/api_backend.go
+2
-2
api_tracer.go
eth/api_tracer.go
+9
-9
backend.go
eth/backend.go
+6
-8
No files found.
eth/api.go
View file @
b17e4a87
...
...
@@ -35,7 +35,6 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie"
...
...
@@ -70,7 +69,7 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func
(
api
*
PublicEthereumAPI
)
ChainId
()
hexutil
.
Uint64
{
chainID
:=
new
(
big
.
Int
)
if
config
:=
api
.
e
.
chainConfig
;
config
.
IsEIP155
(
api
.
e
.
blockchain
.
CurrentBlock
()
.
Number
())
{
if
config
:=
api
.
e
.
blockchain
.
Config
()
;
config
.
IsEIP155
(
api
.
e
.
blockchain
.
CurrentBlock
()
.
Number
())
{
chainID
=
config
.
ChainID
}
return
(
hexutil
.
Uint64
)(
chainID
.
Uint64
())
...
...
@@ -288,14 +287,13 @@ func (api *PublicDebugAPI) DumpBlock(blockNr rpc.BlockNumber) (state.Dump, error
// PrivateDebugAPI is the collection of Ethereum full node APIs exposed over
// the private debugging endpoint.
type
PrivateDebugAPI
struct
{
config
*
params
.
ChainConfig
eth
*
Ethereum
eth
*
Ethereum
}
// NewPrivateDebugAPI creates a new API definition for the full node-related
// private debug methods of the Ethereum service.
func
NewPrivateDebugAPI
(
config
*
params
.
ChainConfig
,
eth
*
Ethereum
)
*
PrivateDebugAPI
{
return
&
PrivateDebugAPI
{
config
:
config
,
eth
:
eth
}
func
NewPrivateDebugAPI
(
eth
*
Ethereum
)
*
PrivateDebugAPI
{
return
&
PrivateDebugAPI
{
eth
:
eth
}
}
// Preimage is a debug API function that returns the preimage for a sha3 hash, if known.
...
...
eth/api_backend.go
View file @
b17e4a87
...
...
@@ -44,7 +44,7 @@ type EthAPIBackend struct {
// ChainConfig returns the active chain configuration.
func
(
b
*
EthAPIBackend
)
ChainConfig
()
*
params
.
ChainConfig
{
return
b
.
eth
.
chainConfig
return
b
.
eth
.
blockchain
.
Config
()
}
func
(
b
*
EthAPIBackend
)
CurrentBlock
()
*
types
.
Block
{
...
...
@@ -130,7 +130,7 @@ func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *sta
vmError
:=
func
()
error
{
return
nil
}
context
:=
core
.
NewEVMContext
(
msg
,
header
,
b
.
eth
.
BlockChain
(),
nil
)
return
vm
.
NewEVM
(
context
,
state
,
b
.
eth
.
chainConfig
,
*
b
.
eth
.
blockchain
.
GetVMConfig
()),
vmError
,
nil
return
vm
.
NewEVM
(
context
,
state
,
b
.
eth
.
blockchain
.
Config
()
,
*
b
.
eth
.
blockchain
.
GetVMConfig
()),
vmError
,
nil
}
func
(
b
*
EthAPIBackend
)
SubscribeRemovedLogsEvent
(
ch
chan
<-
core
.
RemovedLogsEvent
)
event
.
Subscription
{
...
...
eth/api_tracer.go
View file @
b17e4a87
...
...
@@ -201,7 +201,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
// Fetch and execute the next block trace tasks
for
task
:=
range
tasks
{
signer
:=
types
.
MakeSigner
(
api
.
config
,
task
.
block
.
Number
())
signer
:=
types
.
MakeSigner
(
api
.
eth
.
blockchain
.
Config
()
,
task
.
block
.
Number
())
// Trace all the transactions contained within
for
i
,
tx
:=
range
task
.
block
.
Transactions
()
{
...
...
@@ -295,7 +295,7 @@ func (api *PrivateDebugAPI) traceChain(ctx context.Context, start, end *types.Bl
break
}
// Finalize the state so any modifications are written to the trie
root
,
err
:=
statedb
.
Commit
(
api
.
eth
.
chainConfig
.
IsEIP158
(
block
.
Number
()))
root
,
err
:=
statedb
.
Commit
(
api
.
eth
.
blockchain
.
Config
()
.
IsEIP158
(
block
.
Number
()))
if
err
!=
nil
{
failed
=
err
break
...
...
@@ -460,7 +460,7 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block,
}
// Execute all the transaction contained within the block concurrently
var
(
signer
=
types
.
MakeSigner
(
api
.
config
,
block
.
Number
())
signer
=
types
.
MakeSigner
(
api
.
eth
.
blockchain
.
Config
()
,
block
.
Number
())
txs
=
block
.
Transactions
()
results
=
make
([]
*
txTraceResult
,
len
(
txs
))
...
...
@@ -501,7 +501,7 @@ func (api *PrivateDebugAPI) traceBlock(ctx context.Context, block *types.Block,
msg
,
_
:=
tx
.
AsMessage
(
signer
)
vmctx
:=
core
.
NewEVMContext
(
msg
,
block
.
Header
(),
api
.
eth
.
blockchain
,
nil
)
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
config
,
vm
.
Config
{})
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
eth
.
blockchain
.
Config
()
,
vm
.
Config
{})
if
_
,
_
,
_
,
err
:=
core
.
ApplyMessage
(
vmenv
,
msg
,
new
(
core
.
GasPool
)
.
AddGas
(
msg
.
Gas
()));
err
!=
nil
{
failed
=
err
break
...
...
@@ -561,7 +561,7 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
// Execute transaction, either tracing all or just the requested one
var
(
signer
=
types
.
MakeSigner
(
api
.
config
,
block
.
Number
())
signer
=
types
.
MakeSigner
(
api
.
eth
.
blockchain
.
Config
()
,
block
.
Number
())
dumps
[]
string
)
for
i
,
tx
:=
range
block
.
Transactions
()
{
...
...
@@ -595,7 +595,7 @@ func (api *PrivateDebugAPI) standardTraceBlockToFile(ctx context.Context, block
}
}
// Execute the transaction and flush any traces to disk
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
config
,
vmConf
)
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
eth
.
blockchain
.
Config
()
,
vmConf
)
_
,
_
,
_
,
err
=
core
.
ApplyMessage
(
vmenv
,
msg
,
new
(
core
.
GasPool
)
.
AddGas
(
msg
.
Gas
()))
if
writer
!=
nil
{
writer
.
Flush
()
...
...
@@ -756,7 +756,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
tracer
=
vm
.
NewStructLogger
(
config
.
LogConfig
)
}
// Run the transaction with tracing enabled.
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
config
,
vm
.
Config
{
Debug
:
true
,
Tracer
:
tracer
})
vmenv
:=
vm
.
NewEVM
(
vmctx
,
statedb
,
api
.
eth
.
blockchain
.
Config
()
,
vm
.
Config
{
Debug
:
true
,
Tracer
:
tracer
})
ret
,
gas
,
failed
,
err
:=
core
.
ApplyMessage
(
vmenv
,
message
,
new
(
core
.
GasPool
)
.
AddGas
(
message
.
Gas
()))
if
err
!=
nil
{
...
...
@@ -796,7 +796,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
return
nil
,
vm
.
Context
{},
nil
,
err
}
// Recompute transactions up to the target index.
signer
:=
types
.
MakeSigner
(
api
.
config
,
block
.
Number
())
signer
:=
types
.
MakeSigner
(
api
.
eth
.
blockchain
.
Config
()
,
block
.
Number
())
for
idx
,
tx
:=
range
block
.
Transactions
()
{
// Assemble the transaction call message and return if the requested offset
...
...
@@ -806,7 +806,7 @@ func (api *PrivateDebugAPI) computeTxEnv(blockHash common.Hash, txIndex int, ree
return
msg
,
context
,
statedb
,
nil
}
// Not yet the searched for transaction, execute on top of the current state
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
api
.
config
,
vm
.
Config
{})
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
api
.
eth
.
blockchain
.
Config
()
,
vm
.
Config
{})
if
_
,
_
,
_
,
err
:=
core
.
ApplyMessage
(
vmenv
,
msg
,
new
(
core
.
GasPool
)
.
AddGas
(
tx
.
Gas
()));
err
!=
nil
{
return
nil
,
vm
.
Context
{},
nil
,
fmt
.
Errorf
(
"transaction %#x failed: %v"
,
tx
.
Hash
(),
err
)
}
...
...
eth/backend.go
View file @
b17e4a87
...
...
@@ -61,8 +61,7 @@ type LesServer interface {
// Ethereum implements the Ethereum full node service.
type
Ethereum
struct
{
config
*
Config
chainConfig
*
params
.
ChainConfig
config
*
Config
// Channel for shutting down the service
shutdownChan
chan
bool
// Channel for shutting down the Ethereum
...
...
@@ -134,7 +133,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
eth
:=
&
Ethereum
{
config
:
config
,
chainDb
:
chainDb
,
chainConfig
:
chainConfig
,
eventMux
:
ctx
.
EventMux
,
accountManager
:
ctx
.
AccountManager
,
engine
:
CreateConsensusEngine
(
ctx
,
chainConfig
,
&
config
.
Ethash
,
config
.
MinerNotify
,
config
.
MinerNoverify
,
chainDb
),
...
...
@@ -169,7 +167,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
}
cacheConfig
=
&
core
.
CacheConfig
{
Disabled
:
config
.
NoPruning
,
TrieCleanLimit
:
config
.
TrieCleanCache
,
TrieDirtyLimit
:
config
.
TrieDirtyCache
,
TrieTimeLimit
:
config
.
TrieTimeout
}
)
eth
.
blockchain
,
err
=
core
.
NewBlockChain
(
chainDb
,
cacheConfig
,
eth
.
chainConfig
,
eth
.
engine
,
vmConfig
,
eth
.
shouldPreserve
)
eth
.
blockchain
,
err
=
core
.
NewBlockChain
(
chainDb
,
cacheConfig
,
chainConfig
,
eth
.
engine
,
vmConfig
,
eth
.
shouldPreserve
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -184,13 +182,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if
config
.
TxPool
.
Journal
!=
""
{
config
.
TxPool
.
Journal
=
ctx
.
ResolvePath
(
config
.
TxPool
.
Journal
)
}
eth
.
txPool
=
core
.
NewTxPool
(
config
.
TxPool
,
eth
.
chainConfig
,
eth
.
blockchain
)
eth
.
txPool
=
core
.
NewTxPool
(
config
.
TxPool
,
chainConfig
,
eth
.
blockchain
)
if
eth
.
protocolManager
,
err
=
NewProtocolManager
(
eth
.
chainConfig
,
config
.
SyncMode
,
config
.
NetworkId
,
eth
.
eventMux
,
eth
.
txPool
,
eth
.
engine
,
eth
.
blockchain
,
chainDb
,
config
.
Whitelist
);
err
!=
nil
{
if
eth
.
protocolManager
,
err
=
NewProtocolManager
(
chainConfig
,
config
.
SyncMode
,
config
.
NetworkId
,
eth
.
eventMux
,
eth
.
txPool
,
eth
.
engine
,
eth
.
blockchain
,
chainDb
,
config
.
Whitelist
);
err
!=
nil
{
return
nil
,
err
}
eth
.
miner
=
miner
.
New
(
eth
,
eth
.
chainConfig
,
eth
.
EventMux
(),
eth
.
engine
,
config
.
MinerRecommit
,
config
.
MinerGasFloor
,
config
.
MinerGasCeil
,
eth
.
isLocalBlock
)
eth
.
miner
=
miner
.
New
(
eth
,
chainConfig
,
eth
.
EventMux
(),
eth
.
engine
,
config
.
MinerRecommit
,
config
.
MinerGasFloor
,
config
.
MinerGasCeil
,
eth
.
isLocalBlock
)
eth
.
miner
.
SetExtra
(
makeExtraData
(
config
.
MinerExtraData
))
eth
.
APIBackend
=
&
EthAPIBackend
{
eth
,
nil
}
...
...
@@ -302,7 +300,7 @@ func (s *Ethereum) APIs() []rpc.API {
},
{
Namespace
:
"debug"
,
Version
:
"1.0"
,
Service
:
NewPrivateDebugAPI
(
s
.
chainConfig
,
s
),
Service
:
NewPrivateDebugAPI
(
s
),
},
{
Namespace
:
"net"
,
Version
:
"1.0"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment