diff --git a/cmd/process.go b/cmd/process.go index ff5b526..8a1b383 100644 --- a/cmd/process.go +++ b/cmd/process.go @@ -11,6 +11,8 @@ import ( cctptypes "github.com/circlefin/noble-cctp/x/cctp/types" "github.com/spf13/cobra" "github.com/strangelove-ventures/noble-cctp-relayer/circle" + "github.com/strangelove-ventures/noble-cctp-relayer/ethereum" + "github.com/strangelove-ventures/noble-cctp-relayer/noble" "github.com/strangelove-ventures/noble-cctp-relayer/types" ) @@ -194,13 +196,25 @@ func filterLowTransfers(cfg *types.Config, logger log.Logger, msg *types.Message return true } - if bm.Amount.LT(math.NewIntFromUint64(cfg.MinAmount)) { + var minBurnAmount uint64 + if msg.DestDomain == types.Domain(4) { + minBurnAmount = cfg.Chains["noble"].(*noble.ChainConfig).MinAmount + } else { + for _, chain := range cfg.Chains { + c := chain.(*ethereum.ChainConfig) + if c.Domain == msg.DestDomain { + minBurnAmount = c.MinAmount + } + } + } + + if bm.Amount.LT(math.NewIntFromUint64(minBurnAmount)) { logger.Info( "Filtered tx because the transfer amount is less than the minimum allowed amount", "source_domain", msg.SourceDomain, "source_tx", msg.SourceTxHash, "amount", bm.Amount, - "min_amount", cfg.MinAmount, + "min_amount", minBurnAmount, ) return true } @@ -210,7 +224,7 @@ func filterLowTransfers(cfg *types.Config, logger log.Logger, msg *types.Message "source_domain", msg.SourceDomain, "source_tx", msg.SourceTxHash, "amount", bm.Amount.Uint64(), - "min_amount", cfg.MinAmount, + "min_amount", minBurnAmount, ) return false diff --git a/cmd/root.go b/cmd/root.go index d941dd6..d98f8f5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -112,7 +112,6 @@ func Parse(file string) (*types.Config, error) { ProcessorWorkerCount: cfg.ProcessorWorkerCount, Api: cfg.Api, Chains: make(map[string]types.ChainConfig), - MinAmount: cfg.MinAmount, } for name, chain := range cfg.Chains { diff --git a/config/sample-config.yaml b/config/sample-config.yaml index 58d9883..ccf0a79 100644 --- a/config/sample-config.yaml +++ b/config/sample-config.yaml @@ -12,6 +12,8 @@ chains: broadcast-retries: 5 # number of times to attempt the broadcast broadcast-retry-interval: 10 # time between retries in seconds + min-amount: 10 + minter-private-key: # private key @@ -30,6 +32,8 @@ chains: block-queue-channel-size: 1000000 # 1000000 is a safe default, increase number if starting from a very early block + min-amount: 0 + minter-private-key: # hex encoded privateKey # source domain id -> destination domain id diff --git a/ethereum/chain.go b/ethereum/chain.go index 3a55f92..10414c8 100644 --- a/ethereum/chain.go +++ b/ethereum/chain.go @@ -29,6 +29,7 @@ type Ethereum struct { minterAddress string maxRetries int retryIntervalSeconds int + minAmount uint64 mu sync.Mutex } @@ -45,6 +46,7 @@ func NewChain( privateKey string, maxRetries int, retryIntervalSeconds int, + minAmount uint64, ) (*Ethereum, error) { privEcdsaKey, ethereumAddress, err := GetEcdsaKeyAddress(privateKey) if err != nil { @@ -63,6 +65,7 @@ func NewChain( minterAddress: ethereumAddress, maxRetries: maxRetries, retryIntervalSeconds: retryIntervalSeconds, + minAmount: minAmount, }, nil } diff --git a/ethereum/config.go b/ethereum/config.go index f1a810f..eda1a3f 100644 --- a/ethereum/config.go +++ b/ethereum/config.go @@ -19,6 +19,8 @@ type ChainConfig struct { BroadcastRetries int `yaml:"broadcast-retries"` BroadcastRetryInterval int `yaml:"broadcast-retry-interval"` + MinAmount uint64 `yaml:"min-amount"` + // TODO move to keyring MinterPrivateKey string `yaml:"minter-private-key"` } @@ -36,5 +38,6 @@ func (c *ChainConfig) Chain(name string) (types.Chain, error) { c.MinterPrivateKey, c.BroadcastRetries, c.BroadcastRetryInterval, + c.MinAmount, ) } diff --git a/noble/chain.go b/noble/chain.go index e1c20d9..6ee81ca 100644 --- a/noble/chain.go +++ b/noble/chain.go @@ -35,6 +35,7 @@ type Noble struct { maxRetries int retryIntervalSeconds int blockQueueChannelSize uint64 + minamount uint64 mu sync.Mutex } @@ -51,6 +52,7 @@ func NewChain( maxRetries int, retryIntervalSeconds int, blockQueueChannelSize uint64, + minAmount uint64, ) (*Noble, error) { cc, err := cosmos.NewProvider(rpcURL) if err != nil { @@ -80,6 +82,7 @@ func NewChain( maxRetries: maxRetries, retryIntervalSeconds: retryIntervalSeconds, blockQueueChannelSize: blockQueueChannelSize, + minamount: minAmount, }, nil } diff --git a/noble/config.go b/noble/config.go index bcad409..d1f0596 100644 --- a/noble/config.go +++ b/noble/config.go @@ -21,6 +21,8 @@ type ChainConfig struct { BlockQueueChannelSize uint64 `yaml:"block-queue-channel-size"` + MinAmount uint64 `yaml:"min-amount"` + // TODO move to keyring MinterPrivateKey string `yaml:"minter-private-key"` } @@ -38,5 +40,6 @@ func (c *ChainConfig) Chain(name string) (types.Chain, error) { c.BroadcastRetries, c.BroadcastRetryInterval, c.BlockQueueChannelSize, + c.MinAmount, ) } diff --git a/types/config.go b/types/config.go index 1b3c06c..af50034 100644 --- a/types/config.go +++ b/types/config.go @@ -12,7 +12,6 @@ type Config struct { Api struct { TrustedProxies []string `yaml:"trusted-proxies"` } `yaml:"api"` - MinAmount uint64 `yaml:"min-amount"` } type ConfigWrapper struct { @@ -27,7 +26,6 @@ type ConfigWrapper struct { Api struct { TrustedProxies []string `yaml:"trusted-proxies"` } `yaml:"api"` - MinAmount uint64 `yaml:"min-amount"` } type ChainConfig interface {