Skip to content

Commit

Permalink
Merge pull request #233 from blxdyx/snapshotsync
Browse files Browse the repository at this point in the history
Fix the history data error
  • Loading branch information
blxdyx authored Oct 21, 2023
2 parents b234090 + 72c9f4f commit 24b2aaa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
15 changes: 13 additions & 2 deletions turbo/snapshotsync/block_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -1436,7 +1447,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()
Expand Down

0 comments on commit 24b2aaa

Please sign in to comment.