Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions hive_integration/nodocker/engine/engine_env.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import
../../../nimbus/[
config,
constants,
core/sealer,
core/chain,
core/tx_pool,
core/tx_pool/tx_item,
Expand All @@ -45,7 +44,6 @@ type
com : CommonRef
node : EthereumNode
server : RpcHttpServer
sealer : SealingEngineRef
ttd : DifficultyInt
client : RpcHttpClient
sync : BeaconSyncRef
Expand Down Expand Up @@ -93,7 +91,7 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
chain = newChain(com)

com.initializeEmptyDb()
let txPool = TxPoolRef.new(com, conf.engineSigner)
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of this last arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, as a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, it appears, after POW has been removed more thoroughly, because this miner variable is also used for that purpose, and some tests still therefore refer to it. This requires more care than POA, because currently it appears to start in POW in several instances, then transition to POS almost, but not quite, immediately on startup.

It might be cleaner to address POW first, but ultimately, either ordering works, as long as there's not an expectation that POW mode produces blocks with non-zero miners in the meantime, which should be fine insofar as it doesn't seem important it produces block at all at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


node.addEthHandlerCapability(
node.peerPool,
Expand All @@ -117,9 +115,6 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
echo "Failed to create rpc server: ", error
quit(QuitFailure)

sealer = SealingEngineRef.new(
chain, ctx, conf.engineSigner,
txPool, EngineStopped)
sync = if com.ttd().isSome:
BeaconSyncRef.init(node, chain, ctx.rng, conf.maxPeers, id=conf.tcpPort.int)
else:
Expand All @@ -135,8 +130,6 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
if chainFile.len > 0:
if not importRlpBlock(chainFolder / chainFile, com):
quit(QuitFailure)
elif not enableAuth:
sealer.start()

server.start()

Expand All @@ -153,7 +146,6 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
com : com,
node : node,
server : server,
sealer : sealer,
client : client,
sync : sync,
txPool : txPool,
Expand All @@ -165,7 +157,6 @@ proc close*(env: EngineEnv) =
if not env.sync.isNil:
env.sync.stop()
waitFor env.client.close()
waitFor env.sealer.stop()
waitFor env.server.closeWait()

proc setRealTTD*(env: EngineEnv) =
Expand Down
4 changes: 0 additions & 4 deletions hive_integration/nodocker/engine/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import
transaction,
vm_state,
vm_types,
core/clique,
core/dao,
core/validate,
core/chain/chain_desc,
Expand Down Expand Up @@ -107,9 +106,6 @@ proc setBlock*(c: ChainRef; header: BlockHeader;
let dbTx = c.db.beginTransaction()
defer: dbTx.dispose()

var cliqueState = c.clique.cliqueSave
defer: c.clique.cliqueRestore(cliqueState)

c.com.hardForkTransition(header)

# Needed for figuring out whether KVT cleanup is due (see at the end)
Expand Down
2 changes: 1 addition & 1 deletion hive_integration/nodocker/graphql/graphql_sim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ proc main() =
)

com.initializeEmptyDb()
let txPool = TxPoolRef.new(com, conf.engineSigner)
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)
discard importRlpBlock(blocksFile, com)
let ctx = setupGraphqlContext(com, ethNode, txPool)

Expand Down
14 changes: 2 additions & 12 deletions hive_integration/nodocker/rpc/test_env.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import
../../../nimbus/config,
../../../nimbus/rpc,
../../../nimbus/utils/utils,
../../../nimbus/core/[chain, tx_pool, sealer],
../../../nimbus/core/[chain, tx_pool],
../../../tests/test_helpers,
./vault

Expand All @@ -28,7 +28,6 @@ type
vault*: Vault
rpcClient*: RpcClient
rpcServer: RpcServer
sealingEngine: SealingEngineRef
stopServer: StopServerProc

const
Expand Down Expand Up @@ -85,28 +84,20 @@ proc setupEnv*(): TestEnv =
com.initializeEmptyDb()

let chainRef = newChain(com)
let txPool = TxPoolRef.new(com, conf.engineSigner)
let txPool = TxPoolRef.new(com, ZERO_ADDRESS)

# txPool must be informed of active head
# so it can know the latest account state
let head = com.db.getCanonicalHead()
doAssert txPool.smartHead(head)

let sealingEngine = SealingEngineRef.new(
chainRef, ethCtx, conf.engineSigner,
txPool, EngineStopped
)

let rpcServer = setupRpcServer(ethCtx, com, ethNode, txPool, conf)
let rpcClient = newRpcHttpClient()
waitFor rpcClient.connect("127.0.0.1", Port(8545), false)
let stopServer = stopRpcHttpServer

sealingEngine.start()

let t = TestEnv(
rpcClient: rpcClient,
sealingEngine: sealingEngine,
rpcServer: rpcServer,
vault : newVault(chainID, gasPrice, rpcClient),
stopServer: stopServer
Expand All @@ -116,5 +107,4 @@ proc setupEnv*(): TestEnv =

proc stopEnv*(t: TestEnv) =
waitFor t.rpcClient.close()
waitFor t.sealingEngine.stop()
t.stopServer(t.rpcServer)
37 changes: 0 additions & 37 deletions nimbus/common/chain_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const
CustomNet* = 0.NetworkId
# these are public network id
MainNet* = 1.NetworkId
GoerliNet* = 5.NetworkId
SepoliaNet* = 11155111.NetworkId
HoleskyNet* = 17000.NetworkId

Expand Down Expand Up @@ -356,10 +355,6 @@ proc validateChainConfig*(conf: ChainConfig): bool =
if cur.time.isSome:
lastTimeBasedFork = cur

if conf.clique.period.isSome or
conf.clique.epoch.isSome:
conf.consensusType = ConsensusType.POA

proc parseGenesis*(data: string): Genesis
{.gcsafe.} =
try:
Expand Down Expand Up @@ -473,29 +468,6 @@ proc chainConfigForNetwork*(id: NetworkId): ChainConfig =
terminalTotalDifficulty: some(mainNetTTD),
shanghaiTime: some(1_681_338_455.EthTime)
)
of GoerliNet:
ChainConfig(
clique: CliqueOptions(period: some(15), epoch: some(30000)),
consensusType: ConsensusType.POA,
chainId: GoerliNet.ChainId,
# Genesis: # 2015-07-30 15:26:13 UTC
homesteadBlock: some(0.toBlockNumber), # Included in genesis
daoForkSupport: false,
eip150Block: some(0.toBlockNumber), # Included in genesis
eip150Hash: toDigest("0000000000000000000000000000000000000000000000000000000000000000"),
eip155Block: some(0.toBlockNumber), # Included in genesis
eip158Block: some(0.toBlockNumber), # Included in genesis
byzantiumBlock: some(0.toBlockNumber), # Included in genesis
constantinopleBlock: some(0.toBlockNumber), # Included in genesis
petersburgBlock: some(0.toBlockNumber), # Included in genesis
istanbulBlock: some(1_561_651.toBlockNumber), # 2019-10-30 13:53:05 UTC
muirGlacierBlock: some(4_460_644.toBlockNumber), # Skipped in Goerli
berlinBlock: some(4_460_644.toBlockNumber), # 2021-03-18 05:29:51 UTC
londonBlock: some(5_062_605.toBlockNumber), # 2021-07-01 03:19:39 UTC
terminalTotalDifficulty: some(10790000.u256),
shanghaiTime: some(1_678_832_736.EthTime),
cancunTime: some(1_705_473_120.EthTime), # 2024-01-17 06:32:00
)
of SepoliaNet:
const sepoliaTTD = parse("17000000000000000",UInt256)
ChainConfig(
Expand Down Expand Up @@ -553,15 +525,6 @@ proc genesisBlockForNetwork*(id: NetworkId): Genesis
difficulty: 17179869184.u256,
alloc: decodePrealloc(mainnetAllocData)
)
of GoerliNet:
Genesis(
nonce: 0.toBlockNonce,
timestamp: EthTime(0x5c51a607),
extraData: hexToSeqByte("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
gasLimit: 0xa00000,
difficulty: 1.u256,
alloc: decodePrealloc(goerliAllocData)
)
of SepoliaNet:
Genesis(
nonce: 0.toBlockNonce,
Expand Down
29 changes: 4 additions & 25 deletions nimbus/common/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import
std/[options],
chronicles,
eth/trie/trie_defs,
../core/[pow, clique, casper],
../core/[pow, casper],
../db/[core_db, ledger, storage_types],
../utils/[utils, ec_recover],
".."/[constants, errors],
Expand Down Expand Up @@ -91,9 +91,6 @@ type
pow: PowRef
## Wrapper around `hashimotoLight()` and lookup cache

poa: Clique
## For non-PoA networks this descriptor is ignored.

pos: CasperRef
## Proof Of Stake descriptor

Expand Down Expand Up @@ -161,10 +158,6 @@ proc init(com : CommonRef,
com.ldgType = (if ldgType == LedgerType(0): LedgerCache else: ldgType)
com.pruneHistory= pruneHistory

# Initalise the PoA state regardless of whether it is needed on the current
# network. For non-PoA networks this descriptor is ignored.
com.poa = newClique(com.db, com.cliquePeriod, com.cliqueEpoch)

# Always initialise the PoW epoch cache even though it migh no be used
com.pow = PowRef.new
com.pos = CasperRef.new
Expand Down Expand Up @@ -281,7 +274,6 @@ proc clone*(com: CommonRef, db: CoreDbRef): CommonRef =
currentFork : com.currentFork,
consensusType: com.consensusType,
pow : com.pow,
poa : com.poa,
pos : com.pos,
ldgType : com.ldgType,
pruneHistory : com.pruneHistory)
Expand Down Expand Up @@ -353,19 +345,10 @@ func forkGTE*(com: CommonRef, fork: HardFork): bool =
com.currentFork >= fork

# TODO: move this consensus code to where it belongs
proc minerAddress*(com: CommonRef; header: BlockHeader): EthAddress
func minerAddress*(com: CommonRef; header: BlockHeader): EthAddress
{.gcsafe, raises: [CatchableError].} =
if com.consensusType != ConsensusType.POA:
# POW and POS return header.coinbase
return header.coinbase

# POA return ecRecover
let account = header.ecRecover
if account.isErr:
let msg = "Could not recover account address: " & $account.error
raise newException(ValidationError, msg)

account.value
# POW and POS return header.coinbase
return header.coinbase

func forkId*(com: CommonRef, head, time: uint64): ForkID {.gcsafe.} =
## EIP 2364/2124
Expand Down Expand Up @@ -436,10 +419,6 @@ func startOfHistory*(com: CommonRef): Hash256 =
## Getter
com.startOfHistory

func poa*(com: CommonRef): Clique =
## Getter
com.poa

func pow*(com: CommonRef): PowRef =
## Getter
com.pow
Expand Down
4 changes: 0 additions & 4 deletions nimbus/common/hardforks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ type
# algorithm: Ethash
POW

# Proof of Authority
# algorithm: Clique
POA

# Proof of Stake
# algorithm: Casper
POS
Expand Down
11 changes: 0 additions & 11 deletions nimbus/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ type
abbr: "e"
name: "import-key" }: InputFile

engineSigner* {.
desc: "Set the signer address(as 20 bytes hex) and enable sealing engine to run and " &
"producing blocks at specified interval (only PoA/Clique supported)"
defaultValue: ZERO_ADDRESS
defaultValueDesc: ""
abbr: "s"
name: "engine-signer" }: EthAddress

verifyFrom* {.
desc: "Enable extra verification when current block number greater than verify-from"
defaultValueDesc: ""
Expand Down Expand Up @@ -616,7 +608,6 @@ proc getNetworkId(conf: NimbusConf): Option[NetworkId] =
let network = toLowerAscii(conf.network)
case network
of "mainnet": return some MainNet
of "goerli" : return some GoerliNet
of "sepolia": return some SepoliaNet
of "holesky": return some HoleskyNet
else:
Expand Down Expand Up @@ -693,8 +684,6 @@ proc getBootNodes*(conf: NimbusConf): seq[ENode] =
case conf.networkId
of MainNet:
bootstrapNodes.setBootnodes(MainnetBootnodes)
of GoerliNet:
bootstrapNodes.setBootnodes(GoerliBootnodes)
of SepoliaNet:
bootstrapNodes.setBootnodes(SepoliaBootnodes)
of HoleskyNet:
Expand Down
11 changes: 3 additions & 8 deletions nimbus/core/chain/chain_desc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import
../../common/common,
../../utils/utils,
../../vm_types,
../pow,
../clique
../pow

export
common
Expand Down Expand Up @@ -62,12 +61,12 @@ proc newChain*(com: CommonRef,
vmState: vmState,
)

proc newChain*(com: CommonRef): ChainRef =
func newChain*(com: CommonRef): ChainRef =
## Constructor for the `Chain` descriptor object. All sub-object descriptors
## are initialised with defaults. So is extra block chain validation
## * `enabled` for PoA networks (such as Goerli)
## * `disabled` for non-PaA networks
let extraValidation = com.consensus in {ConsensusType.POA, ConsensusType.POS}
let extraValidation = com.consensus == ConsensusType.POS
ChainRef(
com: com,
validateBlock: true,
Expand All @@ -81,10 +80,6 @@ proc vmState*(c: ChainRef): BaseVMState =
## Getter
c.vmState

proc clique*(c: ChainRef): Clique =
## Getter
c.com.poa

proc pow*(c: ChainRef): PowRef =
## Getter
c.com.pow
Expand Down
Loading