From 2897b2bcd7a2c318e620fe5e854b6ba9fe3d9386 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Sat, 21 Oct 2023 10:11:44 +0800 Subject: [PATCH 1/5] update snapshots --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 36a1285ca5a..d033500505c 100644 --- a/go.mod +++ b/go.mod @@ -302,6 +302,6 @@ replace ( github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-tendermint v0.0.0-20230417032003-4cda1f296fb2 github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20210702154020-550e1cd83ec1 github.com/ledgerwatch/erigon-lib => github.com/node-real/bsc-erigon-lib v1.0.2-0.20230724023158-8adca9da31b4 - github.com/ledgerwatch/erigon-snapshot => github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20230920065254-96e73b3e4c1e + github.com/ledgerwatch/erigon-snapshot => github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20231021015030-17ba1845df17 github.com/tendermint/tendermint => github.com/bnb-chain/tendermint v0.31.15 ) diff --git a/go.sum b/go.sum index a666bd6494e..d2c83e0b548 100644 --- a/go.sum +++ b/go.sum @@ -1221,8 +1221,8 @@ github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/node-real/bsc-erigon-lib v1.0.2-0.20230724023158-8adca9da31b4 h1:jbF1TMYLiYs2Mkgb/5aj8buz+28JivDVw0u1dqcD+gY= github.com/node-real/bsc-erigon-lib v1.0.2-0.20230724023158-8adca9da31b4/go.mod h1:VfsdM52udAY3ghsNxdJcIVQJDEqE5eVBkFfYQkNHnO4= -github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20230920065254-96e73b3e4c1e h1:79/htDi94BTlgoomyhDMAU7Uh6GEPL1F9m49/DqduoI= -github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20230920065254-96e73b3e4c1e/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= +github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20231021015030-17ba1845df17 h1:zFAkTm6tkDYTc7A6LqLg1OMz2GTIQgGKr3JylF7vVAg= +github.com/node-real/bsc-erigon-snapshot v1.0.1-0.20231021015030-17ba1845df17/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/nxadm/tail v1.4.9-0.20211216163028-4472660a31a6 h1:iZ5rEHU561k2tdi/atkIsrP5/3AX3BjyhYtC96nJ260= From 296c10f39644988636e1de720b9f6b83d9fe6a1f Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 12 Oct 2023 14:15:47 +0800 Subject: [PATCH 2/5] revert the DumpTxs commit --- turbo/snapshotsync/block_snapshots.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index 5370d3e1ac6..f263b49e293 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -1325,6 +1325,7 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF } defer f.Close() + var prevTxID uint64 numBuf := make([]byte, binary.MaxVarintLen64) parseCtx := types2.NewTxParseContext(*chainID) parseCtx.WithSender(false) @@ -1415,8 +1416,18 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF if err := addSystemTx(tx, body.BaseTxId); err != nil { return false, err } + if prevTxID > 0 { + prevTxID++ + } else { + prevTxID = body.BaseTxId + } binary.BigEndian.PutUint64(numBuf, body.BaseTxId+1) - if err := tx.ForAmount(kv.EthTx, numBuf, body.TxAmount-2, func(_, tv []byte) error { + if err := tx.ForAmount(kv.EthTx, numBuf[:8], body.TxAmount-2, func(tk, tv []byte) error { + id := binary.BigEndian.Uint64(tk) + if prevTxID != 0 && id != prevTxID+1 { + panic(fmt.Sprintf("no gaps in tx ids are allowed: block %d does jump from %d to %d", blockNum, prevTxID, id)) + } + prevTxID = id parseCtx.WithSender(len(senders) == 0) valueBuf, err = parse(tv, valueBuf, senders, j) if err != nil { From fa38dd5697e7efe384cc62e1cb11124c6a8a3870 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Fri, 13 Oct 2023 15:32:26 +0800 Subject: [PATCH 3/5] RPCdaemon: fix to work also with snapshot --- cmd/rpcdaemon/commands/eth_block.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rpcdaemon/commands/eth_block.go b/cmd/rpcdaemon/commands/eth_block.go index 8257bbd4abd..b31e3674d88 100644 --- a/cmd/rpcdaemon/commands/eth_block.go +++ b/cmd/rpcdaemon/commands/eth_block.go @@ -93,7 +93,7 @@ func (api *APIImpl) CallBundle(ctx context.Context, txHashes []common.Hash, stat } ibs := state.New(stateReader) - parent := rawdb.ReadHeader(tx, hash, stateBlockNumber) + parent, _ := api.headerByRPCNumber(rpc.BlockNumber(stateBlockNumber), tx) if parent == nil { return nil, fmt.Errorf("block %d(%x) not found", stateBlockNumber, hash) } From c6ec56622e1673d0f6e1c6a5b0616f833fb6419d Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 19 Oct 2023 10:35:27 +0800 Subject: [PATCH 4/5] add some logs --- turbo/snapshotsync/block_snapshots.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index f263b49e293..f7af06d8ecd 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -1424,6 +1424,7 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF binary.BigEndian.PutUint64(numBuf, body.BaseTxId+1) if err := tx.ForAmount(kv.EthTx, numBuf[:8], body.TxAmount-2, func(tk, tv []byte) error { id := binary.BigEndian.Uint64(tk) + log.Info(fmt.Sprintf("DumpTxs now block %d, prevTxID %d, nowID %d", blockNum, prevTxID, id)) if prevTxID != 0 && id != prevTxID+1 { panic(fmt.Sprintf("no gaps in tx ids are allowed: block %d does jump from %d to %d", blockNum, prevTxID, id)) } @@ -1447,7 +1448,7 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF if err := addSystemTx(tx, body.BaseTxId+uint64(body.TxAmount)-1); err != nil { return false, err } - + prevTxID++ select { case <-ctx.Done(): return false, ctx.Err() From 72c9f4f9802e229508ed7dd8dd565cf11b300955 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 19 Oct 2023 11:35:32 +0800 Subject: [PATCH 5/5] remove some logs --- turbo/snapshotsync/block_snapshots.go | 1 - 1 file changed, 1 deletion(-) diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index f7af06d8ecd..36843b9908f 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -1424,7 +1424,6 @@ func DumpTxs(ctx context.Context, db kv.RoDB, segmentFile, tmpDir string, blockF binary.BigEndian.PutUint64(numBuf, body.BaseTxId+1) if err := tx.ForAmount(kv.EthTx, numBuf[:8], body.TxAmount-2, func(tk, tv []byte) error { id := binary.BigEndian.Uint64(tk) - log.Info(fmt.Sprintf("DumpTxs now block %d, prevTxID %d, nowID %d", blockNum, prevTxID, id)) if prevTxID != 0 && id != prevTxID+1 { panic(fmt.Sprintf("no gaps in tx ids are allowed: block %d does jump from %d to %d", blockNum, prevTxID, id)) }