diff --git a/.gitignore b/.gitignore index 8fe65ec..5a93ab0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea noble-cctp-relayer +.ignore \ No newline at end of file diff --git a/cmd/noble/listener.go b/cmd/noble/listener.go index a8284fb..7f11ee6 100644 --- a/cmd/noble/listener.go +++ b/cmd/noble/listener.go @@ -1,32 +1,37 @@ package noble import ( - "cosmossdk.io/log" "encoding/json" "fmt" - "github.com/strangelove-ventures/noble-cctp-relayer/config" - "github.com/strangelove-ventures/noble-cctp-relayer/types" "io" "net/http" "strconv" "sync" "time" + + "cosmossdk.io/log" + "github.com/strangelove-ventures/noble-cctp-relayer/config" + "github.com/strangelove-ventures/noble-cctp-relayer/types" ) func StartListener(cfg config.Config, logger log.Logger, processingQueue chan *types.MessageState) { // set up client - logger.Info(fmt.Sprintf("Starting Noble listener at block %d", cfg.Networks.Source.Noble.StartBlock)) + logger.Info(fmt.Sprintf("Starting Noble listener at block %d looking back %d blocks", + cfg.Networks.Source.Noble.StartBlock, + cfg.Networks.Source.Noble.LookbackPeriod)) var wg sync.WaitGroup wg.Add(1) // enqueue block heights currentBlock := cfg.Networks.Source.Noble.StartBlock + lookback := cfg.Networks.Source.Noble.LookbackPeriod chainTip := GetNobleChainTip(cfg) blockQueue := make(chan uint64, 1000000) // history + currentBlock = currentBlock - lookback for currentBlock <= chainTip { blockQueue <- currentBlock currentBlock++ diff --git a/config/config.go b/config/config.go index e21c0aa..b0c29b6 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ type Config struct { RPC string `yaml:"rpc"` RequestQueueSize uint32 `yaml:"request-queue-size"` StartBlock uint64 `yaml:"start-block"` + LookbackPeriod uint64 `yaml:"lookback-period"` Workers uint32 `yaml:"workers"` Enabled bool `yaml:"enabled"` } `yaml:"noble"` diff --git a/go.mod b/go.mod index 1fbc761..37b03a5 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( ) require ( + cosmossdk.io/math v1.0.0-beta.4 github.com/circlefin/noble-cctp v0.0.0-20230911222715-829029fbba29 github.com/cometbft/cometbft v0.38.0 github.com/gin-gonic/gin v1.8.1 @@ -30,7 +31,6 @@ require ( cosmossdk.io/api v0.3.1 // indirect cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/math v1.1.2 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/4meepo/tagalign v1.3.2 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect diff --git a/go.sum b/go.sum index d686b6f..b645a79 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,8 @@ cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98ok cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= -cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= -cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= +cosmossdk.io/math v1.0.0-beta.4 h1:JtKedVLGzA0vv84xjYmZ75RKG35Kf2WwcFu8IjRkIIw= +cosmossdk.io/math v1.0.0-beta.4/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=