From 6956e2ec6bf28e7d24f6e655514825ba15690f29 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 22 Apr 2020 09:44:40 -0400 Subject: [PATCH 1/5] Bump go.{mod,sum} --- go.mod | 4 ++-- go.sum | 29 +++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 32d5dcf3d7a..b21c566b99f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/cosmos/cosmos-sdk require ( github.com/99designs/keyring v1.1.4 github.com/bgentry/speakeasy v0.1.0 - github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d + github.com/btcsuite/btcd v0.20.1-beta github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d github.com/cosmos/ledger-cosmos-go v0.11.1 github.com/gibson042/canonicaljson-go v1.0.3 @@ -29,7 +29,7 @@ require ( github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.15.1 github.com/tendermint/iavl v0.13.3 - github.com/tendermint/tendermint v0.33.3 + github.com/tendermint/tendermint v0.33.4 github.com/tendermint/tm-db v0.5.1 gopkg.in/yaml.v2 v2.2.8 ) diff --git a/go.sum b/go.sum index ec436c7c9eb..b5b7f93b566 100644 --- a/go.sum +++ b/go.sum @@ -6,12 +6,15 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw= github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +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/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 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/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -37,9 +40,14 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d h1:xG8Pj6Y6J760xwETNmMzmlt38QSwz0BLp1cZ09g27uw= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= +github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a h1:RQMUrEILyYJEoAT34XS/kLu40vC0+po/UfxrBBA4qZE= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= +github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= @@ -174,6 +182,8 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -183,6 +193,8 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8 github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f h1:8N8XWLZelZNibkhM1FuF+3Ad3YIbgirjdMiVA0eUkaM= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= +github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= @@ -331,6 +343,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.5.0 h1:Ctq0iGpCmr3jeP77kbF2UxgvRwzWWz+4Bh9/vJTyg1A= github.com/prometheus/client_golang v1.5.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.5.1 h1:bdHYieyGlH+6OLEk2YQha8THib30KP0/yD0YH9m6xcA= +github.com/prometheus/client_golang v1.5.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -356,6 +370,8 @@ github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= +github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.2.2 h1:qAuQxio6lmZ3ghpeSMrhqT+Xq/FkuimzWD8o0YR9Gmo= github.com/regen-network/cosmos-proto v0.2.2/go.mod h1:4jLYG3Qk6EtkOj3/FK7ziS5+LurpGPzJ41ungpzThcw= github.com/regen-network/protobuf v1.3.2-alpha.regen.1 h1:YdeZbBS0lG1D13COb7b57+nM/RGgIs8WF9DwitU6EBM= @@ -430,8 +446,8 @@ github.com/tendermint/iavl v0.13.3 h1:expgBDY1MX+6/3sqrIxGChbTNf9N9aTJ67SH4bPchC github.com/tendermint/iavl v0.13.3/go.mod h1:2lE7GiWdSvc7kvT78ncIKmkOjCnp6JEnSb2O7B9htLw= github.com/tendermint/tendermint v0.33.2 h1:NzvRMTuXJxqSsFed2J7uHmMU5N1CVzSpfi3nCc882KY= github.com/tendermint/tendermint v0.33.2/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= -github.com/tendermint/tendermint v0.33.3 h1:6lMqjEoCGejCzAghbvfQgmw87snGSqEhDTo/jw+W8CI= -github.com/tendermint/tendermint v0.33.3/go.mod h1:25DqB7YvV1tN3tHsjWoc2vFtlwICfrub9XO6UBO+4xk= +github.com/tendermint/tendermint v0.33.4 h1:NM3G9618yC5PaaxGrcAySc5ylc1PAANeIx42u2Re/jo= +github.com/tendermint/tendermint v0.33.4/go.mod h1:6NW9DVkvsvqmCY6wbRsOo66qGDhMXglRL70aXajvBEA= github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY= github.com/tendermint/tm-db v0.5.1 h1:H9HDq8UEA7Eeg13kdYckkgwwkQLBnJGgX4PgLJRhieY= github.com/tendermint/tm-db v0.5.1/go.mod h1:g92zWjHpCYlEvQXvy9M168Su8V1IBEeawpXVVBaK4f4= @@ -468,6 +484,9 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 h1:ULYEB3JvPRE/IfO+9uO7vKV/xzVTO7XPAwm8xbf4w2g= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= +golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -496,6 +515,8 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -524,6 +545,8 @@ golang.org/x/sys v0.0.0-20200107162124-548cf772de50/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -575,6 +598,8 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k= +google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 77e5f5521c99d5432e95f4f8e5b12472c3bad883 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 22 Apr 2020 10:00:29 -0400 Subject: [PATCH 2/5] Update APIs from Tendermint --- client/context/context.go | 6 ++++-- client/context/verifier.go | 4 ++-- server/tm_cmds.go | 10 ++++++---- tests/util.go | 7 +++---- x/genutil/utils.go | 9 +++++---- x/ibc/07-tendermint/update.go | 7 +++++-- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/client/context/context.go b/client/context/context.go index 7b0fa273155..1e8b91deff9 100644 --- a/client/context/context.go +++ b/client/context/context.go @@ -10,6 +10,7 @@ import ( "github.com/tendermint/tendermint/libs/cli" tmlite "github.com/tendermint/tendermint/lite" rpcclient "github.com/tendermint/tendermint/rpc/client" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/client/flags" @@ -80,7 +81,7 @@ func NewCLIContextWithInputAndFrom(input io.Reader, from string) CLIContext { if !offline { nodeURI = viper.GetString(flags.FlagNode) if nodeURI != "" { - rpc, err = rpcclient.NewHTTP(nodeURI, "/websocket") + rpc, err = rpchttp.New(nodeURI, "/websocket") if err != nil { fmt.Printf("failted to get client: %v\n", err) os.Exit(1) @@ -192,10 +193,11 @@ func (ctx CLIContext) WithTrustNode(trustNode bool) CLIContext { // WithNodeURI returns a copy of the context with an updated node URI. func (ctx CLIContext) WithNodeURI(nodeURI string) CLIContext { ctx.NodeURI = nodeURI - client, err := rpcclient.NewHTTP(nodeURI, "/websocket") + client, err := rpchttp.New(nodeURI, "/websocket") if err != nil { panic(err) } + ctx.Client = client return ctx } diff --git a/client/context/verifier.go b/client/context/verifier.go index 856c585b5a2..b849d3e397d 100644 --- a/client/context/verifier.go +++ b/client/context/verifier.go @@ -7,7 +7,7 @@ import ( "github.com/tendermint/tendermint/libs/log" tmlite "github.com/tendermint/tendermint/lite" tmliteproxy "github.com/tendermint/tendermint/lite/proxy" - rpcclient "github.com/tendermint/tendermint/rpc/client" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ) const ( @@ -43,7 +43,7 @@ func CreateVerifier(ctx CLIContext, cacheSize int) (tmlite.Verifier, error) { // create an RPC client based off of the RPC URI if no RPC client exists client := ctx.Client if client == nil { - client, err = rpcclient.NewHTTP(ctx.NodeURI, "/websocket") + client, err = rpchttp.New(ctx.NodeURI, "/websocket") if err != nil { return nil, err } diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 2667e55a7df..44b0736d3bc 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -42,12 +42,14 @@ func ShowValidatorCmd(ctx *Context) *cobra.Command { Use: "show-validator", Short: "Show this node's tendermint validator info", RunE: func(cmd *cobra.Command, args []string) error { - cfg := ctx.Config UpgradeOldPrivValFile(cfg) - privValidator := pvm.LoadOrGenFilePV( - cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()) - valPubKey := privValidator.GetPubKey() + + privValidator := pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()) + valPubKey, err := privValidator.GetPubKey() + if err != nil { + return err + } if viper.GetString(cli.OutputFlag) == "json" { return printlnJSON(valPubKey) diff --git a/tests/util.go b/tests/util.go index 9b37d12c698..2bc7ee43587 100644 --- a/tests/util.go +++ b/tests/util.go @@ -10,8 +10,7 @@ import ( "time" "github.com/stretchr/testify/require" - - tmclient "github.com/tendermint/tendermint/rpc/client" + rpchttp "github.com/tendermint/tendermint/rpc/client/http" ctypes "github.com/tendermint/tendermint/rpc/core/types" rpcclient "github.com/tendermint/tendermint/rpc/lib/client" @@ -29,7 +28,7 @@ func WaitForNextHeightTM(port string) { func WaitForNextNBlocksTM(n int64, port string) { // get the latest block and wait for n more url := fmt.Sprintf("http://localhost:%v", port) - cl, err := tmclient.NewHTTP(url, "/websocket") + cl, err := rpchttp.New(url, "/websocket") if err != nil { panic(fmt.Sprintf("failed to create Tendermint HTTP client: %s", err)) } @@ -56,7 +55,7 @@ func WaitForHeightTM(height int64, port string) { } func waitForHeightTM(height int64, url string) { - cl, err := tmclient.NewHTTP(url, "/websocket") + cl, err := rpchttp.New(url, "/websocket") if err != nil { panic(fmt.Sprintf("failed to create Tendermint HTTP client: %s", err)) } diff --git a/x/genutil/utils.go b/x/genutil/utils.go index 3d8aa8f2ed0..b8c0d53136f 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -47,9 +47,7 @@ func ExportGenesisFileWithTime( } // InitializeNodeValidatorFiles creates private validator and p2p configuration files. -func InitializeNodeValidatorFiles(config *cfg.Config, -) (nodeID string, valPubKey crypto.PubKey, err error) { - +func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey crypto.PubKey, err error) { nodeKey, err := p2p.LoadOrGenNodeKey(config.NodeKeyFile()) if err != nil { return "", nil, err @@ -68,7 +66,10 @@ func InitializeNodeValidatorFiles(config *cfg.Config, return "", nil, err } - valPubKey = privval.LoadOrGenFilePV(pvKeyFile, pvStateFile).GetPubKey() + valPubKey, err = privval.LoadOrGenFilePV(pvKeyFile, pvStateFile).GetPubKey() + if err != nil { + return "", nil, err + } return nodeID, valPubKey, nil } diff --git a/x/ibc/07-tendermint/update.go b/x/ibc/07-tendermint/update.go index 4233e893460..5ca21eef303 100644 --- a/x/ibc/07-tendermint/update.go +++ b/x/ibc/07-tendermint/update.go @@ -85,8 +85,11 @@ func checkValidity( } // Verify next header with the last header's validatorset as trusted validatorset - err := lite.Verify(clientState.GetChainID(), &clientState.LastHeader.SignedHeader, clientState.LastHeader.ValidatorSet, - &header.SignedHeader, header.ValidatorSet, clientState.TrustingPeriod, currentTimestamp, lite.DefaultTrustLevel) + err := lite.Verify( + clientState.GetChainID(), &clientState.LastHeader.SignedHeader, + clientState.LastHeader.ValidatorSet, &header.SignedHeader, header.ValidatorSet, + clientState.TrustingPeriod, currentTimestamp, lite.DefaultTrustLevel, + ) if err != nil { return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, err.Error()) } From 469589f7f45d5a61b7eb6a2dfe948785e8df580f Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 22 Apr 2020 11:21:18 -0400 Subject: [PATCH 3/5] Add max clock drift to client state --- x/ibc/07-tendermint/client/cli/tx.go | 15 ++++++++---- x/ibc/07-tendermint/client/rest/rest.go | 1 + x/ibc/07-tendermint/client/rest/tx.go | 2 +- x/ibc/07-tendermint/types/client_state.go | 29 ++++++++++++++--------- x/ibc/07-tendermint/types/msgs.go | 5 +++- x/ibc/07-tendermint/update.go | 2 +- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/x/ibc/07-tendermint/client/cli/tx.go b/x/ibc/07-tendermint/client/cli/tx.go index 26bab999652..23d861f7849 100644 --- a/x/ibc/07-tendermint/client/cli/tx.go +++ b/x/ibc/07-tendermint/client/cli/tx.go @@ -26,15 +26,15 @@ import ( // in https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#create func GetCmdCreateClient(cdc *codec.Codec) *cobra.Command { cmd := &cobra.Command{ - Use: "create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period]", + Use: "create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift]", Short: "create new client with a consensus state", Long: strings.TrimSpace(fmt.Sprintf(`create new client with a specified identifier and consensus state: Example: -$ %s tx ibc client create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] --from node0 --home ../node0/cli --chain-id $CID +$ %s tx ibc client create [client-id] [path/to/consensus_state.json] [trusting_period] [unbonding_period] [max_clock_drift] --from node0 --home ../node0/cli --chain-id $CID `, version.ClientName), ), - Args: cobra.ExactArgs(4), + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { inBuf := bufio.NewReader(cmd.InOrStdin()) txBldr := authtypes.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) @@ -64,7 +64,14 @@ $ %s tx ibc client create [client-id] [path/to/consensus_state.json] [trusting_p return err } - msg := ibctmtypes.NewMsgCreateClient(clientID, header, trustingPeriod, ubdPeriod, cliCtx.GetFromAddress()) + maxClockDrift, err := time.ParseDuration(args[4]) + if err != nil { + return err + } + + msg := ibctmtypes.NewMsgCreateClient( + clientID, header, trustingPeriod, ubdPeriod, maxClockDrift, cliCtx.GetFromAddress(), + ) if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/ibc/07-tendermint/client/rest/rest.go b/x/ibc/07-tendermint/client/rest/rest.go index 6a5f50dea87..afe1efda409 100644 --- a/x/ibc/07-tendermint/client/rest/rest.go +++ b/x/ibc/07-tendermint/client/rest/rest.go @@ -30,6 +30,7 @@ type CreateClientReq struct { Header ibctmtypes.Header `json:"consensus_state" yaml:"consensus_state"` TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"` UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"` + MaxClockDrift time.Duration `json:"max_clock_drift" yaml:"max_clock_drift"` } // UpdateClientReq defines the properties of a update client request's body. diff --git a/x/ibc/07-tendermint/client/rest/tx.go b/x/ibc/07-tendermint/client/rest/tx.go index 942325fe85f..1e2458d5da9 100644 --- a/x/ibc/07-tendermint/client/rest/tx.go +++ b/x/ibc/07-tendermint/client/rest/tx.go @@ -52,7 +52,7 @@ func createClientHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { msg := ibctmtypes.NewMsgCreateClient( req.ClientID, req.Header, - req.TrustingPeriod, req.UnbondingPeriod, + req.TrustingPeriod, req.UnbondingPeriod, req.MaxClockDrift, fromAddr, ) diff --git a/x/ibc/07-tendermint/types/client_state.go b/x/ibc/07-tendermint/types/client_state.go index 581ddf1b489..2974072372a 100644 --- a/x/ibc/07-tendermint/types/client_state.go +++ b/x/ibc/07-tendermint/types/client_state.go @@ -25,49 +25,56 @@ var _ clientexported.ClientState = ClientState{} type ClientState struct { // Client ID ID string `json:"id" yaml:"id"` + // Duration of the period since the LastestTimestamp during which the // submitted headers are valid for upgrade TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"` + // Duration of the staking unbonding period UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"` + + // MaxClockDrift defines how much new (untrusted) header's Time can drift into + // the future. + MaxClockDrift time.Duration + // Block height when the client was frozen due to a misbehaviour FrozenHeight uint64 `json:"frozen_height" yaml:"frozen_height"` + // Last Header that was stored by client LastHeader Header `json:"last_header" yaml:"last_header"` } // InitializeFromMsg creates a tendermint client state from a CreateClientMsg -func InitializeFromMsg( - msg MsgCreateClient, -) (ClientState, error) { - return Initialize(msg.GetClientID(), msg.TrustingPeriod, msg.UnbondingPeriod, msg.Header) +func InitializeFromMsg(msg MsgCreateClient) (ClientState, error) { + return Initialize( + msg.GetClientID(), msg.TrustingPeriod, msg.UnbondingPeriod, msg.MaxClockDrift, msg.Header, + ) } // Initialize creates a client state and validates its contents, checking that // the provided consensus state is from the same client type. func Initialize( - id string, trustingPeriod, ubdPeriod time.Duration, - header Header, + id string, trustingPeriod, ubdPeriod, maxClockDrift time.Duration, header Header, ) (ClientState, error) { + if trustingPeriod >= ubdPeriod { return ClientState{}, errors.New("trusting period should be < unbonding period") } - clientState := NewClientState( - id, trustingPeriod, ubdPeriod, header, - ) + clientState := NewClientState(id, trustingPeriod, ubdPeriod, maxClockDrift, header) return clientState, nil } // NewClientState creates a new ClientState instance func NewClientState( - id string, trustingPeriod, ubdPeriod time.Duration, - header Header, + id string, trustingPeriod, ubdPeriod, maxClockDrift time.Duration, header Header, ) ClientState { + return ClientState{ ID: id, TrustingPeriod: trustingPeriod, UnbondingPeriod: ubdPeriod, + MaxClockDrift: maxClockDrift, LastHeader: header, FrozenHeight: 0, } diff --git a/x/ibc/07-tendermint/types/msgs.go b/x/ibc/07-tendermint/types/msgs.go index 170c69d2e60..07bbb9270d4 100644 --- a/x/ibc/07-tendermint/types/msgs.go +++ b/x/ibc/07-tendermint/types/msgs.go @@ -32,19 +32,22 @@ type MsgCreateClient struct { Header Header `json:"header" yaml:"header"` TrustingPeriod time.Duration `json:"trusting_period" yaml:"trusting_period"` UnbondingPeriod time.Duration `json:"unbonding_period" yaml:"unbonding_period"` + MaxClockDrift time.Duration `json:"max_clock_drift" yaml:"max_clock_drift"` Signer sdk.AccAddress `json:"address" yaml:"address"` } // NewMsgCreateClient creates a new MsgCreateClient instance func NewMsgCreateClient( id string, header Header, - trustingPeriod, unbondingPeriod time.Duration, signer sdk.AccAddress, + trustingPeriod, unbondingPeriod, maxClockDrift time.Duration, signer sdk.AccAddress, ) MsgCreateClient { + return MsgCreateClient{ ClientID: id, Header: header, TrustingPeriod: trustingPeriod, UnbondingPeriod: unbondingPeriod, + MaxClockDrift: maxClockDrift, Signer: signer, } } diff --git a/x/ibc/07-tendermint/update.go b/x/ibc/07-tendermint/update.go index 5ca21eef303..cee63ee6d9c 100644 --- a/x/ibc/07-tendermint/update.go +++ b/x/ibc/07-tendermint/update.go @@ -88,7 +88,7 @@ func checkValidity( err := lite.Verify( clientState.GetChainID(), &clientState.LastHeader.SignedHeader, clientState.LastHeader.ValidatorSet, &header.SignedHeader, header.ValidatorSet, - clientState.TrustingPeriod, currentTimestamp, lite.DefaultTrustLevel, + clientState.TrustingPeriod, currentTimestamp, clientState.MaxClockDrift, lite.DefaultTrustLevel, ) if err != nil { return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, err.Error()) From 28d67575572a77028d9dbf861ef72f7f615649e2 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 22 Apr 2020 11:36:47 -0400 Subject: [PATCH 4/5] Test updates --- x/ibc/07-tendermint/misbehaviour_test.go | 23 ++++++++++++------- x/ibc/07-tendermint/tendermint_test.go | 7 +++++- x/ibc/07-tendermint/update_test.go | 29 +++++++++++++++--------- x/ibc/20-transfer/handler_test.go | 13 ++++++++--- x/ibc/20-transfer/keeper/keeper_test.go | 13 ++++++++--- x/ibc/ante/ante_test.go | 13 ++++++++--- 6 files changed, 69 insertions(+), 29 deletions(-) diff --git a/x/ibc/07-tendermint/misbehaviour_test.go b/x/ibc/07-tendermint/misbehaviour_test.go index 655ce135df4..1965a7f307c 100644 --- a/x/ibc/07-tendermint/misbehaviour_test.go +++ b/x/ibc/07-tendermint/misbehaviour_test.go @@ -14,7 +14,10 @@ import ( func (suite *TendermintTestSuite) TestCheckMisbehaviour() { altPrivVal := tmtypes.NewMockPV() - altVal := tmtypes.NewValidator(altPrivVal.GetPubKey(), 4) + altPubKey, err := altPrivVal.GetPubKey() + suite.Require().NoError(err) + + altVal := tmtypes.NewValidator(altPubKey, 4) // Create bothValSet with both suite validator and altVal bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -23,7 +26,11 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { // Create signer array and ensure it is in same order as bothValSet var bothSigners []tmtypes.PrivValidator - if bytes.Compare(altPrivVal.GetPubKey().Address(), suite.privVal.GetPubKey().Address()) == -1 { + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + + if bytes.Compare(altPubKey.Address(), pubKey.Address()) == -1 { bothSigners = []tmtypes.PrivValidator{altPrivVal, suite.privVal} } else { bothSigners = []tmtypes.PrivValidator{suite.privVal, altPrivVal} @@ -41,7 +48,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }{ { "valid misbehavior evidence", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: bothValSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, bothValSet, bothSigners), @@ -54,7 +61,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }, { "valid misbehavior at height greater than last consensusState", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Height: height - 1, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: bothValSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, bothValSet, bothSigners), @@ -67,7 +74,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }, { "consensus state's valset hash different from evidence should still pass", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Height: height - 1, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: suite.valSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, bothValSet, bothSigners), @@ -80,7 +87,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }, { "first valset has too much change", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: bothValSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, altValSet, altSigners), @@ -93,7 +100,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }, { "second valset has too much change", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: bothValSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, bothValSet, bothSigners), @@ -106,7 +113,7 @@ func (suite *TendermintTestSuite) TestCheckMisbehaviour() { }, { "both valsets have too much change", - ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ibctmtypes.ConsensusState{Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot(tmhash.Sum([]byte("app_hash"))), ValidatorSet: bothValSet}, ibctmtypes.Evidence{ Header1: ibctmtypes.CreateTestHeader(chainID, height, suite.now, altValSet, altSigners), diff --git a/x/ibc/07-tendermint/tendermint_test.go b/x/ibc/07-tendermint/tendermint_test.go index c5f9b6d0d45..9792d3034bc 100644 --- a/x/ibc/07-tendermint/tendermint_test.go +++ b/x/ibc/07-tendermint/tendermint_test.go @@ -18,6 +18,7 @@ const ( height = 4 trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) type TendermintTestSuite struct { @@ -45,7 +46,11 @@ func (suite *TendermintTestSuite) SetupTest() { // Header time is intended to be time for any new header used for updates suite.headerTime = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) suite.privVal = tmtypes.NewMockPV() - val := tmtypes.NewValidator(suite.privVal.GetPubKey(), 10) + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + + val := tmtypes.NewValidator(pubKey, 10) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) // Suite header is intended to be header passed in for initial ClientState // Thus it should have same height and time as ClientState diff --git a/x/ibc/07-tendermint/update_test.go b/x/ibc/07-tendermint/update_test.go index 3cc190ece6f..38dd55e03b5 100644 --- a/x/ibc/07-tendermint/update_test.go +++ b/x/ibc/07-tendermint/update_test.go @@ -20,7 +20,10 @@ func (suite *TendermintTestSuite) TestCheckValidity() { // Setup different validators and signers for testing different types of updates altPrivVal := tmtypes.NewMockPV() - altVal := tmtypes.NewValidator(altPrivVal.GetPubKey(), height) + altPubKey, err := altPrivVal.GetPubKey() + suite.Require().NoError(err) + + altVal := tmtypes.NewValidator(altPubKey, height) // Create bothValSet with both suite validator and altVal. Would be valid update bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -28,9 +31,13 @@ func (suite *TendermintTestSuite) TestCheckValidity() { altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) signers := []tmtypes.PrivValidator{suite.privVal} + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + // Create signer array and ensure it is in same order as bothValSet var bothSigners []tmtypes.PrivValidator - if bytes.Compare(altPrivVal.GetPubKey().Address(), suite.privVal.GetPubKey().Address()) == -1 { + if bytes.Compare(altPubKey.Address(), pubKey.Address()) == -1 { bothSigners = []tmtypes.PrivValidator{altPrivVal, suite.privVal} } else { bothSigners = []tmtypes.PrivValidator{suite.privVal, altPrivVal} @@ -46,7 +53,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "successful update with next height and same validator set", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.headerTime, suite.valSet, signers) currentTime = suite.now }, @@ -55,7 +62,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "successful update with future height and different validator set", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+5, suite.headerTime, bothValSet, bothSigners) currentTime = suite.now }, @@ -64,7 +71,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "unsuccessful update with next height: update header mismatches nextValSetHash", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.headerTime, bothValSet, bothSigners) currentTime = suite.now }, @@ -73,7 +80,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "unsuccessful update with future height: too much change in validator set", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+5, suite.headerTime, altValSet, altSigners) currentTime = suite.now }, @@ -82,7 +89,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "unsuccessful update: trusting period has passed since last client timestamp", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.headerTime, suite.valSet, signers) // make current time pass trusting period from last timestamp on clientstate currentTime = suite.now.Add(ubdPeriod) @@ -92,7 +99,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "unsuccessful update: header timestamp is past current timestamp", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.now.Add(time.Minute), suite.valSet, signers) currentTime = suite.now }, @@ -101,7 +108,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "unsuccessful update: header timestamp is not past last client timestamp", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.clientTime, suite.valSet, signers) currentTime = suite.now }, @@ -110,7 +117,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "header basic validation failed", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) newHeader = ibctmtypes.CreateTestHeader(chainID, height+1, suite.headerTime, suite.valSet, signers) // cause new header to fail validatebasic by changing commit height to mismatch header height newHeader.SignedHeader.Commit.Height = height - 1 @@ -121,7 +128,7 @@ func (suite *TendermintTestSuite) TestCheckValidity() { { name: "header height < latest client height", setup: func() { - clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header) + clientState = ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) // Make new header at height less than latest client state newHeader = ibctmtypes.CreateTestHeader(chainID, height-1, suite.headerTime, suite.valSet, signers) currentTime = suite.now diff --git a/x/ibc/20-transfer/handler_test.go b/x/ibc/20-transfer/handler_test.go index 89046a94930..221b051920d 100644 --- a/x/ibc/20-transfer/handler_test.go +++ b/x/ibc/20-transfer/handler_test.go @@ -38,6 +38,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) // define variables used for testing @@ -133,7 +134,13 @@ type TestChain struct { func NewTestChain(clientID string) *TestChain { privVal := tmtypes.NewMockPV() - validator := tmtypes.NewValidator(privVal.GetPubKey(), 1) + + pubKey, err := privVal.GetPubKey() + if err != nil { + panic(err) + } + + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} now := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) @@ -182,7 +189,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { ctxTarget := chain.GetContext() // create client - clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) + clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header) if err != nil { return err } @@ -251,7 +258,7 @@ func (chain *TestChain) updateClient(client *TestChain) { ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( - ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, client.Header), + ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), ) // _, _, err := simapp.SignCheckDeliver( diff --git a/x/ibc/20-transfer/keeper/keeper_test.go b/x/ibc/20-transfer/keeper/keeper_test.go index ca8e352d8cd..f5405e4eac3 100644 --- a/x/ibc/20-transfer/keeper/keeper_test.go +++ b/x/ibc/20-transfer/keeper/keeper_test.go @@ -37,6 +37,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) // define variables used for testing @@ -106,7 +107,13 @@ type TestChain struct { func NewTestChain(clientID string) *TestChain { privVal := tmtypes.NewMockPV() - validator := tmtypes.NewValidator(privVal.GetPubKey(), 1) + + pubKey, err := privVal.GetPubKey() + if err != nil { + panic(err) + } + + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} now := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) @@ -155,7 +162,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { ctxTarget := chain.GetContext() // create client - clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) + clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header) if err != nil { return err } @@ -224,7 +231,7 @@ func (chain *TestChain) updateClient(client *TestChain) { ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( - ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, client.Header), + ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), ) // _, _, err := simapp.SignCheckDeliver( diff --git a/x/ibc/ante/ante_test.go b/x/ibc/ante/ante_test.go index 72e20f398b4..96bf724c97a 100644 --- a/x/ibc/ante/ante_test.go +++ b/x/ibc/ante/ante_test.go @@ -34,6 +34,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) // define variables used for testing @@ -185,7 +186,13 @@ type TestChain struct { func NewTestChain(clientID string) *TestChain { privVal := tmtypes.NewMockPV() - validator := tmtypes.NewValidator(privVal.GetPubKey(), 1) + + pubKey, err := privVal.GetPubKey() + if err != nil { + panic(err) + } + + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} now := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) @@ -234,7 +241,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { ctxTarget := chain.GetContext() // create client - clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) + clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header) if err != nil { return err } @@ -302,7 +309,7 @@ func (chain *TestChain) updateClient(client *TestChain) { ctxTarget, client.ClientID, uint64(client.Header.Height-1), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( - ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, client.Header), + ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), ) // _, _, err := simapp.SignCheckDeliver( From 1061a1b2dd7ec07824b93d115ccfc26f14bc3e6c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 22 Apr 2020 13:09:33 -0400 Subject: [PATCH 5/5] Update APIs from Tendermint --- x/ibc/02-client/keeper/client_test.go | 23 ++++++---- x/ibc/02-client/keeper/keeper_test.go | 20 +++++---- x/ibc/03-connection/keeper/keeper_test.go | 13 ++++-- x/ibc/04-channel/keeper/keeper_test.go | 13 ++++-- .../07-tendermint/types/client_state_test.go | 42 +++++++++---------- x/ibc/07-tendermint/types/evidence_test.go | 11 ++++- x/ibc/07-tendermint/types/msgs_test.go | 16 +++---- x/ibc/07-tendermint/types/tendermint_test.go | 7 +++- 8 files changed, 91 insertions(+), 54 deletions(-) diff --git a/x/ibc/02-client/keeper/client_test.go b/x/ibc/02-client/keeper/client_test.go index e06cee175df..b04a51f9ed3 100644 --- a/x/ibc/02-client/keeper/client_test.go +++ b/x/ibc/02-client/keeper/client_test.go @@ -37,12 +37,12 @@ func (suite *KeeperTestSuite) TestCreateClient() { i := i if tc.expPanic { suite.Require().Panics(func() { - clientState, err := ibctmtypes.Initialize(tc.clientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(tc.clientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) suite.Require().NoError(err, "err on client state initialization") suite.keeper.CreateClient(suite.ctx, clientState, suite.consensusState) }, "Msg %d didn't panic: %s", i, tc.msg) } else { - clientState, err := ibctmtypes.Initialize(tc.clientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(tc.clientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if tc.expPass { suite.Require().NoError(err, "errored on initialization") suite.Require().NotNil(clientState, "valid test case %d failed: %s", i, tc.msg) @@ -79,7 +79,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { expPass bool }{ {"valid update", func() error { - clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if err != nil { return err } @@ -113,7 +113,7 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() { return nil }, false}, {"invalid header", func() error { - clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if err != nil { return err } @@ -197,16 +197,21 @@ func (suite *KeeperTestSuite) TestUpdateClientLocalhost() { func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { altPrivVal := tmtypes.NewMockPV() - altVal := tmtypes.NewValidator(altPrivVal.GetPubKey(), 4) + altPubKey, err := altPrivVal.GetPubKey() + suite.Require().NoError(err) + altVal := tmtypes.NewValidator(altPubKey, 4) // Create bothValSet with both suite validator and altVal bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) // Create alternative validator set with only altVal altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + // Create signer array and ensure it is in same order as bothValSet var bothSigners []tmtypes.PrivValidator - if bytes.Compare(altPrivVal.GetPubKey().Address(), suite.privVal.GetPubKey().Address()) == -1 { + if bytes.Compare(altPubKey.Address(), pubKey.Address()) == -1 { bothSigners = []tmtypes.PrivValidator{altPrivVal, suite.privVal} } else { bothSigners = []tmtypes.PrivValidator{suite.privVal, altPrivVal} @@ -230,7 +235,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { }, func() error { suite.consensusState.ValidatorSet = bothValSet - clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if err != nil { return err } @@ -250,7 +255,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { }, func() error { suite.consensusState.ValidatorSet = bothValSet - clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if err != nil { return err } @@ -305,7 +310,7 @@ func (suite *KeeperTestSuite) TestCheckMisbehaviourAndUpdateState() { ClientID: testClientID, }, func() error { - clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, err := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) if err != nil { return err } diff --git a/x/ibc/02-client/keeper/keeper_test.go b/x/ibc/02-client/keeper/keeper_test.go index b636d6a8570..30f6bf405e7 100644 --- a/x/ibc/02-client/keeper/keeper_test.go +++ b/x/ibc/02-client/keeper/keeper_test.go @@ -29,6 +29,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) type KeeperTestSuite struct { @@ -54,7 +55,11 @@ func (suite *KeeperTestSuite) SetupTest() { suite.ctx = app.BaseApp.NewContext(isCheckTx, abci.Header{Height: testClientHeight, ChainID: testClientID, Time: now2}) suite.keeper = &app.IBCKeeper.ClientKeeper suite.privVal = tmtypes.NewMockPV() - validator := tmtypes.NewValidator(suite.privVal.GetPubKey(), 1) + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + + validator := tmtypes.NewValidator(pubKey, 1) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) suite.header = ibctmtypes.CreateTestHeader(testClientID, testClientHeight, now2, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) suite.consensusState = ibctmtypes.ConsensusState{ @@ -67,7 +72,8 @@ func (suite *KeeperTestSuite) SetupTest() { var validators staking.Validators for i := 1; i < 11; i++ { privVal := tmtypes.NewMockPV() - pk := privVal.GetPubKey() + pk, err := privVal.GetPubKey() + suite.Require().NoError(err) val := staking.NewValidator(sdk.ValAddress(pk.Address()), pk, staking.Description{}) val.Status = sdk.Bonded val.Tokens = sdk.NewInt(rand.Int63()) @@ -82,7 +88,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestSetClientState() { - clientState := ibctmtypes.NewClientState(testClientID, trustingPeriod, ubdPeriod, ibctmtypes.Header{}) + clientState := ibctmtypes.NewClientState(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}) suite.keeper.SetClientState(suite.ctx, clientState) retrievedState, found := suite.keeper.GetClientState(suite.ctx, testClientID) @@ -113,9 +119,9 @@ func (suite *KeeperTestSuite) TestSetClientConsensusState() { func (suite KeeperTestSuite) TestGetAllClients() { expClients := []exported.ClientState{ - ibctmtypes.NewClientState(testClientID2, trustingPeriod, ubdPeriod, ibctmtypes.Header{}), - ibctmtypes.NewClientState(testClientID3, trustingPeriod, ubdPeriod, ibctmtypes.Header{}), - ibctmtypes.NewClientState(testClientID, trustingPeriod, ubdPeriod, ibctmtypes.Header{}), + ibctmtypes.NewClientState(testClientID2, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}), + ibctmtypes.NewClientState(testClientID3, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}), + ibctmtypes.NewClientState(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, ibctmtypes.Header{}), } for i := range expClients { @@ -155,7 +161,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { func (suite KeeperTestSuite) TestConsensusStateHelpers() { // initial setup - clientState, _ := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, suite.header) + clientState, _ := ibctmtypes.Initialize(testClientID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header) suite.keeper.SetClientState(suite.ctx, clientState) suite.keeper.SetClientConsensusState(suite.ctx, testClientID, testClientHeight, suite.consensusState) diff --git a/x/ibc/03-connection/keeper/keeper_test.go b/x/ibc/03-connection/keeper/keeper_test.go index 13c03d1bf1f..50cf2940cf5 100644 --- a/x/ibc/03-connection/keeper/keeper_test.go +++ b/x/ibc/03-connection/keeper/keeper_test.go @@ -36,6 +36,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) type KeeperTestSuite struct { @@ -136,7 +137,13 @@ type TestChain struct { func NewTestChain(clientID string) *TestChain { privVal := tmtypes.NewMockPV() - validator := tmtypes.NewValidator(privVal.GetPubKey(), 1) + + pubKey, err := privVal.GetPubKey() + if err != nil { + panic(err) + } + + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} now := time.Now() @@ -191,7 +198,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { ctxTarget := chain.GetContext() // create client - clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) + clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header) if err != nil { return err } @@ -267,7 +274,7 @@ func (chain *TestChain) updateClient(client *TestChain) { ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( - ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, client.Header), + ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), ) // _, _, err := simapp.SignCheckDeliver( diff --git a/x/ibc/04-channel/keeper/keeper_test.go b/x/ibc/04-channel/keeper/keeper_test.go index 1f8bcb5c5cb..7c4bd3d0246 100644 --- a/x/ibc/04-channel/keeper/keeper_test.go +++ b/x/ibc/04-channel/keeper/keeper_test.go @@ -46,6 +46,7 @@ const ( trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) type KeeperTestSuite struct { @@ -219,7 +220,13 @@ type TestChain struct { func NewTestChain(clientID string) *TestChain { privVal := tmtypes.NewMockPV() - validator := tmtypes.NewValidator(privVal.GetPubKey(), 1) + + pubKey, err := privVal.GetPubKey() + if err != nil { + panic(err) + } + + validator := tmtypes.NewValidator(pubKey, 1) valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) signers := []tmtypes.PrivValidator{privVal} now := time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) @@ -268,7 +275,7 @@ func (chain *TestChain) CreateClient(client *TestChain) error { ctxTarget := chain.GetContext() // create client - clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, client.Header) + clientState, err := ibctmtypes.Initialize(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header) if err != nil { return err } @@ -336,7 +343,7 @@ func (chain *TestChain) updateClient(client *TestChain) { ctxTarget, client.ClientID, uint64(client.Header.Height), consensusState, ) chain.App.IBCKeeper.ClientKeeper.SetClientState( - ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, client.Header), + ctxTarget, ibctmtypes.NewClientState(client.ClientID, trustingPeriod, ubdPeriod, maxClockDrift, client.Header), ) // _, _, err := simapp.SignCheckDeliver( diff --git a/x/ibc/07-tendermint/types/client_state_test.go b/x/ibc/07-tendermint/types/client_state_test.go index b5d37ca06ad..21247cc6747 100644 --- a/x/ibc/07-tendermint/types/client_state_test.go +++ b/x/ibc/07-tendermint/types/client_state_test.go @@ -37,7 +37,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -46,7 +46,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -64,7 +64,7 @@ func (suite *TendermintTestSuite) TestVerifyClientConsensusState() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), ValidatorSet: suite.valSet, @@ -116,7 +116,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), connection: conn, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -126,7 +126,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), connection: conn, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -146,7 +146,7 @@ func (suite *TendermintTestSuite) TestVerifyConnectionState() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), connection: conn, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -199,7 +199,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), channel: ch, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -209,7 +209,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), channel: ch, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -229,7 +229,7 @@ func (suite *TendermintTestSuite) TestVerifyChannelState() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), channel: ch, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -279,7 +279,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), commitment: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -289,7 +289,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), commitment: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -309,7 +309,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketCommitment() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), commitment: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -359,7 +359,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ack: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -369,7 +369,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ack: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -389,7 +389,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgement() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), ack: []byte{}, consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), @@ -438,7 +438,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -447,7 +447,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -465,7 +465,7 @@ func (suite *TendermintTestSuite) TestVerifyPacketAcknowledgementAbsence() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), ValidatorSet: suite.valSet, @@ -513,7 +513,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { // }, { name: "ApplyPrefix failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -522,7 +522,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { }, { name: "latest client height < height", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), }, @@ -540,7 +540,7 @@ func (suite *TendermintTestSuite) TestVerifyNextSeqRecv() { }, { name: "proof verification failed", - clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, suite.header), + clientState: ibctmtypes.NewClientState(chainID, trustingPeriod, ubdPeriod, maxClockDrift, suite.header), consensusState: ibctmtypes.ConsensusState{ Root: commitmenttypes.NewMerkleRoot(suite.header.AppHash), ValidatorSet: suite.valSet, diff --git a/x/ibc/07-tendermint/types/evidence_test.go b/x/ibc/07-tendermint/types/evidence_test.go index 0f363827cdf..815b583ddc4 100644 --- a/x/ibc/07-tendermint/types/evidence_test.go +++ b/x/ibc/07-tendermint/types/evidence_test.go @@ -32,7 +32,10 @@ func (suite *TendermintTestSuite) TestEvidence() { func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { altPrivVal := tmtypes.NewMockPV() - altVal := tmtypes.NewValidator(altPrivVal.GetPubKey(), height) + altPubKey, err := altPrivVal.GetPubKey() + suite.Require().NoError(err) + + altVal := tmtypes.NewValidator(altPubKey, height) // Create bothValSet with both suite validator and altVal bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) @@ -40,9 +43,13 @@ func (suite *TendermintTestSuite) TestEvidenceValidateBasic() { altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) signers := []tmtypes.PrivValidator{suite.privVal} + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + // Create signer array and ensure it is in same order as bothValSet var bothSigners []tmtypes.PrivValidator - if bytes.Compare(altPrivVal.GetPubKey().Address(), suite.privVal.GetPubKey().Address()) == -1 { + if bytes.Compare(altPubKey.Address(), pubKey.Address()) == -1 { bothSigners = []tmtypes.PrivValidator{altPrivVal, suite.privVal} } else { bothSigners = []tmtypes.PrivValidator{suite.privVal, altPrivVal} diff --git a/x/ibc/07-tendermint/types/msgs_test.go b/x/ibc/07-tendermint/types/msgs_test.go index d00561d99d2..5a36acd677f 100644 --- a/x/ibc/07-tendermint/types/msgs_test.go +++ b/x/ibc/07-tendermint/types/msgs_test.go @@ -17,14 +17,14 @@ func (suite *TendermintTestSuite) TestMsgCreateClientValidateBasic() { expPass bool errMsg string }{ - {ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, trustingPeriod, ubdPeriod, signer), true, "success msg should pass"}, - {ibctmtypes.NewMsgCreateClient("BADCHAIN", suite.header, trustingPeriod, ubdPeriod, signer), false, "invalid client id passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, signer), false, "unregistered client type passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, signer), false, "invalid Consensus State in msg passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, 0, ubdPeriod, signer), false, "zero trusting period passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, 0, signer), false, "zero unbonding period passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, nil), false, "Empty address passed"}, - {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, nil), false, "Empty chain ID"}, + {ibctmtypes.NewMsgCreateClient(exported.ClientTypeTendermint, suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), true, "success msg should pass"}, + {ibctmtypes.NewMsgCreateClient("BADCHAIN", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "invalid client id passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "unregistered client type passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, signer), false, "invalid Consensus State in msg passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, 0, ubdPeriod, maxClockDrift, signer), false, "zero trusting period passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, 0, maxClockDrift, signer), false, "zero unbonding period passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, nil), false, "Empty address passed"}, + {ibctmtypes.NewMsgCreateClient("goodchain", suite.header, trustingPeriod, ubdPeriod, maxClockDrift, nil), false, "Empty chain ID"}, } for i, tc := range cases { diff --git a/x/ibc/07-tendermint/types/tendermint_test.go b/x/ibc/07-tendermint/types/tendermint_test.go index d12c3fd1f95..3deeadccef4 100644 --- a/x/ibc/07-tendermint/types/tendermint_test.go +++ b/x/ibc/07-tendermint/types/tendermint_test.go @@ -18,6 +18,7 @@ const ( height = 4 trustingPeriod time.Duration = time.Hour * 24 * 7 * 2 ubdPeriod time.Duration = time.Hour * 24 * 7 * 3 + maxClockDrift time.Duration = time.Second * 10 ) type TendermintTestSuite struct { @@ -38,7 +39,11 @@ func (suite *TendermintTestSuite) SetupTest() { suite.now = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) suite.privVal = tmtypes.NewMockPV() - val := tmtypes.NewValidator(suite.privVal.GetPubKey(), 10) + + pubKey, err := suite.privVal.GetPubKey() + suite.Require().NoError(err) + + val := tmtypes.NewValidator(pubKey, 10) suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) suite.header = ibctmtypes.CreateTestHeader(chainID, height, suite.now, suite.valSet, []tmtypes.PrivValidator{suite.privVal}) }