Skip to content

Commit

Permalink
Merge pull request bnb-chain#8 from krish-nr/krish/p2p_sync
Browse files Browse the repository at this point in the history
feat: support snap sync for OP chains
  • Loading branch information
owen-reorg authored Oct 18, 2023
2 parents 695adff + ca83786 commit 38bc840
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ func newHandler(config *handlerConfig) (*handler, error) {
log.Warn("Switch sync mode from full sync to snap sync")
}
} else {
if h.chain.CurrentBlock().Number.Uint64() > 0 {
blockNumber := h.chain.CurrentBlock().Number
if blockNumber.Uint64() > 0 && (!config.Chain.Config().IsOptimism() || blockNumber.Cmp(config.Chain.Config().BedrockBlock) != 0) {
// Print warning log if database is not empty to run snap sync.
// For OP chains, snap sync from bedrock block is allowed.
log.Warn("Switch sync mode from snap sync to full sync")
} else {
// If snap sync was requested and our database is empty, grant it
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/snap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ func ServiceGetByteCodesQuery(chain *core.BlockChain, req *GetByteCodesPacket) [
// Peers should not request the empty code, but if they do, at
// least sent them back a correct response without db lookups
codes = append(codes, []byte{})
} else if blob, err := chain.ContractCodeWithPrefix(hash); err == nil {
} else if blob, err := chain.ContractCode(hash); err == nil {
codes = append(codes, blob)
bytes += uint64(len(blob))
}
Expand Down

0 comments on commit 38bc840

Please sign in to comment.