From d930bc034742b15eba2629b7c71530343032765d Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Wed, 7 Jun 2023 21:06:44 +0530 Subject: [PATCH 01/12] improvements --- go.mod | 17 +- go.sum | 82 +++- monitor/evmabi/PriceFeed.json | 900 ++++++++++++++++++++++++++++++++++ monitor/evmquery.go | 92 ++++ monitor/execute.go | 55 +-- monitor/query.go | 276 ++++++----- monitor/slack.go | 77 +++ 7 files changed, 1351 insertions(+), 148 deletions(-) create mode 100644 monitor/evmabi/PriceFeed.json create mode 100644 monitor/evmquery.go create mode 100644 monitor/slack.go diff --git a/go.mod b/go.mod index fe43170..f890cc9 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/ojo-network/contractMonitor go 1.19 require ( + github.com/ethereum/go-ethereum v1.12.0 github.com/joho/godotenv v1.5.1 github.com/rs/zerolog v1.29.1 github.com/slack-go/slack v0.12.2 @@ -11,22 +12,34 @@ require ( ) require ( + github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/deckarep/golang-set/v2 v2.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-ole/go-ole v1.2.1 // indirect + github.com/go-stack/stack v1.8.1 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.4.2 // indirect + github.com/tklauser/go-sysconf v0.3.5 // indirect + github.com/tklauser/numcpus v0.2.2 // indirect + golang.org/x/crypto v0.9.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 14e43a3..cac9f0e 100644 --- a/go.sum +++ b/go.sum @@ -38,7 +38,16 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= +github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -46,26 +55,49 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= +github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= +github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= +github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= +github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= +github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -91,6 +123,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -119,51 +153,75 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= +github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/slack-go/slack v0.12.2 h1:x3OppyMyGIbbiyFhsBmpf9pwkUzMhthJMRNmNlA4LaQ= github.com/slack-go/slack v0.12.2/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= @@ -178,6 +236,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= +github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -191,6 +250,14 @@ github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gt github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= +github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -208,6 +275,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -218,6 +287,7 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -292,6 +362,7 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -324,11 +395,13 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -346,6 +419,7 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -485,12 +559,16 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/monitor/evmabi/PriceFeed.json b/monitor/evmabi/PriceFeed.json new file mode 100644 index 0000000..3dfcf5a --- /dev/null +++ b/monitor/evmabi/PriceFeed.json @@ -0,0 +1,900 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "MedianDisabled", + "type": "error" + }, + { + "inputs": [], + "name": "UnAuthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "DeviationPosted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "MedianPosted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "MedianStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "PricePosted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "RemovedFromWhitelist", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "previousAdminRole", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "newAdminRole", + "type": "bytes32" + } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bool", + "name": "status", + "type": "bool" + } + ], + "name": "WhitelistStatus", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "Whitelisted", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RELAYER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "USD", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "relayer", + "type": "address" + } + ], + "name": "assignRelayerRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetName", + "type": "bytes32" + } + ], + "name": "getDeviationData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "_assetNames", + "type": "bytes32[]" + } + ], + "name": "getDeviationDataBulk", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data[]", + "name": "deviationData", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetName", + "type": "bytes32" + } + ], + "name": "getMedianData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "internalType": "struct PriceFeed.MedianData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "_assetNames", + "type": "bytes32[]" + } + ], + "name": "getMedianDataBulk", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "internalType": "struct PriceFeed.MedianData[]", + "name": "medianData", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_base", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "_qoute", + "type": "bytes32" + } + ], + "name": "getPrice", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "baseResolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "quoteResolveTime", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Price", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_assetName", + "type": "bytes32" + } + ], + "name": "getPriceData", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "_assetNames", + "type": "bytes32[]" + } + ], + "name": "getPriceDataBulk", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data[]", + "name": "priceData", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + } + ], + "name": "getRoleAdmin", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "hasRole", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data[]", + "name": "_deviations", + "type": "tuple[]" + }, + { + "internalType": "bool", + "name": "_disableResolve", + "type": "bool" + } + ], + "name": "postDeviations", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } + ], + "internalType": "struct PriceFeed.MedianData[]", + "name": "_medians", + "type": "tuple[]" + }, + { + "internalType": "bool", + "name": "_disableResolve", + "type": "bool" + } + ], + "name": "postMedians", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "assetName", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resolveTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + } + ], + "internalType": "struct PriceFeed.Data[]", + "name": "_prices", + "type": "tuple[]" + }, + { + "internalType": "bool", + "name": "_disableResolve", + "type": "bool" + } + ], + "name": "postPrices", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "removeAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "relayer", + "type": "address" + } + ], + "name": "revokeRelayerRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "role", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_status", + "type": "bool" + } + ], + "name": "setMedianStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "_status", + "type": "bool" + } + ], + "name": "setWhitelistStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_user", + "type": "address" + } + ], + "name": "whitelistAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/monitor/evmquery.go b/monitor/evmquery.go new file mode 100644 index 0000000..742aa2c --- /dev/null +++ b/monitor/evmquery.go @@ -0,0 +1,92 @@ +package monitor + +import ( + "context" + _ "embed" + "fmt" + "log" + "math/big" + "strings" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" +) + +//go:embed evmabi/PriceFeed.json +var oracleABI string + +func checkBalanceEvm(ctx context.Context, threshold, warning *big.Int, network, rpc, accountAddress string) error { + client, err := ethclient.Dial(rpc) + if err != nil { + log.Fatalf("Failed to connect to the Ethereum client: %v", err) + } + + address := common.HexToAddress(accountAddress) + balance, err := client.BalanceAt(ctx, address, nil) + if err != nil { + log.Fatalf("Failed to get balance: %v", err) + } + + if balance.Cmp(warning) <= 0 { + slackchan <- createLowBalanceAttachment(balance.Cmp(threshold) > 0, balance.String(), "ETH", accountAddress, network) + } + + return nil +} + +func checkQueryEVM(network, rpc, contractAddress, _assetName string) error { + client, err := ethclient.Dial(rpc) + if err != nil { + log.Fatalf("Failed to connect to the Ethereum client: %v", err) + } + + address := common.HexToAddress(contractAddress) + + // Ensure to replace YourContractABI with your actual contract's ABI + parsedABI, err := abi.JSON(strings.NewReader(oracleABI)) + if err != nil { + return fmt.Errorf("Failed to parse contract ABI: %v", err) + } + + bytesAssetName := []byte(_assetName) + paddedAssetName := common.RightPadBytes(bytesAssetName, 32) // ETH uses 32 bytes + + result, err := parsedABI.Pack("getMedianData", paddedAssetName) + if err != nil { + return fmt.Errorf("Failed to pack data for function call: %v", err) + } + + msg := ethereum.CallMsg{To: &address, Data: result} + output, err := client.CallContract(context.Background(), msg, nil) + if err != nil { + return fmt.Errorf("Failed to call contract: %v", err) + } + + var medianData struct { + AssetName [32]byte + ResolveTime *big.Int + ID *big.Int + Values []*big.Int + } + + err = parsedABI.UnpackIntoInterface(&medianData, "getMedianData", output) + if err != nil { + return fmt.Errorf("Failed to unpack data from function call: %v", err) + } + + check.Lock() + defer check.Unlock() + + id := medianData.ID.Int64() + if id <= globallist[contractAddress] { + slackchan <- createStaleRequestIDAttachment(globallist[contractAddress], id, contractAddress, network) + return nil + } + + // update to latest id + globallist[contractAddress] = id + + return nil +} diff --git a/monitor/execute.go b/monitor/execute.go index 3aaa465..bd15ed9 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -18,19 +18,33 @@ import ( const ( deviation = "eyJnZXRfZGV2aWF0aW9uX3JlZiI6IHsic3ltYm9sIjogIkFUT00ifX0=" + median = "eyJnZXRfbWVkaWFuX3JlZiI6IHsic3ltYm9sIjogIkFUT00ifX0=" + rate = "eyJnZXRfcmVmIjogeyJzeW1ib2wiOiAiQVRPTSJ9fQ==" ) -var ( - slackchan chan slack.Attachment - errchan chan error - check sync.Mutex - globallist map[string]int64 +type IDS struct { + requestID int64 + medianID int64 + deviationID int64 +} - LowBalance = "Low Balance" - StaleRequestID = "No New Request id" +var ( + slackchan chan slack.Attachment + errchan chan error + wg sync.WaitGroup + + LowBalance = "Low Balance" + StaleRateRequestID = "No New Request id" + StaleMedianRequestID = "No New Median id" + StaleDeviationRequestID = "No New Deviation id" ) -const RELAYER = "cw-relayer" +const ( + RELAYER = "cw-relayer" + RATE_ID = "Rate Request id" + MEDIAN_ID = "Median Rate Request id" + DEVIATION_ID = "Deviation Request id" +) var rootCmd = &cobra.Command{ Use: "monitor [config-file]", @@ -56,8 +70,6 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { slackchan = make(chan slack.Attachment, len(config.AddressMap)) errchan = make(chan error, len(config.AddressMap)) - globallist = make(map[string]int64) - logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.InfoLevel).With().Timestamp().Logger() cronDuration, err := time.ParseDuration(config.CronInterval) @@ -66,31 +78,10 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { } ctx, cancel := context.WithCancel(cmd.Context()) - var wg sync.WaitGroup for network, asset := range config.AddressMap { - globallist[asset.ContractAddress] = 0 rpc := config.NetworkRpc[network] wg.Add(1) - go func(ctx context.Context, threshold, warning int64, network, denom, rpc, relayer, contractAddress string) { - defer wg.Done() - for { - select { - case <-ctx.Done(): - return - default: - if err := checkBalance(threshold, warning, network, denom, rpc, relayer); err != nil { - errchan <- err - } - - err := checkQuery(network, rpc, contractAddress) - if err != nil { - errchan <- err - } - - time.Sleep(cronDuration) - } - } - }(ctx, asset.Threshold, asset.WarningThreshold, network, asset.Denom, rpc, asset.RelayerAddress, asset.ContractAddress) + newCosmwasChecker(ctx, cronDuration, asset.Threshold, asset.WarningThreshold, network, asset.Denom, rpc, asset.ContractAddress, RELAYER) } go func() { diff --git a/monitor/query.go b/monitor/query.go index 2a3ec9c..e65c844 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -1,6 +1,7 @@ package monitor import ( + "context" "encoding/json" "fmt" "io" @@ -8,34 +9,79 @@ import ( "strconv" "time" - "github.com/slack-go/slack" + "golang.org/x/sync/errgroup" ) -type Response struct { - Data struct { - Rate string `json:"rate"` - ResolveTime string `json:"resolve_time"` - RequestID string `json:"request_id"` - } `json:"data"` -} +type ( + Response struct { + Data struct { + RequestID string `json:"request_id"` + } `json:"data"` + } + + Balance struct { + Denom string `json:"denom"` + Amount string `json:"amount"` + } + + Pagination struct { + NextKey *string `json:"next_key"` + Total string `json:"total"` + } -type Balance struct { - Denom string `json:"denom"` - Amount string `json:"amount"` + BalResponse struct { + Balances []Balance `json:"balances"` + Pagination Pagination `json:"pagination"` + } +) + +type cosmwasmChecker struct { + threshold, warning int64 + network, denom, rpc, contractAddress, relayerAddress string + reportMedian, reportDeviation bool + requestID, deviationID, medianID int64 } -type Pagination struct { - NextKey *string `json:"next_key"` - Total string `json:"total"` +func newCosmwasChecker(ctx context.Context, duration time.Duration, threshold, warning int64, network, denom, rpc, contractAddress, relayerAddress string, reportMedian, reportDeviation bool) { + checker := &cosmwasmChecker{ + threshold: threshold, + warning: warning, + network: network, + denom: denom, + rpc: rpc, + contractAddress: contractAddress, + relayerAddress: relayerAddress, + reportMedian: reportMedian, + reportDeviation: reportDeviation, + } + + go checker.startCron(ctx, duration) } -type BalResponse struct { - Balances []Balance `json:"balances"` - Pagination Pagination `json:"pagination"` +func (c *cosmwasmChecker) startCron(ctx context.Context, duration time.Duration) { + for { + select { + case <-ctx.Done(): + wg.Done() + return + + default: + err := c.checkBalance() + if err != nil { + errchan <- err + } + + err = c.checkQuery(ctx) + if err != nil { + errchan <- err + } + time.Sleep(duration) + } + } } -func checkBalance(threshold, warning int64, network, denom, rpc, relayerAddress string) error { - bal := fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", rpc, relayerAddress) +func (c *cosmwasmChecker) checkBalance() error { + bal := fmt.Sprintf("%s/cosmos/bank/v1beta1/balances/%s", c.rpc, c.relayerAddress) balResp, err := http.Get(bal) if err != nil { return err @@ -52,7 +98,7 @@ func checkBalance(threshold, warning int64, network, denom, rpc, relayerAddress return err } for _, balance := range balResponse.Balances { - if balance.Denom != denom { + if balance.Denom != c.denom { continue } @@ -61,112 +107,118 @@ func checkBalance(threshold, warning int64, network, denom, rpc, relayerAddress return err } - if amount <= warning { - slackchan <- createLowBalanceAttachment((amount <= warning) && (amount > threshold), balance.Amount, denom, relayerAddress, network) + if amount <= c.warning { + slackchan <- createLowBalanceAttachment((amount <= c.warning) && (amount > c.threshold), balance.Amount, c.denom, c.relayerAddress, c.network) } } return nil } -func checkQuery(network, rpc, address string) error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", rpc, address, deviation) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } +func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { + g, _ := errgroup.WithContext(ctx) - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) - if err != nil { - return err - } + g.Go(func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, rate) + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() - check.Lock() - defer check.Unlock() + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return err + } - requestID := globallist[address] - globallist[address] = num - if num <= requestID { - slackchan <- createStaleRequestIDAttachment(num, response.Data.RequestID, address, network) - } + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return err + } - return nil -} + num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + if err != nil { + return err + } -func createLowBalanceAttachment(warning bool, balance, denom, relayerAddress, network string) slack.Attachment { - attachment := slack.Attachment{ - Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), - Title: fmt.Sprintf(":exclamation: %s", LowBalance), - Color: "danger", - Fields: []slack.AttachmentField{ - { - Title: "Relayer Address", - Value: fmt.Sprintf("```%s```", relayerAddress), - Short: false, - }, - { - Title: "Current balance", - Value: fmt.Sprintf("```%s%s```", balance, denom), - Short: true, - }, - { - Title: "Network", - Value: fmt.Sprintf("```%s```", network), - Short: true, - }, - }, - Footer: "Monitor Bot", - Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)), - } + if num <= c.requestID { + slackchan <- createStaleRequestIDAttachment(StaleRateRequestID, c.requestID, num, c.contractAddress, c.network) + return nil + } - if warning { - attachment.Color = "ff9966" + c.requestID = num + return nil + }) + + if c.reportDeviation { + g.Go(func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, deviation) + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return err + } + + num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + if err != nil { + return err + } + + if num <= c.deviationID { + slackchan <- createStaleRequestIDAttachment(StaleDeviationRequestID, c.deviationID, num, c.contractAddress, c.network) + return nil + } + + // update to latest id + c.deviationID = num + return nil + }) } - return attachment -} - -func createStaleRequestIDAttachment(oldRequestID int64, currentRequestID string, contractAddress, network string) slack.Attachment { - attachment := slack.Attachment{ - Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), - Title: fmt.Sprintf(":exclamation: %s", StaleRequestID), - Color: "danger", - Fields: []slack.AttachmentField{ - { - Title: "Contract Address", - Value: fmt.Sprintf("```%s```", contractAddress), - Short: false, - }, - { - Title: "Current Request ID", - Value: fmt.Sprintf("```%s```", currentRequestID), - Short: true, - }, - { - Title: "Old Request ID", - Value: fmt.Sprintf("```%s```", strconv.FormatInt(oldRequestID, 10)), - Short: true, - }, - { - Title: "Network", - Value: fmt.Sprintf("```%s```", network), - Short: false, - }, - }, - Footer: "Monitor Bot", - Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)), + if c.reportMedian { + g.Go(func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, median) + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return err + } + + num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + if err != nil { + return err + } + + if num <= c.deviationID { + slackchan <- createStaleRequestIDAttachment(StaleMedianRequestID, c.deviationID, num, c.contractAddress, c.network) + return nil + } + + // update to latest id + c.medianID = num + return nil + }) } - return attachment + return g.Wait() } diff --git a/monitor/slack.go b/monitor/slack.go new file mode 100644 index 0000000..30fd358 --- /dev/null +++ b/monitor/slack.go @@ -0,0 +1,77 @@ +package monitor + +import ( + "encoding/json" + "fmt" + "strconv" + "time" + + "github.com/slack-go/slack" +) + +func createLowBalanceAttachment(warning bool, balance, denom, relayerAddress, network string) slack.Attachment { + attachment := slack.Attachment{ + Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), + Title: fmt.Sprintf(":exclamation: %s", LowBalance), + Color: "danger", + Fields: []slack.AttachmentField{ + { + Title: "Relayer Address", + Value: fmt.Sprintf("```%s```", relayerAddress), + Short: false, + }, + { + Title: "Current balance", + Value: fmt.Sprintf("```%s%s```", balance, denom), + Short: true, + }, + { + Title: "Network", + Value: fmt.Sprintf("```%s```", network), + Short: true, + }, + }, + Footer: "Monitor Bot", + Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)), + } + + if warning { + attachment.Color = "ff9966" + } + + return attachment +} + +func createStaleRequestIDAttachment(requestTitle string, oldRequestID int64, currentRequestID int64, contractAddress, network string) slack.Attachment { + attachment := slack.Attachment{ + Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), + Title: fmt.Sprintf(":exclamation: %s", requestTitle), + Color: "danger", + Fields: []slack.AttachmentField{ + { + Title: "Contract Address", + Value: fmt.Sprintf("```%s```", contractAddress), + Short: false, + }, + { + Title: "Current Request ID", + Value: fmt.Sprintf("```%s```", currentRequestID), + Short: true, + }, + { + Title: "Old Request ID", + Value: fmt.Sprintf("```%s```", strconv.FormatInt(oldRequestID, 10)), + Short: true, + }, + { + Title: "Network", + Value: fmt.Sprintf("```%s```", network), + Short: false, + }, + }, + Footer: "Monitor Bot", + Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)), + } + + return attachment +} From 4e150a7ccd1f80c02d010d4f260ffbbf1a3cf73d Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Wed, 7 Jun 2023 21:44:20 +0530 Subject: [PATCH 02/12] fields in config and updating sample --- config.toml | 2 + config/config.go | 12 +- monitor/evmabi/PriceFeed.json | 900 ---------------------------------- monitor/evmquery.go | 92 ---- monitor/execute.go | 14 +- monitor/query.go | 176 ++++--- 6 files changed, 125 insertions(+), 1071 deletions(-) delete mode 100644 monitor/evmabi/PriceFeed.json delete mode 100644 monitor/evmquery.go diff --git a/config.toml b/config.toml index 9c8bc88..716f67e 100644 --- a/config.toml +++ b/config.toml @@ -6,6 +6,8 @@ relayer_address = "juno1rkhrfuq7k2k68k0hctrmv8efyxul6tgn8hny6y" denom="ujuno" warning_threshold=5000000 threshold=1000000 +report_median=true +report_deviation=true [network_rpc] juno-testnet = "https://juno-api.polkachu.com" \ No newline at end of file diff --git a/config/config.go b/config/config.go index 64fe518..773495e 100644 --- a/config/config.go +++ b/config/config.go @@ -15,11 +15,13 @@ type ( } Relayer struct { - ContractAddress string `mapstructure:"contract_address"` - RelayerAddress string `mapstructure:"relayer_address"` - Denom string `mapstructure:"denom"` - WarningThreshold int64 `mapstructure:"warning_threshold"` - Threshold int64 `mapstructure:"threshold"` + ContractAddress string `mapstructure:"contract_address" validate:"required"` + RelayerAddress string `mapstructure:"relayer_address" validate:"required"` + Denom string `mapstructure:"denom" validate:"required"` + WarningThreshold int64 `mapstructure:"warning_threshold" validate:"required"` + Threshold int64 `mapstructure:"threshold" validate:"required"` + ReportMedian bool `mapstructure:"report_median" validate:"required"` + ReportDeviation bool `mapstructure:"report_deviation" validate:"required"` } AccessToken struct { diff --git a/monitor/evmabi/PriceFeed.json b/monitor/evmabi/PriceFeed.json deleted file mode 100644 index 3dfcf5a..0000000 --- a/monitor/evmabi/PriceFeed.json +++ /dev/null @@ -1,900 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "MedianDisabled", - "type": "error" - }, - { - "inputs": [], - "name": "UnAuthorized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "relayer", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "name": "DeviationPosted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "relayer", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "name": "MedianPosted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bool", - "name": "status", - "type": "bool" - } - ], - "name": "MedianStatus", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "relayer", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "timestamp", - "type": "uint256" - } - ], - "name": "PricePosted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "RemovedFromWhitelist", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bool", - "name": "status", - "type": "bool" - } - ], - "name": "WhitelistStatus", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "user", - "type": "address" - } - ], - "name": "Whitelisted", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "RELAYER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "USD", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "relayer", - "type": "address" - } - ], - "name": "assignRelayerRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "claimOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_assetName", - "type": "bytes32" - } - ], - "name": "getDeviationData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "_assetNames", - "type": "bytes32[]" - } - ], - "name": "getDeviationDataBulk", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data[]", - "name": "deviationData", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_assetName", - "type": "bytes32" - } - ], - "name": "getMedianData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "internalType": "struct PriceFeed.MedianData", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "_assetNames", - "type": "bytes32[]" - } - ], - "name": "getMedianDataBulk", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "internalType": "struct PriceFeed.MedianData[]", - "name": "medianData", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_base", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "_qoute", - "type": "bytes32" - } - ], - "name": "getPrice", - "outputs": [ - { - "components": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "baseResolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "quoteResolveTime", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Price", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "_assetName", - "type": "bytes32" - } - ], - "name": "getPriceData", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32[]", - "name": "_assetNames", - "type": "bytes32[]" - } - ], - "name": "getPriceDataBulk", - "outputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data[]", - "name": "priceData", - "type": "tuple[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data[]", - "name": "_deviations", - "type": "tuple[]" - }, - { - "internalType": "bool", - "name": "_disableResolve", - "type": "bool" - } - ], - "name": "postDeviations", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "internalType": "uint256[]", - "name": "values", - "type": "uint256[]" - } - ], - "internalType": "struct PriceFeed.MedianData[]", - "name": "_medians", - "type": "tuple[]" - }, - { - "internalType": "bool", - "name": "_disableResolve", - "type": "bool" - } - ], - "name": "postMedians", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "assetName", - "type": "bytes32" - }, - { - "internalType": "uint256", - "name": "value", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "resolveTime", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "id", - "type": "uint256" - } - ], - "internalType": "struct PriceFeed.Data[]", - "name": "_prices", - "type": "tuple[]" - }, - { - "internalType": "bool", - "name": "_disableResolve", - "type": "bool" - } - ], - "name": "postPrices", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "removeAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "relayer", - "type": "address" - } - ], - "name": "revokeRelayerRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_status", - "type": "bool" - } - ], - "name": "setMedianStatus", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "_status", - "type": "bool" - } - ], - "name": "setWhitelistStatus", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "whitelistAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/monitor/evmquery.go b/monitor/evmquery.go deleted file mode 100644 index 742aa2c..0000000 --- a/monitor/evmquery.go +++ /dev/null @@ -1,92 +0,0 @@ -package monitor - -import ( - "context" - _ "embed" - "fmt" - "log" - "math/big" - "strings" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" -) - -//go:embed evmabi/PriceFeed.json -var oracleABI string - -func checkBalanceEvm(ctx context.Context, threshold, warning *big.Int, network, rpc, accountAddress string) error { - client, err := ethclient.Dial(rpc) - if err != nil { - log.Fatalf("Failed to connect to the Ethereum client: %v", err) - } - - address := common.HexToAddress(accountAddress) - balance, err := client.BalanceAt(ctx, address, nil) - if err != nil { - log.Fatalf("Failed to get balance: %v", err) - } - - if balance.Cmp(warning) <= 0 { - slackchan <- createLowBalanceAttachment(balance.Cmp(threshold) > 0, balance.String(), "ETH", accountAddress, network) - } - - return nil -} - -func checkQueryEVM(network, rpc, contractAddress, _assetName string) error { - client, err := ethclient.Dial(rpc) - if err != nil { - log.Fatalf("Failed to connect to the Ethereum client: %v", err) - } - - address := common.HexToAddress(contractAddress) - - // Ensure to replace YourContractABI with your actual contract's ABI - parsedABI, err := abi.JSON(strings.NewReader(oracleABI)) - if err != nil { - return fmt.Errorf("Failed to parse contract ABI: %v", err) - } - - bytesAssetName := []byte(_assetName) - paddedAssetName := common.RightPadBytes(bytesAssetName, 32) // ETH uses 32 bytes - - result, err := parsedABI.Pack("getMedianData", paddedAssetName) - if err != nil { - return fmt.Errorf("Failed to pack data for function call: %v", err) - } - - msg := ethereum.CallMsg{To: &address, Data: result} - output, err := client.CallContract(context.Background(), msg, nil) - if err != nil { - return fmt.Errorf("Failed to call contract: %v", err) - } - - var medianData struct { - AssetName [32]byte - ResolveTime *big.Int - ID *big.Int - Values []*big.Int - } - - err = parsedABI.UnpackIntoInterface(&medianData, "getMedianData", output) - if err != nil { - return fmt.Errorf("Failed to unpack data from function call: %v", err) - } - - check.Lock() - defer check.Unlock() - - id := medianData.ID.Int64() - if id <= globallist[contractAddress] { - slackchan <- createStaleRequestIDAttachment(globallist[contractAddress], id, contractAddress, network) - return nil - } - - // update to latest id - globallist[contractAddress] = id - - return nil -} diff --git a/monitor/execute.go b/monitor/execute.go index bd15ed9..b27d18d 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -81,7 +81,19 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { for network, asset := range config.AddressMap { rpc := config.NetworkRpc[network] wg.Add(1) - newCosmwasChecker(ctx, cronDuration, asset.Threshold, asset.WarningThreshold, network, asset.Denom, rpc, asset.ContractAddress, RELAYER) + newCosmwasmChecker( + ctx, + cronDuration, + asset.Threshold, + asset.WarningThreshold, + network, + asset.Denom, + rpc, + asset.ContractAddress, + asset.RelayerAddress, + asset.ReportMedian, + asset.ReportDeviation, + ) } go func() { diff --git a/monitor/query.go b/monitor/query.go index e65c844..7dd5bd9 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -42,7 +42,7 @@ type cosmwasmChecker struct { requestID, deviationID, medianID int64 } -func newCosmwasChecker(ctx context.Context, duration time.Duration, threshold, warning int64, network, denom, rpc, contractAddress, relayerAddress string, reportMedian, reportDeviation bool) { +func newCosmwasmChecker(ctx context.Context, duration time.Duration, threshold, warning int64, network, denom, rpc, contractAddress, relayerAddress string, reportMedian, reportDeviation bool) { checker := &cosmwasmChecker{ threshold: threshold, warning: warning, @@ -108,7 +108,13 @@ func (c *cosmwasmChecker) checkBalance() error { } if amount <= c.warning { - slackchan <- createLowBalanceAttachment((amount <= c.warning) && (amount > c.threshold), balance.Amount, c.denom, c.relayerAddress, c.network) + slackchan <- createLowBalanceAttachment( + (amount <= c.warning) && (amount > c.threshold), + balance.Amount, + c.denom, + c.relayerAddress, + c.network, + ) } } @@ -118,41 +124,9 @@ func (c *cosmwasmChecker) checkBalance() error { func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { g, _ := errgroup.WithContext(ctx) - g.Go(func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, rate) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } - - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) - if err != nil { - return err - } - - if num <= c.requestID { - slackchan <- createStaleRequestIDAttachment(StaleRateRequestID, c.requestID, num, c.contractAddress, c.network) - return nil - } - - c.requestID = num - return nil - }) - - if c.reportDeviation { - g.Go(func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, deviation) + g.Go( + func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, rate) resp, err := http.Get(url) if err != nil { return err @@ -174,50 +148,106 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { return err } - if num <= c.deviationID { - slackchan <- createStaleRequestIDAttachment(StaleDeviationRequestID, c.deviationID, num, c.contractAddress, c.network) + if num <= c.requestID { + slackchan <- createStaleRequestIDAttachment( + StaleRateRequestID, + c.requestID, + num, + c.contractAddress, + c.network, + ) return nil } - // update to latest id - c.deviationID = num + c.requestID = num return nil - }) + }, + ) + + if c.reportDeviation { + g.Go( + func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, deviation) + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return err + } + + num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + if err != nil { + return err + } + + if num <= c.deviationID { + slackchan <- createStaleRequestIDAttachment( + StaleDeviationRequestID, + c.deviationID, + num, + c.contractAddress, + c.network, + ) + return nil + } + + // update to latest id + c.deviationID = num + return nil + }, + ) } if c.reportMedian { - g.Go(func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, median) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } - - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) - if err != nil { - return err - } - - if num <= c.deviationID { - slackchan <- createStaleRequestIDAttachment(StaleMedianRequestID, c.deviationID, num, c.contractAddress, c.network) + g.Go( + func() error { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, median) + resp, err := http.Get(url) + if err != nil { + return err + } + defer resp.Body.Close() + + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return err + } + + num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + if err != nil { + return err + } + + if num <= c.deviationID { + slackchan <- createStaleRequestIDAttachment( + StaleMedianRequestID, + c.deviationID, + num, + c.contractAddress, + c.network, + ) + return nil + } + + // update to latest id + c.medianID = num return nil - } - - // update to latest id - c.medianID = num - return nil - }) + }, + ) } return g.Wait() From a41d9bddbc22773ddf60d2a36dc7ee172a897e3f Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Wed, 7 Jun 2023 22:06:33 +0530 Subject: [PATCH 03/12] improving error logging --- monitor/execute.go | 13 ++----------- monitor/query.go | 47 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/monitor/execute.go b/monitor/execute.go index b27d18d..7a10206 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -30,7 +30,6 @@ type IDS struct { var ( slackchan chan slack.Attachment - errchan chan error wg sync.WaitGroup LowBalance = "Low Balance" @@ -69,9 +68,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { client := slack.New(accessToken.SlackToken, slack.OptionDebug(false)) slackchan = make(chan slack.Attachment, len(config.AddressMap)) - errchan = make(chan error, len(config.AddressMap)) logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.InfoLevel).With().Timestamp().Logger() - cronDuration, err := time.ParseDuration(config.CronInterval) if err != nil { return err @@ -93,20 +90,15 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { asset.RelayerAddress, asset.ReportMedian, asset.ReportDeviation, + logger, ) } - go func() { - for err := range errchan { - logger.Err(err).Msg("Error in monitoring") - } - }() - go func() { for attachment := range slackchan { _, timestamp, err := client.PostMessage(accessToken.SlackChannel, slack.MsgOptionAttachments(attachment)) if err != nil { - errchan <- err + logger.Err(err).Msg("error posting slack message") } logger.Info().Str("Posted at timestamp", timestamp).Msg("slack message posted") @@ -120,7 +112,6 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { logger.Info().Msg("closing monitor, waiting for all routines to exit") wg.Wait() // waiting for all goroutines to exit - close(errchan) close(slackchan) return nil } diff --git a/monitor/query.go b/monitor/query.go index 7dd5bd9..41aa382 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -9,6 +9,7 @@ import ( "strconv" "time" + "github.com/rs/zerolog" "golang.org/x/sync/errgroup" ) @@ -36,13 +37,35 @@ type ( ) type cosmwasmChecker struct { - threshold, warning int64 - network, denom, rpc, contractAddress, relayerAddress string - reportMedian, reportDeviation bool - requestID, deviationID, medianID int64 + threshold int64 + warning int64 + network string + denom string + rpc string + contractAddress string + relayerAddress string + reportMedian bool + reportDeviation bool + requestID int64 + deviationID int64 + medianID int64 + logger zerolog.Logger } -func newCosmwasmChecker(ctx context.Context, duration time.Duration, threshold, warning int64, network, denom, rpc, contractAddress, relayerAddress string, reportMedian, reportDeviation bool) { +func newCosmwasmChecker( + ctx context.Context, + duration time.Duration, + threshold int64, + warning int64, + network string, + denom string, + rpc string, + contractAddress string, + relayerAddress string, + reportMedian bool, + reportDeviation bool, + logger zerolog.Logger, +) { checker := &cosmwasmChecker{ threshold: threshold, warning: warning, @@ -53,6 +76,7 @@ func newCosmwasmChecker(ctx context.Context, duration time.Duration, threshold, relayerAddress: relayerAddress, reportMedian: reportMedian, reportDeviation: reportDeviation, + logger: logger, } go checker.startCron(ctx, duration) @@ -68,13 +92,22 @@ func (c *cosmwasmChecker) startCron(ctx context.Context, duration time.Duration) default: err := c.checkBalance() if err != nil { - errchan <- err + c.logger.Err(err). + Str("relayer", c.relayerAddress). + Str("contract", c.contractAddress). + Str("network", c.network). + Msg("Error in querying balance") } err = c.checkQuery(ctx) if err != nil { - errchan <- err + c.logger.Err(err). + Str("relayer", c.relayerAddress). + Str("contract", c.contractAddress). + Str("network", c.network). + Msg("Error in querying request ids") } + time.Sleep(duration) } } From 9661d6f7a422d8c1e9d586338b03e4adc1b280a6 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 16:34:41 +0530 Subject: [PATCH 04/12] modifications and github actions --- .github/workflows/release.yml | 68 ++++++++++++++++++++++++++++++++++ .goreleaser.yml | 50 +++++++++++++++++++++++++ monitor/execute.go | 2 + monitor/version.go | 70 +++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml create mode 100644 monitor/version.go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0459f96 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release contract monitor + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - "v[0-9]+\\.[0-9]+\\.[0-9]+" # Official release version tags e.g. v2.0.5 + - "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # Release candidate tags e.g. v1.0.3-rc4 + - "v[0-9]+\\.[0-9]+\\.[0-9]+-alpha[0-9]+" # Alpha release testing tags e.g. v0.0.3-alpha1 + +permissions: + contents: write + id-token: write + +jobs: + goreleaser: + strategy: + matrix: + os: [ubuntu-latest, ubuntu-20.04] + runs-on: ${{matrix.os}} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-go@v4 + with: + go-version: 1.19 + cache: true + cache-dependency-path: go.sum + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/*}" >> $GITHUB_ENV + + - name: Check GLIBC version + if: startsWith(matrix.os, 'ubuntu-') + run: | + echo "GLIBC_VERSION=$(ldd --version | grep ldd | awk '{print $NF}')" >> $GITHUB_ENV + + # Ref: https://goreleaser.com/limitations/semver + - name: Tag without prefix locally to avoid error in goreleaser + run: |- + git tag -d ${{ env.RELEASE_VERSION }} || echo "No such a tag exists before" + git tag ${{ env.RELEASE_VERSION }} HEAD + + - name: Build + uses: goreleaser/goreleaser-action@v4 + if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Enable:ReleaseBuild') + with: + version: latest + args: build --rm-dist --skip-validate # skip validate skips initial sanity checks in order to be able to fully run + env: + GORELEASER_CURRENT_TAG: ${{ env.RELEASE_VERSION }} + GLIBC_VERSION: ${{ env.GLIBC_VERSION }} + + - name: release + if: startsWith(github.ref, 'refs/tags/') + uses: goreleaser/goreleaser-action@v4 + with: + # Note, we have to pin to v0.179.0 due to newer releases enforcing + # correct semantic versioning even when '--skip-validate' is provided. + # + # Ref: https://github.com/goreleaser/goreleaser/pull/2503 + version: v0.179.0 + args: release --rm-dist --skip-validate + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_CURRENT_TAG: ${{ env.RELEASE_VERSION }} + GLIBC_VERSION: ${{ env.GLIBC_VERSION }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..19c3d0e --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,50 @@ +project_name: relayerMonitor + +env: + - CGO_ENABLED=1 + +before: + hooks: + - go mod download + +builds: + - main: ./ + id: "relayerMonitor" + binary: relayerMonitor + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} + goos: + - linux + goarch: + - amd64 + +archives: + - id: bin + format: binary + name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}-glibc-{{.Env.GLIBC_VERSION}}" + + - id: tarball + format: tar.gz + wrap_in_directory: true + format_overrides: + - goos: windows + format: zip + name_template: '{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}-glibc-{{.Env.GLIBC_VERSION}}' + files: + - README.md + +release: + disable: false + +snapshot: + name_template: SNAPSHOT-{{ .Commit }} + +checksum: + name_template: 'SHA256SUMS-{{ replace .Version "version/" "cw-relayer-version-" }}-glibc-{{.Env.GLIBC_VERSION}}.txt' + algorithm: sha256 + +changelog: + skip: false \ No newline at end of file diff --git a/monitor/execute.go b/monitor/execute.go index 7a10206..534a053 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -57,6 +57,8 @@ func Execute() { fmt.Println(err) os.Exit(1) } + + rootCmd.AddCommand(getVersionCmd()) } func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { diff --git a/monitor/version.go b/monitor/version.go new file mode 100644 index 0000000..d1c9d35 --- /dev/null +++ b/monitor/version.go @@ -0,0 +1,70 @@ +package monitor + +import ( + "encoding/json" + "fmt" + "runtime" + + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" +) + +const ( + flagFormat = "format" +) + +var ( + // Version defines the application version (defined at compile time) + Version = "" + + // Commit defines the application commit hash (defined at compile time) + Commit = "" + + versionFormat string +) + +type versionInfo struct { + Version string `json:"version" yaml:"version"` + Commit string `json:"commit" yaml:"commit"` + Go string `json:"go" yaml:"go"` +} + +func getVersionCmd() *cobra.Command { + versionCmd := &cobra.Command{ + Use: "version", + Short: "Print binary version information", + RunE: func(cmd *cobra.Command, args []string) error { + verInfo := versionInfo{ + Version: Version, + Commit: Commit, + Go: fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH), + } + + var bz []byte + + var err error + switch versionFormat { + case "json": + bz, err = json.Marshal(verInfo) + + default: + bz, err = yaml.Marshal(&verInfo) + } + if err != nil { + return err + } + + _, err = fmt.Println(string(bz)) + return err + }, + } + + versionCmd.Flags().StringVar( + &versionFormat, + flagFormat, + "text", + "Print the version in the given format (text|json)", + ) + + return versionCmd +} From 5e553b497e909fec8a2fbdfe67ed247e8a710bf7 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 16:37:50 +0530 Subject: [PATCH 05/12] adding codeowners --- .github/CODEOWNERS | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..5eba45c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,8 @@ + +# CODEOWNERS: https://help.github.com/articles/about-codeowners/ + +# NOTE: Order is important; the last matching pattern takes the +# most precedence. + +# Primary repo maintainers +* @ojo-network/core-devs \ No newline at end of file From c235abcfaafde40a8d71ef9ce821e70815a2583c Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 22:50:32 +0530 Subject: [PATCH 06/12] minor improvements --- Makefile | 8 +++-- config.toml | 14 ++++----- config/config.go | 17 +++++----- go.mod | 18 ++--------- go.sum | 75 +------------------------------------------- main.go | 2 +- monitor/execute.go | 22 ++++++------- monitor/query.go | 78 ++++++++++++++-------------------------------- monitor/slack.go | 8 ++--- 9 files changed, 66 insertions(+), 176 deletions(-) diff --git a/Makefile b/Makefile index a3eb177..0874597 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -BUILD_DIR ?= $(CURDIR)/build +build: + go build -o ./ ./... -build: go.sum - CGO_ENABLED=0 go build -mod=readonly -o $(BUILD_DIR)/monitor ./... \ No newline at end of file +start: + ${MAKE} build + ./relayerMonitor ./config.toml \ No newline at end of file diff --git a/config.toml b/config.toml index 716f67e..4c3df50 100644 --- a/config.toml +++ b/config.toml @@ -1,13 +1,13 @@ -cron_interval="30s" +cron_interval="10s" [address_map.juno-testnet] -contract_address = "juno1yqm8q56hjv8sd4r37wdhkkdt3wu45gc5ptrjmd9k0nhvavl0354qwcf249" -relayer_address = "juno1rkhrfuq7k2k68k0hctrmv8efyxul6tgn8hny6y" -denom="ujuno" -warning_threshold=5000000 -threshold=1000000 +contract_address = "juno1v7na2m53cm3rkxxpe0k62yra3nkpeq7dy5zr528795fgymxrlz2ql4jsqp" +relayer_address = "juno1mlaew6aj273mw6j4uhtcvpv7ujjt0zc8az7lre" +denom="ujunox" +warning_threshold=500000000 +threshold=10000000000 report_median=true report_deviation=true [network_rpc] -juno-testnet = "https://juno-api.polkachu.com" \ No newline at end of file +juno-testnet = "https://juno-testnet-api.polkachu.com" \ No newline at end of file diff --git a/config/config.go b/config/config.go index 773495e..4562f32 100644 --- a/config/config.go +++ b/config/config.go @@ -15,13 +15,16 @@ type ( } Relayer struct { - ContractAddress string `mapstructure:"contract_address" validate:"required"` - RelayerAddress string `mapstructure:"relayer_address" validate:"required"` - Denom string `mapstructure:"denom" validate:"required"` - WarningThreshold int64 `mapstructure:"warning_threshold" validate:"required"` - Threshold int64 `mapstructure:"threshold" validate:"required"` - ReportMedian bool `mapstructure:"report_median" validate:"required"` - ReportDeviation bool `mapstructure:"report_deviation" validate:"required"` + ContractAddress string `mapstructure:"contract_address" validate:"required"` + RelayerAddress string `mapstructure:"relayer_address" validate:"required"` + Denom string `mapstructure:"denom" validate:"required"` + + // threshold is less than warning threshold + WarningThreshold int64 `mapstructure:"warning_threshold" validate:"required"` + Threshold int64 `mapstructure:"threshold" validate:"required"` + + ReportMedian bool `mapstructure:"report_median" validate:"required"` + ReportDeviation bool `mapstructure:"report_deviation" validate:"required"` } AccessToken struct { diff --git a/go.mod b/go.mod index f890cc9..f0b4907 100644 --- a/go.mod +++ b/go.mod @@ -1,45 +1,33 @@ -module github.com/ojo-network/contractMonitor +module github.com/ojo-network/relayerMonitor go 1.19 require ( - github.com/ethereum/go-ethereum v1.12.0 github.com/joho/godotenv v1.5.1 github.com/rs/zerolog v1.29.1 github.com/slack-go/slack v0.12.2 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 + golang.org/x/sync v0.1.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect - github.com/deckarep/golang-set/v2 v2.1.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-ole/go-ole v1.2.1 // indirect - github.com/go-stack/stack v1.8.1 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect - github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.4.2 // indirect - github.com/tklauser/go-sysconf v0.3.5 // indirect - github.com/tklauser/numcpus v0.2.2 // indirect - golang.org/x/crypto v0.9.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index cac9f0e..8b54328 100644 --- a/go.sum +++ b/go.sum @@ -38,16 +38,7 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= -github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -55,49 +46,26 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= -github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= -github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= -github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= -github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= -github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -123,8 +91,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -153,39 +119,30 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= -github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= @@ -194,34 +151,21 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= -github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/slack-go/slack v0.12.2 h1:x3OppyMyGIbbiyFhsBmpf9pwkUzMhthJMRNmNlA4LaQ= github.com/slack-go/slack v0.12.2/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= @@ -236,7 +180,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -250,14 +193,6 @@ github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gt github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= -github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= -github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= -github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= -github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -275,8 +210,6 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -287,7 +220,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -363,6 +295,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -395,7 +328,6 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -419,7 +351,6 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -559,16 +490,12 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.go b/main.go index da23cd0..7efc29e 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -import "github.com/ojo-network/contractMonitor/monitor" +import "github.com/ojo-network/relayerMonitor/monitor" func main() { monitor.Execute() diff --git a/monitor/execute.go b/monitor/execute.go index 534a053..1ae3541 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -13,7 +13,7 @@ import ( "github.com/slack-go/slack" "github.com/spf13/cobra" - "github.com/ojo-network/contractMonitor/config" + "github.com/ojo-network/relayerMonitor/config" ) const ( @@ -31,18 +31,14 @@ type IDS struct { var ( slackchan chan slack.Attachment wg sync.WaitGroup +) - LowBalance = "Low Balance" +const ( StaleRateRequestID = "No New Request id" StaleMedianRequestID = "No New Median id" StaleDeviationRequestID = "No New Deviation id" -) - -const ( - RELAYER = "cw-relayer" - RATE_ID = "Rate Request id" - MEDIAN_ID = "Median Rate Request id" - DEVIATION_ID = "Deviation Request id" + LowBalance = "Low Balance" + Relayer = "Relayer" ) var rootCmd = &cobra.Command{ @@ -76,6 +72,8 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { return err } + logger.Info().Msg("Relayer monitor starting...") + ctx, cancel := context.WithCancel(cmd.Context()) for network, asset := range config.AddressMap { rpc := config.NetworkRpc[network] @@ -94,6 +92,8 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { asset.ReportDeviation, logger, ) + + logger.Info().Str("network", network).Str("relayer address", asset.RelayerAddress).Msg("monitoring") } go func() { @@ -111,9 +111,9 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { for { select { case <-ctx.Done(): - logger.Info().Msg("closing monitor, waiting for all routines to exit") + logger.Info().Msg("closing monitor, waiting for all monitors to exit") - wg.Wait() // waiting for all goroutines to exit + wg.Wait() close(slackchan) return nil } diff --git a/monitor/query.go b/monitor/query.go index 41aa382..ad8db71 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -159,24 +159,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { g.Go( func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, rate) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } - - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + num, err := c.returnLatestID(rate) if err != nil { return err } @@ -200,24 +183,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { if c.reportDeviation { g.Go( func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, deviation) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } - - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + num, err := c.returnLatestID(deviation) if err != nil { return err } @@ -243,24 +209,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { if c.reportMedian { g.Go( func() error { - url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, median) - resp, err := http.Get(url) - if err != nil { - return err - } - defer resp.Body.Close() - - responseBody, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - - var response Response - if err := json.Unmarshal(responseBody, &response); err != nil { - return err - } - - num, err := strconv.ParseInt(response.Data.RequestID, 10, 64) + num, err := c.returnLatestID(median) if err != nil { return err } @@ -285,3 +234,24 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { return g.Wait() } + +func (c *cosmwasmChecker) returnLatestID(request string) (int64, error) { + url := fmt.Sprintf("%s/cosmwasm/wasm/v1/contract/%s/smart/%s", c.rpc, c.contractAddress, request) + resp, err := http.Get(url) + if err != nil { + return -1, err + } + defer resp.Body.Close() + + responseBody, err := io.ReadAll(resp.Body) + if err != nil { + return -1, err + } + + var response Response + if err := json.Unmarshal(responseBody, &response); err != nil { + return -1, err + } + + return strconv.ParseInt(response.Data.RequestID, 10, 64) +} diff --git a/monitor/slack.go b/monitor/slack.go index 30fd358..7fa7c74 100644 --- a/monitor/slack.go +++ b/monitor/slack.go @@ -11,7 +11,7 @@ import ( func createLowBalanceAttachment(warning bool, balance, denom, relayerAddress, network string) slack.Attachment { attachment := slack.Attachment{ - Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), + Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, Relayer), Title: fmt.Sprintf(":exclamation: %s", LowBalance), Color: "danger", Fields: []slack.AttachmentField{ @@ -44,7 +44,7 @@ func createLowBalanceAttachment(warning bool, balance, denom, relayerAddress, ne func createStaleRequestIDAttachment(requestTitle string, oldRequestID int64, currentRequestID int64, contractAddress, network string) slack.Attachment { attachment := slack.Attachment{ - Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, RELAYER), + Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, Relayer), Title: fmt.Sprintf(":exclamation: %s", requestTitle), Color: "danger", Fields: []slack.AttachmentField{ @@ -55,12 +55,12 @@ func createStaleRequestIDAttachment(requestTitle string, oldRequestID int64, cur }, { Title: "Current Request ID", - Value: fmt.Sprintf("```%s```", currentRequestID), + Value: fmt.Sprintf("```%d```", currentRequestID), Short: true, }, { Title: "Old Request ID", - Value: fmt.Sprintf("```%s```", strconv.FormatInt(oldRequestID, 10)), + Value: fmt.Sprintf("```%d```", oldRequestID), Short: true, }, { From 67336b54b90351cbeb2edc96f0b988f89024171e Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 23:01:12 +0530 Subject: [PATCH 07/12] go mod fixes --- .goreleaser.yml | 6 +++--- Makefile | 2 +- go.mod | 2 +- main.go | 2 +- monitor/execute.go | 9 ++++++--- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 19c3d0e..ea69868 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: relayerMonitor +project_name: contractMonitor env: - CGO_ENABLED=1 @@ -9,8 +9,8 @@ before: builds: - main: ./ - id: "relayerMonitor" - binary: relayerMonitor + id: "contractMonitor" + binary: contractMonitor mod_timestamp: "{{ .CommitTimestamp }}" flags: - -trimpath diff --git a/Makefile b/Makefile index 0874597..93583c4 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,4 @@ build: start: ${MAKE} build - ./relayerMonitor ./config.toml \ No newline at end of file + ./contractMonitor ./config.toml \ No newline at end of file diff --git a/go.mod b/go.mod index f0b4907..ebed022 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/ojo-network/relayerMonitor +module github.com/ojo-network/contractMonitor go 1.19 diff --git a/main.go b/main.go index 7efc29e..da23cd0 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -import "github.com/ojo-network/relayerMonitor/monitor" +import "github.com/ojo-network/contractMonitor/monitor" func main() { monitor.Execute() diff --git a/monitor/execute.go b/monitor/execute.go index 1ae3541..a9b6ffe 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -13,7 +13,7 @@ import ( "github.com/slack-go/slack" "github.com/spf13/cobra" - "github.com/ojo-network/relayerMonitor/config" + "github.com/ojo-network/contractMonitor/config" ) const ( @@ -72,7 +72,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { return err } - logger.Info().Msg("Relayer monitor starting...") + logger.Info().Msg("Contract monitor starting...") ctx, cancel := context.WithCancel(cmd.Context()) for network, asset := range config.AddressMap { @@ -93,7 +93,10 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { logger, ) - logger.Info().Str("network", network).Str("relayer address", asset.RelayerAddress).Msg("monitoring") + logger.Info().Str("network", network). + Str("relayer address", asset.RelayerAddress). + Str("contract address", asset.ContractAddress). + Msg("monitoring") } go func() { From aa9ad3d80fb79b36850d0e9558363937168629ec Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 23:14:18 +0530 Subject: [PATCH 08/12] go releaser fix --- .goreleaser.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ea69868..3030e96 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -33,8 +33,6 @@ archives: - goos: windows format: zip name_template: '{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}-glibc-{{.Env.GLIBC_VERSION}}' - files: - - README.md release: disable: false From 86bc11aafdf7151d058a10fb53afff47da00f5a6 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 23:20:41 +0530 Subject: [PATCH 09/12] github action update --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0459f96..f60de2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,9 @@ name: Release contract monitor on: push: + branches: + - main + # Sequence of patterns matched against refs/tags tags: - "v[0-9]+\\.[0-9]+\\.[0-9]+" # Official release version tags e.g. v2.0.5 From bce5ea52c32f7275fce0f164060aeb1d29afe866 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 23:47:40 +0530 Subject: [PATCH 10/12] median bug fix --- monitor/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/query.go b/monitor/query.go index ad8db71..b025a7f 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -214,7 +214,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { return err } - if num <= c.deviationID { + if num <= c.medianID { slackchan <- createStaleRequestIDAttachment( StaleMedianRequestID, c.deviationID, From 4e058cfd54f7e261d65ef3574369d10c44e05476 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Thu, 8 Jun 2023 23:52:39 +0530 Subject: [PATCH 11/12] bug fixes and config update --- config.toml | 20 ++++++++++---------- monitor/query.go | 12 ++++++------ monitor/slack.go | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/config.toml b/config.toml index 4c3df50..a152077 100644 --- a/config.toml +++ b/config.toml @@ -1,13 +1,13 @@ -cron_interval="10s" +cron_interval="50s" -[address_map.juno-testnet] -contract_address = "juno1v7na2m53cm3rkxxpe0k62yra3nkpeq7dy5zr528795fgymxrlz2ql4jsqp" -relayer_address = "juno1mlaew6aj273mw6j4uhtcvpv7ujjt0zc8az7lre" -denom="ujunox" -warning_threshold=500000000 -threshold=10000000000 -report_median=true -report_deviation=true +[address_map.juno] +contract_address = "juno1yqm8q56hjv8sd4r37wdhkkdt3wu45gc5ptrjmd9k0nhvavl0354qwcf249" +relayer_address = "juno1rkhrfuq7k2k68k0hctrmv8efyxul6tgn8hny6y" +denom="ujuno" +warning_threshold=500000000000000000 +threshold=1000000 +report_median = true +report_deviation = true [network_rpc] -juno-testnet = "https://juno-testnet-api.polkachu.com" \ No newline at end of file +juno = "https://juno-api.polkachu.com" \ No newline at end of file diff --git a/monitor/query.go b/monitor/query.go index b025a7f..833d6c8 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -167,10 +167,10 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { if num <= c.requestID { slackchan <- createStaleRequestIDAttachment( StaleRateRequestID, - c.requestID, - num, c.contractAddress, c.network, + c.requestID, + num, ) return nil } @@ -191,10 +191,10 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { if num <= c.deviationID { slackchan <- createStaleRequestIDAttachment( StaleDeviationRequestID, - c.deviationID, - num, c.contractAddress, c.network, + c.deviationID, + num, ) return nil } @@ -217,10 +217,10 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { if num <= c.medianID { slackchan <- createStaleRequestIDAttachment( StaleMedianRequestID, - c.deviationID, - num, c.contractAddress, c.network, + c.medianID, + num, ) return nil } diff --git a/monitor/slack.go b/monitor/slack.go index 7fa7c74..c35abb2 100644 --- a/monitor/slack.go +++ b/monitor/slack.go @@ -42,7 +42,7 @@ func createLowBalanceAttachment(warning bool, balance, denom, relayerAddress, ne return attachment } -func createStaleRequestIDAttachment(requestTitle string, oldRequestID int64, currentRequestID int64, contractAddress, network string) slack.Attachment { +func createStaleRequestIDAttachment(requestTitle, contractAddress, network string, oldRequestID, currentRequestID int64) slack.Attachment { attachment := slack.Attachment{ Pretext: fmt.Sprintf("*Network*: %s\n*Relayer*: %s", network, Relayer), Title: fmt.Sprintf(":exclamation: %s", requestTitle), From 3ba0941aaf8632ef7dad2f9dc413f6cb93e7c335 Mon Sep 17 00:00:00 2001 From: Aniket Dixit Date: Mon, 12 Jun 2023 14:45:31 +0530 Subject: [PATCH 12/12] comments and minor changes --- Makefile | 6 ++++-- monitor/execute.go | 18 ++++++++++++------ monitor/query.go | 8 ++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 93583c4..bd7749c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ build: - go build -o ./ ./... + go build -o ./build/ ./... start: ${MAKE} build - ./contractMonitor ./config.toml \ No newline at end of file + ./contractMonitor ./config.toml + +.PHONY: build start \ No newline at end of file diff --git a/monitor/execute.go b/monitor/execute.go index a9b6ffe..031e2b6 100644 --- a/monitor/execute.go +++ b/monitor/execute.go @@ -16,10 +16,16 @@ import ( "github.com/ojo-network/contractMonitor/config" ) +// base64 encoding for queries const ( + // {"get_deviation_ref": {"symbol": "ATOM"}} deviation = "eyJnZXRfZGV2aWF0aW9uX3JlZiI6IHsic3ltYm9sIjogIkFUT00ifX0=" - median = "eyJnZXRfbWVkaWFuX3JlZiI6IHsic3ltYm9sIjogIkFUT00ifX0=" - rate = "eyJnZXRfcmVmIjogeyJzeW1ib2wiOiAiQVRPTSJ9fQ==" + + // {"get_median_ref": {"symbol": "ATOM"}} + median = "eyJnZXRfbWVkaWFuX3JlZiI6IHsic3ltYm9sIjogIkFUT00ifX0=" + + // {"get_ref": {"symbol": "ATOM"}} + rate = "eyJnZXRfcmVmIjogeyJzeW1ib2wiOiAiQVRPTSJ9fQ==" ) type IDS struct { @@ -29,7 +35,7 @@ type IDS struct { } var ( - slackchan chan slack.Attachment + slackChan chan slack.Attachment wg sync.WaitGroup ) @@ -64,7 +70,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { } client := slack.New(accessToken.SlackToken, slack.OptionDebug(false)) - slackchan = make(chan slack.Attachment, len(config.AddressMap)) + slackChan = make(chan slack.Attachment, len(config.AddressMap)) logger := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).Level(zerolog.InfoLevel).With().Timestamp().Logger() cronDuration, err := time.ParseDuration(config.CronInterval) @@ -100,7 +106,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { } go func() { - for attachment := range slackchan { + for attachment := range slackChan { _, timestamp, err := client.PostMessage(accessToken.SlackChannel, slack.MsgOptionAttachments(attachment)) if err != nil { logger.Err(err).Msg("error posting slack message") @@ -117,7 +123,7 @@ func cwRelayerCmdHandler(cmd *cobra.Command, args []string) error { logger.Info().Msg("closing monitor, waiting for all monitors to exit") wg.Wait() - close(slackchan) + close(slackChan) return nil } } diff --git a/monitor/query.go b/monitor/query.go index 833d6c8..e153750 100644 --- a/monitor/query.go +++ b/monitor/query.go @@ -141,7 +141,7 @@ func (c *cosmwasmChecker) checkBalance() error { } if amount <= c.warning { - slackchan <- createLowBalanceAttachment( + slackChan <- createLowBalanceAttachment( (amount <= c.warning) && (amount > c.threshold), balance.Amount, c.denom, @@ -165,7 +165,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { } if num <= c.requestID { - slackchan <- createStaleRequestIDAttachment( + slackChan <- createStaleRequestIDAttachment( StaleRateRequestID, c.contractAddress, c.network, @@ -189,7 +189,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { } if num <= c.deviationID { - slackchan <- createStaleRequestIDAttachment( + slackChan <- createStaleRequestIDAttachment( StaleDeviationRequestID, c.contractAddress, c.network, @@ -215,7 +215,7 @@ func (c *cosmwasmChecker) checkQuery(ctx context.Context) error { } if num <= c.medianID { - slackchan <- createStaleRequestIDAttachment( + slackChan <- createStaleRequestIDAttachment( StaleMedianRequestID, c.contractAddress, c.network,