Skip to content

Commit

Permalink
Merge pull request #2652 from ledgerwatch/stable-2021-09-02
Browse files Browse the repository at this point in the history
Stable 2021 09 02
  • Loading branch information
mandrigin authored Sep 9, 2021
2 parents 6747d29 + f9e4090 commit 4585841
Show file tree
Hide file tree
Showing 49 changed files with 1,389 additions and 664 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ make erigon
```

Please note the `--datadir` option that allows you to store Erigon files in a non-default location, in this example,
in `goerli` subdirectory of the current directory. Name of the directory `--datadir` does not have to match the name if
in `goerli` subdirectory of the current directory. Name of the directory `--datadir` does not have to match the name of
the chain in `--chain`.

### Mining
Expand Down
23 changes: 0 additions & 23 deletions cmd/erigon/main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package main

import (
"context"
"fmt"
"os"

"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/core/rawdb"
"github.com/ledgerwatch/erigon/params"
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
"github.com/ledgerwatch/erigon/turbo/node"
Expand All @@ -32,24 +27,6 @@ func runErigon(cliCtx *cli.Context) {
logger.Info("Build info", "git_branch", params.GitBranch, "git_tag", params.GitTag, "git_commit", params.GitCommit)
nodeCfg := node.NewNodConfigUrfave(cliCtx)
ethCfg := node.NewEthConfigUrfave(cliCtx, nodeCfg)
if cliCtx.GlobalIsSet(utils.DataDirFlag.Name) {
// Check if we have an already initialized chain and fall back to
// that if so. Otherwise we need to generate a new genesis spec.
chaindb := utils.MakeChainDatabase(logger, nodeCfg)
if err := chaindb.View(context.Background(), func(tx kv.Tx) error {
h, err := rawdb.ReadCanonicalHash(tx, 0)
if err != nil {
panic(err)
}
if h != (common.Hash{}) {
ethCfg.Genesis = nil // fallback to db content
}
return nil
}); err != nil {
panic(err)
}
chaindb.Close()
}

ethNode, err := node.New(nodeCfg, ethCfg, logger)
if err != nil {
Expand Down
32 changes: 28 additions & 4 deletions cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ func readCallTraces(chaindata string, block uint64) error {
if err2 != nil {
return err2
}
var acc common.Address = common.HexToAddress("0x511bc4556d823ae99630ae8de28b9b80df90ea2e")
var acc = common.HexToAddress("0x511bc4556d823ae99630ae8de28b9b80df90ea2e")
for k, v, err = idxCursor.Seek(acc[:]); k != nil && err == nil && bytes.HasPrefix(k, acc[:]); k, v, err = idxCursor.Next() {
bm := roaring64.New()
_, err = bm.ReadFrom(bytes.NewReader(v))
Expand Down Expand Up @@ -1994,9 +1994,9 @@ func scanTxs(chaindata string) error {
}

func scanReceipts3(chaindata string, block uint64) error {
dbdb := mdbx.MustOpen(chaindata)
defer dbdb.Close()
tx, err := dbdb.BeginRw(context.Background())
db := mdbx.MustOpen(chaindata)
defer db.Close()
tx, err := db.BeginRw(context.Background())
if err != nil {
return err
}
Expand Down Expand Up @@ -2255,6 +2255,27 @@ func runBlock(ibs *state.IntraBlockState, txnWriter state.StateWriter, blockWrit
return receipts, nil
}

func devTx(chaindata string) error {
db := mdbx.MustOpen(chaindata)
defer db.Close()
tx, err := db.BeginRo(context.Background())
if err != nil {
return err
}
defer tx.Rollback()
b, err := rawdb.ReadBlockByNumber(tx, 0)
tool.Check(err)
cc, err := rawdb.ReadChainConfig(tx, b.Hash())
tool.Check(err)
txn := types.NewTransaction(1, common.Address{}, uint256.NewInt(100), 100_000, uint256.NewInt(1), []byte{1})
signedTx, err := types.SignTx(txn, *types.LatestSigner(cc), core.DevnetSignPrivateKey)
tool.Check(err)
buf := bytes.NewBuffer(nil)
err = signedTx.MarshalBinary(buf)
tool.Check(err)
fmt.Printf("%x\n", buf.Bytes())
return nil
}
func main() {
flag.Parse()

Expand Down Expand Up @@ -2414,6 +2435,9 @@ func main() {

case "scanReceipts3":
err = scanReceipts3(*chaindata, uint64(*block))

case "devTx":
err = devTx(*chaindata)
}

if err != nil {
Expand Down
9 changes: 7 additions & 2 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,11 @@ func stageSenders(db kv.RwDB, ctx context.Context) error {
s := stage(sync, tx, nil, stages.Senders)
log.Info("Stage", "name", s.ID, "progress", s.BlockNumber)

cfg := stagedsync.StageSendersCfg(db, chainConfig, tmpdir)
pm, err := prune.Get(tx)
if err != nil {
return err
}
cfg := stagedsync.StageSendersCfg(db, chainConfig, tmpdir, pm)
if unwind > 0 {
u := sync.NewUnwindState(stages.Senders, s.BlockNumber-unwind, s.BlockNumber)
err = stagedsync.UnwindSendersStage(u, tx, cfg, ctx)
Expand Down Expand Up @@ -940,6 +944,7 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig)
cfg := ethconfig.Defaults
cfg.Prune = pm
cfg.BatchSize = batchSize
cfg.TxPool.Disable = true
if miningConfig != nil {
cfg.Miner = *miningConfig
}
Expand All @@ -958,7 +963,7 @@ func newSync(ctx context.Context, db kv.RwDB, miningConfig *params.MiningConfig)

miningSync := stagedsync.New(
stagedsync.MiningStages(ctx,
stagedsync.StageMiningCreateBlockCfg(db, miner, *chainConfig, engine, txPool, tmpdir),
stagedsync.StageMiningCreateBlockCfg(db, miner, *chainConfig, engine, txPool, nil, nil, tmpdir),
stagedsync.StageMiningExecCfg(db, miner, events, *chainConfig, engine, &vm.Config{}, tmpdir),
stagedsync.StageHashStateCfg(db, tmpdir),
stagedsync.StageTrieCfg(db, false, true, tmpdir),
Expand Down
1 change: 1 addition & 0 deletions cmd/integration/commands/state_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func syncBySmallSteps(db kv.RwDB, miningConfig params.MiningConfig, ctx context.
*chainConfig,
engine,
txPool,
nil, nil,
tmpDir),
quit)
if err != nil {
Expand Down
Loading

0 comments on commit 4585841

Please sign in to comment.