Skip to content

Commit

Permalink
Remove erigon_issuance & erigon_watchTheBurn (erigontech#6685)
Browse files Browse the repository at this point in the history
Some issuance happens on the CL side now, so removing support for these
now inaccurate proprietary methods to make our life easier.
  • Loading branch information
yperbasis authored Jan 24, 2023
1 parent f44b22f commit 37741b7
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 570 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ By default, on Ethereum Mainnet, Görli, and Sepolia, the Engine API is disabled
If you want to use an external Consensus Layer, run Erigon with flag `--externalcl`.
_Warning:_ Staking (block production) is not possible with the embedded CL – use `--externalcl` instead.

### Optional stages

There is an optional stage that can be enabled through flags:

* `--watch-the-burn`, Enable WatchTheBurn stage which keeps track of ETH issuance and is required to
use `erigon_watchTheBurn`.

### Testnets

If you would like to give Erigon a try, but do not have spare 2TB on your drive, a good option is to start syncing one
Expand Down
40 changes: 32 additions & 8 deletions cmd/erigon-el/stages/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"

proto_downloader "github.com/ledgerwatch/erigon-lib/gointerfaces/downloader"

"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/state"

"github.com/ledgerwatch/erigon/cmd/sentry/sentry"
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/core/vm"
Expand All @@ -23,8 +23,8 @@ import (
func nullStage(firstCycle bool, badBlockUnwind bool, s *stagedsync.StageState, u stagedsync.Unwinder, tx kv.RwTx, quiet bool) error {
return nil
}
func ExecutionStages(ctx context.Context, sm prune.Mode, snapshots stagedsync.SnapshotsCfg, headers stagedsync.HeadersCfg, cumulativeIndex stagedsync.CumulativeIndexCfg, blockHashCfg stagedsync.BlockHashesCfg, bodies stagedsync.BodiesCfg, issuance stagedsync.IssuanceCfg, senders stagedsync.SendersCfg, exec stagedsync.ExecuteBlockCfg, hashState stagedsync.HashStateCfg, trieCfg stagedsync.TrieCfg, history stagedsync.HistoryCfg, logIndex stagedsync.LogIndexCfg, callTraces stagedsync.CallTracesCfg, txLookup stagedsync.TxLookupCfg, finish stagedsync.FinishCfg, test bool) []*stagedsync.Stage {
defaultStages := stagedsync.DefaultStages(ctx, snapshots, headers, cumulativeIndex, blockHashCfg, bodies, issuance, senders, exec, hashState, trieCfg, history, logIndex, callTraces, txLookup, finish, test)
func ExecutionStages(ctx context.Context, sm prune.Mode, snapshots stagedsync.SnapshotsCfg, headers stagedsync.HeadersCfg, cumulativeIndex stagedsync.CumulativeIndexCfg, blockHashCfg stagedsync.BlockHashesCfg, bodies stagedsync.BodiesCfg, senders stagedsync.SendersCfg, exec stagedsync.ExecuteBlockCfg, hashState stagedsync.HashStateCfg, trieCfg stagedsync.TrieCfg, history stagedsync.HistoryCfg, logIndex stagedsync.LogIndexCfg, callTraces stagedsync.CallTracesCfg, txLookup stagedsync.TxLookupCfg, finish stagedsync.FinishCfg, test bool) []*stagedsync.Stage {
defaultStages := stagedsync.DefaultStages(ctx, snapshots, headers, cumulativeIndex, blockHashCfg, bodies, senders, exec, hashState, trieCfg, history, logIndex, callTraces, txLookup, finish, test)
// Remove body/headers stages
defaultStages[1].Forward = nullStage
defaultStages[4].Forward = nullStage
Expand Down Expand Up @@ -58,7 +58,19 @@ func NewStagedSync(ctx context.Context,

return stagedsync.New(
ExecutionStages(ctx, cfg.Prune,
stagedsync.StageSnapshotsCfg(db, *controlServer.ChainConfig, dirs, snapshots, blockRetire, snapDownloader, blockReader, notifications.Events, engine, cfg.HistoryV3, agg),
stagedsync.StageSnapshotsCfg(
db,
*controlServer.ChainConfig,
dirs,
snapshots,
blockRetire,
snapDownloader,
blockReader,
notifications.Events,
engine,
cfg.HistoryV3,
agg,
),
stagedsync.StageHeadersCfg(
db,
controlServer.Hd,
Expand All @@ -73,11 +85,22 @@ func NewStagedSync(ctx context.Context,
blockReader,
dirs.Tmp,
notifications,
forkValidator),
forkValidator,
),
stagedsync.StageCumulativeIndexCfg(db),
stagedsync.StageBlockHashesCfg(db, dirs.Tmp, controlServer.ChainConfig),
stagedsync.StageBodiesCfg(db, controlServer.Bd, controlServer.SendBodyRequest, controlServer.Penalize, controlServer.BroadcastNewBlock, cfg.Sync.BodyDownloadTimeoutSeconds, *controlServer.ChainConfig, snapshots, blockReader, cfg.HistoryV3),
stagedsync.StageIssuanceCfg(db, controlServer.ChainConfig, blockReader, cfg.EnabledIssuance),
stagedsync.StageBodiesCfg(
db,
controlServer.Bd,
controlServer.SendBodyRequest,
controlServer.Penalize,
controlServer.BroadcastNewBlock,
cfg.Sync.BodyDownloadTimeoutSeconds,
*controlServer.ChainConfig,
snapshots,
blockReader,
cfg.HistoryV3,
),
stagedsync.StageSendersCfg(db, controlServer.ChainConfig, false, dirs.Tmp, cfg.Prune, blockRetire, controlServer.Hd),
stagedsync.StageExecuteBlocksCfg(
db,
Expand All @@ -104,7 +127,8 @@ func NewStagedSync(ctx context.Context,
stagedsync.StageLogIndexCfg(db, cfg.Prune, dirs.Tmp),
stagedsync.StageCallTracesCfg(db, cfg.Prune, 0, dirs.Tmp),
stagedsync.StageTxLookupCfg(db, cfg.Prune, dirs.Tmp, snapshots, controlServer.ChainConfig.Bor),
stagedsync.StageFinishCfg(db, dirs.Tmp, forkValidator), runInTestMode),
stagedsync.StageFinishCfg(db, dirs.Tmp, forkValidator),
runInTestMode),
stagedsync.DefaultUnwindOrder,
stagedsync.DefaultPruneOrder,
), nil
Expand Down
1 change: 0 additions & 1 deletion cmd/rpcdaemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ The following table shows the current implementation status of Erigon's RPC daem
| erigon_getHeaderByNumber | Yes | Erigon only |
| erigon_getLogsByHash | Yes | Erigon only |
| erigon_forks | Yes | Erigon only |
| erigon_issuance | Yes | Erigon only |
| erigon_getBlockByTimestamp | Yes | Erigon only |
| erigon_BlockNumber | Yes | Erigon only |
| erigon_getLatestLogs | Yes | Erigon only |
Expand Down
3 changes: 0 additions & 3 deletions cmd/rpcdaemon/commands/erigon_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ type ErigonAPI interface {
// Gets cannonical block receipt through hash. If the block is not cannonical returns error
GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash libcommon.Hash) ([]map[string]interface{}, error)

// WatchTheBurn / reward related (see ./erigon_issuance.go)
WatchTheBurn(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)

// CumulativeChainTraffic / related to chain traffic (see ./erigon_cumulative_index.go)
CumulativeChainTraffic(ctx context.Context, blockNr rpc.BlockNumber) (ChainTraffic, error)

Expand Down
132 changes: 0 additions & 132 deletions cmd/rpcdaemon/commands/erigon_issuance.go

This file was deleted.

5 changes: 0 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ var (
Usage: "Comma separared list of addresses, whoes transactions will traced in transaction pool with debug printing",
Value: "",
}
EnabledIssuance = cli.BoolFlag{
Name: "watch-the-burn",
Usage: "Enable WatchTheBurn stage to keep track of ETH issuance",
}
// Miner settings
MiningEnabledFlag = cli.BoolFlag{
Name: "mine",
Expand Down Expand Up @@ -1524,7 +1520,6 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C

cfg.Ethstats = ctx.String(EthStatsURLFlag.Name)
cfg.P2PEnabled = len(nodeConfig.P2P.SentryAddr) == 0
cfg.EnabledIssuance = ctx.Bool(EnabledIssuance.Name)
cfg.HistoryV3 = ctx.Bool(HistoryV3Flag.Name)
if ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkID = ctx.Uint64(NetworkIdFlag.Name)
Expand Down
45 changes: 0 additions & 45 deletions docs/readthedocs/source/rpc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2383,51 +2383,6 @@ Array - An array of type Log some of which may be null found in the block. See e
* - ``ARRAY``
- An array of type Log some of which may be null found in the block. See ``eth_getFilterChanges``

--------------
erigon_issuance
-----------

Returns the total issuance (block reward plus uncle reward) for the given block.

**Parameters**

.. list-table::
:widths: 25 75
:header-rows: 1

* - Type
- Description
* - ``QUANTITY | TAG``
- Integer block number or one of "earliest", "latest" or "pending"


**Example**

::

curl -s --data '{"jsonrpc":"2.0","method":"erigon_issuance","params":["0x3"],"id":"1"}' -H "Content-Type: application/json" -X POST http://localhost:8545

**Returns**

Object - An object of type Issuance

.. list-table::
:widths: 15 15 70
:header-rows: 1

* - Type
- Name
- Description
* - ``QUANTITY``
- ``blockReward``
- The issuance to the miner of the block (includes nephew reward but not transaction fees)
* - ``QUANTITY``
- ``uncleReward``
- The issuance to miners of included uncle (if any)
* - ``QUANTITY``
- ``issuance``
- The sum of blockReward and uncleReward

--------------

debug_storageRangeAt
Expand Down
3 changes: 0 additions & 3 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ type Config struct {

StateStream bool

// Enable WatchTheBurn stage
EnabledIssuance bool

// New DB and Snapshots format of history allows: parallel blocks execution, get state as of given transaction without executing whole block.",
HistoryV3 bool

Expand Down
15 changes: 1 addition & 14 deletions eth/stagedsync/default_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/ledgerwatch/erigon/eth/stagedsync/stages"
)

func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersCfg, cumulativeIndex CumulativeIndexCfg, blockHashCfg BlockHashesCfg, bodies BodiesCfg, issuance IssuanceCfg, senders SendersCfg, exec ExecuteBlockCfg, hashState HashStateCfg, trieCfg TrieCfg, history HistoryCfg, logIndex LogIndexCfg, callTraces CallTracesCfg, txLookup TxLookupCfg, finish FinishCfg, test bool) []*Stage {
func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersCfg, cumulativeIndex CumulativeIndexCfg, blockHashCfg BlockHashesCfg, bodies BodiesCfg, senders SendersCfg, exec ExecuteBlockCfg, hashState HashStateCfg, trieCfg TrieCfg, history HistoryCfg, logIndex LogIndexCfg, callTraces CallTracesCfg, txLookup TxLookupCfg, finish FinishCfg, test bool) []*Stage {
return []*Stage{
{
ID: stages.Snapshots,
Expand Down Expand Up @@ -210,19 +210,6 @@ func DefaultStages(ctx context.Context, snapshots SnapshotsCfg, headers HeadersC
return PruneTxLookup(p, tx, txLookup, ctx, firstCycle)
},
},
{
ID: stages.Issuance,
Description: "Issuance computation",
Forward: func(firstCycle bool, badBlockUnwind bool, s *StageState, u Unwinder, tx kv.RwTx, quiet bool) error {
return SpawnStageIssuance(issuance, s, tx, ctx)
},
Unwind: func(firstCycle bool, u *UnwindState, s *StageState, tx kv.RwTx) error {
return UnwindIssuanceStage(u, issuance, tx, ctx)
},
Prune: func(firstCycle bool, p *PruneState, tx kv.RwTx) error {
return PruneIssuanceStage(p, issuance, tx, ctx)
},
},
{
ID: stages.Finish,
Description: "Final: update current block for the RPC API",
Expand Down
Loading

0 comments on commit 37741b7

Please sign in to comment.