diff --git a/Dockerfile b/Dockerfile index 57bf511..db8bc19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,13 @@ FROM golang:1.17-alpine as builder WORKDIR /tmp +COPY opera-1.1.3-rc5.patch /tmp/ RUN apk add --no-cache make gcc musl-dev linux-headers git RUN go clean -modcache -RUN git clone --depth 1 --branch release/1.1.3-rc.5 https://github.com/Fantom-foundation/go-opera.git && \ - cd go-opera && \ +RUN git clone --depth 1 --branch release/1.1.3-rc.5 https://github.com/Fantom-foundation/go-opera.git + +RUN cd go-opera && \ + git apply ../opera-1.1.3-rc5.patch && \ make FROM golang:1.17-alpine @@ -14,7 +17,7 @@ WORKDIR /root/.opera COPY --from=builder /tmp/go-opera/build /usr/local/bin RUN mkdir /opt/genesis -RUN wget -O /opt/genesis/mainnet.g https://opera.fantom.network/mainnet.g -RUN wget -O /opt/genesis/testnet.g https://opera.fantom.network/testnet.g +RUN wget -O /opt/genesis/mainnet.g https://storage.googleapis.com/fantom-opera-genesis/mainnet.g +RUN wget -O /opt/genesis/testnet.g https://storage.googleapis.com/fantom-opera-genesis/testnet.g ENTRYPOINT ["opera"] diff --git a/opera-1.1.3-rc5.patch b/opera-1.1.3-rc5.patch new file mode 100644 index 0000000..18a835b --- /dev/null +++ b/opera-1.1.3-rc5.patch @@ -0,0 +1,43 @@ +diff --git forkSrcPrefix/gossip/handler.go forkDstPrefix/gossip/handler.go +index 1d5a48a183afdf92b6b2fe47f37397818e82e292..fcb134bd35da545947f16219ce56d8c41596c934 100644 +--- forkSrcPrefix/gossip/handler.go ++++ forkDstPrefix/gossip/handler.go +@@ -3,6 +3,7 @@ package gossip + import ( + "errors" + "fmt" ++ "github.com/ethereum/go-ethereum/p2p/enode" + "math" + "math/rand" + "strings" +@@ -773,6 +774,17 @@ func (h *handler) highestPeerProgress() PeerProgress { + return max + } + ++// isUseless checks if the peer is banned from discovery and ban it if it should be ++func isUseless(node *enode.Node, name string) bool { ++ useless := discfilter.Banned(node.ID(), node.Record()) ++ lowerName := strings.ToLower(name) ++ if !useless && !strings.Contains(lowerName, "opera") && !strings.Contains(lowerName, "sonic") { ++ useless = true ++ discfilter.Ban(node.ID()) ++ } ++ return useless ++} ++ + // handle is the callback invoked to manage the life cycle of a peer. When + // this function terminates, the peer is disconnected. + func (h *handler) handle(p *peer) error { +@@ -783,11 +795,7 @@ func (h *handler) handle(p *peer) error { + p.Log().Error("Snapshot extension barrier failed", "err", err) + return err + } +- useless := discfilter.Banned(p.Node().ID(), p.Node().Record()) +- if !useless && (!eligibleForSnap(p.Peer) || !strings.Contains(strings.ToLower(p.Name()), "opera")) { +- useless = true +- discfilter.Ban(p.ID()) +- } ++ useless := isUseless(p.Node(), p.Name()) + if !p.Peer.Info().Network.Trusted && useless { + if h.peers.UselessNum() >= h.maxPeers/10 { + // don't allow more than 10% of useless peers