Skip to content

Commit

Permalink
Compatibility with dencun hardfork
Browse files Browse the repository at this point in the history
  • Loading branch information
alrevuelta committed Jan 12, 2024
1 parent 7eed713 commit 7a0a13f
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 267 deletions.
23 changes: 14 additions & 9 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

builderApiV1 "github.com/attestantio/go-builder-client/api/v1"
eth2 "github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/avast/retry-go/v4"
"github.com/dappnode/mev-sp-oracle/config"
Expand Down Expand Up @@ -390,7 +391,7 @@ func (m *ApiService) handleStatus(w http.ResponseWriter, req *http.Request) {
m.respondError(w, http.StatusInternalServerError, "could not get exex chainid: "+err.Error())
}

depositContract, err := m.Onchain.ConsensusClient.DepositContract(context.Background())
depositContract, err := m.Onchain.ConsensusClient.DepositContract(context.Background(), &eth2.DepositContractOpts{})
if err != nil {
m.respondError(w, http.StatusInternalServerError, "could not get deposit contract: "+err.Error())
}
Expand All @@ -406,23 +407,25 @@ func (m *ApiService) handleStatus(w http.ResponseWriter, req *http.Request) {
execInSync = true
}

consSync, err := m.Onchain.ConsensusClient.NodeSyncing(context.Background())
consSync, err := m.Onchain.ConsensusClient.NodeSyncing(context.Background(), &eth2.NodeSyncingOpts{})
if err != nil {
m.respondError(w, http.StatusInternalServerError, "could not get consensus sync progress: "+err.Error())
}

// Allow some slots to avoid jitter
consInSync := false
if uint64(consSync.SyncDistance) < 2 {
if uint64(consSync.Data.SyncDistance) < 2 {
consInSync = true
}

finality, err := m.Onchain.ConsensusClient.Finality(context.Background(), "finalized")
finality, err := m.Onchain.ConsensusClient.Finality(context.Background(), &eth2.FinalityOpts{
State: "finalized",
})
if err != nil {
m.respondError(w, http.StatusInternalServerError, "could not get consensus latest finalized slot: "+err.Error())
}

finalizedEpoch := uint64(finality.Finalized.Epoch)
finalizedEpoch := uint64(finality.Data.Finalized.Epoch)
finalizedSlot := finalizedEpoch * constants.SlotsInEpoch

oracleSync := false
Expand Down Expand Up @@ -460,8 +463,8 @@ func (m *ApiService) handleStatus(w http.ResponseWriter, req *http.Request) {
PreviousCheckpointAge: utils.SlotsToTime(finalizedSlot-onchainSlot, constants.SecondsInSlot),
PreviousCheckpointAgeUnix: (finalizedSlot - onchainSlot) * constants.SecondsInSlot,
ExecutionChainId: chainId.String(),
ConsensusChainId: strconv.FormatUint(depositContract.ChainID, 10),
DepositContact: hexutil.Encode(depositContract.Address[:]),
ConsensusChainId: strconv.FormatUint(depositContract.Data.ChainID, 10),
DepositContact: hexutil.Encode(depositContract.Data.Address[:]),
}

m.respondOK(w, status)
Expand Down Expand Up @@ -1191,12 +1194,14 @@ func (m *ApiService) OracleReady(maxSlotsBehind uint64) bool {
// otherwise the oracle wont be able to reply, since from time to time its normal that it fall behind sync
// since it has to process the new epochs that keep arriving.

finality, err := m.Onchain.ConsensusClient.Finality(context.Background(), "finalized")
finality, err := m.Onchain.ConsensusClient.Finality(context.Background(), &eth2.FinalityOpts{
State: "finalized",
})
if err != nil {
return false
}

finalizedSlot := uint64(finality.Finalized.Epoch) * constants.SlotsInEpoch
finalizedSlot := uint64(finality.Data.Finalized.Epoch) * constants.SlotsInEpoch
slotsFromFinalized := finalizedSlot - m.oracle.State().LatestProcessedSlot

// Use this if we want full in sync to latest finalized
Expand Down
34 changes: 15 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,50 @@ module github.com/dappnode/mev-sp-oracle
go 1.19

require (
github.com/attestantio/go-builder-client v0.3.1
github.com/attestantio/go-builder-client v0.4.2
github.com/avast/retry-go/v4 v4.5.0
github.com/gorilla/mux v1.8.0
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/miguelmota/go-solidity-sha3 v0.1.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.17.0
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
github.com/rs/zerolog v1.31.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/txaty/go-merkletree v0.1.15
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
golang.org/x/crypto v0.17.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-kzg-4844 v0.6.0 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.3.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/ferranbt/fastssz v0.1.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-yaml v1.11.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -57,7 +55,6 @@ require (
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect
github.com/r3labs/sse/v2 v2.10.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/supranational/blst v0.3.11 // indirect
Expand All @@ -68,21 +65,20 @@ require (
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/tools v0.15.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
github.com/attestantio/go-eth2-client v0.18.3
github.com/ethereum/go-ethereum v1.13.4
golang.org/x/sys v0.13.0 // indirect
github.com/attestantio/go-eth2-client v0.19.8
github.com/ethereum/go-ethereum v1.13.10
golang.org/x/sys v0.15.0 // indirect
)
Loading

0 comments on commit 7a0a13f

Please sign in to comment.