fixes, deployed to dev

This commit is contained in:
Felipe Andrade 2023-07-18 10:21:19 -07:00
parent 1b021a6efc
commit 4a3850c179
7 changed files with 35 additions and 15 deletions

@ -6,7 +6,7 @@ ARG GITVERSION=docker
RUN apk add make jq git gcc musl-dev linux-headers
COPY ./ufm /app
COPY ./op-ufm /app
WORKDIR /app
@ -14,17 +14,16 @@ RUN make ufm
FROM alpine:3.18
COPY ./ufm/entrypoint.sh /bin/entrypoint.sh
COPY --from=builder /app/entrypoint.sh /bin/entrypoint.sh
COPY --from=builder /app/bin/ufm /bin/ufm
RUN apk update && \
apk add ca-certificates && \
chmod +x /bin/entrypoint.sh
EXPOSE 8080
VOLUME /etc/ufm
COPY --from=builder /app/bin/op-ufm /bin/op-ufm
EXPOSE 8080
ENTRYPOINT ["/bin/entrypoint.sh"]
CMD ["/bin/op-ufm", "/etc/op-ufm/config.toml"]
CMD ["/bin/ufm", "/etc/ufm/config.toml"]

21
op-ufm/op-ufm/Makefile Normal file

@ -0,0 +1,21 @@
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT)
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)
LDFLAGSSTRING +=-X main.GitVersion=$(GITVERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)"
ufm:
go build -v $(LDFLAGS) -o ./bin/ufm ./cmd/ufm
.PHONY: ufm
fmt:
go mod tidy
gofmt -w .
.PHONY: fmt
test:
go test -race -v ./...
.PHONY: test
lint:
go vet ./...
.PHONY: test

@ -18,10 +18,10 @@ const (
var (
Debug bool
errorsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
errorsTotal = promauto.NewGaugeVec(prometheus.GaugeOpts{
Namespace: MetricsNamespace,
Name: "errors_total",
Help: "Count of errors.",
Help: "Count of errors",
}, []string{
"provider",
"error",
@ -119,7 +119,7 @@ func RecordGasUsed(provider string, val uint64) {
log.Debug("metric add", "m", "gas_used",
"provider", provider, "val", val)
}
gasUsed.WithLabelValues(provider).Add(float64(val))
gasUsed.WithLabelValues(provider).Set(float64(val))
}
func RecordFirstSeenLatency(providerSource string, providerSeen string, latency time.Duration) {

@ -22,7 +22,7 @@ func (p *Provider) Heartbeat(ctx context.Context) {
expectedTransactions := make([]*TransactionState, 0, len(p.txPool.Transactions))
alreadySeen := 0
for _, st := range p.txPool.Transactions {
if st.ProviderSentTo == p.name {
if st.ProviderSource == p.name {
continue
}
if _, exist := st.SeenBy[p.name]; exist {
@ -59,16 +59,16 @@ func (p *Provider) Heartbeat(ctx context.Context) {
latency := time.Since(st.SentAt)
if st.FirstSeen.IsZero() {
st.FirstSeen = time.Now()
metrics.RecordFirstSeenLatency(st.ProviderSentTo, p.name, latency)
metrics.RecordFirstSeenLatency(st.ProviderSource, p.name, latency)
log.Info("transaction first seen",
"hash", hash,
"firstSeenLatency", latency,
"providerSource", st.ProviderSentTo,
"providerSource", st.ProviderSource,
"providerSeen", p.name)
}
if _, exist := st.SeenBy[p.name]; !exist {
st.SeenBy[p.name] = time.Now()
metrics.RecordProviderToProviderLatency(st.ProviderSentTo, p.name, latency)
metrics.RecordProviderToProviderLatency(st.ProviderSource, p.name, latency)
}
st.M.Unlock()

@ -86,7 +86,7 @@ func (p *Provider) RoundTrip(ctx context.Context) {
p.txPool.M.Lock()
p.txPool.Transactions[txHash.Hex()] = &TransactionState{
Hash: txHash,
ProviderSentTo: p.name,
ProviderSource: p.name,
SentAt: sentAt,
SeenBy: make(map[string]time.Time),
}

@ -25,7 +25,7 @@ type TransactionState struct {
M sync.Mutex
SentAt time.Time
ProviderSentTo string
ProviderSource string
FirstSeen time.Time