From 24b05fd981e0417a005981ec3760ae87b082c7e7 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Fri, 16 Sep 2022 16:20:57 +0100 Subject: [PATCH 01/13] Use COMDEX chain as base swapping main app for wasm app --- cmd/bdjuno/main.go | 4 +-- go.mod | 3 +-- go.sum | 55 ++++++++++++++++++++-------------------- modules/types/sources.go | 35 +++++++++++++++---------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/cmd/bdjuno/main.go b/cmd/bdjuno/main.go index 8fa85800..9fb9439b 100644 --- a/cmd/bdjuno/main.go +++ b/cmd/bdjuno/main.go @@ -16,7 +16,7 @@ import ( "github.com/forbole/bdjuno/v3/database" "github.com/forbole/bdjuno/v3/modules" - cmdxapp "github.com/comdex-official/comdex/app" + wasmapp "github.com/CosmWasm/wasmd/app" gaiaapp "github.com/cosmos/gaia/v6/app" ) @@ -57,7 +57,7 @@ func main() { func getBasicManagers() []module.BasicManager { return []module.BasicManager{ gaiaapp.ModuleBasics, - cmdxapp.ModuleBasics, + wasmapp.ModuleBasics, } } diff --git a/go.mod b/go.mod index 1a999a06..53011755 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.17 require ( github.com/CosmWasm/wasmd v0.22.0 - github.com/comdex-official/comdex v0.1.1 github.com/cosmos/cosmos-sdk v0.45.3 github.com/cosmos/gaia/v6 v6.0.4 github.com/forbole/juno/v3 v3.3.1-0.20220803134534-55af63c839ac @@ -137,7 +136,7 @@ require ( ) replace ( - github.com/comdex-official/comdex => github.com/huichiaotsou/comdex v0.1.1-exportkeepers-a + github.com/CosmWasm/wasmd => github.com/mmsinclair/wasmd v0.22.0 github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.1 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/forbole/tendermint v0.34.13-0.20210820072129-a2a4af55563d diff --git a/go.sum b/go.sum index 0cc4b466..d8a5662d 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,7 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= @@ -66,8 +67,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/CosmWasm/wasmd v0.22.0 h1:6Bn2DDjHvLwZJkYXL+/PRQ9bSll0ReX2IZqRt/BQkhg= -github.com/CosmWasm/wasmd v0.22.0/go.mod h1:kNDnMAQDJyVek9k6SxCNijMCzOROzzUGBRT8r/vr7oY= github.com/CosmWasm/wasmvm v1.0.0-beta5 h1:38M8z89LB5cFMYB5vfjewMzz9Pr8TB1QBHdjnrWnkas= github.com/CosmWasm/wasmvm v1.0.0-beta5/go.mod h1:mtwKxbmsko1zdwpaKiRkRwxijMmIAtnLaX5/UT2nPFk= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -76,11 +75,8 @@ github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= @@ -121,7 +117,6 @@ github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZw github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/bandprotocol/bandchain-packet v0.0.2/go.mod h1:pk/wJxznWERdDVU2WWpzt8Tr0WvDSkT66JDYVdIECAo= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -209,10 +204,12 @@ github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4x github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.15.3/go.mod h1:OLjQiAQ4fGD2KDZooyJG9yz+p2ao2IAYSbke8mVvSA4= +github.com/cosmos/iavl v0.17.1/go.mod h1:7aisPZK8yCpQdy3PMvKeO+bhq1NwDjUwjzxwwROUxFk= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= -github.com/cosmos/ibc-go v1.0.0/go.mod h1:2wHKQUa+BLJMEyN635KrHfmTTwSNHBtXcqdY8JWGuXA= +github.com/cosmos/ibc-go/v2 v2.0.0/go.mod h1:n53VhNSUxCtMLysvgyNhwrGHL8OW+318LMjtSmaVe9Q= github.com/cosmos/ibc-go/v2 v2.0.2/go.mod h1:XUmW7wmubCRhIEAGtMGS+5IjiSSmcAwihoN/yPGd6Kk= +github.com/cosmos/ibc-go/v2 v2.0.3/go.mod h1:XUmW7wmubCRhIEAGtMGS+5IjiSSmcAwihoN/yPGd6Kk= github.com/cosmos/ibc-go/v2 v2.2.0 h1:nqpvElI9ku5oQZtKvLerhZ/UXH7QoL44VBTWwZkS4C8= github.com/cosmos/ibc-go/v2 v2.2.0/go.mod h1:rAHRlBcRiHPP/JszN+08SJx3pegww9bcVncIb9QLx7I= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= @@ -222,6 +219,7 @@ github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9 github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -261,6 +259,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/enigmampc/btcutil v1.0.3-0.20200723161021-e2fb6adb2a25/go.mod h1:hTr8+TLQmkUkgcuh3mcr5fjrT9c64ZzsBCdCEC6UppY= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= @@ -268,10 +267,12 @@ github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= @@ -303,6 +304,7 @@ github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmC github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= +github.com/go-co-op/gocron v1.13.0/go.mod h1:GD5EIEly1YNW+LovFVx5dzbYVcIc8544K99D8UVRpGo= github.com/go-co-op/gocron v1.16.1 h1:N4MhkCmYx22WqYoII13mMMFW/Fv4RJuz8ft/YPPK7MY= github.com/go-co-op/gocron v1.16.1/go.mod h1:W/N9G7bntRo5fVQlmjncvqSt74jxCxHfjyHlgcB33T8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -324,12 +326,6 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= -github.com/go-openapi/spec v0.20.3/go.mod h1:gG4F8wdEDN+YPBMVnzE85Rbhf+Th2DTvA9nFPQ5AYEg= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= @@ -356,7 +352,6 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= @@ -472,6 +467,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/gravity-devs/liquidity v1.4.6/go.mod h1:RcE8hMHhY+0bnKVEShiLi+zbboAxNRKTtPgleeJjM5I= github.com/gravity-devs/liquidity v1.5.0 h1:QOMLCOBrvp6FYUDMbBPJ+K3Oi9UF/q74c1cp48SsCRs= github.com/gravity-devs/liquidity v1.5.0/go.mod h1:67P0tk9OThjyIdXlIkxtBzCN+gTqNVc02uqLcrd7dT0= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -497,6 +493,7 @@ github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIv github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= @@ -547,8 +544,6 @@ github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= -github.com/huichiaotsou/comdex v0.1.1-exportkeepers-a h1:ygGSXB+SQH3e2s+a9TYIT/DuefNqLouwIjyzEkjqFqA= -github.com/huichiaotsou/comdex v0.1.1-exportkeepers-a/go.mod h1:wYpKRpB9iWQdwDy7RxWtOtY41IYI18EzW+XuGV1BP48= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -575,7 +570,6 @@ github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+ github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -599,6 +593,7 @@ github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNr github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= @@ -635,9 +630,6 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -689,6 +681,8 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mmsinclair/wasmd v0.22.0 h1:FUTFqMBcZtrdYpvCAleeHc6r1fdfwWVWlsVTaKEcsMM= +github.com/mmsinclair/wasmd v0.22.0/go.mod h1:ChFAJLM/loaeVoVZfN2p53BV7m98WA8ejQVmD60b4rM= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -802,6 +796,7 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -871,6 +866,7 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= @@ -878,7 +874,6 @@ github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F7 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -904,8 +899,9 @@ github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= +github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -918,8 +914,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.0/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= +github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= @@ -948,7 +944,6 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/swaggo/swag v1.7.4/go.mod h1:zD8h6h4SPv7t3l+4BKdRquqW1ASWjKZgT6Qv9z3kNqI= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= @@ -982,7 +977,6 @@ github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI= github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= @@ -1053,6 +1047,7 @@ golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= @@ -1060,6 +1055,7 @@ golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1126,7 +1122,6 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1161,8 +1156,10 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b h1:MWaHNqZy3KTpuTMAGvv+Kw+ylsEpmyJZizz1dqxnu28= golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1284,8 +1281,10 @@ golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/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-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1418,6 +1417,7 @@ google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1493,6 +1493,8 @@ google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= @@ -1552,7 +1554,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/modules/types/sources.go b/modules/types/sources.go index 310bce4d..5abd9091 100644 --- a/modules/types/sources.go +++ b/modules/types/sources.go @@ -2,11 +2,11 @@ package types import ( "fmt" + wasmapp "github.com/CosmWasm/wasmd/app" + "github.com/CosmWasm/wasmd/x/wasm" "os" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - cmdxapp "github.com/comdex-official/comdex/app" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/tendermint/tendermint/libs/log" @@ -76,32 +76,39 @@ func buildLocalSources(cfg *local.Details, encodingConfig *params.EncodingConfig return nil, err } - cmdxApp := cmdxapp.New(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), source.StoreDB, nil, true, map[int64]bool{}, - cfg.Home, 0, cmdxapp.MakeEncodingConfig(), simapp.EmptyAppOptions{}, nil, + app := simapp.NewSimApp( + log.NewTMLogger(log.NewSyncWriter(os.Stdout)), source.StoreDB, nil, true, map[int64]bool{}, + cfg.Home, 0, simapp.MakeTestEncodingConfig(), simapp.EmptyAppOptions{}, + ) + + wasmApp := wasmapp.NewWasmApp( + log.NewTMLogger(log.NewSyncWriter(os.Stdout)), source.StoreDB, nil, true, map[int64]bool{}, + cfg.Home, 0, wasmapp.MakeEncodingConfig(), wasm.EnableAllProposals, simapp.EmptyAppOptions{}, + nil, ) sources := &Sources{ - BankSource: localbanksource.NewSource(source, banktypes.QueryServer(cmdxApp.BankKeeper)), - DistrSource: localdistrsource.NewSource(source, distrtypes.QueryServer(cmdxApp.DistrKeeper)), - GovSource: localgovsource.NewSource(source, govtypes.QueryServer(cmdxApp.GovKeeper)), - MintSource: localmintsource.NewSource(source, minttypes.QueryServer(cmdxApp.MintKeeper)), - SlashingSource: localslashingsource.NewSource(source, slashingtypes.QueryServer(cmdxApp.SlashingKeeper)), - StakingSource: localstakingsource.NewSource(source, stakingkeeper.Querier{Keeper: cmdxApp.StakingKeeper}), - WasmSource: localwasmsource.NewSource(source, wasmkeeper.Querier(&cmdxApp.WasmKeeper)), + BankSource: localbanksource.NewSource(source, banktypes.QueryServer(app.BankKeeper)), + DistrSource: localdistrsource.NewSource(source, distrtypes.QueryServer(app.DistrKeeper)), + GovSource: localgovsource.NewSource(source, govtypes.QueryServer(app.GovKeeper)), + MintSource: localmintsource.NewSource(source, minttypes.QueryServer(app.MintKeeper)), + SlashingSource: localslashingsource.NewSource(source, slashingtypes.QueryServer(app.SlashingKeeper)), + StakingSource: localstakingsource.NewSource(source, stakingkeeper.Querier{Keeper: app.StakingKeeper}), + WasmSource: localwasmsource.NewSource(source, wasmkeeper.Querier(&wasmApp.WasmKeeper)), } // Mount and initialize the stores - err = source.MountKVStores(cmdxApp, "keys") + err = source.MountKVStores(app, "keys") if err != nil { return nil, err } - err = source.MountTransientStores(cmdxApp, "tkeys") + err = source.MountTransientStores(app, "tkeys") if err != nil { return nil, err } - err = source.MountMemoryStores(cmdxApp, "memKeys") + err = source.MountMemoryStores(app, "memKeys") if err != nil { return nil, err } From bdc557dcb6fac6674696248a4c9aad12ca31676f Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Fri, 16 Sep 2022 19:29:33 +0100 Subject: [PATCH 02/13] Add handlers for Nyx chain --- .gitignore | 1 + database/nym_mixnet_v1.go | 163 ++++++ database/nym_mixnet_v2.go | 113 ++++ database/schema/12-wasm.sql | 3 +- database/schema/13-wasm-events.sql | 13 + database/schema/14-nyx-nym-mixnet.sql | 23 + database/schema/15-nyx-nym-mixnet-v1.sql | 66 +++ database/schema/16-nyx-nym-mixnet-v2.sql | 66 +++ database/types/wasm.go | 51 +- database/wasm.go | 87 ++- go.mod | 4 +- go.sum | 8 +- hasura/metadata/actions.graphql | 191 +++--- hasura/metadata/actions.yaml | 412 ++++--------- hasura/metadata/allow_list.yaml | 2 +- hasura/metadata/api_limits.yaml | 1 + .../functions/public_messages_by_address.yaml | 2 +- .../bdjuno/tables/public_account.yaml | 123 ++-- ...ublic_average_block_time_from_genesis.yaml | 16 +- .../public_average_block_time_per_day.yaml | 16 +- .../public_average_block_time_per_hour.yaml | 16 +- .../public_average_block_time_per_minute.yaml | 16 +- .../databases/bdjuno/tables/public_block.yaml | 172 ++++-- .../bdjuno/tables/public_community_pool.yaml | 16 +- .../tables/public_distribution_params.yaml | 18 +- .../tables/public_double_sign_evidence.yaml | 46 +- .../tables/public_double_sign_vote.yaml | 88 +-- .../tables/public_fee_grant_allowance.yaml | 34 +- .../bdjuno/tables/public_genesis.yaml | 34 +- .../bdjuno/tables/public_gov_params.yaml | 22 +- .../bdjuno/tables/public_inflation.yaml | 28 +- .../bdjuno/tables/public_message.yaml | 54 +- .../bdjuno/tables/public_mint_params.yaml | 18 +- .../bdjuno/tables/public_modules.yaml | 14 +- .../public_nyx_nym_mixnet_v1_gateway.yaml | 11 + ...blic_nyx_nym_mixnet_v1_gateway_events.yaml | 13 + .../public_nyx_nym_mixnet_v1_mixnode.yaml | 25 + ...blic_nyx_nym_mixnet_v1_mixnode_events.yaml | 33 ++ ...blic_nyx_nym_mixnet_v1_mixnode_reward.yaml | 33 ++ ...blic_nyx_nym_mixnet_v1_mixnode_status.yaml | 10 + .../public_nyx_nym_mixnet_v2_events.yaml | 13 + .../public_nyx_nym_mixnet_v2_mixnode.yaml | 25 + ...blic_nyx_nym_mixnet_v2_mixnode_reward.yaml | 13 + ...blic_nyx_nym_mixnet_v2_mixnode_status.yaml | 10 + .../bdjuno/tables/public_pre_commit.yaml | 48 +- .../bdjuno/tables/public_proposal.yaml | 134 ++--- .../tables/public_proposal_deposit.yaml | 50 +- ...public_proposal_staking_pool_snapshot.yaml | 26 +- .../tables/public_proposal_tally_result.yaml | 30 +- ...ic_proposal_validator_status_snapshot.yaml | 38 +- .../bdjuno/tables/public_proposal_vote.yaml | 38 +- .../bdjuno/tables/public_slashing_params.yaml | 18 +- .../bdjuno/tables/public_staking_params.yaml | 18 +- .../bdjuno/tables/public_staking_pool.yaml | 18 +- .../bdjuno/tables/public_supply.yaml | 16 +- .../databases/bdjuno/tables/public_token.yaml | 28 +- .../bdjuno/tables/public_token_price.yaml | 28 +- .../tables/public_token_price_history.yaml | 26 +- .../bdjuno/tables/public_token_unit.yaml | 74 +-- .../bdjuno/tables/public_transaction.yaml | 55 +- .../bdjuno/tables/public_validator.yaml | 196 +++---- .../tables/public_validator_commission.yaml | 26 +- .../tables/public_validator_description.yaml | 34 +- .../bdjuno/tables/public_validator_info.yaml | 34 +- .../tables/public_validator_signing_info.yaml | 26 +- .../tables/public_validator_status.yaml | 28 +- .../tables/public_validator_voting_power.yaml | 30 +- .../bdjuno/tables/public_vesting_account.yaml | 44 +- .../bdjuno/tables/public_vesting_period.yaml | 26 +- .../bdjuno/tables/public_wasm_code.yaml | 36 +- .../bdjuno/tables/public_wasm_contract.yaml | 103 +++- .../tables/public_wasm_execute_contract.yaml | 50 +- .../public_wasm_execute_contract_event.yaml | 19 + .../bdjuno/tables/public_wasm_params.yaml | 22 +- .../databases/bdjuno/tables/tables.yaml | 11 + hasura/metadata/databases/databases.yaml | 4 +- .../graphql_schema_introspection.yaml | 1 + hasura/metadata/inherited_roles.yaml | 1 + hasura/metadata/network.yaml | 1 + hasura/metadata/query_collections.yaml | 39 +- hasura/metadata/rest_endpoints.yaml | 19 +- modules/wasm/handle_block.go | 11 + modules/wasm/handle_genesis.go | 1 + modules/wasm/handle_msg.go | 543 +++++++++++++++++- modules/wasm/handle_tx.go | 11 + modules/wasm/module.go | 6 +- modules/wasm/source/local/source.go | 6 +- modules/wasm/source/remote/source.go | 79 ++- modules/wasm/source/source.go | 2 + types/nym_mixnet_v1.go | 68 +++ types/nym_mixnet_v2.go | 53 ++ types/wasm.go | 4 +- 92 files changed, 2971 insertions(+), 1331 deletions(-) create mode 100644 database/nym_mixnet_v1.go create mode 100644 database/nym_mixnet_v2.go create mode 100644 database/schema/13-wasm-events.sql create mode 100644 database/schema/14-nyx-nym-mixnet.sql create mode 100644 database/schema/15-nyx-nym-mixnet-v1.sql create mode 100644 database/schema/16-nyx-nym-mixnet-v2.sql create mode 100644 hasura/metadata/api_limits.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway_events.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_events.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_reward.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_status.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_events.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_reward.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_status.yaml create mode 100644 hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract_event.yaml create mode 100644 hasura/metadata/graphql_schema_introspection.yaml create mode 100644 hasura/metadata/inherited_roles.yaml create mode 100644 hasura/metadata/network.yaml create mode 100644 modules/wasm/handle_block.go create mode 100644 modules/wasm/handle_tx.go create mode 100644 types/nym_mixnet_v1.go create mode 100644 types/nym_mixnet_v2.go diff --git a/.gitignore b/.gitignore index 8034ed4a..02ca44f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea/ build/ +pgdata # Configuration *.toml diff --git a/database/nym_mixnet_v1.go b/database/nym_mixnet_v1.go new file mode 100644 index 00000000..d91fe028 --- /dev/null +++ b/database/nym_mixnet_v1.go @@ -0,0 +1,163 @@ +package database + +import ( + "encoding/json" + "fmt" + dbtypes "github.com/forbole/bdjuno/v3/database/types" + "github.com/lib/pq" + "github.com/shopspring/decimal" + + cosmosTypes "github.com/cosmos/cosmos-sdk/types" + "github.com/forbole/bdjuno/v3/types" + juno "github.com/forbole/juno/v3/types" +) + +// EnsureExistsNymMixnetV1Mixnode ensures a mixnode is in the store +func (db *Db) EnsureExistsNymMixnetV1Mixnode(mixnode types.MixnodeV1) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_mixnode(identity_key, is_bonded, last_mixnet_status) +VALUES ($1, $2, $3) +ON CONFLICT DO NOTHING +` + _, err := db.Sql.Exec(stmt, + mixnode.IdentityKey, mixnode.IsBonded, mixnode.LastMixnetStatus.String(), + ) + if err != nil { + return fmt.Errorf("error while ensuring Nym mixnode exists: %s", err) + } + + return nil +} + +// SaveNymMixnetV1Mixnode allows to create or update a mixnode +func (db *Db) SaveNymMixnetV1Mixnode(mixnode types.MixnodeV1) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_mixnode(identity_key, is_bonded, last_mixnet_status) +VALUES ($1, $2, $3) +ON CONFLICT (identity_key) DO UPDATE + SET identity_key = excluded.identity_key, + is_bonded = excluded.is_bonded, + last_mixnet_status = excluded.last_mixnet_status +` + _, err := db.Sql.Exec(stmt, + mixnode.IdentityKey, mixnode.IsBonded, mixnode.LastMixnetStatus.String(), + ) + if err != nil { + return fmt.Errorf("error while saving Nym mixnode: %s", err) + } + + return nil +} + +// SaveNymMixnetV1Gateway allows to store the wasm params +func (db *Db) SaveNymMixnetV1Gateway(gateway types.GatewayV1) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_gateway(identity_key, is_bonded) +VALUES ($1, $2) +ON CONFLICT (identity_key) DO UPDATE + SET identity_key = excluded.identity_key, + is_bonded = excluded.is_bonded, +` + _, err := db.Sql.Exec(stmt, + gateway.IdentityKey, gateway.IsBonded, + ) + if err != nil { + return fmt.Errorf("error while saving Nym gateway: %s", err) + } + + return nil +} + +// SaveNymMixnetV1MixnodeEvent allows to store the wasm contract events +func (db *Db) SaveNymMixnetV1MixnodeEvent(eventKind string, actor string, proxy *string, identityKey string, amount *cosmosTypes.Coins, dataType string, dataJson string, executeContract types.WasmExecuteContract, tx *juno.Tx) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_mixnode_events +(event_kind, actor, sender, proxy, identity_key, amount, fee, contract_address, event_type, attributes, executed_at, height, hash) +VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)` + + var dbAmount interface{} + if amount != nil { + dbAmount = pq.Array(dbtypes.NewDbCoins(*amount)) + } + fee := pq.Array(dbtypes.NewDbCoins(tx.GetFee())) + + _, err := db.Sql.Exec(stmt, + eventKind, actor, + executeContract.Sender, + proxy, + identityKey, + dbAmount, fee, + executeContract.ContractAddress, dataType, dataJson, + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} + +// HasNymMixnetV1MixnodeRewardingEvent checks if a rewarding event has been saved +func (db *Db) HasNymMixnetV1MixnodeRewardingEvent(identityKey string, tx *juno.Tx) (bool, error) { + stmt := ` +SELECT COUNT(height) FROM nyx_nym_mixnet_v1_mixnode_reward WHERE identity_key = $1 AND height = $2 AND hash = $3 +` + var count int + err := db.Sql.QueryRow(stmt, identityKey, tx.Height, tx.TxHash).Scan(&count) + + return count > 0, err +} + +// SaveNymMixnetV1MixnodeRewardingEvent allows to store the mixnode rewarding events +func (db *Db) SaveNymMixnetV1MixnodeRewardingEvent(identityKey string, totalNodeReward cosmosTypes.Coins, totalDelegations cosmosTypes.Coins, operatorReward cosmosTypes.Coins, unitDelegatorReward decimal.Decimal, apy float64, stakingSupply cosmosTypes.Coins, profitMarginPercentage int, event cosmosTypes.StringEvent, executeContract types.WasmExecuteContract, tx *juno.Tx) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_mixnode_reward +(sender, identity_key, total_node_reward, total_delegations, operator_reward, unit_delegator_reward, apy, staking_supply, profit_margin_percentage, contract_address, event_type, attributes, executed_at, height, hash) +VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) +ON CONFLICT DO NOTHING` + + var attr = make(map[string]interface{}) // could be `map[string]string` however leaving to handle objects as values + for _, entry := range event.Attributes { + attr[entry.Key] = entry.Value + } + bytes, _ := json.Marshal(attr) + + dbTotalNodeReward := pq.Array(dbtypes.NewDbCoins(totalNodeReward)) + dbTotalDelegations := pq.Array(dbtypes.NewDbCoins(totalDelegations)) + dbOperatorReward := pq.Array(dbtypes.NewDbCoins(operatorReward)) + dbStakingSupply := pq.Array(dbtypes.NewDbCoins(stakingSupply)) + + _, err := db.Sql.Exec(stmt, + executeContract.Sender, + identityKey, + dbTotalNodeReward, + dbTotalDelegations, + dbOperatorReward, + unitDelegatorReward.IntPart(), + apy, + dbStakingSupply, + profitMarginPercentage, + executeContract.ContractAddress, event.Type, string(bytes), + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} + +// SaveNymMixnetV1MixnodeStatus allows to store when the mixnet rewarded set changes +func (db *Db) SaveNymMixnetV1MixnodeStatus(identityKey string, status string, routingScore int, executeContract types.WasmExecuteContract, tx *juno.Tx) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v1_mixnode_status +(mixnet_status, routing_score, identity_key, executed_at, height, hash ) +VALUES ($1, $2, $3, $4, $5, $6)` + + _, err := db.Sql.Exec(stmt, + status, routingScore, identityKey, + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} diff --git a/database/nym_mixnet_v2.go b/database/nym_mixnet_v2.go new file mode 100644 index 00000000..e3a73a5f --- /dev/null +++ b/database/nym_mixnet_v2.go @@ -0,0 +1,113 @@ +package database + +import ( + "encoding/json" + "fmt" + cosmosTypes "github.com/cosmos/cosmos-sdk/types" + dbtypes "github.com/forbole/bdjuno/v3/database/types" + "github.com/forbole/bdjuno/v3/types" + juno "github.com/forbole/juno/v3/types" + "github.com/lib/pq" + "github.com/shopspring/decimal" +) + +// EnsureExistsNymMixnetV2Mixnode ensures a mixnode is in the store +func (db *Db) EnsureExistsNymMixnetV2Mixnode(mixnode types.MixnodeV2) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v2_mixnode(mix_id, identity_key, is_bonded, last_mixnet_status) +VALUES ($1, $2, $3, $4) +ON CONFLICT DO NOTHING +` + _, err := db.Sql.Exec(stmt, + mixnode.MixId, mixnode.IdentityKey, mixnode.IsBonded, mixnode.LastMixnetStatus.String(), + ) + if err != nil { + return fmt.Errorf("error while ensuring Nym mixnode exists: %s", err) + } + + return nil +} + +// SaveNymMixnetV2Mixnode allows to create or update a mixnode +func (db *Db) SaveNymMixnetV2Mixnode(mixnode types.MixnodeV2) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v2_mixnode(mix_id, identity_key, is_bonded, last_mixnet_status) +VALUES ($1, $2, $3, $4) +ON CONFLICT (identity_key) DO UPDATE + SET mix_id = excluded.mix_id, + identity_key = excluded.identity_key, + is_bonded = excluded.is_bonded, + last_mixnet_status = excluded.last_mixnet_status +` + _, err := db.Sql.Exec(stmt, + mixnode.MixId, mixnode.IdentityKey, mixnode.IsBonded, mixnode.LastMixnetStatus.String(), + ) + if err != nil { + return fmt.Errorf("error while saving Nym mixnode: %s", err) + } + + return nil +} + +// HasNymMixnetV2MixnodeRewardingEvent checks if a rewarding event has been saved +func (db *Db) HasNymMixnetV2MixnodeRewardingEvent(mixId uint32, tx *juno.Tx) (bool, error) { + stmt := ` +SELECT COUNT(height) FROM nyx_nym_mixnet_v2_mixnode_reward WHERE mix_id = $1 AND height = $2 AND hash = $3 +` + var count int + err := db.Sql.QueryRow(stmt, mixId, tx.Height, tx.TxHash).Scan(&count) + + return count > 0, err +} + +// SaveNymMixnetV2MixnodeRewardingEvent allows to store the mixnode rewarding events +func (db *Db) SaveNymMixnetV2MixnodeRewardingEvent(mixId uint32, operatorReward cosmosTypes.Coins, delegatesReward cosmosTypes.Coins, priorDelegates cosmosTypes.Coins, priorUnitDelegation decimal.Decimal, apy float64, event cosmosTypes.StringEvent, executeContract types.WasmExecuteContract, tx *juno.Tx) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v2_mixnode_reward +(sender, mix_id, operator_reward, delegates_reward, prior_delegates, prior_unit_delegation, apy, contract_address, event_type, attributes, executed_at, height, hash) +VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) +ON CONFLICT DO NOTHING` + + var attr = make(map[string]interface{}) // could be `map[string]string` however leaving to handle objects as values + for _, entry := range event.Attributes { + attr[entry.Key] = entry.Value + } + bytes, _ := json.Marshal(attr) + + dbOperatorReward := pq.Array(dbtypes.NewDbCoins(operatorReward)) + dbDelegatesReward := pq.Array(dbtypes.NewDbCoins(delegatesReward)) + dbPriorDelegates := pq.Array(dbtypes.NewDbCoins(priorDelegates)) + + _, err := db.Sql.Exec(stmt, + executeContract.Sender, + mixId, + dbOperatorReward, + dbDelegatesReward, + dbPriorDelegates, + priorUnitDelegation.IntPart(), + apy, + executeContract.ContractAddress, event.Type, string(bytes), + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} + +// SaveNymMixnetV2MixnodeStatus allows to store when the mixnet rewarded set changes +func (db *Db) SaveNymMixnetV2MixnodeStatus(mixId uint32, status string, routingScore int64, executeContract types.WasmExecuteContract, tx *juno.Tx) error { + stmt := ` +INSERT INTO nyx_nym_mixnet_v2_mixnode_status +(mixnet_status, routing_score, mix_id, executed_at, height, hash ) +VALUES ($1, $2, $3, $4, $5, $6)` + + _, err := db.Sql.Exec(stmt, + status, routingScore, mixId, + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} diff --git a/database/schema/12-wasm.sql b/database/schema/12-wasm.sql index 869272ea..e7cb7218 100644 --- a/database/schema/12-wasm.sql +++ b/database/schema/12-wasm.sql @@ -50,7 +50,8 @@ CREATE TABLE wasm_execute_contract funds COIN[] NOT NULL DEFAULT '{}', data TEXT NULL, executed_at TIMESTAMP NOT NULL, - height BIGINT NOT NULL + height BIGINT NOT NULL, + hash TEXT NOT NULL ); CREATE INDEX execute_contract_height_index ON wasm_execute_contract (height); \ No newline at end of file diff --git a/database/schema/13-wasm-events.sql b/database/schema/13-wasm-events.sql new file mode 100644 index 00000000..c8d7c5f5 --- /dev/null +++ b/database/schema/13-wasm-events.sql @@ -0,0 +1,13 @@ +CREATE TABLE wasm_execute_contract_event +( + sender TEXT NOT NULL, + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX wasm_execute_contract_event_height_index ON wasm_execute_contract_event (height); +CREATE INDEX wasm_execute_contract_event_hash_index ON wasm_execute_contract_event (hash); +CREATE INDEX wasm_execute_contract_event_event_type_index ON wasm_execute_contract_event (event_type); diff --git a/database/schema/14-nyx-nym-mixnet.sql b/database/schema/14-nyx-nym-mixnet.sql new file mode 100644 index 00000000..4500251c --- /dev/null +++ b/database/schema/14-nyx-nym-mixnet.sql @@ -0,0 +1,23 @@ +CREATE TABLE nyx_nym_mixnet_v1_gateway +( + identity_key TEXT UNIQUE PRIMARY KEY, + is_bonded BOOLEAN NOT NULL +); + +CREATE TABLE nyx_nym_mixnet_v1_gateway_events +( + -- values: bond, unbond + event_kind TEXT NOT NULL, + sender TEXT NOT NULL, + proxy TEXT NULL, + identity_key TEXT NOT NULL REFERENCES nyx_nym_mixnet_v1_gateway (identity_key), + amount COIN NULL, + fee COIN NULL, + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX nyx_nym_mixnet_v1_gateway_events_height_index ON nyx_nym_mixnet_v1_gateway_events (height); diff --git a/database/schema/15-nyx-nym-mixnet-v1.sql b/database/schema/15-nyx-nym-mixnet-v1.sql new file mode 100644 index 00000000..f22ef4c2 --- /dev/null +++ b/database/schema/15-nyx-nym-mixnet-v1.sql @@ -0,0 +1,66 @@ +CREATE TABLE nyx_nym_mixnet_v1_mixnode +( + identity_key TEXT UNIQUE PRIMARY KEY, + is_bonded BOOLEAN NOT NULL, + + -- values: in_active_set, in_standby_set, inactive + last_mixnet_status TEXT NULL +); +CREATE INDEX nyx_nym_mixnet_v1_mixnode_status_index ON nyx_nym_mixnet_v1_mixnode (last_mixnet_status); + +CREATE TABLE nyx_nym_mixnet_v1_mixnode_status +( + -- values: in_active_set, in_standby_set, inactive + mixnet_status TEXT NOT NULL, + + -- in the range 0 to 100 + routing_score INTEGER NOT NULL, + + identity_key TEXT NOT NULL REFERENCES nyx_nym_mixnet_v1_mixnode (identity_key), + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX nyx_nym_mixnet_v1_mixnode_status_height_index ON nyx_nym_mixnet_v1_mixnode_status (height); + +CREATE TABLE nyx_nym_mixnet_v1_mixnode_events +( + -- values: bond, unbond, delegate, undelegate, claim, compound + event_kind TEXT NOT NULL, + -- values: mixnode_operator, mixnode_delegator, mixnet_rewarding, mixnet_monitoring + actor TEXT NOT NULL, + sender TEXT NOT NULL, + proxy TEXT NULL, + identity_key TEXT NOT NULL REFERENCES nyx_nym_mixnet_v1_mixnode (identity_key), + amount COIN[] NOT NULL DEFAULT '{}', + fee COIN[] NOT NULL DEFAULT '{}', + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX nyx_nym_mixnet_v1_mixnode_events_height_index ON nyx_nym_mixnet_v1_mixnode_events (height); + +CREATE TABLE nyx_nym_mixnet_v1_mixnode_reward +( + sender TEXT NOT NULL, + identity_key TEXT NOT NULL REFERENCES nyx_nym_mixnet_v1_mixnode (identity_key), + total_node_reward COIN[] NOT NULL DEFAULT '{}', + total_delegations COIN[] NOT NULL DEFAULT '{}', + operator_reward COIN[] NOT NULL DEFAULT '{}', + unit_delegator_reward BIGINT NOT NULL, + apy FLOAT NOT NULL, + staking_supply COIN[] NOT NULL DEFAULT '{}', + profit_margin_percentage INTEGER NOT NULL, + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL, + UNIQUE (sender, contract_address, identity_key, height, hash) +); +CREATE INDEX nyx_nym_mixnet_v1_mixnode_reward_height_index ON nyx_nym_mixnet_v1_mixnode_reward (height); + diff --git a/database/schema/16-nyx-nym-mixnet-v2.sql b/database/schema/16-nyx-nym-mixnet-v2.sql new file mode 100644 index 00000000..3c4c27d1 --- /dev/null +++ b/database/schema/16-nyx-nym-mixnet-v2.sql @@ -0,0 +1,66 @@ +CREATE TABLE nyx_nym_mixnet_v2_mixnode +( + mix_id BIGINT UNIQUE PRIMARY KEY, + identity_key TEXT NOT NULL, + is_bonded BOOLEAN NOT NULL, + + -- values: in_active_set, in_standby_set, inactive + last_mixnet_status TEXT NULL +); +CREATE INDEX nyx_nym_mixnet_v2_mixnode_status_index ON nyx_nym_mixnet_v2_mixnode (last_mixnet_status); +CREATE INDEX nyx_nym_mixnet_v2_mixnode_identity_key_index ON nyx_nym_mixnet_v2_mixnode (identity_key); + +CREATE TABLE nyx_nym_mixnet_v2_mixnode_status +( + -- values: in_active_set, in_standby_set, inactive + mixnet_status TEXT NOT NULL, + + -- in the range 0 to 1 + routing_score DECIMAL NOT NULL, + + mix_id BIGINT NOT NULL REFERENCES nyx_nym_mixnet_v2_mixnode (mix_id), + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX nyx_nym_mixnet_v2_mixnode_status_height_index ON nyx_nym_mixnet_v2_mixnode_status (height); + +CREATE TABLE nyx_nym_mixnet_v2_events +( + -- values: bond, unbond, delegate, undelegate, claim + event_kind TEXT NOT NULL, + -- values: mixnode_operator, mixnode_delegator, mixnet_rewarding, mixnet_monitoring + actor TEXT NOT NULL, + sender TEXT NOT NULL, + proxy TEXT NULL, + mix_id BIGINT NOT NULL REFERENCES nyx_nym_mixnet_v2_mixnode (mix_id), + identity_key TEXT NOT NULL, + amount COIN NULL, + fee COIN NULL, + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL +); +CREATE INDEX nyx_nym_mixnet_v2_events_height_index ON nyx_nym_mixnet_v2_events (height); + +CREATE TABLE nyx_nym_mixnet_v2_mixnode_reward +( + sender TEXT NOT NULL, + mix_id BIGINT NOT NULL REFERENCES nyx_nym_mixnet_v2_mixnode (mix_id), + operator_reward COIN[] NOT NULL DEFAULT '{}', + delegates_reward COIN[] NOT NULL DEFAULT '{}', + prior_delegates COIN[] NOT NULL DEFAULT '{}', + prior_unit_delegation BIGINT NOT NULL, + apy FLOAT NOT NULL, + contract_address TEXT NOT NULL REFERENCES wasm_contract (contract_address), + event_type TEXT NULL, + attributes JSONB NOT NULL DEFAULT '{}'::JSONB, + executed_at TIMESTAMP NOT NULL, + height BIGINT NOT NULL REFERENCES block (height), + hash TEXT NOT NULL, + UNIQUE (sender, contract_address, mix_id, height, hash) +); +CREATE INDEX nyx_nym_mixnet_v2_mixnode_reward_height_index ON nyx_nym_mixnet_v2_mixnode_reward (height); \ No newline at end of file diff --git a/database/types/wasm.go b/database/types/wasm.go index 8a075716..24a136db 100644 --- a/database/types/wasm.go +++ b/database/types/wasm.go @@ -172,6 +172,7 @@ type WasmExecuteContractRow struct { Data string `db:"data"` ExecutedAt time.Time `db:"executed_at"` Height int64 `db:"height"` + Hash string `db:"hash"` } // NewWasmExecuteContractRow allows to easily create a new WasmExecuteContractRow @@ -183,6 +184,7 @@ func NewWasmExecuteContractRow( data string, executedAt time.Time, height int64, + hash string, ) WasmExecuteContractRow { return WasmExecuteContractRow{ Sender: sender, @@ -192,6 +194,7 @@ func NewWasmExecuteContractRow( Data: data, ExecutedAt: executedAt, Height: height, + Hash: hash, } } @@ -203,5 +206,51 @@ func (a WasmExecuteContractRow) Equals(b WasmExecuteContractRow) bool { a.Funds.Equal(a.Funds) && a.Data == b.Data && a.ExecutedAt == b.ExecutedAt && - a.Height == b.Height + a.Height == b.Height && + a.Hash == b.Hash +} + +// ===================== Execute Contract Event ===================== + +// WasmExecuteContractRow represents a single row inside the "wasm_execute_contract" table +type WasmExecuteContractEventRow struct { + Sender string `db:"sender"` + ContractAddress string `db:"contract_address"` + EventType string `db:"event_type"` + Attributes string `db:"attributes"` + ExecutedAt time.Time `db:"executed_at"` + Height int64 `db:"height"` + Hash string `db:"hash"` +} + +// NewWasmExecuteContractEventRow allows to easily create a new WasmExecuteContractEventRow +func NewWasmExecuteContractEventRow( + sender string, + contractAddress string, + eventType string, + attributes string, + executedAt time.Time, + height int64, + hash string, +) WasmExecuteContractEventRow { + return WasmExecuteContractEventRow{ + Sender: sender, + ContractAddress: contractAddress, + EventType: eventType, + Attributes: attributes, + ExecutedAt: executedAt, + Height: height, + Hash: hash, + } +} + +// Equals return true if one WasmExecuteContractEventRow representing the same row as the original one +func (a WasmExecuteContractEventRow) Equals(b WasmExecuteContractEventRow) bool { + return a.Sender == b.Sender && + a.ContractAddress == b.ContractAddress && + a.EventType == b.EventType && + a.Attributes == b.Attributes && + a.ExecutedAt == b.ExecutedAt && + a.Height == b.Height && + a.Hash == b.Hash } diff --git a/database/wasm.go b/database/wasm.go index d91c6975..5ddea88b 100644 --- a/database/wasm.go +++ b/database/wasm.go @@ -1,11 +1,14 @@ package database import ( + "encoding/json" "fmt" + "github.com/rs/zerolog/log" dbtypes "github.com/forbole/bdjuno/v3/database/types" dbutils "github.com/forbole/bdjuno/v3/database/utils" "github.com/forbole/bdjuno/v3/types" + juno "github.com/forbole/juno/v3/types" "github.com/lib/pq" ) @@ -141,6 +144,13 @@ VALUES ` return nil } +// GetWasmContractExists returns all the wasm contracts matching an address that are currently stored inside the database. +func (db *Db) GetWasmContractExists(contractAddress string) (bool, error) { + var count int + err := db.Sqlx.Select(&count, `SELECT count(contract_address) FROM wasm_contract WHERE contract_address = '`+contractAddress+`'`) + return count > 0, err +} + // SaveWasmExecuteContract allows to store the wasm contract func (db *Db) SaveWasmExecuteContract(wasmExecuteContract types.WasmExecuteContract) error { return db.SaveWasmExecuteContracts([]types.WasmExecuteContract{wasmExecuteContract}) @@ -148,7 +158,7 @@ func (db *Db) SaveWasmExecuteContract(wasmExecuteContract types.WasmExecuteContr // SaveWasmContracts allows to store the wasm contract slice func (db *Db) SaveWasmExecuteContracts(executeContracts []types.WasmExecuteContract) error { - paramsNumber := 7 + paramsNumber := 8 slices := dbutils.SplitWasmExecuteContracts(executeContracts, paramsNumber) for _, contracts := range slices { @@ -168,17 +178,84 @@ func (db *Db) SaveWasmExecuteContracts(executeContracts []types.WasmExecuteContr func (db *Db) saveWasmExecuteContracts(paramNumber int, executeContracts []types.WasmExecuteContract) error { stmt := ` INSERT INTO wasm_execute_contract -(sender, contract_address, raw_contract_message, funds, data, executed_at, height) +(sender, contract_address, raw_contract_message, funds, data, executed_at, height, hash) VALUES ` var args []interface{} for i, executeContract := range executeContracts { ii := i * paramNumber - stmt += fmt.Sprintf("($%d, $%d, $%d, $%d, $%d, $%d, $%d),", - ii+1, ii+2, ii+3, ii+4, ii+5, ii+6, ii+7) + stmt += fmt.Sprintf("($%d, $%d, $%d, $%d, $%d, $%d, $%d, $%d),", + ii+1, ii+2, ii+3, ii+4, ii+5, ii+6, ii+7, ii+8) args = append(args, executeContract.Sender, executeContract.ContractAddress, string(executeContract.RawContractMsg), - pq.Array(dbtypes.NewDbCoins(executeContract.Funds)), executeContract.Data, executeContract.ExecutedAt, executeContract.Height) + pq.Array(dbtypes.NewDbCoins(executeContract.Funds)), executeContract.Data, executeContract.ExecutedAt, executeContract.Height, executeContract.Hash) + } + + stmt = stmt[:len(stmt)-1] // Remove trailing "," + + stmt += ` ON CONFLICT DO NOTHING` + + _, err := db.Sql.Exec(stmt, args...) + if err != nil { + return fmt.Errorf("error while saving wasm execute contracts: %s", err) + } + + return nil +} + +// TODO: figure out if can use Go 1.18 and golang.org/x/exp/slices +func contains(slice []string, item string) bool { + set := make(map[string]struct{}, len(slice)) + for _, s := range slice { + set[s] = struct{}{} + } + + _, ok := set[item] + return ok +} + +// SaveWasmExecuteContractEvents allows to store the wasm contract events +func (db *Db) SaveWasmExecuteContractEvents(executeContract types.WasmExecuteContract, tx *juno.Tx) error { + paramsNumber := 7 + + excludedEventTypes := []string{"message", "execute"} + + stmt := ` +INSERT INTO wasm_execute_contract_event +(sender, contract_address, event_type, attributes, executed_at, height, hash) +VALUES ` + + var args []interface{} + var ii = 0 + for _, txLog := range tx.Logs { + for _, event := range txLog.Events { + + // ignore event types from a list (TODO: make list configurable) + if contains(excludedEventTypes, event.Type) { + continue + } + + stmt += fmt.Sprintf("($%d, $%d, $%d, $%d, $%d, $%d, $%d),", + ii+1, ii+2, ii+3, ii+4, ii+5, ii+6, ii+7) + ii += paramsNumber + + var attr = make(map[string]interface{}) // could be `map[string]string` however leaving to handle objects as values + for _, entry := range event.Attributes { + attr[entry.Key] = entry.Value + } + + bytes, _ := json.Marshal(attr) + + args = append(args, + executeContract.Sender, executeContract.ContractAddress, event.Type, string(bytes), + executeContract.ExecutedAt, executeContract.Height, tx.TxHash) + } + } + + // when no values are inserted, don't execute anything on the database + if ii == 0 { + log.Debug().Str("hash", tx.TxHash).Msg("WasmExecuteContract does not have any events to record, skipping...") + return nil } stmt = stmt[:len(stmt)-1] // Remove trailing "," diff --git a/go.mod b/go.mod index 53011755..af7f2f78 100644 --- a/go.mod +++ b/go.mod @@ -11,12 +11,14 @@ require ( github.com/gogo/protobuf v1.3.3 github.com/jmoiron/sqlx v1.3.5 github.com/lib/pq v1.10.6 + github.com/ohler55/ojg v1.14.5 github.com/pelletier/go-toml v1.9.5 github.com/prometheus/client_golang v1.12.2 github.com/proullon/ramsql v0.0.0-20181213202341-817cee58a244 github.com/rs/zerolog v1.27.0 github.com/spf13/cobra v1.5.0 github.com/stretchr/testify v1.8.0 + github.com/shopspring/decimal v1.3.1 github.com/tendermint/tendermint v0.34.19 google.golang.org/grpc v1.45.0 gopkg.in/yaml.v3 v3.0.1 @@ -136,7 +138,7 @@ require ( ) replace ( - github.com/CosmWasm/wasmd => github.com/mmsinclair/wasmd v0.22.0 + github.com/CosmWasm/wasmd => github.com/mmsinclair/wasmd v0.22.1 github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.1 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/forbole/tendermint v0.34.13-0.20210820072129-a2a4af55563d diff --git a/go.sum b/go.sum index d8a5662d..db5b486c 100644 --- a/go.sum +++ b/go.sum @@ -681,8 +681,8 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mmsinclair/wasmd v0.22.0 h1:FUTFqMBcZtrdYpvCAleeHc6r1fdfwWVWlsVTaKEcsMM= -github.com/mmsinclair/wasmd v0.22.0/go.mod h1:ChFAJLM/loaeVoVZfN2p53BV7m98WA8ejQVmD60b4rM= +github.com/mmsinclair/wasmd v0.22.1 h1:pFoCTyA0XRaJGjMH8a6EOXt+bVhwFBLuByQMiTacEHg= +github.com/mmsinclair/wasmd v0.22.1/go.mod h1:kNDnMAQDJyVek9k6SxCNijMCzOROzzUGBRT8r/vr7oY= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -718,6 +718,8 @@ github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/ohler55/ojg v1.14.5 h1:xCX2oyh/ZaoesbLH6fwVHStSJpk4o4eJs8ttXutzdg0= +github.com/ohler55/ojg v1.14.5/go.mod h1:7Ghirupn8NC8hSSDpI0gcjorPxj+vSVIONDWfliHR1k= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -874,6 +876,8 @@ github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F7 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= diff --git a/hasura/metadata/actions.graphql b/hasura/metadata/actions.graphql index 6a034607..6a21cf08 100644 --- a/hasura/metadata/actions.graphql +++ b/hasura/metadata/actions.graphql @@ -1,81 +1,103 @@ type Query { - action_account_balance( - address: String! - height: Int - ): ActionBalance - - action_delegation_reward( - address: String! - height: Int - ): [ActionDelegationReward] - - action_delegator_withdraw_address( - address: String! - ): ActionAddress! - - action_delegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionDelegationResponse - - action_delegation_total( - address: String! - height: Int - ): ActionBalance - - action_redelegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionRedelegationResponse - - action_unbonding_delegation( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionUnbondingDelegationResponse - - action_unbonding_delegation_total( - address: String! - height: Int - ): ActionBalance - - action_validator_commission_amount( - address: String! - ): ActionValidatorCommissionAmount - - action_validator_delegations( - address: String! - offset: Int - limit: Int - count_total: Boolean - ): ActionDelegationResponse - - action_validator_redelegations_from( - address: String! - height: Int - offset: Int - limit: Int - count_total: Boolean - ): ActionRedelegationResponse - - action_validator_unbonding_delegations( - address: String! - offset: Int - limit: Int - count_total: Boolean - ): ActionUnbondingDelegationResponse + action_account_balance( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_delegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionDelegationResponse +} + +type Query { + action_delegation_reward( + address: String! + height: Int + ): [ActionDelegationReward] +} + +type Query { + action_delegation_total( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_delegator_withdraw_address( + address: String! + ): ActionAddress! +} + +type Query { + action_redelegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionRedelegationResponse +} + +type Query { + action_unbonding_delegation( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionUnbondingDelegationResponse +} + +type Query { + action_unbonding_delegation_total( + address: String! + height: Int + ): ActionBalance +} + +type Query { + action_validator_commission_amount( + address: String! + ): ActionValidatorCommissionAmount +} + +type Query { + action_validator_delegations( + address: String! + offset: Int + limit: Int + count_total: Boolean + ): ActionDelegationResponse +} + +type Query { + action_validator_redelegations_from( + address: String! + height: Int + offset: Int + limit: Int + count_total: Boolean + ): ActionRedelegationResponse +} + +type Query { + action_validator_unbonding_delegations( + address: String! + offset: Int + limit: Int + count_total: Boolean + ): ActionUnbondingDelegationResponse } type ActionBalance { - coins: [ActionCoin] + coins: [ActionCoin] } type ActionDelegationReward { @@ -84,32 +106,37 @@ type ActionDelegationReward { } type ActionAddress { - address: String! + address: String! } type ActionDelegationResponse { - delegations: [ActionDelegation] - pagination: ActionPagination + delegations: [ActionDelegation] + pagination: ActionPagination } type ActionRedelegationResponse { - redelegations: [ActionRedelegation] - pagination: ActionPagination + redelegations: [ActionRedelegation] + pagination: ActionPagination } type ActionUnbondingDelegationResponse { - unbonding_delegations: [ActionUnbondingDelegation] - pagination: ActionPagination + unbonding_delegations: [ActionUnbondingDelegation] + pagination: ActionPagination } type ActionValidatorCommissionAmount { - coins: [ActionCoin] + coins: [ActionCoin] } scalar ActionCoin + scalar ActionDelegation + scalar ActionEntry + scalar ActionPagination + scalar ActionRedelegation + scalar ActionUnbondingDelegation diff --git a/hasura/metadata/actions.yaml b/hasura/metadata/actions.yaml index ae45ad9a..7f12f00d 100644 --- a/hasura/metadata/actions.yaml +++ b/hasura/metadata/actions.yaml @@ -1,291 +1,127 @@ -############### ACTIONS ############### actions: - -##### Bank ##### -- name: action_account_balance - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/account_balance" - output_type: ActionBalance - arguments: - - name: address - type: String! - - name: height - type: Int - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -##### Staking / Delegatagor ##### -- name: action_delegation_reward - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/delegation_reward" - output_type: "[ActionDelegationReward]" - arguments: - - name: address - type: String! - - name: height - type: Int - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_delegator_withdraw_address - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/delegator_withdraw_address" - output_type: ActionAddress - arguments: - - name: address - type: String! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_delegation - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/delegation" - output_type: ActionDelegationResponse - arguments: - - name: address - type: String! - - name: height - type: Int - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_delegation_total - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/delegation_total" - output_type: ActionBalance - arguments: - - name: address - type: String! - - name: height - type: Int - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_redelegation - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/redelegation" - output_type: ActionRedelegationResponse - arguments: - - name: address - type: String! - - name: height - type: Int - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_unbonding_delegation - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/unbonding_delegation" - output_type: ActionUnbondingDelegationResponse - arguments: - - name: address - type: String! - - name: height - type: Int - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_unbonding_delegation_total - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/unbonding_delegation_total" - output_type: ActionBalance - arguments: - - name: address - type: String! - - name: height - type: Int - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -##### Staking / Validator ##### -- name: action_validator_commission_amount - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/validator_commission_amount" - output_type: "[ActionValidatorCommissionAmount]" - arguments: - - name: address - type: String! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_validator_delegations - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/validator_delegations" - output_type: ActionDelegationResponse - arguments: - - name: address - type: String! - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_validator_redelegations_from - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/validator_redelegations_from" - output_type: ActionRedelegationResponse - arguments: - - name: address - type: String! - - name: height - type: Int - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -- name: action_validator_unbonding_delegations - definition: - kind: synchronous - handler: "{{ACTION_BASE_URL}}/validator_unbonding_delegations" - output_type: ActionUnbondingDelegationResponse - arguments: - - name: address - type: String! - - name: offset - type: Int - - name: limit - type: Int - - name: count_total - type: Boolean! - type: query - headers: - - value: application/json - name: Content-Type - permissions: - - role: anonymous - -############### CUSTOM TYPES ############### + - name: action_account_balance + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/account_balance' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_delegation + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/delegation' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_delegation_reward + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/delegation_reward' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_delegation_total + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/delegation_total' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_delegator_withdraw_address + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/delegator_withdraw_address' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_redelegation + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/redelegation' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_unbonding_delegation + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/unbonding_delegation' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_unbonding_delegation_total + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/unbonding_delegation_total' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_validator_commission_amount + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/validator_commission_amount' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_validator_delegations + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/validator_delegations' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_validator_redelegations_from + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/validator_redelegations_from' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous + - name: action_validator_unbonding_delegations + definition: + kind: "" + handler: '{{ACTION_BASE_URL}}/validator_unbonding_delegations' + headers: + - value: application/json + name: Content-Type + permissions: + - role: anonymous custom_types: - scalars: - - name: ActionCoin - - name: ActionDelegation - - name: ActionEntry - - name: ActionPagination - - name: ActionRedelegation - - name: ActionUnbondingDelegation - + enums: [] + input_objects: [] objects: - - name: ActionBalance - fields: - - name: coins - type: [ActionCoin] - - - name: ActionDelegationReward - fields: - - name: coins - type: [ActionCoin] - - name: validator_address - type: String! - - - name: ActionDelegationResponse - fields: - - name: delegations - type: [ActionDelegation] - - name: pagination - type: ActionPagination - - - name: ActionAddress - fields: - - name: address - type: String! - - - name: ActionRedelegationResponse - fields: - - name: redelegations - type: [ActionRedelegation] - - name: pagination - type: ActionPagination - - - name: ActionUnbondingDelegationResponse - fields: - - name: unbonding_delegations - type: [ActionUnbondingDelegation] - - name: pagination - type: ActionPagination - - - name: ActionValidatorCommissionAmount - fields: - - name: coins - type: [ActionCoin] \ No newline at end of file + - name: ActionBalance + - name: ActionDelegationReward + - name: ActionAddress + - name: ActionDelegationResponse + - name: ActionRedelegationResponse + - name: ActionUnbondingDelegationResponse + - name: ActionValidatorCommissionAmount + scalars: + - name: ActionCoin + - name: ActionDelegation + - name: ActionEntry + - name: ActionPagination + - name: ActionRedelegation + - name: ActionUnbondingDelegation diff --git a/hasura/metadata/allow_list.yaml b/hasura/metadata/allow_list.yaml index fe51488c..4ef597ff 100644 --- a/hasura/metadata/allow_list.yaml +++ b/hasura/metadata/allow_list.yaml @@ -1 +1 @@ -[] +- collection: allowed-queries diff --git a/hasura/metadata/api_limits.yaml b/hasura/metadata/api_limits.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/hasura/metadata/api_limits.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/databases/bdjuno/functions/public_messages_by_address.yaml b/hasura/metadata/databases/bdjuno/functions/public_messages_by_address.yaml index 000c8b31..af6bc7be 100644 --- a/hasura/metadata/databases/bdjuno/functions/public_messages_by_address.yaml +++ b/hasura/metadata/databases/bdjuno/functions/public_messages_by_address.yaml @@ -1,3 +1,3 @@ function: - name: messages_by_address schema: public + name: messages_by_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_account.yaml index f3954d25..fccb08a5 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_account.yaml @@ -1,56 +1,77 @@ table: - name: account schema: public + name: account object_relationships: -- name: vesting_account - using: - manual_configuration: - column_mapping: - address: address - insertion_order: null - remote_table: - name: vesting_account - schema: public + - name: vesting_account + using: + manual_configuration: + remote_table: + schema: public + name: vesting_account + insertion_order: null + column_mapping: + address: address array_relationships: -- name: proposal_deposits - using: - foreign_key_constraint_on: - column: depositor_address - table: - name: proposal_deposit - schema: public -- name: proposal_votes - using: - foreign_key_constraint_on: - column: voter_address - table: - name: proposal_vote - schema: public -- name: proposals - using: - foreign_key_constraint_on: - column: proposer_address - table: - name: proposal - schema: public -- name: validator_infos - using: - foreign_key_constraint_on: - column: self_delegate_address - table: - name: validator_info - schema: public -- name: vesting_accounts - using: - foreign_key_constraint_on: - column: address - table: - name: vesting_account - schema: public + - name: feeGrantAllowancesByGranterAddress + using: + foreign_key_constraint_on: + column: granter_address + table: + schema: public + name: fee_grant_allowance + - name: fee_grant_allowances + using: + foreign_key_constraint_on: + column: grantee_address + table: + schema: public + name: fee_grant_allowance + - name: proposal_deposits + using: + foreign_key_constraint_on: + column: depositor_address + table: + schema: public + name: proposal_deposit + - name: proposal_votes + using: + foreign_key_constraint_on: + column: voter_address + table: + schema: public + name: proposal_vote + - name: proposals + using: + foreign_key_constraint_on: + column: proposer_address + table: + schema: public + name: proposal + - name: validator_infos + using: + foreign_key_constraint_on: + column: self_delegate_address + table: + schema: public + name: validator_info + - name: vesting_accounts + using: + foreign_key_constraint_on: + column: address + table: + schema: public + name: vesting_account + - name: wasm_contracts + using: + foreign_key_constraint_on: + column: creator + table: + schema: public + name: wasm_contract select_permissions: -- permission: - allow_aggregations: true - columns: - - address - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - address + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml index ba555d57..af865379 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_from_genesis.yaml @@ -1,11 +1,11 @@ table: - name: average_block_time_from_genesis schema: public + name: average_block_time_from_genesis select_permissions: -- permission: - allow_aggregations: true - columns: - - average_time - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml index 26fe01b5..aedcc615 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_day.yaml @@ -1,11 +1,11 @@ table: - name: average_block_time_per_day schema: public + name: average_block_time_per_day select_permissions: -- permission: - allow_aggregations: true - columns: - - average_time - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml index 75a957db..27dc9c1f 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_hour.yaml @@ -1,11 +1,11 @@ table: - name: average_block_time_per_hour schema: public + name: average_block_time_per_hour select_permissions: -- permission: - allow_aggregations: true - columns: - - average_time - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml index 465f6454..62fee5a3 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_average_block_time_per_minute.yaml @@ -1,11 +1,11 @@ table: - name: average_block_time_per_minute schema: public + name: average_block_time_per_minute select_permissions: -- permission: - allow_aggregations: true - columns: - - average_time - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - average_time + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_block.yaml b/hasura/metadata/databases/bdjuno/tables/public_block.yaml index 5c3f15fc..a479a2e3 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_block.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_block.yaml @@ -1,63 +1,119 @@ table: - name: block schema: public + name: block object_relationships: -- name: validator - using: - foreign_key_constraint_on: proposer_address + - name: validator + using: + foreign_key_constraint_on: proposer_address array_relationships: -- name: pre_commits - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: pre_commit - schema: public -- name: transactions - using: - foreign_key_constraint_on: - column: height - table: - name: transaction - schema: public -- name: validator_voting_powers - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: validator_voting_power - schema: public -- name: proposal_deposits - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: proposal_deposit - schema: public -- name: proposal_votes - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: proposal_vote - schema: public + - name: nyx_nym_mixnet_v1_gateway_events + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v1_gateway_events + - name: nyx_nym_mixnet_v1_mixnode_events + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_events + - name: nyx_nym_mixnet_v1_mixnode_rewards + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_reward + - name: nyx_nym_mixnet_v1_mixnode_statuses + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_status + - name: nyx_nym_mixnet_v2_events + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v2_events + - name: nyx_nym_mixnet_v2_mixnode_rewards + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_reward + - name: nyx_nym_mixnet_v2_mixnode_statuses + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_status + - name: pre_commits + using: + manual_configuration: + remote_table: + schema: public + name: pre_commit + insertion_order: null + column_mapping: + height: height + - name: proposal_deposits + using: + manual_configuration: + remote_table: + schema: public + name: proposal_deposit + insertion_order: null + column_mapping: + height: height + - name: proposal_votes + using: + manual_configuration: + remote_table: + schema: public + name: proposal_vote + insertion_order: null + column_mapping: + height: height + - name: transactions + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: transaction + - name: validator_voting_powers + using: + manual_configuration: + remote_table: + schema: public + name: validator_voting_power + insertion_order: null + column_mapping: + height: height + - name: wasm_execute_contract_events + using: + foreign_key_constraint_on: + column: height + table: + schema: public + name: wasm_execute_contract_event select_permissions: -- permission: - allow_aggregations: true - columns: - - num_txs - - height - - total_gas - - hash - - proposer_address - - timestamp - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - num_txs + - height + - total_gas + - hash + - proposer_address + - timestamp + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml index 21006960..251178e9 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_community_pool.yaml @@ -1,11 +1,11 @@ table: - name: community_pool schema: public + name: community_pool select_permissions: -- permission: - allow_aggregations: true - columns: - - coins - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - coins + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml index ca0ecf72..181aa63d 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_distribution_params.yaml @@ -1,12 +1,12 @@ table: - name: distribution_params schema: public + name: distribution_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml b/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml index 009da39c..3387f45d 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_evidence.yaml @@ -1,27 +1,27 @@ table: - name: double_sign_evidence schema: public + name: double_sign_evidence object_relationships: -- name: doubleSignVoteByVoteAId - using: - foreign_key_constraint_on: vote_a_id -- name: double_sign_vote - using: - foreign_key_constraint_on: vote_b_id + - name: doubleSignVoteByVoteAId + using: + foreign_key_constraint_on: vote_a_id + - name: double_sign_vote + using: + foreign_key_constraint_on: vote_b_id select_permissions: -- permission: - allow_aggregations: true - columns: - - height - - vote_a_id - - vote_b_id - filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - height - - vote_a_id - - vote_b_id - filter: {} - role: client + - role: anonymous + permission: + columns: + - height + - vote_a_id + - vote_b_id + filter: {} + allow_aggregations: true + - role: client + permission: + columns: + - height + - vote_a_id + - vote_b_id + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml b/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml index 03f6217a..b881de73 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_double_sign_vote.yaml @@ -1,49 +1,49 @@ table: - name: double_sign_vote schema: public + name: double_sign_vote object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address array_relationships: -- name: doubleSignEvidencesByVoteBId - using: - foreign_key_constraint_on: - column: vote_b_id - table: - name: double_sign_evidence - schema: public -- name: double_sign_evidences - using: - foreign_key_constraint_on: - column: vote_a_id - table: - name: double_sign_evidence - schema: public + - name: doubleSignEvidencesByVoteBId + using: + foreign_key_constraint_on: + column: vote_b_id + table: + schema: public + name: double_sign_evidence + - name: double_sign_evidences + using: + foreign_key_constraint_on: + column: vote_a_id + table: + schema: public + name: double_sign_evidence select_permissions: -- permission: - allow_aggregations: true - columns: - - id - - type - - height - - round - - block_id - - validator_address - - validator_index - - signature - filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - id - - type - - height - - round - - block_id - - validator_address - - validator_index - - signature - filter: {} - role: client + - role: anonymous + permission: + columns: + - id + - type + - height + - round + - block_id + - validator_address + - validator_index + - signature + filter: {} + allow_aggregations: true + - role: client + permission: + columns: + - id + - type + - height + - round + - block_id + - validator_address + - validator_index + - signature + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml b/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml index dc3ef472..4240f0ec 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_fee_grant_allowance.yaml @@ -1,21 +1,21 @@ table: - name: fee_grant_allowance schema: public + name: fee_grant_allowance object_relationships: -- name: grantee - using: - foreign_key_constraint_on: grantee_address -- name: granter - using: - foreign_key_constraint_on: granter_address + - name: grantee + using: + foreign_key_constraint_on: grantee_address + - name: granter + using: + foreign_key_constraint_on: granter_address select_permissions: -- permission: - allow_aggregations: true - columns: - - id - - grantee_address - - granter_address - - allowance - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - id + - grantee_address + - granter_address + - allowance + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml index c51e829a..642a3370 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_genesis.yaml @@ -1,20 +1,20 @@ table: - name: genesis schema: public + name: genesis select_permissions: -- permission: - allow_aggregations: true - columns: - - chain_id - - initial_height - - time - filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - chain_id - - one_row_id - - time - filter: {} - role: client + - role: anonymous + permission: + columns: + - chain_id + - initial_height + - time + filter: {} + allow_aggregations: true + - role: client + permission: + columns: + - chain_id + - one_row_id + - time + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml index 358c3e92..5045e465 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_gov_params.yaml @@ -1,14 +1,14 @@ table: - name: gov_params schema: public + name: gov_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - deposit_params - - voting_params - - tally_params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - deposit_params + - voting_params + - tally_params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml index 2a348c86..abbe9911 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_inflation.yaml @@ -1,17 +1,17 @@ table: - name: inflation schema: public + name: inflation select_permissions: -- permission: - allow_aggregations: true - columns: - - value - - height - filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - height - filter: {} - role: client + - role: anonymous + permission: + columns: + - value + - height + filter: {} + allow_aggregations: true + - role: client + permission: + columns: + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_message.yaml b/hasura/metadata/databases/bdjuno/tables/public_message.yaml index aa572e71..c487fb34 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_message.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_message.yaml @@ -1,26 +1,36 @@ table: - name: message schema: public + name: message object_relationships: -- name: transaction - using: - manual_configuration: - remote_table: - schema: public - name: transaction - insertion_order: - column_mapping: - transaction_hash: hash + - name: transaction + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + transaction_hash: hash + - name: transactionByPartitionIdTransactionHash + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + transaction_hash: hash + partition_id: partition_id select_permissions: -- permission: - allow_aggregations: true - columns: - - transaction_hash - - index - - type - - value - - involved_accounts_addresses - - partition_id - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - transaction_hash + - index + - type + - value + - involved_accounts_addresses + - partition_id + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml index 948bcdc1..f94607e0 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_mint_params.yaml @@ -1,12 +1,12 @@ table: - name: mint_params schema: public + name: mint_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml index 6ebde2ec..f6f45538 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_modules.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_modules.yaml @@ -1,10 +1,10 @@ table: - name: modules schema: public + name: modules select_permissions: -- permission: - allow_aggregations: true - columns: - - module_name - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - module_name + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway.yaml new file mode 100644 index 00000000..6531a978 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway.yaml @@ -0,0 +1,11 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_gateway +array_relationships: + - name: nyx_nym_mixnet_v1_gateway_events + using: + foreign_key_constraint_on: + column: identity_key + table: + schema: public + name: nyx_nym_mixnet_v1_gateway_events diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway_events.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway_events.yaml new file mode 100644 index 00000000..7eec940c --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_gateway_events.yaml @@ -0,0 +1,13 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_gateway_events +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v1_gateway + using: + foreign_key_constraint_on: identity_key + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode.yaml new file mode 100644 index 00000000..ef39c0c9 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode.yaml @@ -0,0 +1,25 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_mixnode +array_relationships: + - name: nyx_nym_mixnet_v1_mixnode_events + using: + foreign_key_constraint_on: + column: identity_key + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_events + - name: nyx_nym_mixnet_v1_mixnode_rewards + using: + foreign_key_constraint_on: + column: identity_key + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_reward + - name: nyx_nym_mixnet_v1_mixnode_statuses + using: + foreign_key_constraint_on: + column: identity_key + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_status diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_events.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_events.yaml new file mode 100644 index 00000000..4893350d --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_events.yaml @@ -0,0 +1,33 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_events +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v1_mixnode + using: + foreign_key_constraint_on: identity_key + - name: transaction + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + hash: hash + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address + - name: wasm_execute_contract + using: + manual_configuration: + remote_table: + schema: public + name: wasm_execute_contract + insertion_order: null + column_mapping: + height: height + hash: hash + contract_address: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_reward.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_reward.yaml new file mode 100644 index 00000000..507b34c3 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_reward.yaml @@ -0,0 +1,33 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_reward +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v1_mixnode + using: + foreign_key_constraint_on: identity_key + - name: transaction + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + hash: hash + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address + - name: wasm_execute_contract + using: + manual_configuration: + remote_table: + schema: public + name: wasm_execute_contract + insertion_order: null + column_mapping: + height: height + hash: hash + contract_address: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_status.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_status.yaml new file mode 100644 index 00000000..32494189 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v1_mixnode_status.yaml @@ -0,0 +1,10 @@ +table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_status +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v1_mixnode + using: + foreign_key_constraint_on: identity_key diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_events.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_events.yaml new file mode 100644 index 00000000..29e40a04 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_events.yaml @@ -0,0 +1,13 @@ +table: + schema: public + name: nyx_nym_mixnet_v2_events +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v2_mixnode + using: + foreign_key_constraint_on: mix_id + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode.yaml new file mode 100644 index 00000000..be599bfd --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode.yaml @@ -0,0 +1,25 @@ +table: + schema: public + name: nyx_nym_mixnet_v2_mixnode +array_relationships: + - name: nyx_nym_mixnet_v2_events + using: + foreign_key_constraint_on: + column: mix_id + table: + schema: public + name: nyx_nym_mixnet_v2_events + - name: nyx_nym_mixnet_v2_mixnode_rewards + using: + foreign_key_constraint_on: + column: mix_id + table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_reward + - name: nyx_nym_mixnet_v2_mixnode_statuses + using: + foreign_key_constraint_on: + column: mix_id + table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_status diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_reward.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_reward.yaml new file mode 100644 index 00000000..eafabe38 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_reward.yaml @@ -0,0 +1,13 @@ +table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_reward +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v2_mixnode + using: + foreign_key_constraint_on: mix_id + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_status.yaml b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_status.yaml new file mode 100644 index 00000000..d28479e7 --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_nyx_nym_mixnet_v2_mixnode_status.yaml @@ -0,0 +1,10 @@ +table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_status +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: nyx_nym_mixnet_v2_mixnode + using: + foreign_key_constraint_on: mix_id diff --git a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml index e97a6db7..8488d600 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_pre_commit.yaml @@ -1,28 +1,28 @@ table: - name: pre_commit schema: public + name: pre_commit object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - height - - timestamp - - voting_power - - proposer_priority - filter: {} - role: anonymous -- permission: - allow_aggregations: true - columns: - - validator_address - - height - - timestamp - - voting_power - - proposer_priority - filter: {} - role: client + - role: anonymous + permission: + columns: + - validator_address + - height + - timestamp + - voting_power + - proposer_priority + filter: {} + allow_aggregations: true + - role: client + permission: + columns: + - validator_address + - height + - timestamp + - voting_power + - proposer_priority + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml index aeaa47b2..1b34441e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal.yaml @@ -1,72 +1,72 @@ table: - name: proposal schema: public + name: proposal object_relationships: -- name: proposal_tally_result - using: - manual_configuration: - column_mapping: - id: proposal_id - insertion_order: null - remote_table: - name: proposal_tally_result - schema: public -- name: proposer - using: - foreign_key_constraint_on: proposer_address -- name: staking_pool_snapshot - using: - manual_configuration: - column_mapping: - id: proposal_id - insertion_order: null - remote_table: - name: proposal_staking_pool_snapshot - schema: public + - name: proposal_tally_result + using: + manual_configuration: + remote_table: + schema: public + name: proposal_tally_result + insertion_order: null + column_mapping: + id: proposal_id + - name: proposer + using: + foreign_key_constraint_on: proposer_address + - name: staking_pool_snapshot + using: + manual_configuration: + remote_table: + schema: public + name: proposal_staking_pool_snapshot + insertion_order: null + column_mapping: + id: proposal_id array_relationships: -- name: proposal_deposits - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_deposit - schema: public -- name: proposal_tally_results - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_tally_result - schema: public -- name: proposal_votes - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_vote - schema: public -- name: validator_status_snapshots - using: - foreign_key_constraint_on: - column: proposal_id - table: - name: proposal_validator_status_snapshot - schema: public + - name: proposal_deposits + using: + foreign_key_constraint_on: + column: proposal_id + table: + schema: public + name: proposal_deposit + - name: proposal_tally_results + using: + foreign_key_constraint_on: + column: proposal_id + table: + schema: public + name: proposal_tally_result + - name: proposal_votes + using: + foreign_key_constraint_on: + column: proposal_id + table: + schema: public + name: proposal_vote + - name: validator_status_snapshots + using: + foreign_key_constraint_on: + column: proposal_id + table: + schema: public + name: proposal_validator_status_snapshot select_permissions: -- permission: - allow_aggregations: true - columns: - - title - - description - - proposal_route - - proposal_type - - id - - submit_time - - deposit_end_time - - voting_start_time - - voting_end_time - - proposer_address - - status - - content - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - title + - description + - proposal_route + - proposal_type + - id + - submit_time + - deposit_end_time + - voting_start_time + - voting_end_time + - proposer_address + - status + - content + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml index 7c480ff8..5b9f1e4e 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_deposit.yaml @@ -1,29 +1,29 @@ table: - name: proposal_deposit schema: public + name: proposal_deposit object_relationships: -- name: block - using: - manual_configuration: - column_mapping: - height: height - insertion_order: null - remote_table: - name: block - schema: public -- name: depositor - using: - foreign_key_constraint_on: depositor_address -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: block + using: + manual_configuration: + remote_table: + schema: public + name: block + insertion_order: null + column_mapping: + height: height + - name: depositor + using: + foreign_key_constraint_on: depositor_address + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: true - columns: - - proposal_id - - depositor_address - - amount - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - depositor_address + - amount + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml index 3f03cced..2459c453 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_staking_pool_snapshot.yaml @@ -1,17 +1,17 @@ table: - name: proposal_staking_pool_snapshot schema: public + name: proposal_staking_pool_snapshot object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: true - columns: - - proposal_id - - bonded_tokens - - not_bonded_tokens - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - bonded_tokens + - not_bonded_tokens + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml index e2e21c5f..7c2da16a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_tally_result.yaml @@ -1,19 +1,19 @@ table: - name: proposal_tally_result schema: public + name: proposal_tally_result object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: true - columns: - - proposal_id - - yes - - abstain - - no - - no_with_veto - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - "yes" + - abstain + - "no" + - no_with_veto + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml index 769e27f3..7d836197 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_validator_status_snapshot.yaml @@ -1,23 +1,23 @@ table: - name: proposal_validator_status_snapshot schema: public + name: proposal_validator_status_snapshot object_relationships: -- name: proposal - using: - foreign_key_constraint_on: proposal_id -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: proposal + using: + foreign_key_constraint_on: proposal_id + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - id - - proposal_id - - validator_address - - voting_power - - status - - jailed - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - id + - proposal_id + - validator_address + - voting_power + - status + - jailed + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml index 30b70e03..b7579ae1 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_proposal_vote.yaml @@ -1,23 +1,23 @@ table: - name: proposal_vote schema: public + name: proposal_vote object_relationships: -- name: account - using: - foreign_key_constraint_on: voter_address -- name: block - using: - foreign_key_constraint_on: height -- name: proposal - using: - foreign_key_constraint_on: proposal_id + - name: account + using: + foreign_key_constraint_on: voter_address + - name: block + using: + foreign_key_constraint_on: height + - name: proposal + using: + foreign_key_constraint_on: proposal_id select_permissions: -- permission: - allow_aggregations: true - columns: - - proposal_id - - voter_address - - option - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - proposal_id + - voter_address + - option + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml index 4969d9e2..f6ce1cfe 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_slashing_params.yaml @@ -1,12 +1,12 @@ table: - name: slashing_params schema: public + name: slashing_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml index be445552..33fb4a69 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_params.yaml @@ -1,12 +1,12 @@ table: - name: staking_params schema: public + name: staking_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - params - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - params + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml index b2dfa5e6..2e38c5ac 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_staking_pool.yaml @@ -1,12 +1,12 @@ table: - name: staking_pool schema: public + name: staking_pool select_permissions: -- permission: - allow_aggregations: true - columns: - - height - - bonded_tokens - - not_bonded_tokens - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - height + - bonded_tokens + - not_bonded_tokens + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml index 7e748d71..f7650140 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_supply.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_supply.yaml @@ -1,11 +1,11 @@ table: - name: supply schema: public + name: supply select_permissions: -- permission: - allow_aggregations: true - columns: - - coins - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - coins + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_token.yaml b/hasura/metadata/databases/bdjuno/tables/public_token.yaml index efb055e4..33adc1f4 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token.yaml @@ -1,18 +1,18 @@ table: - name: token schema: public + name: token array_relationships: -- name: token_units - using: - foreign_key_constraint_on: - column: token_name - table: - name: token_unit - schema: public + - name: token_units + using: + foreign_key_constraint_on: + column: token_name + table: + schema: public + name: token_unit select_permissions: -- permission: - allow_aggregations: true - columns: - - name - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - name + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml index e28c7abb..8cdcc7d1 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price.yaml @@ -1,18 +1,18 @@ table: - name: token_price schema: public + name: token_price object_relationships: -- name: token_unit - using: - foreign_key_constraint_on: unit_name + - name: token_unit + using: + foreign_key_constraint_on: unit_name select_permissions: -- permission: - allow_aggregations: true - columns: - - id - - unit_name - - price - - market_cap - - timestamp - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - id + - unit_name + - price + - market_cap + - timestamp + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml index 45a77136..9133b348 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_price_history.yaml @@ -1,17 +1,17 @@ table: - name: token_price_history schema: public + name: token_price_history object_relationships: -- name: token_unit - using: - foreign_key_constraint_on: unit_name + - name: token_unit + using: + foreign_key_constraint_on: unit_name select_permissions: -- permission: - allow_aggregations: true - columns: - - market_cap - - price - - timestamp - - unit_name - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - market_cap + - price + - timestamp + - unit_name + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml index 6b11f818..0d31ea3b 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_token_unit.yaml @@ -1,42 +1,42 @@ table: - name: token_unit schema: public + name: token_unit object_relationships: -- name: token - using: - foreign_key_constraint_on: token_name -- name: token_price - using: - manual_configuration: - column_mapping: - denom: unit_name - insertion_order: null - remote_table: - name: token_price - schema: public + - name: token + using: + foreign_key_constraint_on: token_name + - name: token_price + using: + manual_configuration: + remote_table: + schema: public + name: token_price + insertion_order: null + column_mapping: + denom: unit_name array_relationships: -- name: token_price_histories - using: - foreign_key_constraint_on: - column: unit_name - table: - name: token_price_history - schema: public -- name: token_prices - using: - foreign_key_constraint_on: - column: unit_name - table: - name: token_price - schema: public + - name: token_price_histories + using: + foreign_key_constraint_on: + column: unit_name + table: + schema: public + name: token_price_history + - name: token_prices + using: + foreign_key_constraint_on: + column: unit_name + table: + schema: public + name: token_price select_permissions: -- permission: - allow_aggregations: true - columns: - - aliases - - denom - - exponent - - price_id - - token_name - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - aliases + - denom + - exponent + - price_id + - token_name + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml index 8cd83c73..887b14a9 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_transaction.yaml @@ -1,26 +1,37 @@ table: - name: transaction schema: public + name: transaction object_relationships: -- name: block - using: - foreign_key_constraint_on: height + - name: block + using: + foreign_key_constraint_on: height +array_relationships: + - name: messagesByTransactionHashPartitionId + using: + manual_configuration: + remote_table: + schema: public + name: message + insertion_order: null + column_mapping: + hash: transaction_hash + partition_id: partition_id select_permissions: -- permission: - allow_aggregations: true - columns: - - hash - - height - - success - - messages - - memo - - signatures - - signer_infos - - fee - - gas_wanted - - gas_used - - raw_log - - logs - - partition_id - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - hash + - height + - success + - messages + - memo + - signatures + - signer_infos + - fee + - gas_wanted + - gas_used + - raw_log + - logs + - partition_id + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml index a2fbf811..29d4d541 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator.yaml @@ -1,103 +1,103 @@ table: - name: validator schema: public + name: validator object_relationships: -- name: validator_info - using: - manual_configuration: - column_mapping: - consensus_address: consensus_address - insertion_order: null - remote_table: - name: validator_info - schema: public -- name: proposal_validator_status_snapshot - using: - manual_configuration: - column_mapping: - consensus_address: validator_address - insertion_order: null - remote_table: - name: proposal_validator_status_snapshot - schema: public + - name: proposal_validator_status_snapshot + using: + manual_configuration: + remote_table: + schema: public + name: proposal_validator_status_snapshot + insertion_order: null + column_mapping: + consensus_address: validator_address + - name: validator_info + using: + manual_configuration: + remote_table: + schema: public + name: validator_info + insertion_order: null + column_mapping: + consensus_address: consensus_address array_relationships: -- name: blocks - using: - foreign_key_constraint_on: - column: proposer_address - table: - name: block - schema: public -- name: double_sign_votes - using: - foreign_key_constraint_on: - column: validator_address - table: - name: double_sign_vote - schema: public -- name: pre_commits - using: - foreign_key_constraint_on: - column: validator_address - table: - name: pre_commit - schema: public -- name: validator_commissions - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_commission - schema: public -- name: validator_descriptions - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_description - schema: public -- name: validator_infos - using: - foreign_key_constraint_on: - column: consensus_address - table: - name: validator_info - schema: public -- name: validator_signing_infos - using: - manual_configuration: - column_mapping: - consensus_address: validator_address - insertion_order: null - remote_table: - name: validator_signing_info - schema: public -- name: validator_statuses - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_status - schema: public -- name: validator_voting_powers - using: - foreign_key_constraint_on: - column: validator_address - table: - name: validator_voting_power - schema: public -- name: proposal_validator_status_snapshots - using: - foreign_key_constraint_on: - column: validator_address - table: - name: proposal_validator_status_snapshot - schema: public + - name: blocks + using: + foreign_key_constraint_on: + column: proposer_address + table: + schema: public + name: block + - name: double_sign_votes + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: double_sign_vote + - name: pre_commits + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: pre_commit + - name: proposal_validator_status_snapshots + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: proposal_validator_status_snapshot + - name: validator_commissions + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: validator_commission + - name: validator_descriptions + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: validator_description + - name: validator_infos + using: + foreign_key_constraint_on: + column: consensus_address + table: + schema: public + name: validator_info + - name: validator_signing_infos + using: + manual_configuration: + remote_table: + schema: public + name: validator_signing_info + insertion_order: null + column_mapping: + consensus_address: validator_address + - name: validator_statuses + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: validator_status + - name: validator_voting_powers + using: + foreign_key_constraint_on: + column: validator_address + table: + schema: public + name: validator_voting_power select_permissions: -- permission: - allow_aggregations: true - columns: - - consensus_address - - consensus_pubkey - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - consensus_address + - consensus_pubkey + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml index bbe8d3a6..625a1663 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_commission.yaml @@ -1,17 +1,17 @@ table: - name: validator_commission schema: public + name: validator_commission object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - commission - - min_self_delegation - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - commission + - min_self_delegation + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml index 3edb4f67..ec821683 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_description.yaml @@ -1,21 +1,21 @@ table: - name: validator_description schema: public + name: validator_description object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - moniker - - identity - - website - - security_contact - - details - - height - - avatar_url - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - moniker + - identity + - website + - security_contact + - details + - height + - avatar_url + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml index fb8d8b4e..719b0e78 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_info.yaml @@ -1,21 +1,21 @@ table: - name: validator_info schema: public + name: validator_info object_relationships: -- name: account - using: - foreign_key_constraint_on: self_delegate_address -- name: validator - using: - foreign_key_constraint_on: consensus_address + - name: account + using: + foreign_key_constraint_on: self_delegate_address + - name: validator + using: + foreign_key_constraint_on: consensus_address select_permissions: -- permission: - allow_aggregations: true - columns: - - consensus_address - - operator_address - - self_delegate_address - - max_change_rate - - max_rate - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - consensus_address + - operator_address + - self_delegate_address + - max_change_rate + - max_rate + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml index dba8155f..6c75450c 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_signing_info.yaml @@ -1,16 +1,16 @@ table: - name: validator_signing_info schema: public + name: validator_signing_info select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - start_height - - index_offset - - jailed_until - - tombstoned - - missed_blocks_counter - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - start_height + - index_offset + - jailed_until + - tombstoned + - missed_blocks_counter + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml index 1e983d9a..cebd4092 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_status.yaml @@ -1,18 +1,18 @@ table: - name: validator_status schema: public + name: validator_status object_relationships: -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - status - - jailed - - tombstoned - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - status + - jailed + - tombstoned + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml b/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml index 6710ad5c..8feca928 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_validator_voting_power.yaml @@ -1,19 +1,19 @@ table: - name: validator_voting_power schema: public + name: validator_voting_power object_relationships: -- name: block - using: - foreign_key_constraint_on: height -- name: validator - using: - foreign_key_constraint_on: validator_address + - name: block + using: + foreign_key_constraint_on: height + - name: validator + using: + foreign_key_constraint_on: validator_address select_permissions: -- permission: - allow_aggregations: true - columns: - - validator_address - - voting_power - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - validator_address + - voting_power + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml index 1b095315..cba411d7 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_account.yaml @@ -1,27 +1,27 @@ table: - name: vesting_account schema: public + name: vesting_account object_relationships: -- name: account - using: - foreign_key_constraint_on: address + - name: account + using: + foreign_key_constraint_on: address array_relationships: -- name: vesting_periods - using: - foreign_key_constraint_on: - column: vesting_account_id - table: - name: vesting_period - schema: public + - name: vesting_periods + using: + foreign_key_constraint_on: + column: vesting_account_id + table: + schema: public + name: vesting_period select_permissions: -- permission: - allow_aggregations: true - columns: - - id - - type - - address - - original_vesting - - end_time - - start_time - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - id + - type + - address + - original_vesting + - end_time + - start_time + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml index dc4de32c..67992ed5 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_vesting_period.yaml @@ -1,17 +1,17 @@ table: - name: vesting_period schema: public + name: vesting_period object_relationships: -- name: vesting_account - using: - foreign_key_constraint_on: vesting_account_id + - name: vesting_account + using: + foreign_key_constraint_on: vesting_account_id select_permissions: -- permission: - allow_aggregations: true - columns: - - vesting_account_id - - period_order - - length - - amount - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - vesting_account_id + - period_order + - length + - amount + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_wasm_code.yaml b/hasura/metadata/databases/bdjuno/tables/public_wasm_code.yaml index b77262da..bba2570a 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_wasm_code.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_wasm_code.yaml @@ -1,22 +1,22 @@ table: - name: wasm_code schema: public + name: wasm_code array_relationships: -- name: wasm_contracts - using: - foreign_key_constraint_on: - column: code_id - table: - name: wasm_contract - schema: public + - name: wasm_contracts + using: + foreign_key_constraint_on: + column: code_id + table: + schema: public + name: wasm_contract select_permissions: -- permission: - allow_aggregations: true - columns: - - sender - - byte_code - - instantiate_permission - - code_id - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - sender + - byte_code + - instantiate_permission + - code_id + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_wasm_contract.yaml b/hasura/metadata/databases/bdjuno/tables/public_wasm_contract.yaml index 618e003e..06063a79 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_wasm_contract.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_wasm_contract.yaml @@ -1,34 +1,79 @@ table: - name: wasm_contract schema: public + name: wasm_contract object_relationships: -- name: wasm_code - using: - foreign_key_constraint_on: code_id + - name: account + using: + foreign_key_constraint_on: creator + - name: wasm_code + using: + foreign_key_constraint_on: code_id array_relationships: -- name: wasm_execute_contracts - using: - foreign_key_constraint_on: - column: contract_address - table: - name: wasm_execute_contract - schema: public + - name: nyx_nym_mixnet_v1_gateway_events + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: nyx_nym_mixnet_v1_gateway_events + - name: nyx_nym_mixnet_v1_mixnode_events + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_events + - name: nyx_nym_mixnet_v1_mixnode_rewards + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: nyx_nym_mixnet_v1_mixnode_reward + - name: nyx_nym_mixnet_v2_events + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: nyx_nym_mixnet_v2_events + - name: nyx_nym_mixnet_v2_mixnode_rewards + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: nyx_nym_mixnet_v2_mixnode_reward + - name: wasm_execute_contract_events + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: wasm_execute_contract_event + - name: wasm_execute_contracts + using: + foreign_key_constraint_on: + column: contract_address + table: + schema: public + name: wasm_execute_contract select_permissions: -- permission: - allow_aggregations: true - columns: - - sender - - creator - - admin - - code_id - - label - - raw_contract_message - - funds - - contract_address - - data - - instantiated_at - - contract_info_extension - - contract_states - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - sender + - creator + - admin + - code_id + - label + - raw_contract_message + - funds + - contract_address + - data + - instantiated_at + - contract_info_extension + - contract_states + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract.yaml b/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract.yaml index 2b95b6cc..f775c0db 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract.yaml @@ -1,20 +1,38 @@ table: - name: wasm_execute_contract schema: public + name: wasm_execute_contract object_relationships: -- name: wasm_contract - using: - foreign_key_constraint_on: contract_address + - name: block + using: + manual_configuration: + remote_table: + schema: public + name: block + insertion_order: null + column_mapping: + height: height + - name: transaction + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + hash: hash + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address select_permissions: -- permission: - allow_aggregations: true - columns: - - sender - - contract_address - - raw_contract_message - - funds - - data - - executed_at - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - sender + - contract_address + - raw_contract_message + - funds + - data + - executed_at + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract_event.yaml b/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract_event.yaml new file mode 100644 index 00000000..ab9239ea --- /dev/null +++ b/hasura/metadata/databases/bdjuno/tables/public_wasm_execute_contract_event.yaml @@ -0,0 +1,19 @@ +table: + schema: public + name: wasm_execute_contract_event +object_relationships: + - name: block + using: + foreign_key_constraint_on: height + - name: transaction + using: + manual_configuration: + remote_table: + schema: public + name: transaction + insertion_order: null + column_mapping: + hash: hash + - name: wasm_contract + using: + foreign_key_constraint_on: contract_address diff --git a/hasura/metadata/databases/bdjuno/tables/public_wasm_params.yaml b/hasura/metadata/databases/bdjuno/tables/public_wasm_params.yaml index a69dc549..2b0dc521 100644 --- a/hasura/metadata/databases/bdjuno/tables/public_wasm_params.yaml +++ b/hasura/metadata/databases/bdjuno/tables/public_wasm_params.yaml @@ -1,14 +1,14 @@ table: - name: wasm_params schema: public + name: wasm_params select_permissions: -- permission: - allow_aggregations: true - columns: - - one_row_id - - code_upload_access - - instantiate_default_permission - - max_wasm_code_size - - height - filter: {} - role: anonymous + - role: anonymous + permission: + columns: + - one_row_id + - code_upload_access + - instantiate_default_permission + - max_wasm_code_size + - height + filter: {} + allow_aggregations: true diff --git a/hasura/metadata/databases/bdjuno/tables/tables.yaml b/hasura/metadata/databases/bdjuno/tables/tables.yaml index 8ef246b0..3adaa440 100644 --- a/hasura/metadata/databases/bdjuno/tables/tables.yaml +++ b/hasura/metadata/databases/bdjuno/tables/tables.yaml @@ -15,6 +15,16 @@ - "!include public_message.yaml" - "!include public_mint_params.yaml" - "!include public_modules.yaml" +- "!include public_nyx_nym_mixnet_v1_gateway.yaml" +- "!include public_nyx_nym_mixnet_v1_gateway_events.yaml" +- "!include public_nyx_nym_mixnet_v1_mixnode.yaml" +- "!include public_nyx_nym_mixnet_v1_mixnode_events.yaml" +- "!include public_nyx_nym_mixnet_v1_mixnode_reward.yaml" +- "!include public_nyx_nym_mixnet_v1_mixnode_status.yaml" +- "!include public_nyx_nym_mixnet_v2_events.yaml" +- "!include public_nyx_nym_mixnet_v2_mixnode.yaml" +- "!include public_nyx_nym_mixnet_v2_mixnode_reward.yaml" +- "!include public_nyx_nym_mixnet_v2_mixnode_status.yaml" - "!include public_pre_commit.yaml" - "!include public_proposal.yaml" - "!include public_proposal_deposit.yaml" @@ -43,4 +53,5 @@ - "!include public_wasm_code.yaml" - "!include public_wasm_contract.yaml" - "!include public_wasm_execute_contract.yaml" +- "!include public_wasm_execute_contract_event.yaml" - "!include public_wasm_params.yaml" diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml index 44731b43..486d6802 100644 --- a/hasura/metadata/databases/databases.yaml +++ b/hasura/metadata/databases/databases.yaml @@ -2,14 +2,14 @@ kind: postgres configuration: connection_info: + use_prepared_statements: true database_url: from_env: HASURA_GRAPHQL_DATABASE_URL isolation_level: read-committed pool_settings: connection_lifetime: 600 + retries: 1 idle_timeout: 180 max_connections: 50 - retries: 1 - use_prepared_statements: true tables: "!include bdjuno/tables/tables.yaml" functions: "!include bdjuno/functions/functions.yaml" diff --git a/hasura/metadata/graphql_schema_introspection.yaml b/hasura/metadata/graphql_schema_introspection.yaml new file mode 100644 index 00000000..61a4dcac --- /dev/null +++ b/hasura/metadata/graphql_schema_introspection.yaml @@ -0,0 +1 @@ +disabled_for_roles: [] diff --git a/hasura/metadata/inherited_roles.yaml b/hasura/metadata/inherited_roles.yaml new file mode 100644 index 00000000..fe51488c --- /dev/null +++ b/hasura/metadata/inherited_roles.yaml @@ -0,0 +1 @@ +[] diff --git a/hasura/metadata/network.yaml b/hasura/metadata/network.yaml new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/hasura/metadata/network.yaml @@ -0,0 +1 @@ +{} diff --git a/hasura/metadata/query_collections.yaml b/hasura/metadata/query_collections.yaml index fe51488c..fda932dc 100644 --- a/hasura/metadata/query_collections.yaml +++ b/hasura/metadata/query_collections.yaml @@ -1 +1,38 @@ -[] +- name: allowed-queries + definition: + queries: + - name: GetNymMixnetV1MixnodeRewards + query: | + query GetNymMixnetV1MixnodeRewards ($identity_key: String) { + nyx_nym_mixnet_v1_mixnode_reward(where: {identity_key:{_eq:$identity_key}}) { + identity_key + executed_at + hash + height + executed_at + operator_reward + total_node_reward + total_delegations + unit_delegator_reward + } + } + - name: SearchNymMixnetV1MixnodeRewards + query: | + query GetNymMixnetV1MixnodeRewards ($offset: Int!, $limit: Int!, $where: nyx_nym_mixnet_v1_mixnode_reward_bool_exp!) { + nyx_nym_mixnet_v1_mixnode_reward_aggregate(where: $where) { + aggregate { + totalCount: count + } + } + nyx_nym_mixnet_v1_mixnode_reward(where: $where, limit: $limit, offset: $offset) { + identity_key + executed_at + hash + height + executed_at + operator_reward + total_node_reward + total_delegations + unit_delegator_reward + } + } diff --git a/hasura/metadata/rest_endpoints.yaml b/hasura/metadata/rest_endpoints.yaml index fe51488c..f6f48d20 100644 --- a/hasura/metadata/rest_endpoints.yaml +++ b/hasura/metadata/rest_endpoints.yaml @@ -1 +1,18 @@ -[] +- definition: + query: + collection_name: allowed-queries + query_name: SearchNymMixnetV1MixnodeRewards + url: nym/mixnet/v1/mixnodes/rewards + methods: + - POST + name: SearchNymMixnetV1MixnodeRewards + comment: Paged search for mixnode rewards +- definition: + query: + collection_name: allowed-queries + query_name: GetNymMixnetV1MixnodeRewards + url: nym/mixnet/v1/mixnodes/rewards/:identity_key + methods: + - GET + name: GetNymMixnetV1MixnodeRewards + comment: Gets rewards per mixnode diff --git a/modules/wasm/handle_block.go b/modules/wasm/handle_block.go new file mode 100644 index 00000000..6b5eda55 --- /dev/null +++ b/modules/wasm/handle_block.go @@ -0,0 +1,11 @@ +package wasm + +import ( + juno "github.com/forbole/juno/v3/types" + tmctypes "github.com/tendermint/tendermint/rpc/core/types" +) + +// HandleBlock implements modules.BlockModule +func (m *Module) HandleBlock(block *tmctypes.ResultBlock, results *tmctypes.ResultBlockResults, txs []*juno.Tx, vals *tmctypes.ResultValidators) error { + return nil +} diff --git a/modules/wasm/handle_genesis.go b/modules/wasm/handle_genesis.go index 3e1d91cd..aba8d98e 100644 --- a/modules/wasm/handle_genesis.go +++ b/modules/wasm/handle_genesis.go @@ -134,6 +134,7 @@ func (m *Module) SaveGenesisMsgs(msgs []wasmtypes.GenesisState_GenMsgs, doc *tmt "", doc.GenesisTime, doc.InitialHeight, + "", ) genesisExecuteContracts = append(genesisExecuteContracts, executeContract) } diff --git a/modules/wasm/handle_msg.go b/modules/wasm/handle_msg.go index 90c62c5c..7033dc94 100644 --- a/modules/wasm/handle_msg.go +++ b/modules/wasm/handle_msg.go @@ -3,17 +3,26 @@ package wasm import ( "encoding/base64" "fmt" + "github.com/rs/zerolog/log" + "reflect" "strconv" + "strings" "time" + "github.com/ohler55/ojg/jp" + "github.com/ohler55/ojg/oj" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/forbole/bdjuno/v3/types" juno "github.com/forbole/juno/v3/types" + "github.com/shopspring/decimal" ) // HandleMsg implements modules.MessageModule func (m *Module) HandleMsg(index int, msg sdk.Msg, tx *juno.Tx) error { + log.Trace().Str("txhash", tx.TxHash).Msg("wasm HandleMsg") + if len(tx.Logs) == 0 { return nil } @@ -147,6 +156,31 @@ func (m *Module) HandleMsgInstantiateContract(index int, tx *juno.Tx, msg *wasmt // HandleMsgExecuteContract allows to properly handle a MsgExecuteContract // Execute Event executes an instantiated contract func (m *Module) HandleMsgExecuteContract(index int, tx *juno.Tx, msg *wasmtypes.MsgExecuteContract) error { + log.Trace().Str("txhash", tx.TxHash).Msg("wasm HandleMsgExecuteContract") + + // + // parse the ExecuteContract message body + // + msgJson, err := oj.ParseString(string(msg.Msg)) + + // use reflection to get the message name by pulling the 1st field name from the JSON struct + messageName := "" + v := reflect.ValueOf(msgJson) + if v.Len() == 1 && len(v.MapKeys()) == 1 { + messageName = v.MapKeys()[0].String() + } else { + log.Warn().Str("txhash", tx.TxHash).Str("messageJson", string(msg.Msg)).Msg("Unable to parse message name from JSON") + } + + // skip some message types: + // - `write_k_v` will bloat the pgsql database with contract state imports + if messageName == "write_k_v" { + log.Trace().Str("txhash", tx.TxHash).Str("messageName", messageName).Msg("Skipping contract message") + return err + } + + log.Debug().Int64("height", tx.Height).Str("txhash", tx.TxHash).Str("messageName", messageName).Msg("Processing contract message") + // Get Execute Contract event event, err := tx.FindEventByType(index, wasmtypes.EventTypeExecute) if err != nil { @@ -168,12 +202,461 @@ func (m *Module) HandleMsgExecuteContract(index int, tx *juno.Tx, msg *wasmtypes return fmt.Errorf("error while parsing time: %s", err) } - return m.db.SaveWasmExecuteContract( - types.NewWasmExecuteContract( - msg.Sender, msg.Contract, msg.Msg, msg.Funds, - string(resultDataBz), timestamp, tx.Height, - ), + contractExists, err := m.db.GetWasmContractExists(msg.Contract) + + if !contractExists { + contractAddress := msg.Contract + + // default values + contractInfoCreator := "unknown" + contractInfoAdmin := "unknown" + contractInfoCodeID := uint64(0) + contractInfoLabel := "" + + // Check if there is a record of the contract, otherwise look it up + contractInfo, err := m.source.GetContractInfo(tx.Height, contractAddress) + if err != nil { + log.Trace().Str("contractAddress", contractAddress).Int64("height", tx.Height).Msg("Unable to get contract info, using default values...") + } else { + contractInfoCreator = contractInfo.Creator + contractInfoAdmin = contractInfo.Admin + contractInfoCodeID = contractInfo.CodeID + contractInfoLabel = contractInfo.Label + } + + createdBlockHeight := int64(0) + if contractInfo != nil && contractInfo.Created != nil { + createdBlockHeight = int64(contractInfo.Created.BlockHeight) + } + + emptyBytes := make([]byte, 0) + var initPermission wasmtypes.AccessConfig + newCode := types.NewWasmCode( + contractInfoCreator, emptyBytes, &initPermission, contractInfoCodeID, createdBlockHeight, + ) + + err = m.db.SaveWasmCode(newCode) + if err != nil { + return fmt.Errorf("error while saving contract code: %s", err) + } + + // Get contract info extension + contractInfoExt := "" + if contractInfo != nil && contractInfo.Extension != nil { + var extentionI wasmtypes.ContractInfoExtension + err = m.cdc.UnpackAny(contractInfo.Extension, &extentionI) + if err != nil { + return fmt.Errorf("error while getting contract info extension: %s", err) + } + contractInfoExt = extentionI.String() + } + + // Get contract states (at the height the contract was created) + var contractStates []wasmtypes.Model + //contractStates, err := m.source.GetContractStates(int64(contractInfo.Created.BlockHeight), contractAddress) + //if err != nil { + // return fmt.Errorf("error while getting genesis contract states: %s", err) + //} + + err = m.db.SaveAccounts([]types.Account{ + types.NewAccount(msg.Sender)}) + if err != nil { + log.Debug().Msg(fmt.Errorf("error while saving Sender account %s: %s", msg.Sender, err).Error()) + } + err = m.db.SaveAccounts([]types.Account{ + types.NewAccount(contractInfoAdmin)}) + if err != nil { + log.Debug().Msg(fmt.Errorf("error while saving Admin account %s: %s", contractInfo.Admin, err).Error()) + } + + // Set to default values, that will hopefully be overwritten during the next migration of this contract + emptyRawMessage := []byte("{}") + emptyFunds := sdk.Coins{sdk.Coin{}} + + contract := types.NewWasmContract( + msg.Sender, contractInfoAdmin, contractInfoCodeID, contractInfoLabel, + emptyRawMessage, emptyFunds, + contractAddress, string(resultDataBz), timestamp, + contractInfoCreator, contractInfoExt, contractStates, createdBlockHeight, + ) + + err = m.db.SaveWasmContracts( + []types.WasmContract{contract}, + ) + if err != nil { + return fmt.Errorf("error while saving contract info: %s", err) + } + } + + execute := types.NewWasmExecuteContract( + msg.Sender, msg.Contract, msg.Msg, msg.Funds, + string(resultDataBz), timestamp, tx.Height, tx.TxHash, ) + + // save a record of the raw contract execution details + err = m.db.SaveWasmExecuteContract(execute) + + // save a row for each event in the contract execution + err = m.db.SaveWasmExecuteContractEvents(execute, tx) + if err != nil { + log.Err(err).Msg("Could not save events for WasmExecuteContract") + } + + // process Nym Mixnet v1 messages + err = m.handleMessageNymMixnetV1(msgJson, messageName, msg, execute, tx) + + //panic("lets stop after one message") + + return err +} + +func (m *Module) handleMessageNymMixnetV1(msgJson interface{}, messageName string, msg *wasmtypes.MsgExecuteContract, execute types.WasmExecuteContract, tx *juno.Tx) error { + var err error + + // extract identity keys from the body of the contract execution message, and keep the last one found + identityKey := "" + matches := matchJsonPathIdentityKey(msgJson) + for _, v := range matches { + identityKey = fmt.Sprint(v) + err = m.db.EnsureExistsNymMixnetV1Mixnode(types.NewMixnodeV1(identityKey, true, types.Inactive)) + } + + proxy := matchJsonPathProxy(msgJson) + actor := getActorFromMessageName(messageName) + amount := msg.Funds + data := string(msg.Msg) + + // don't write the system actor events, because they are noisy and are already captured in the table `wasm_execute_contract_event` + if !strings.HasPrefix(actor, "system") { + err = m.db.EnsureExistsNymMixnetV1Mixnode(types.NewMixnodeV1(identityKey, true, types.Inactive)) + err = m.db.SaveNymMixnetV1MixnodeEvent( + messageName, actor, proxy, identityKey, &amount, messageName, data, execute, tx) + if err != nil { + log.Err(err).Msg("Error while saving mixnode event") + } + } + + switch messageName { + case "reward_mixnode": + // try v2 first, then fallback to v1 + _, err = m.tryHandleMixnetV2RewardMessage(msg, execute, tx) + if err != nil { + _, err = m.tryHandleMixnetV1RewardMessage(msg, execute, tx) + } + } + + for _, txLog := range tx.Logs { + for _, event := range txLog.Events { + + switch event.Type { + case "wasm-v2_mix_rewarding": + mixId := getValueFromNamedAttribute(event.Attributes, "mix_id") + operatorRewardAttr := getValueFromNamedAttribute(event.Attributes, "operator_reward") + delegatesRewardAttr := getValueFromNamedAttribute(event.Attributes, "delegates_reward") + priorDelegatesAttr := getValueFromNamedAttribute(event.Attributes, "prior_delegates") + priorUnitDelegationAttr := getValueFromNamedAttribute(event.Attributes, "prior_unit_delegation") + + var mixIdInt *uint32 + if mixId != nil { + value, _ := strconv.ParseUint(*mixId, 10, 32) + value2 := uint32(value) + mixIdInt = &value2 + } + + if mixId != nil && mixIdInt != nil && operatorRewardAttr != nil && delegatesRewardAttr != nil && priorDelegatesAttr != nil && priorUnitDelegationAttr != nil { + + err = m.db.EnsureExistsNymMixnetV2Mixnode(types.NewMixnodeV2(*mixIdInt, "", true, types.MixnodeStatus(types.InRewardedSet))) + if err != nil { + log.Err(err).Str("msg", string(msg.Msg)).Msg("Error while saving mixnode") + continue + } + + // check if processed + hasRow, err := m.db.HasNymMixnetV2MixnodeRewardingEvent(*mixIdInt, tx) + if err != nil { + log.Err(err).Msg("Failed to check if row exists in nyx_nym_mixnet_v2_mixnode_reward") + } + if hasRow { + log.Trace().Uint32("mixIdInt", *mixIdInt).Str("hash", tx.TxHash).Int64("height", tx.Height).Msg("Skipping...") + continue + } + + operatorRewardCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(decimal.RequireFromString(*operatorRewardAttr).IntPart()))) + delegatesRewardCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(decimal.RequireFromString(*delegatesRewardAttr).IntPart()))) + priorDelegatesCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(decimal.RequireFromString(*priorDelegatesAttr).IntPart()))) + priorUnitDelegationCoin := decimal.RequireFromString(*priorUnitDelegationAttr) + + // TODO: calculate + apy := decimal.Zero + + err = m.db.SaveNymMixnetV2MixnodeRewardingEvent(*mixIdInt, operatorRewardCoin, delegatesRewardCoin, priorDelegatesCoin, priorUnitDelegationCoin, apy.InexactFloat64(), event, execute, tx) + return err + } + + case "wasm-mix_rewarding": + + eventIdentityKey := getValueFromNamedAttribute(event.Attributes, "identity") + pledge := getValueFromNamedAttribute(event.Attributes, "pledge") + delegated := getValueFromNamedAttribute(event.Attributes, "delegated") + totalNodeRewardAttr := getValueFromNamedAttribute(event.Attributes, "total_node_reward") + + // C_m (in uNYM) is fixed 40 NYMs per 720 epochs = 40_000_000 / 30 / 24 + costPerEpoch := decimal.NewFromInt(55_556) + + // get the profit margin for the epoch + nodeProfitMargin := decimal.NewFromInt(0) + + sigmaAttr := getValueFromNamedAttribute(event.Attributes, "sigma") + lambdaAttr := getValueFromNamedAttribute(event.Attributes, "lambda") + + if eventIdentityKey != nil && pledge != nil && delegated != nil && totalNodeRewardAttr != nil && sigmaAttr != nil && lambdaAttr != nil { + + // check if processed + hasRow, err := m.db.HasNymMixnetV1MixnodeRewardingEvent(*eventIdentityKey, tx) + if err != nil { + log.Err(err).Msg("Failed to check if row exists in nyx_nym_mixnet_v1_mixnode_reward") + } + if hasRow { + log.Trace().Str("identityKey", *eventIdentityKey).Str("hash", tx.TxHash).Int64("height", tx.Height).Msg("Skipping...") + continue + } + + // lookup the profit margin from the snapshot + profitMargin, err := m.source.GetNymMixnetContractV1MixnodeProfitMargin(tx.Height, execute.ContractAddress, *eventIdentityKey, m.cdc) + if err != nil { + log.Err(err).Str("eventIdentityKey", *eventIdentityKey).Int64("height", tx.Height).Msg("Failed to get profit margin") + } + if profitMargin != nil { + nodeProfitMargin = decimal.NewFromInt(int64(*profitMargin)).Div(decimal.NewFromInt(100)) + } + + sigma, errSigma := decimal.NewFromString(*sigmaAttr) + lambda, errLambda := decimal.NewFromString(*lambdaAttr) + totalNodeReward, errTNR := decimal.NewFromString(*totalNodeRewardAttr) + + if errSigma != nil || errLambda != nil || errTNR != nil { + log.Err(errSigma).Str("sigma", *sigmaAttr).Msg("Error parsing sigma") + log.Err(errLambda).Str("lambda", *lambdaAttr).Msg("Error parsing lambda") + log.Err(errTNR).Str("totalNodeReward", *totalNodeRewardAttr).Msg("Error parsing total node reward") + } else { + // prevent division by zero + if sigma.IsZero() { + log.Warn().Str("sigma", *sigmaAttr).Msg("Skipping to avoid division by zero...") + continue + } + + f1 := decimal.NewFromInt(1).Sub(nodeProfitMargin) + f2 := totalNodeReward.Sub(costPerEpoch) + operatorReward := nodeProfitMargin.Add(f1.Mul(lambda.Div(sigma))).Mul(f2) // (u_i + (1 - ui).(l/s)).(R_i - CM_i) + operatorReward = decimal.Min(costPerEpoch, totalNodeReward).Add(decimal.Max(decimal.Zero, operatorReward)) // min(CM_i, R_i) + max(0, ...) + + totalDelegationsInt, _ := sdk.NewIntFromString(*delegated) + totalPledgeInt, _ := sdk.NewIntFromString(*pledge) + + totalBond := decimal.NewFromInt(totalPledgeInt.Int64()).Add(decimal.NewFromInt(totalDelegationsInt.Int64())) + stakingSupply := totalBond.Div(sigma) + + // prevent division by zero + if stakingSupply.IsZero() { + log.Warn().Int64("totalDelegationsInt", totalDelegationsInt.Int64()).Int64("totalPledgeInt", totalPledgeInt.Int64()).Msg("Skipping to avoid division by zero in stakingSupply...") + continue + } + if totalDelegationsInt.IsZero() { + log.Warn().Int64("totalDelegationsInt", totalDelegationsInt.Int64()).Msg("Skipping to avoid division by zero in totalDelegationsInt...") + continue + } + + totalDelegationsCoin := sdk.NewCoins(sdk.NewCoin("unym", totalDelegationsInt)) + + delegatorsReward := decimal.Max(decimal.Zero, totalNodeReward.Sub(operatorReward)) + unitDelegatorReward := decimal.Zero + apy := decimal.Zero + if !delegatorsReward.IsZero() { + unitDelegatorReward = delegatorsReward.Mul(decimal.NewFromInt(1_000_000_000_000)).Div(decimal.NewFromInt(totalDelegationsInt.Int64())) + apy = unitDelegatorReward.Mul(decimal.NewFromInt(24)).Mul(decimal.NewFromInt(365)).Div(decimal.NewFromInt(1_000_000_000_000)) + } + + totalNodeRewardCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(totalNodeReward.RoundBank(6).IntPart()))) + operatorRewardCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(operatorReward.RoundBank(6).IntPart()))) + stakingSupplyCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(stakingSupply.RoundBank(6).IntPart()))) + + profitMarginPercentage := int(nodeProfitMargin.Mul(decimal.NewFromInt(100)).IntPart()) + + err = m.db.EnsureExistsNymMixnetV1Mixnode(types.NewMixnodeV1(*eventIdentityKey, true, types.Inactive)) + + log.Info().Str("identityKey", *eventIdentityKey).Uint8("profit", *profitMargin).Int64("height", tx.Height).Msg("Saving mixnode rewarding event") + + err = m.db.SaveNymMixnetV1MixnodeRewardingEvent( + *eventIdentityKey, totalNodeRewardCoin, totalDelegationsCoin, operatorRewardCoin, unitDelegatorReward, apy.InexactFloat64(), stakingSupplyCoin, profitMarginPercentage, + event, execute, tx) + + if err != nil { + log.Error().Err(err).Msg("❌ Oh no") + } else { + log.Trace().Int64("height", tx.Height).Str("hash", tx.TxHash).Msg("✅ Saved rewarding event") + } + } + } + } + } + } + return err +} + +func (m *Module) tryHandleMixnetV1RewardMessage(msg *wasmtypes.MsgExecuteContract, execute types.WasmExecuteContract, tx *juno.Tx) (*types.MixnetV1RewardMixnodeMessage, error) { + rewardMixnodeMessage, err := types.ParseMixnetV1RewardMixnodeMessage(msg.Msg.Bytes()) + if rewardMixnodeMessage != nil { + rewardedIdentityKey := rewardMixnodeMessage.RewardMixnode.Identity + status := "in_active_set" + statusType := types.MixnodeStatus(types.InActiveSet) + if !rewardMixnodeMessage.RewardMixnode.Params.InActiveSet { + status = "in_standby_set" + statusType = types.MixnodeStatus(types.InStandbySet) + } + uptime, err := strconv.Atoi(rewardMixnodeMessage.RewardMixnode.Params.Uptime) + if err != nil { + log.Err(err).Str("json", string(msg.Msg.Bytes())).Msg("Unable to parse uptime") + } else { + log.Trace().Str("identity_key", rewardedIdentityKey).Msg("✅ Saving mixnode status") + err = m.db.EnsureExistsNymMixnetV1Mixnode(types.NewMixnodeV1(rewardedIdentityKey, true, statusType)) + if err != nil { + log.Err(err).Str("msg", string(msg.Msg)).Msg("Error while saving mixnode") + } + err = m.db.SaveNymMixnetV1MixnodeStatus(rewardedIdentityKey, status, uptime, execute, tx) + if err != nil { + log.Err(err).Str("msg", string(msg.Msg)).Msg("Error while saving mixnode status") + } + } + } + return rewardMixnodeMessage, err +} + +func (m *Module) tryHandleMixnetV2RewardMessage(msg *wasmtypes.MsgExecuteContract, execute types.WasmExecuteContract, tx *juno.Tx) (*types.MixnetV2MessageRewardMixnode, error) { + rewardMixnodeMessage, err := types.ParseMixnetV2MessageRewardMixnode(msg.Msg.Bytes()) + if rewardMixnodeMessage != nil { + mixId := rewardMixnodeMessage.RewardMixnode.MixId + status := "in_rewarded_set" + statusType := types.MixnodeStatus(types.InRewardedSet) + performance, err := strconv.ParseFloat(rewardMixnodeMessage.RewardMixnode.Performance, 32) + if err != nil { + log.Err(err).Str("json", string(msg.Msg.Bytes())).Msg("Unable to parse performance") + } else { + log.Trace().Int64("height", tx.Height).Str("hash", tx.TxHash).Uint32("mix_id", mixId).Msg("✅ Saving mixnode status") + // TODO: v2 + err = m.db.EnsureExistsNymMixnetV2Mixnode(types.NewMixnodeV2(mixId, "", true, statusType)) + if err != nil { + log.Err(err).Str("msg", string(msg.Msg)).Msg("Error while saving mixnode") + } + performanceInt := int64(performance * 100) + err = m.db.SaveNymMixnetV2MixnodeStatus(mixId, status, performanceInt, execute, tx) + if err != nil { + log.Err(err).Str("msg", string(msg.Msg)).Msg("Error while saving mixnode status") + } + } + } + return rewardMixnodeMessage, err +} + +func getActorFromMessageName(messageName string) string { + switch messageName { + + // + // MIXNET v1 + // + + // operator messages + case "compound_operator_reward_on_behalf", + "compound_operator_reward", + "bond_mixnode", + "unbond_mixnode", + "update_mixnode_config", + "update_mixnode_config_on_behalf", + "bond_gateway", + "unbond_gateway", + "bond_mixnode_on_behalf", + "unbond_mixnode_on_behalf", + "bond_gateway_on_behalf", + "unbond_gateway_on_behalf": + return "operator" + + // delegator messages + case "compound_delegator_reward_on_behalf", + "compound_delegator_reward", + "delegate_to_mixnode", + "undelegate_from_mixnode", + "delegate_to_mixnode_on_behalf", + "undelegate_from_mixnode_on_behalf": + return "delegator" + + // system messages + case "update_rewarding_validator_address", + "reconcile_delegations", + "checkpoint_mixnodes", + "reward_mixnode", + "write_rewarded_set", + "advance_current_epoch", + "init_epoch": + return "system.rewarding" + + // + // VESTING + // + + case "create_account": + return "admin.vesting" + + case "withdraw_vested_coins", + "transfer_ownership", + "update_staking_address": + return "vesting_account" + + case + "update_mixnet_address": + return "operator" + case + "track_unbond_mixnode", + "track_unbond_gateway", + "track_undelegation": + return "system.vesting" + + // + // MIXNET v2 + // + + case "update_contract_state_params", + "update_active_set_size", + "update_rewarding_params", + "update_interval_config": + return "admin.mixnet_v2" + + case "reconcile_epoch_events": + return "system.mixnet_v2" + + case "update_mixnode_cost_params", + "update_mixnode_cost_params_on_behalf", + "withdraw_operator_reward", + "withdraw_operator_reward_on_behalf": + return "operator" + + case "withdraw_delegator_reward", + "withdraw_delegator_reward_on_behalf": + return "delegator" + + case "testing_resolve_all_pending_events": + return "qa" + } + + log.Warn().Str("messageName", messageName).Msg("Unable to determine actor from message name") + return "" +} + +func getValueFromNamedAttribute(attributes []sdk.Attribute, key string) *string { + for _, attr := range attributes { + if attr.Key == key { + return &attr.Value + } + } + return nil } // HandleMsgMigrateContract allows to properly handle a MsgMigrateContract @@ -209,3 +692,53 @@ func (m *Module) HandleMsgUpdateAdmin(msg *wasmtypes.MsgUpdateAdmin) error { func (m *Module) HandleMsgClearAdmin(msg *wasmtypes.MsgClearAdmin) error { return m.db.UpdateContractAdmin(msg.Sender, msg.Contract, "") } + +var xIdentityKey jp.Expr + +func matchJsonPathIdentityKey(data interface{}) (results []interface{}) { + if xIdentityKey == nil { + parsed, err := jp.ParseString(`$.*['identity','mix_identity','identity_key']`) + xIdentityKey = parsed + if err != nil { + log.Err(err).Msg("failed to parse json path for identity key") + } + } + return xIdentityKey.Get(data) +} + +var xProxy jp.Expr + +func matchJsonPathProxy(data interface{}) *string { + if xProxy == nil { + parsed, err := jp.ParseString(`$.*['proxy']`) + xProxy = parsed + if err != nil { + log.Err(err).Msg("failed to parse json path for proxy") + } + } + matches := xProxy.Get(data) + if len(matches) > 0 { + val := fmt.Sprint(matches[0]) + return &val + } + return nil +} + +var xMixId jp.Expr + +func matchJsonPathMixId(data interface{}) *uint32 { + if xMixId == nil { + parsed, err := jp.ParseString(`$.*['mix_id']`) + xMixId = parsed + if err != nil { + log.Err(err).Msg("failed to parse json path for mix id") + } + } + value, err := strconv.Atoi(fmt.Sprint(xMixId.Get(data))) + if err != nil { + log.Err(err).Msg("failed to parse mix id from string value") + return nil + } + value2 := uint32(value) + return &value2 +} diff --git a/modules/wasm/handle_tx.go b/modules/wasm/handle_tx.go new file mode 100644 index 00000000..1d3b9e5d --- /dev/null +++ b/modules/wasm/handle_tx.go @@ -0,0 +1,11 @@ +package wasm + +import ( + juno "github.com/forbole/juno/v3/types" +) + +// HandleTx implements modules.TransactionModule +func (m *Module) HandleTx(tx *juno.Tx) error { + //log.Debug().Str("txhash", tx.TxHash).Msg("wasm HandleTx") + return nil +} diff --git a/modules/wasm/module.go b/modules/wasm/module.go index 1576c83e..f8c1b93f 100644 --- a/modules/wasm/module.go +++ b/modules/wasm/module.go @@ -10,8 +10,10 @@ import ( ) var ( - _ modules.Module = &Module{} - _ modules.MessageModule = &Module{} + _ modules.Module = &Module{} + _ modules.MessageModule = &Module{} + _ modules.TransactionModule = &Module{} + _ modules.BlockModule = &Module{} ) // Module represent x/wasm module diff --git a/modules/wasm/source/local/source.go b/modules/wasm/source/local/source.go index 2169f866..d7621afe 100644 --- a/modules/wasm/source/local/source.go +++ b/modules/wasm/source/local/source.go @@ -2,8 +2,8 @@ package local import ( "fmt" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/forbole/juno/v3/node/local" @@ -81,3 +81,7 @@ func (s Source) GetContractStates(height int64, contractAddr string) ([]wasmtype return models, nil } + +func (s Source) GetNymMixnetContractV1MixnodeProfitMargin(height int64, contractAddress string, identityKey string, cdc codec.Codec) (*uint8, error) { + panic("not implemented for local") +} diff --git a/modules/wasm/source/remote/source.go b/modules/wasm/source/remote/source.go index 46bf91d8..412bda8d 100644 --- a/modules/wasm/source/remote/source.go +++ b/modules/wasm/source/remote/source.go @@ -1,11 +1,13 @@ package remote import ( + "encoding/json" "fmt" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/query" "github.com/forbole/juno/v3/node/remote" + "github.com/rs/zerolog/log" wasmsource "github.com/forbole/bdjuno/v3/modules/wasm/source" ) @@ -71,3 +73,78 @@ func (s Source) GetContractStates(height int64, contractAddr string) ([]wasmtype return models, nil } + +func (s Source) GetNymMixnetContractV1MixnodeProfitMargin(height int64, contractAddress string, identityKey string, cdc codec.Codec) (*uint8, error) { + body := []byte(fmt.Sprintf(`{ + "get_mixnode_at_height": { + "mix_identity": "%s", + "height": %v + } + }`, identityKey, height)) + + request := wasmtypes.QuerySmartContractStateRequest{ + Address: contractAddress, + QueryData: body, + } + res, err := s.wasmClient.SmartContractState(s.Ctx, &request) + + if err != nil { + log.Err(err).Str("identityKey", identityKey).Msg("Could not get profit margin") + return nil, err + } + + // marshal to JSON to avoid a protobuf definition of the MixnodeSnap (auto-generated below) + jsonBytes, err := cdc.MarshalJSON(res) + + if err != nil { + log.Err(err).Msg("Could marshal response to JSON") + return nil, err + } + + var mixnodeSnapshotPartial *MixnodeSnapshot = &MixnodeSnapshot{} + err = json.Unmarshal(jsonBytes, mixnodeSnapshotPartial) + if err != nil { + log.Err(err).Msg("Could not marshal response to JSON") + return nil, err + } + + value := uint8(mixnodeSnapshotPartial.Data.MixNode.ProfitMarginPercent) + return &value, nil +} + +type MixnodeSnapshot struct { + Data struct { + PledgeAmount struct { + Denom string `json:"denom"` + Amount string `json:"amount"` + } `json:"pledge_amount"` + Owner string `json:"owner"` + Layer int `json:"layer"` + BlockHeight int `json:"block_height"` + MixNode struct { + Host string `json:"host"` + MixPort int `json:"mix_port"` + VerlocPort int `json:"verloc_port"` + HttpApiPort int `json:"http_api_port"` + SphinxKey string `json:"sphinx_key"` + IdentityKey string `json:"identity_key"` + Version string `json:"version"` + ProfitMarginPercent int `json:"profit_margin_percent"` + } `json:"mix_node"` + Proxy interface{} `json:"proxy"` + AccumulatedRewards string `json:"accumulated_rewards"` + EpochRewards struct { + Params struct { + RewardBlockstamp int `json:"reward_blockstamp"` + Uptime string `json:"uptime"` + InActiveSet bool `json:"in_active_set"` + } `json:"params"` + Result struct { + Reward string `json:"reward"` + Lambda string `json:"lambda"` + Sigma string `json:"sigma"` + } `json:"result"` + EpochId int `json:"epoch_id"` + } `json:"epoch_rewards"` + } `json:"data"` +} diff --git a/modules/wasm/source/source.go b/modules/wasm/source/source.go index 786deb2e..3f814967 100644 --- a/modules/wasm/source/source.go +++ b/modules/wasm/source/source.go @@ -2,9 +2,11 @@ package source import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/codec" ) type Source interface { GetContractInfo(height int64, contractAddr string) (*wasmtypes.QueryContractInfoResponse, error) GetContractStates(height int64, contractAddress string) ([]wasmtypes.Model, error) + GetNymMixnetContractV1MixnodeProfitMargin(height int64, contractAddress string, identityKey string, cdc codec.Codec) (*uint8, error) } diff --git a/types/nym_mixnet_v1.go b/types/nym_mixnet_v1.go new file mode 100644 index 00000000..cee2f3f2 --- /dev/null +++ b/types/nym_mixnet_v1.go @@ -0,0 +1,68 @@ +package types + +import ( + "encoding/json" +) + +type MixnodeStatus int + +const ( + InActiveSet = iota + InStandbySet + Inactive + InRewardedSet +) + +func (status MixnodeStatus) String() string { + return []string{"in_active_set", "in_standby_set", "inactive", "in_rewarded_set"}[status] +} + +type MixnodeV1 struct { + IdentityKey string + IsBonded bool + LastMixnetStatus MixnodeStatus +} + +func NewMixnodeV1( + identityKey string, + isBonded bool, + lastMixnetStatus MixnodeStatus, +) MixnodeV1 { + return MixnodeV1{ + IdentityKey: identityKey, + IsBonded: isBonded, + LastMixnetStatus: lastMixnetStatus, + } +} + +type GatewayV1 struct { + IdentityKey string + IsBonded bool +} + +func NewGatewayV1( + identityKey string, + isBonded bool, +) GatewayV1 { + return GatewayV1{ + IdentityKey: identityKey, + IsBonded: isBonded, + } +} + +type MixnetV1RewardMixnodeMessage struct { + RewardMixnode struct { + Params struct { + Uptime string `json:"uptime"` + InActiveSet bool `json:"in_active_set"` + RewardBlockstamp int `json:"reward_blockstamp"` + } `json:"params"` + Identity string `json:"identity"` + } `json:"reward_mixnode"` +} + +func ParseMixnetV1RewardMixnodeMessage(data []byte) (*MixnetV1RewardMixnodeMessage, error) { + var result *MixnetV1RewardMixnodeMessage + err := json.Unmarshal(data, &result) + return result, err +} diff --git a/types/nym_mixnet_v2.go b/types/nym_mixnet_v2.go new file mode 100644 index 00000000..7eb21185 --- /dev/null +++ b/types/nym_mixnet_v2.go @@ -0,0 +1,53 @@ +package types + +import "encoding/json" + +type MixnodeV2 struct { + MixId uint32 + IdentityKey string + IsBonded bool + LastMixnetStatus MixnodeStatus +} + +func NewMixnodeV2( + mixId uint32, + identityKey string, + isBonded bool, + lastMixnetStatus MixnodeStatus, +) MixnodeV2 { + return MixnodeV2{ + MixId: mixId, + IdentityKey: identityKey, + IsBonded: isBonded, + LastMixnetStatus: lastMixnetStatus, + } +} + +type MixnetV2MessageRewardMixnode struct { + RewardMixnode struct { + MixId uint32 `json:"mix_id"` + Performance string `json:"performance"` + } `json:"reward_mixnode"` +} + +func ParseMixnetV2MessageRewardMixnode(data []byte) (*MixnetV2MessageRewardMixnode, error) { + var result *MixnetV2MessageRewardMixnode + err := json.Unmarshal(data, &result) + return result, err +} + +type MixnetV2EventRewardMixnode struct { + MixId string `json:"mix_id"` + OperatorReward string `json:"operator_reward"` + PriorDelegates string `json:"prior_delegates"` + DelegatesReward string `json:"delegates_reward"` + IntervalDetails string `json:"interval_details"` + ContractAddress string `json:"_contract_address"` + PriorUnitDelegation string `json:"prior_unit_delegation"` +} + +func ParseMixnetV2EventRewardMixnod(data []byte) (*MixnetV2EventRewardMixnode, error) { + var result *MixnetV2EventRewardMixnode + err := json.Unmarshal(data, &result) + return result, err +} diff --git a/types/wasm.go b/types/wasm.go index ffe9a1ed..a1ab5f53 100644 --- a/types/wasm.go +++ b/types/wasm.go @@ -132,12 +132,13 @@ type WasmExecuteContract struct { Data string ExecutedAt time.Time Height int64 + Hash string } // NewWasmExecuteContract allows to build a new x/wasm execute contract instance func NewWasmExecuteContract( sender string, contractAddress string, rawMsg wasmtypes.RawContractMessage, - funds sdk.Coins, data string, executedAt time.Time, height int64, + funds sdk.Coins, data string, executedAt time.Time, height int64, hash string, ) WasmExecuteContract { rawContractMsg, _ := rawMsg.MarshalJSON() @@ -149,5 +150,6 @@ func NewWasmExecuteContract( Data: data, ExecutedAt: executedAt, Height: height, + Hash: hash, } } From 0969ae0bce5b16cd5d826213363274d75b15b059 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 15:16:57 +0100 Subject: [PATCH 03/13] Change docker image bases --- Dockerfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1be2e92d..adc1e7ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,16 @@ -FROM golang:1.16-alpine AS builder -RUN apk update && apk add --no-cache make git +FROM golang:1.16-bullseye AS builder WORKDIR /go/src/github.com/forbole/bdjuno COPY . ./ RUN go mod download RUN make build +RUN ldd build/bdjuno > /deps.txt +RUN echo $(ldd build/bdjuno | grep libwasmvm.so | awk '{ print $3 }') -FROM alpine:latest -WORKDIR /bdjuno -COPY --from=builder /go/src/github.com/forbole/bdjuno/build/bdjuno /usr/bin/bdjuno +FROM debian:bullseye +WORKDIR /root +RUN apt-get update && apt-get install ca-certificates -y +COPY --from=builder /deps.txt /root/deps.txt +COPY --from=builder /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.0.0-beta5/api/libwasmvm.so /root +COPY --from=builder /go/src/github.com/forbole/bdjuno/build/bdjuno /root/bdjuno +ENV LD_LIBRARY_PATH=/root CMD [ "bdjuno" ] From be7cc666916c52b6a062270212ec3bbe36a010c8 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 15:24:17 +0100 Subject: [PATCH 04/13] Change golang version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index adc1e7ba..87d52390 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.16-bullseye AS builder +FROM golang:1.19-bullseye AS builder WORKDIR /go/src/github.com/forbole/bdjuno COPY . ./ RUN go mod download From 26335cf09d8db46dd05d187cedad3fcd748386c6 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 17:43:53 +0100 Subject: [PATCH 05/13] Add hasura bootstrap --- hasura/Dockerfile | 5 +++++ hasura/docker-entrypoint.sh | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 hasura/Dockerfile create mode 100644 hasura/docker-entrypoint.sh diff --git a/hasura/Dockerfile b/hasura/Dockerfile new file mode 100644 index 00000000..8726947f --- /dev/null +++ b/hasura/Dockerfile @@ -0,0 +1,5 @@ +FROM node:16 + +COPY docker-entrypoint.sh /bin/docker-entrypoint.sh +RUN chmod +x /bin/docker-entrypoint.sh +ENTRYPOINT ["/bin/docker-entrypoint.sh"] \ No newline at end of file diff --git a/hasura/docker-entrypoint.sh b/hasura/docker-entrypoint.sh new file mode 100644 index 00000000..a0fb2569 --- /dev/null +++ b/hasura/docker-entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e + +npm install --global hasura-cli + +cd hasura/metadata +hasura metadata apply --endpoint http://hasura:8080 \ No newline at end of file From 6351f09f7b2144bf9b9502a01ead1cf94b1af2f2 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 17:46:57 +0100 Subject: [PATCH 06/13] Slience hasura cli --- hasura/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura/docker-entrypoint.sh b/hasura/docker-entrypoint.sh index a0fb2569..82094c6e 100644 --- a/hasura/docker-entrypoint.sh +++ b/hasura/docker-entrypoint.sh @@ -4,4 +4,4 @@ set -e npm install --global hasura-cli cd hasura/metadata -hasura metadata apply --endpoint http://hasura:8080 \ No newline at end of file +hasura metadata apply --endpoint http://hasura:8080 --skip-update-check \ No newline at end of file From e958d9db9704aa59a5e5445efb0d5bb065ebfcff Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 17:51:15 +0100 Subject: [PATCH 07/13] Add admin secret --- hasura/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura/docker-entrypoint.sh b/hasura/docker-entrypoint.sh index 82094c6e..ceda3af2 100644 --- a/hasura/docker-entrypoint.sh +++ b/hasura/docker-entrypoint.sh @@ -4,4 +4,4 @@ set -e npm install --global hasura-cli cd hasura/metadata -hasura metadata apply --endpoint http://hasura:8080 --skip-update-check \ No newline at end of file +hasura metadata apply --endpoint http://hasura:8080 --skip-update-check --admin-secret HASURA_ADMIN_SECRET \ No newline at end of file From 719e6c0d702a95efd5c0a88bc187b9fcb310ce1a Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Wed, 19 Oct 2022 17:54:30 +0100 Subject: [PATCH 08/13] typo --- hasura/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hasura/docker-entrypoint.sh b/hasura/docker-entrypoint.sh index ceda3af2..cc64955a 100644 --- a/hasura/docker-entrypoint.sh +++ b/hasura/docker-entrypoint.sh @@ -4,4 +4,4 @@ set -e npm install --global hasura-cli cd hasura/metadata -hasura metadata apply --endpoint http://hasura:8080 --skip-update-check --admin-secret HASURA_ADMIN_SECRET \ No newline at end of file +hasura metadata apply --endpoint http://hasura:8080 --skip-update-check --admin-secret $HASURA_ADMIN_SECRET \ No newline at end of file From e6822c3d749ba1dbeeb07739d5f98155678b3213 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Fri, 28 Oct 2022 17:08:34 +0100 Subject: [PATCH 09/13] v2 APY --- modules/wasm/handle_msg.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/wasm/handle_msg.go b/modules/wasm/handle_msg.go index 7033dc94..a166c847 100644 --- a/modules/wasm/handle_msg.go +++ b/modules/wasm/handle_msg.go @@ -386,8 +386,12 @@ func (m *Module) handleMessageNymMixnetV1(msgJson interface{}, messageName strin priorDelegatesCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(decimal.RequireFromString(*priorDelegatesAttr).IntPart()))) priorUnitDelegationCoin := decimal.RequireFromString(*priorUnitDelegationAttr) - // TODO: calculate - apy := decimal.Zero + delegations := decimal.RequireFromString(*priorDelegatesAttr) + delegatorsReward := decimal.RequireFromString(*delegatesRewardAttr) + + // NB: this is only for the delegators, not the entire node rewards + delegatorsReturn := delegatorsReward.Div(delegations).Mul(decimal.NewFromInt(24 * 365)) + apy := delegatorsReturn err = m.db.SaveNymMixnetV2MixnodeRewardingEvent(*mixIdInt, operatorRewardCoin, delegatesRewardCoin, priorDelegatesCoin, priorUnitDelegationCoin, apy.InexactFloat64(), event, execute, tx) return err From 2d0b80c4f6bf1fc90e4bb883a0b7639dab23ca83 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Fri, 28 Oct 2022 17:08:53 +0100 Subject: [PATCH 10/13] Clean up events older than 2 days --- database/wasm.go | 13 +++++++++++++ modules/wasm/handle_msg.go | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/database/wasm.go b/database/wasm.go index 5ddea88b..ea011b43 100644 --- a/database/wasm.go +++ b/database/wasm.go @@ -214,6 +214,19 @@ func contains(slice []string, item string) bool { return ok } +// CleanUpWasmExecuteContractEvents cleans up events that are too old to stop database bloat +func (db *Db) CleanUpWasmExecuteContractEvents() error { + + stmt := `DELETE FROM wasm_execute_contract_event WHERE executed_at < CURRENT_DATE - interval '2 days';` + + _, err := db.Sql.Exec(stmt) + if err != nil { + return fmt.Errorf("error while cleaning up wasm execute contracts: %s", err) + } + + return nil +} + // SaveWasmExecuteContractEvents allows to store the wasm contract events func (db *Db) SaveWasmExecuteContractEvents(executeContract types.WasmExecuteContract, tx *juno.Tx) error { paramsNumber := 7 diff --git a/modules/wasm/handle_msg.go b/modules/wasm/handle_msg.go index a166c847..20f39c01 100644 --- a/modules/wasm/handle_msg.go +++ b/modules/wasm/handle_msg.go @@ -305,6 +305,12 @@ func (m *Module) HandleMsgExecuteContract(index int, tx *juno.Tx, msg *wasmtypes // process Nym Mixnet v1 messages err = m.handleMessageNymMixnetV1(msgJson, messageName, msg, execute, tx) + // clean up events + err = m.db.CleanUpWasmExecuteContractEvents() + if err != nil { + log.Err(err).Msg("Could not clean up events for WasmExecuteContract") + } + //panic("lets stop after one message") return err From 39d271ea732dcf0b6237775321a053b536eca60a Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Fri, 28 Oct 2022 17:57:43 +0100 Subject: [PATCH 11/13] Add args --- database/wasm.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/database/wasm.go b/database/wasm.go index ea011b43..6880e21d 100644 --- a/database/wasm.go +++ b/database/wasm.go @@ -217,9 +217,11 @@ func contains(slice []string, item string) bool { // CleanUpWasmExecuteContractEvents cleans up events that are too old to stop database bloat func (db *Db) CleanUpWasmExecuteContractEvents() error { - stmt := `DELETE FROM wasm_execute_contract_event WHERE executed_at < CURRENT_DATE - interval '2 days';` + var args []interface{} + + stmt := `DELETE FROM wasm_execute_contract_event WHERE executed_at < CURRENT_DATE - interval '2 days'` - _, err := db.Sql.Exec(stmt) + _, err := db.Sql.Exec(stmt, args...) if err != nil { return fmt.Errorf("error while cleaning up wasm execute contracts: %s", err) } From 30fd28aed683f5e37f9b41a7b54f027fc8bbaa85 Mon Sep 17 00:00:00 2001 From: Mark Sinclair Date: Tue, 1 Nov 2022 09:40:39 +0000 Subject: [PATCH 12/13] - handle undelegation messages - add custom actions to return delegations and rewards --- database/nym_mixnet_v1.go | 31 +++ database/types/nym_mixnet_v1.go | 46 +++++ .../actions/handle_additional_operations.go | 11 +- modules/actions/handlers/nyx_nym_mixnet_v1.go | 195 ++++++++++++++++++ modules/actions/module.go | 5 +- modules/actions/types/handler.go | 5 +- modules/actions/types/nyx_nym_mixnet_v1.go | 45 ++++ modules/actions/types/payload.go | 21 +- modules/registrar.go | 2 +- modules/wasm/handle_msg.go | 25 ++- 10 files changed, 376 insertions(+), 10 deletions(-) create mode 100644 database/types/nym_mixnet_v1.go create mode 100644 modules/actions/handlers/nyx_nym_mixnet_v1.go create mode 100644 modules/actions/types/nyx_nym_mixnet_v1.go diff --git a/database/nym_mixnet_v1.go b/database/nym_mixnet_v1.go index d91fe028..567208dc 100644 --- a/database/nym_mixnet_v1.go +++ b/database/nym_mixnet_v1.go @@ -5,6 +5,7 @@ import ( "fmt" dbtypes "github.com/forbole/bdjuno/v3/database/types" "github.com/lib/pq" + "github.com/rs/zerolog/log" "github.com/shopspring/decimal" cosmosTypes "github.com/cosmos/cosmos-sdk/types" @@ -68,6 +69,24 @@ ON CONFLICT (identity_key) DO UPDATE return nil } +func (db *Db) GetNymMixnetV1MixnodeEvent(eventKind string, identityKey string, sender *string, height *int64, executedAt *string) ([]dbtypes.NyxNymMixnetV1MixnodeEventsRow, error) { + filter := fmt.Sprintf("WHERE event_kind = '%s' AND identity_key = '%s'", eventKind, identityKey) + order := "height ASC, executed_at ASC" + if sender != nil { + filter = fmt.Sprintf("%s AND sender = '%s'", filter, *sender) + } + if height != nil { + filter = fmt.Sprintf("%s AND height >= %d", filter, *height) + } else if executedAt != nil { + filter = fmt.Sprintf("%s AND executed_at >= '%s'", filter, *executedAt) + } + stmt := fmt.Sprintf(`SELECT * FROM nyx_nym_mixnet_v1_mixnode_events %s ORDER BY %s`, filter, order) + + var rows []dbtypes.NyxNymMixnetV1MixnodeEventsRow + err := db.Sqlx.Select(&rows, stmt) + return rows, err +} + // SaveNymMixnetV1MixnodeEvent allows to store the wasm contract events func (db *Db) SaveNymMixnetV1MixnodeEvent(eventKind string, actor string, proxy *string, identityKey string, amount *cosmosTypes.Coins, dataType string, dataJson string, executeContract types.WasmExecuteContract, tx *juno.Tx) error { stmt := ` @@ -107,6 +126,18 @@ SELECT COUNT(height) FROM nyx_nym_mixnet_v1_mixnode_reward WHERE identity_key = return count > 0, err } +func (db *Db) GetNymMixnetV1MixnodeRewardEvent(identityKey string, heightMin uint64, heightMax *uint64) ([]dbtypes.NyxNymMixnetV1MixnodeRewardRow, error) { + stmt := fmt.Sprintf(`SELECT * FROM nyx_nym_mixnet_v1_mixnode_reward WHERE height >= %d AND identity_key = '%s'`, heightMin, identityKey) + if heightMax != nil && *heightMax > 0 { + stmt = fmt.Sprintf("%s AND height <= %d", stmt, *heightMax) + } + stmt = fmt.Sprintf("%s ORDER BY height ASC", stmt) + var rows []dbtypes.NyxNymMixnetV1MixnodeRewardRow + err := db.Sqlx.Select(&rows, stmt) + log.Info().Int("count", len(rows)).Err(err).Msg(stmt) + return rows, err +} + // SaveNymMixnetV1MixnodeRewardingEvent allows to store the mixnode rewarding events func (db *Db) SaveNymMixnetV1MixnodeRewardingEvent(identityKey string, totalNodeReward cosmosTypes.Coins, totalDelegations cosmosTypes.Coins, operatorReward cosmosTypes.Coins, unitDelegatorReward decimal.Decimal, apy float64, stakingSupply cosmosTypes.Coins, profitMarginPercentage int, event cosmosTypes.StringEvent, executeContract types.WasmExecuteContract, tx *juno.Tx) error { stmt := ` diff --git a/database/types/nym_mixnet_v1.go b/database/types/nym_mixnet_v1.go new file mode 100644 index 00000000..1eeb6249 --- /dev/null +++ b/database/types/nym_mixnet_v1.go @@ -0,0 +1,46 @@ +package types + +import "time" + +// NyxNymMixnetV1MixnodeEventsRow represents a single row inside the nyx_nym_mixnet_v1_mixnode_events table +type NyxNymMixnetV1MixnodeEventsRow struct { + EventKind string `db:"event_kind"` + Actor string `db:"actor"` + Sender string `db:"sender"` + Proxy *string `db:"proxy"` + IdentityKey string `db:"identity_key"` + + ContractAddress string `db:"contract_address"` + EventType string `db:"event_type"` + Hash string `db:"hash"` + + Attributes interface{} `db:"attributes"` + ExecutedAt time.Time `db:"executed_at"` + + Fee *DbCoins `db:"fee"` + Amount *DbCoins `db:"amount"` + Height int64 `db:"height"` +} + +// NyxNymMixnetV1MixnodeRewardRow represents a single row inside the nyx_nym_mixnet_v1_mixnode_reward table +type NyxNymMixnetV1MixnodeRewardRow struct { + Sender string `db:"sender"` + IdentityKey string `db:"identity_key"` + + TotalNodeReward DbCoins `db:"total_node_reward"` + TotalDelegations DbCoins `db:"total_delegations"` + OperatorReward DbCoins `db:"operator_reward"` + UnitDelegatorReward uint64 `db:"unit_delegator_reward"` // TODO: should be a decimal type + Apy float64 `db:"apy"` + StakingSupply DbCoins `db:"staking_supply"` + ProfitMarginPercentage uint64 `db:"profit_margin_percentage"` + + ContractAddress string `db:"contract_address"` + EventType string `db:"event_type"` + + Attributes interface{} `db:"attributes"` + ExecutedAt time.Time `db:"executed_at"` + + Height int64 `db:"height"` + Hash string `db:"hash"` +} diff --git a/modules/actions/handle_additional_operations.go b/modules/actions/handle_additional_operations.go index 4b532788..7cf91d6d 100644 --- a/modules/actions/handle_additional_operations.go +++ b/modules/actions/handle_additional_operations.go @@ -1,6 +1,7 @@ package actions import ( + "github.com/rs/zerolog/log" "os" "os/signal" "sync" @@ -15,8 +16,10 @@ var ( ) func (m *Module) RunAdditionalOperations() error { + log.Info().Msg("Starting actions worker...") + // Build the worker - context := actionstypes.NewContext(m.node, m.sources) + context := actionstypes.NewContext(m.node, m.sources, m.db) worker := actionstypes.NewActionsWorker(context) // Register the endpoints @@ -41,6 +44,12 @@ func (m *Module) RunAdditionalOperations() error { worker.RegisterHandler("/validator_redelegations_from", handlers.ValidatorRedelegationsFromHandler) worker.RegisterHandler("/validator_unbonding_delegations", handlers.ValidatorUnbondingDelegationsHandler) + // -- Nyx -- + // -- Nym -- + // -- Mixnet v1 -- + worker.RegisterHandler("/nyx/nym/mixnet/v1/mixnode/delegations", handlers.NyxNymMixnetV1DelegationsHandler) + worker.RegisterHandler("/nyx/nym/mixnet/v1/mixnode/rewards", handlers.NyxNymMixnetV1RewardsHandler) + // Listen for and trap any OS signal to gracefully shutdown and exit m.trapSignal() diff --git a/modules/actions/handlers/nyx_nym_mixnet_v1.go b/modules/actions/handlers/nyx_nym_mixnet_v1.go new file mode 100644 index 00000000..e2384c3f --- /dev/null +++ b/modules/actions/handlers/nyx_nym_mixnet_v1.go @@ -0,0 +1,195 @@ +package handlers + +import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + dbtypes "github.com/forbole/bdjuno/v3/database/types" + "github.com/forbole/bdjuno/v3/modules/actions/types" + "github.com/rs/zerolog/log" + "time" +) + +func NyxNymMixnetV1DelegationsHandler(ctx *types.Context, payload *types.Payload) (interface{}, error) { + address := payload.GetAddress() + identityKey := payload.GetIdentityKey() + height := payload.GetHeight() + + log.Debug().Str("address", address). + Str("identity_key", *identityKey). + Interface("height", height). + Msg("executing NyxNymMixnetV1DelegationsHandler action") + + if identityKey == nil { + return nil, fmt.Errorf("identity key not specified") + } + + delegations, err := getDelegations(ctx, *identityKey, address, height) + + log.Debug().Interface("delegations", delegations).Msg("Got delegations") + + return delegations, err +} + +func NyxNymMixnetV1RewardsHandler(ctx *types.Context, payload *types.Payload) (interface{}, error) { + address := payload.GetAddress() + identityKey := payload.GetIdentityKey() + height := payload.GetHeight() + + log.Debug().Str("address", address). + Str("identity_key", *identityKey). + Interface("height", height). + Msg("executing NyxNymMixnetV1RewardsHandler action") + + if identityKey == nil { + return nil, fmt.Errorf("identity key not specified") + } + + delegations, err := getDelegations(ctx, *identityKey, address, height) + if err != nil { + return nil, err + } + + rewards := make([]types.NyxNymMixnetV1Rewards, len(delegations)) + + for i, delegation := range delegations { + var heightEnd uint64 + + if delegation.End != nil { + heightEnd = delegation.End.Height + } + + log.Debug().Str("identity", *identityKey).Uint64("start", delegation.Start.Height).Uint64("end", heightEnd).Msg("Getting rewards") + + rewardEventsDb, err := ctx.Db.GetNymMixnetV1MixnodeRewardEvent(*identityKey, delegation.Start.Height, &heightEnd) + if err != nil { + return nil, fmt.Errorf("failed to get reward events: %s", err) + } + + rewardEvents := make([]types.NyxNymMixnetV1Reward, len(rewardEventsDb)) + totalRewards := sdk.NewDec(0) + delegationDec := sdk.MustNewDecFromStr(delegation.Delegation.Amount) + for j, event := range rewardEventsDb { + totalNodeReward := event.TotalNodeReward.ToCoins()[0] + unitDelegatorReward := sdk.NewDec(int64(event.UnitDelegatorReward)).Quo(sdk.NewDec(1_000_000_000_000)) + + //reward := decimal.NewFromInt(int64(event.UnitDelegatorReward)).Mul(decimal.RequireFromString(delegation.Delegation.Amount)).Div(decimal.NewFromInt(1_000_000_000_000)) + reward := delegationDec.Mul(unitDelegatorReward) + rewardAsInt := reward.RoundInt64() + totalRewards = totalRewards.Add(sdk.NewDec(rewardAsInt)) + + rewardEvents[j] = types.NyxNymMixnetV1Reward{ + Timestamp: event.ExecutedAt, + Height: uint64(event.Height), + TotalNodeReward: types.Coin{ + Amount: totalNodeReward.Amount.String(), + Denom: totalNodeReward.Denom, + }, + Reward: types.Coin{ + Amount: reward.RoundInt().String(), + Denom: totalNodeReward.Denom, + }, + EpochApy: event.Apy, + } + } + + endTS := time.Now() + if delegation.End != nil { + endTS = delegation.End.Timestamp + } + duration := endTS.Sub(delegation.Start.Timestamp) + durationSecs := int64(duration.Seconds()) + returnPerSecond := totalRewards.Quo(delegationDec).QuoInt64(durationSecs) + returnPerYear := returnPerSecond.MulInt64(365 * 24 * 60 * 60) + + rewards[i] = types.NyxNymMixnetV1Rewards{ + DelegatorAddress: delegation.DelegatorAddress, + MixnodeIdentityKey: delegation.MixnodeIdentityKey, + Start: delegation.Start, + End: delegation.End, + Delegation: delegation.Delegation, + Rewards: rewardEvents, + TotalRewards: types.Coin{ + Amount: totalRewards.Quo(sdk.NewDec(1_000_000)).String(), + Denom: "nym", + }, + APY: returnPerYear.MustFloat64(), + } + } + + return rewards, nil +} + +func getDelegations(ctx *types.Context, identityKey string, address string, height *int64) ([]types.NyxNymMixnetV1Delegation, error) { + dbDelegations, err := ctx.Db.GetNymMixnetV1MixnodeEvent("delegate_to_mixnode", identityKey, &address, height, nil) + if err != nil { + return nil, fmt.Errorf("error while getting event rows: %s", err) + } + + log.Debug().Str("identityKey", identityKey).Str("address", address).Int64("height", *height).Int("count delegations", len(dbDelegations)).Msg("Got delegations") + + dbUndelegations, err := ctx.Db.GetNymMixnetV1MixnodeEvent("undelegation", identityKey, &address, height, nil) + if err != nil { + return nil, fmt.Errorf("error while getting event rows: %s", err) + } + + log.Debug().Int("count undelegations", len(dbUndelegations)).Msg("Got undelegations") + + delegations := make([]types.NyxNymMixnetV1Delegation, len(dbDelegations)) + + for i, delegation := range dbDelegations { + undelegation, j := contains(dbUndelegations, delegation.IdentityKey) + + // undelegation must occur after delegation + if undelegation != nil && undelegation.Height <= delegation.Height { + dbUndelegations = remove(dbUndelegations, j) + undelegation = nil + } + + amountCoins := delegation.Amount.ToCoins() + amount := "0" + denom := "unym" + + if len(amount) > 0 { + amount = amountCoins[0].Amount.String() + denom = amountCoins[0].Denom + } else { + log.Warn().Interface("delegation", delegation).Msg("Zero delegation") + } + + delegations[i] = types.NyxNymMixnetV1Delegation{ + DelegatorAddress: delegation.Sender, + MixnodeIdentityKey: delegation.IdentityKey, + Start: types.NyxNymMixnetV1DelegationTimestamp{ + Timestamp: delegation.ExecutedAt, + Height: uint64(delegation.Height), + }, + End: nil, + Delegation: types.Coin{ + Amount: amount, + Denom: denom, + }, + } + if undelegation != nil { + delegations[i].End = &types.NyxNymMixnetV1DelegationTimestamp{ + Timestamp: undelegation.ExecutedAt, + Height: uint64(undelegation.Height), + } + dbUndelegations = remove(dbUndelegations, j) + } + } + + return delegations, nil +} + +func remove(slice []dbtypes.NyxNymMixnetV1MixnodeEventsRow, indexToRemove int) []dbtypes.NyxNymMixnetV1MixnodeEventsRow { + return append(slice[:indexToRemove], slice[indexToRemove+1:]...) +} + +func contains(arr []dbtypes.NyxNymMixnetV1MixnodeEventsRow, identityKey string) (*dbtypes.NyxNymMixnetV1MixnodeEventsRow, int) { + for i, item := range arr { + if item.IdentityKey == identityKey { + return &item, i + } + } + return nil, 0 +} diff --git a/modules/actions/module.go b/modules/actions/module.go index a7c40ee0..5e4999b1 100644 --- a/modules/actions/module.go +++ b/modules/actions/module.go @@ -2,6 +2,7 @@ package actions import ( "github.com/cosmos/cosmos-sdk/simapp/params" + "github.com/forbole/bdjuno/v3/database" "github.com/forbole/juno/v3/modules" "github.com/forbole/juno/v3/node" "github.com/forbole/juno/v3/node/builder" @@ -24,9 +25,10 @@ type Module struct { cfg *Config node node.Node sources *modulestypes.Sources + db *database.Db } -func NewModule(cfg config.Config, encodingConfig *params.EncodingConfig) *Module { +func NewModule(cfg config.Config, encodingConfig *params.EncodingConfig, db *database.Db) *Module { bz, err := cfg.GetBytes() if err != nil { panic(err) @@ -58,6 +60,7 @@ func NewModule(cfg config.Config, encodingConfig *params.EncodingConfig) *Module cfg: actionsCfg, node: junoNode, sources: sources, + db: db, } } diff --git a/modules/actions/types/handler.go b/modules/actions/types/handler.go index f233a2d4..86a27a1b 100644 --- a/modules/actions/types/handler.go +++ b/modules/actions/types/handler.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "github.com/forbole/bdjuno/v3/database" "github.com/forbole/juno/v3/node" @@ -12,13 +13,15 @@ import ( type Context struct { node node.Node Sources *modulestypes.Sources + Db *database.Db } // NewContext returns a new Context instance -func NewContext(node node.Node, sources *modulestypes.Sources) *Context { +func NewContext(node node.Node, sources *modulestypes.Sources, db *database.Db) *Context { return &Context{ node: node, Sources: sources, + Db: db, } } diff --git a/modules/actions/types/nyx_nym_mixnet_v1.go b/modules/actions/types/nyx_nym_mixnet_v1.go new file mode 100644 index 00000000..ec74a317 --- /dev/null +++ b/modules/actions/types/nyx_nym_mixnet_v1.go @@ -0,0 +1,45 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types/query" + "time" +) + +// ========================= Delegation Response ========================= + +type NyxNymMixnetV1DelegationResponse struct { + Delegations []NyxNymMixnetV1Delegation `json:"delegations"` + Pagination *query.PageResponse `json:"pagination"` +} + +type NyxNymMixnetV1Delegation struct { + DelegatorAddress string `json:"delegator_address"` + MixnodeIdentityKey string `json:"mixnode_identity_key"` + Start NyxNymMixnetV1DelegationTimestamp `json:"start"` + End *NyxNymMixnetV1DelegationTimestamp `json:"end"` + Delegation Coin `json:"delegation"` +} + +type NyxNymMixnetV1DelegationTimestamp struct { + Timestamp time.Time `json:"timestamp"` + Height uint64 `json:"height"` +} + +type NyxNymMixnetV1Reward struct { + Timestamp time.Time `json:"timestamp"` + Height uint64 `json:"height"` + TotalNodeReward Coin `json:"total_node_reward"` + Reward Coin `json:"reward"` + EpochApy float64 `json:"epoch_apy"` +} + +type NyxNymMixnetV1Rewards struct { + DelegatorAddress string `json:"delegator_address"` + MixnodeIdentityKey string `json:"mixnode_identity_key"` + Start NyxNymMixnetV1DelegationTimestamp `json:"start"` + End *NyxNymMixnetV1DelegationTimestamp `json:"end"` + Delegation Coin `json:"delegation"` + Rewards []NyxNymMixnetV1Reward `json:"rewards"` + TotalRewards Coin `json:"total_rewards"` + APY float64 `json:"apy"` +} diff --git a/modules/actions/types/payload.go b/modules/actions/types/payload.go index 18e9cacd..5a6b15f8 100644 --- a/modules/actions/types/payload.go +++ b/modules/actions/types/payload.go @@ -13,6 +13,16 @@ func (p *Payload) GetAddress() string { return p.Input.Address } +// GetIdentityKey returns the identity key associated with this payload, if any +func (p *Payload) GetIdentityKey() *string { + return &p.Input.IdentityKey +} + +// GetHeight returns the block height associated with this payload, if any +func (p *Payload) GetHeight() *int64 { + return &p.Input.Height +} + // GetPagination returns the pagination asasociated with this payload, if any func (p *Payload) GetPagination() *query.PageRequest { return &query.PageRequest{ @@ -23,9 +33,10 @@ func (p *Payload) GetPagination() *query.PageRequest { } type PayloadArgs struct { - Address string `json:"address"` - Height int64 `json:"height"` - Offset uint64 `json:"offset"` - Limit uint64 `json:"limit"` - CountTotal bool `json:"count_total"` + Address string `json:"address"` + IdentityKey string `json:"identity_key"` + Height int64 `json:"height"` + Offset uint64 `json:"offset"` + Limit uint64 `json:"limit"` + CountTotal bool `json:"count_total"` } diff --git a/modules/registrar.go b/modules/registrar.go index 45f6236a..a84815dc 100644 --- a/modules/registrar.go +++ b/modules/registrar.go @@ -72,7 +72,7 @@ func (r *Registrar) BuildModules(ctx registrar.Context) jmodules.Modules { panic(err) } - actionsModule := actions.NewModule(ctx.JunoConfig, ctx.EncodingConfig) + actionsModule := actions.NewModule(ctx.JunoConfig, ctx.EncodingConfig, db) authModule := auth.NewModule(r.parser, cdc, db) bankModule := bank.NewModule(r.parser, sources.BankSource, cdc, db) consensusModule := consensus.NewModule(db) diff --git a/modules/wasm/handle_msg.go b/modules/wasm/handle_msg.go index 20f39c01..9cb27d12 100644 --- a/modules/wasm/handle_msg.go +++ b/modules/wasm/handle_msg.go @@ -2,6 +2,7 @@ package wasm import ( "encoding/base64" + "encoding/json" "fmt" "github.com/rs/zerolog/log" "reflect" @@ -355,6 +356,26 @@ func (m *Module) handleMessageNymMixnetV1(msgJson interface{}, messageName strin for _, event := range txLog.Events { switch event.Type { + case "wasm-undelegation": + proxyAttr := getValueFromNamedAttribute(event.Attributes, "proxy") + amountAttr := getValueFromNamedAttribute(event.Attributes, "amount") + delegatorAttr := getValueFromNamedAttribute(event.Attributes, "delegator") + identityKeyAttr := getValueFromNamedAttribute(event.Attributes, "delegation_target") + + if amountAttr != nil && delegatorAttr != nil && identityKeyAttr != nil { + amountCoin := sdk.NewCoins(sdk.NewCoin("unym", sdk.NewInt(decimal.RequireFromString(*amountAttr).IntPart()))) + jsonBytes, errJson := json.Marshal(event.Attributes) + if errJson != nil { + jsonAttr := string(jsonBytes) + err = m.db.SaveNymMixnetV1MixnodeEvent("undelegation", "delegator", proxyAttr, *identityKeyAttr, &amountCoin, "wasm-undelegation", jsonAttr, execute, tx) + if err != nil { + log.Err(err).Msg("Error while saving mixnode v1 event for wasm-undelegation") + } + } else { + log.Err(errJson).Msg("Error while saving mixnode v1 event for wasm-undelegation attributes to JSON") + } + } + case "wasm-v2_mix_rewarding": mixId := getValueFromNamedAttribute(event.Attributes, "mix_id") operatorRewardAttr := getValueFromNamedAttribute(event.Attributes, "operator_reward") @@ -400,7 +421,9 @@ func (m *Module) handleMessageNymMixnetV1(msgJson interface{}, messageName strin apy := delegatorsReturn err = m.db.SaveNymMixnetV2MixnodeRewardingEvent(*mixIdInt, operatorRewardCoin, delegatesRewardCoin, priorDelegatesCoin, priorUnitDelegationCoin, apy.InexactFloat64(), event, execute, tx) - return err + if err != nil { + log.Err(err).Msg("Failed to save row in nyx_nym_mixnet_v2_mixnode_reward") + } } case "wasm-mix_rewarding": From 9816c89ee36ecc53a1c436e35ec82cfe2e507ff4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Dec 2022 23:11:38 +0000 Subject: [PATCH 13/13] build(deps): bump technote-space/get-diff-action from 6.1.0 to 6.1.2 Bumps [technote-space/get-diff-action](https://github.com/technote-space/get-diff-action) from 6.1.0 to 6.1.2. - [Release notes](https://github.com/technote-space/get-diff-action/releases) - [Changelog](https://github.com/technote-space/get-diff-action/blob/main/.releasegarc) - [Commits](https://github.com/technote-space/get-diff-action/compare/v6.1.0...v6.1.2) --- updated-dependencies: - dependency-name: technote-space/get-diff-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c0ff681e..a2c49188 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 6 steps: - uses: actions/checkout@v3 - - uses: technote-space/get-diff-action@v6.1.0 + - uses: technote-space/get-diff-action@v6.1.2 with: SUFFIX_FILTER: | .go