diff --git a/eth/handler.go b/eth/handler.go index b39f5d0fd8..d72be2883a 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -162,8 +162,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 diff --git a/eth/protocols/snap/handler.go b/eth/protocols/snap/handler.go index 55781ac54b..c57ac5e2e3 100644 --- a/eth/protocols/snap/handler.go +++ b/eth/protocols/snap/handler.go @@ -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)) }