mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-04 00:05:22 +00:00
Remove unneeded nimbus imports (#2154)
Also specifically select from the still required nimbus imports.
This commit is contained in:
parent
d12300ecc9
commit
1512f95067
@ -15,7 +15,6 @@ import
|
|||||||
beacon_chain/spec/forks,
|
beacon_chain/spec/forks,
|
||||||
beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
|
beacon_chain/spec/datatypes/[phase0, altair, bellatrix],
|
||||||
beacon_chain/gossip_processing/light_client_processor,
|
beacon_chain/gossip_processing/light_client_processor,
|
||||||
../../../nimbus/constants,
|
|
||||||
../wire/[portal_protocol, portal_stream, portal_protocol_config],
|
../wire/[portal_protocol, portal_stream, portal_protocol_config],
|
||||||
"."/[beacon_content, beacon_db, beacon_chain_historical_summaries]
|
"."/[beacon_content, beacon_db, beacon_chain_historical_summaries]
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import
|
|||||||
../../common/common_types,
|
../../common/common_types,
|
||||||
../../database/content_db,
|
../../database/content_db,
|
||||||
../../network_metadata,
|
../../network_metadata,
|
||||||
../../../nimbus/constants,
|
|
||||||
../wire/[portal_protocol, portal_stream, portal_protocol_config],
|
../wire/[portal_protocol, portal_stream, portal_protocol_config],
|
||||||
"."/[history_content, accumulator, beacon_chain_historical_roots]
|
"."/[history_content, accumulator, beacon_chain_historical_roots]
|
||||||
|
|
||||||
|
@ -10,32 +10,37 @@
|
|||||||
import
|
import
|
||||||
std/[times, sequtils, strutils, typetraits],
|
std/[times, sequtils, strutils, typetraits],
|
||||||
json_rpc/[rpcproxy, rpcserver],
|
json_rpc/[rpcproxy, rpcserver],
|
||||||
web3/[conversions], # sigh, for FixedBytes marshalling
|
web3/conversions, # sigh, for FixedBytes marshalling
|
||||||
|
web3/eth_api_types,
|
||||||
eth/[common/eth_types, rlp],
|
eth/[common/eth_types, rlp],
|
||||||
beacon_chain/spec/forks,
|
beacon_chain/spec/forks,
|
||||||
../../nimbus/rpc/[rpc_types, filters],
|
|
||||||
../../nimbus/transaction,
|
|
||||||
# TODO: this is a bit weird but having this import makes beacon_light_client
|
|
||||||
# to fail compilation due throwing undeclared `CatchableError` in
|
|
||||||
# `vendor/nimbus-eth2/beacon_chain/spec/keystore.nim`. This is most probably
|
|
||||||
# caused by `readValue` clashing ?
|
|
||||||
# ../../nimbus/common/chain_config
|
|
||||||
../network/history/[history_network, history_content],
|
../network/history/[history_network, history_content],
|
||||||
../network/beacon/beacon_light_client
|
../network/beacon/beacon_light_client
|
||||||
|
|
||||||
# Subset of Eth JSON-RPC API: https://eth.wiki/json-rpc/API
|
from ../../nimbus/transaction import getSender, ValidationError
|
||||||
# Supported subset will eventually be found here:
|
from ../../nimbus/rpc/filters import headerBloomFilter, deriveLogs, filterLogs
|
||||||
# https://github.com/ethereum/stateless-ethereum-specs/blob/master/portal-network.md#json-rpc-api
|
from ../../nimbus/beacon/web3_eth_conv import w3Addr, w3Hash, ethHash
|
||||||
|
|
||||||
|
# Subset of Ethereum execution JSON-RPC API:
|
||||||
|
# https://ethereum.github.io/execution-apis/api-documentation/
|
||||||
|
#
|
||||||
|
# Currently supported subset:
|
||||||
|
# - eth_chainId
|
||||||
|
# - eth_getBlockByHash
|
||||||
|
# - eth_getBlockByNumber - Partially: only by tags and block numbers before TheMerge
|
||||||
|
# - eth_getBlockTransactionCountByHash
|
||||||
|
# - eth_getLogs - Partially: only requests by block hash
|
||||||
|
#
|
||||||
|
# In order to be able to use Fluffy as drop-in replacement for apps/tools that
|
||||||
|
# use the JSON RPC API, unsupported methods can be forwarded to a configured
|
||||||
|
# web3 provider.
|
||||||
|
# Supported methods will be handled by Fluffy by making use of the Portal network,
|
||||||
|
# unsupported methods will be proxied to the given web3 provider.
|
||||||
#
|
#
|
||||||
# In order to already support these calls before every part of the Portal
|
|
||||||
# Network is up, one plan is to get the data directly from an external client
|
|
||||||
# through RPC calls. Practically just playing a proxy to that client.
|
|
||||||
# Can be done by just forwarding the rpc call, or by adding a call here, but
|
|
||||||
# that would introduce a unnecessary serializing/deserializing step.
|
|
||||||
|
|
||||||
# Some similar code as from nimbus `rpc_utils`, but avoiding that import as it
|
# Some similar code as from nimbus `rpc_utils`, but avoiding that import as it
|
||||||
# brings in a lot more. Should restructure `rpc_utils` a bit before using that.
|
# brings in a lot more. Should restructure `rpc_utils` a bit before using that.
|
||||||
func toHash*(value: rpc_types.Hash256): eth_types.Hash256 =
|
func toHash*(value: eth_api_types.Hash256): eth_types.Hash256 =
|
||||||
result.data = value.bytes
|
result.data = value.bytes
|
||||||
|
|
||||||
func init*(
|
func init*(
|
||||||
@ -46,7 +51,7 @@ func init*(
|
|||||||
): T {.raises: [ValidationError].} =
|
): T {.raises: [ValidationError].} =
|
||||||
TransactionObject(
|
TransactionObject(
|
||||||
blockHash: some(w3Hash header.blockHash),
|
blockHash: some(w3Hash header.blockHash),
|
||||||
blockNumber: some(rpc_types.BlockNumber(header.blockNumber.truncate(uint64))),
|
blockNumber: some(eth_api_types.BlockNumber(header.blockNumber.truncate(uint64))),
|
||||||
`from`: w3Addr tx.getSender(),
|
`from`: w3Addr tx.getSender(),
|
||||||
gas: Quantity(tx.gasLimit),
|
gas: Quantity(tx.gasLimit),
|
||||||
gasPrice: Quantity(tx.gasPrice),
|
gasPrice: Quantity(tx.gasPrice),
|
||||||
@ -76,7 +81,7 @@ func init*(
|
|||||||
let blockHash = header.blockHash
|
let blockHash = header.blockHash
|
||||||
|
|
||||||
var blockObject = BlockObject(
|
var blockObject = BlockObject(
|
||||||
number: rpc_types.BlockNumber(header.blockNumber.truncate(uint64)),
|
number: eth_api_types.BlockNumber(header.blockNumber.truncate(uint64)),
|
||||||
hash: w3Hash blockHash,
|
hash: w3Hash blockHash,
|
||||||
parentHash: w3Hash header.parentHash,
|
parentHash: w3Hash header.parentHash,
|
||||||
nonce: some(FixedBytes[8](header.nonce)),
|
nonce: some(FixedBytes[8](header.nonce)),
|
||||||
@ -102,7 +107,7 @@ func init*(
|
|||||||
|
|
||||||
if not isUncle:
|
if not isUncle:
|
||||||
blockObject.uncles = body.uncles.map(
|
blockObject.uncles = body.uncles.map(
|
||||||
proc(h: BlockHeader): rpc_types.Hash256 =
|
proc(h: eth_types.BlockHeader): eth_api_types.Hash256 =
|
||||||
w3Hash h.blockHash
|
w3Hash h.blockHash
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -119,8 +124,6 @@ func init*(
|
|||||||
blockObject
|
blockObject
|
||||||
|
|
||||||
proc installEthApiHandlers*(
|
proc installEthApiHandlers*(
|
||||||
# Currently only HistoryNetwork needed, later we might want a master object
|
|
||||||
# holding all the networks.
|
|
||||||
rpcServerWithProxy: var RpcProxy,
|
rpcServerWithProxy: var RpcProxy,
|
||||||
historyNetwork: HistoryNetwork,
|
historyNetwork: HistoryNetwork,
|
||||||
beaconLightClient: Opt[LightClient],
|
beaconLightClient: Opt[LightClient],
|
||||||
@ -208,7 +211,7 @@ proc installEthApiHandlers*(
|
|||||||
return Quantity(uint64(1))
|
return Quantity(uint64(1))
|
||||||
|
|
||||||
rpcServerWithProxy.rpc("eth_getBlockByHash") do(
|
rpcServerWithProxy.rpc("eth_getBlockByHash") do(
|
||||||
data: rpc_types.Hash256, fullTransactions: bool
|
data: eth_api_types.Hash256, fullTransactions: bool
|
||||||
) -> Option[BlockObject]:
|
) -> Option[BlockObject]:
|
||||||
## Returns information about a block by hash.
|
## Returns information about a block by hash.
|
||||||
##
|
##
|
||||||
@ -225,7 +228,7 @@ proc installEthApiHandlers*(
|
|||||||
return some(BlockObject.init(header, body, fullTransactions))
|
return some(BlockObject.init(header, body, fullTransactions))
|
||||||
|
|
||||||
rpcServerWithProxy.rpc("eth_getBlockByNumber") do(
|
rpcServerWithProxy.rpc("eth_getBlockByNumber") do(
|
||||||
quantityTag: BlockTag, fullTransactions: bool
|
quantityTag: RtBlockIdentifier, fullTransactions: bool
|
||||||
) -> Option[BlockObject]:
|
) -> Option[BlockObject]:
|
||||||
if quantityTag.kind == bidAlias:
|
if quantityTag.kind == bidAlias:
|
||||||
let tag = quantityTag.alias.toLowerAscii
|
let tag = quantityTag.alias.toLowerAscii
|
||||||
@ -283,7 +286,7 @@ proc installEthApiHandlers*(
|
|||||||
return some(BlockObject.init(header, body, fullTransactions))
|
return some(BlockObject.init(header, body, fullTransactions))
|
||||||
|
|
||||||
rpcServerWithProxy.rpc("eth_getBlockTransactionCountByHash") do(
|
rpcServerWithProxy.rpc("eth_getBlockTransactionCountByHash") do(
|
||||||
data: rpc_types.Hash256
|
data: eth_api_types.Hash256
|
||||||
) -> Quantity:
|
) -> Quantity:
|
||||||
## Returns the number of transactions in a block from a block matching the
|
## Returns the number of transactions in a block from a block matching the
|
||||||
## given block hash.
|
## given block hash.
|
||||||
@ -310,7 +313,7 @@ proc installEthApiHandlers*(
|
|||||||
|
|
||||||
rpcServerWithProxy.rpc("eth_getLogs") do(
|
rpcServerWithProxy.rpc("eth_getLogs") do(
|
||||||
filterOptions: FilterOptions
|
filterOptions: FilterOptions
|
||||||
) -> seq[FilterLog]:
|
) -> seq[LogObject]:
|
||||||
if filterOptions.blockHash.isNone():
|
if filterOptions.blockHash.isNone():
|
||||||
# Currently only queries by blockhash are supported.
|
# Currently only queries by blockhash are supported.
|
||||||
# To support range queries the Indicies network is required.
|
# To support range queries the Indicies network is required.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user