From e4016985765263c6d51224cfad05a3a5bc46130a Mon Sep 17 00:00:00 2001 From: martin-cll <121895364+martin-cll@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:33:55 +1000 Subject: [PATCH] MERC-6190: Remove bid/ask fields from Mercury v4 schema (#76) --- go.mod | 34 +++--- go.sum | 57 +++++----- mercury/v4/aggregate_functions_test.go | 42 ------- mercury/v4/mercury.go | 78 +------------ mercury/v4/mercury_observation_v4.pb.go | 70 +++++------- mercury/v4/mercury_observation_v4.proto | 2 - mercury/v4/mercury_test.go | 144 +----------------------- mercury/v4/observation.go | 16 +-- 8 files changed, 80 insertions(+), 363 deletions(-) diff --git a/go.mod b/go.mod index b9adc1f..bfaf01c 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,16 @@ module github.com/smartcontractkit/chainlink-data-streams -go 1.21 +go 1.22 + +toolchain go1.22.5 require ( github.com/hashicorp/go-plugin v1.6.2-0.20240829161738-06afb6d7ae99 github.com/shopspring/decimal v1.4.0 - github.com/smartcontractkit/chainlink-common v0.2.2-0.20240731184516-249ef7ad0cdc + github.com/smartcontractkit/chainlink-common v0.2.2-0.20240903184200-6488292a85e3 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 + golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa google.golang.org/protobuf v1.34.2 ) @@ -19,28 +21,27 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fatih/color v1.14.1 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/invopop/jsonschema v0.12.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect - github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9 // indirect github.com/oklog/run v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -50,6 +51,7 @@ require ( github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 // indirect + github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/x448/float16 v0.8.4 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0 // indirect @@ -62,15 +64,15 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/text v0.17.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect google.golang.org/grpc v1.65.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -// until merged upstream: https://github.com/mwitkow/grpc-proxy/pull/69 -replace github.com/mwitkow/grpc-proxy => github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f +// until merged upstream: https://github.com/omissis/go-jsonschema/pull/264 +replace github.com/atombender/go-jsonschema => github.com/nolag/go-jsonschema v0.16.0-rtinianov diff --git a/go.sum b/go.sum index 9fc5af8..75a792e 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= -github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 h1:ymLjT4f35nQbASLnvxEde4XOBL+Sn7rFuV+FOJqkljg= @@ -35,6 +35,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -66,8 +68,8 @@ github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpS github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1/go.mod h1:lXGCsh6c22WGtjr+qGHj1otzZpV/1kwTMAqkwZsnWRU= github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 h1:pRhl55Yx1eC7BZ1N+BBWwnKaMyD8uC+34TLdndZMAKk= github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0/go.mod h1:XKMd7iuf/RGPSMJ/U4HP0zS2Z9Fh8Ps9a+6X26m/tmI= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/hashicorp/consul/sdk v0.16.0 h1:SE9m0W6DEfgIVCJX7xU+iv/hUl4m/nxqMTnCdMxDpJ8= github.com/hashicorp/consul/sdk v0.16.0/go.mod h1:7pxqqhqoaPqnBnzXD1StKed62LqJeClzVsUEy85Zr0A= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= @@ -97,12 +99,10 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= @@ -129,10 +129,10 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 h1:WCcC4vZDS1tYNxjWlwRJZQy28r8CM github.com/santhosh-tekuri/jsonschema/v5 v5.2.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240731184516-249ef7ad0cdc h1:nNZqLasN8y5huDKX76JUZtni7WkUI36J61//czbJpDM= -github.com/smartcontractkit/chainlink-common v0.2.2-0.20240731184516-249ef7ad0cdc/go.mod h1:Jg1sCTsbxg76YByI8ifpFby3FvVqISStHT8ypy9ocmY= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240903184200-6488292a85e3 h1:fkfOoAPviqO2rN8ngvejsDa7WKcw4paGEFA4/Znu0L0= +github.com/smartcontractkit/chainlink-common v0.2.2-0.20240903184200-6488292a85e3/go.mod h1:D/qaCoq0SxXzg5NRN5FtBRv98VBf+D2NOC++RbvvuOc= +github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7 h1:12ijqMM9tvYVEm+nR826WsrNi6zCKpwBhuApq127wHs= +github.com/smartcontractkit/grpc-proxy v0.0.0-20240830132753-a7e17fec5ab7/go.mod h1:FX7/bVdoep147QQhsOPkYsPEXhGZjeYx6lBSaSXtZOA= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c h1:lIyMbTaF2H0Q71vkwZHX/Ew4KF2BxiKhqEXwF8rn+KI= github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -178,11 +178,11 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 h1:wDLEX9a7YQoKdKNQt88rtydkqDxeGaBUTnIYc3iG/mA= -golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= +golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= 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= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -198,8 +198,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -207,8 +207,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -225,15 +225,16 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -252,10 +253,10 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210401141331-865547bb08e2/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY= -google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d h1:JU0iKnSg02Gmb5ZdV8nYsKEKsP6o/FGVWTrw4i1DA9A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd h1:BBOTEWLuuEGQy9n1y9MhVJ9Qt0BDu21X8qZs71/uPZo= +google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd/go.mod h1:fO8wJzT2zbQbAjbIoos1285VfEIYKDDY+Dt+WpTkh6g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd h1:6TEm2ZxXoQmFWFlt1vNxvVOa1Q0dXFQD1m/rYjXmS0E= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= diff --git a/mercury/v4/aggregate_functions_test.go b/mercury/v4/aggregate_functions_test.go index 36170cb..ba18a29 100644 --- a/mercury/v4/aggregate_functions_test.go +++ b/mercury/v4/aggregate_functions_test.go @@ -13,10 +13,6 @@ type testParsedAttributedObservation struct { Timestamp uint32 BenchmarkPrice *big.Int BenchmarkPriceValid bool - Bid *big.Int - BidValid bool - Ask *big.Int - AskValid bool MaxFinalizedTimestamp int64 MaxFinalizedTimestampValid bool LinkFee *big.Int @@ -32,12 +28,6 @@ func (t testParsedAttributedObservation) GetTimestamp() uint32 { re func (t testParsedAttributedObservation) GetBenchmarkPrice() (*big.Int, bool) { return t.BenchmarkPrice, t.BenchmarkPriceValid } -func (t testParsedAttributedObservation) GetBid() (*big.Int, bool) { - return t.Bid, t.BidValid -} -func (t testParsedAttributedObservation) GetAsk() (*big.Int, bool) { - return t.Ask, t.AskValid -} func (t testParsedAttributedObservation) GetMaxFinalizedTimestamp() (int64, bool) { return t.MaxFinalizedTimestamp, t.MaxFinalizedTimestampValid } @@ -66,10 +56,6 @@ func newValidParsedAttributedObservations() []testParsedAttributedObservation { BenchmarkPrice: big.NewInt(123), BenchmarkPriceValid: true, - Bid: big.NewInt(120), - BidValid: true, - Ask: big.NewInt(130), - AskValid: true, MaxFinalizedTimestamp: 1679448456, MaxFinalizedTimestampValid: true, @@ -87,10 +73,6 @@ func newValidParsedAttributedObservations() []testParsedAttributedObservation { BenchmarkPrice: big.NewInt(456), BenchmarkPriceValid: true, - Bid: big.NewInt(450), - BidValid: true, - Ask: big.NewInt(460), - AskValid: true, MaxFinalizedTimestamp: 1679448456, MaxFinalizedTimestampValid: true, @@ -108,10 +90,6 @@ func newValidParsedAttributedObservations() []testParsedAttributedObservation { BenchmarkPrice: big.NewInt(789), BenchmarkPriceValid: true, - Bid: big.NewInt(780), - BidValid: true, - Ask: big.NewInt(800), - AskValid: true, MaxFinalizedTimestamp: 1679448456, MaxFinalizedTimestampValid: true, @@ -129,10 +107,6 @@ func newValidParsedAttributedObservations() []testParsedAttributedObservation { BenchmarkPrice: big.NewInt(456), BenchmarkPriceValid: true, - Bid: big.NewInt(450), - BidValid: true, - Ask: big.NewInt(460), - AskValid: true, MaxFinalizedTimestamp: 1679513477, MaxFinalizedTimestampValid: true, @@ -167,10 +141,6 @@ func NewInvalidParsedAttributedObservations() []testParsedAttributedObservation BenchmarkPrice: big.NewInt(123), BenchmarkPriceValid: false, - Bid: big.NewInt(120), - BidValid: false, - Ask: big.NewInt(130), - AskValid: false, MaxFinalizedTimestamp: 1679648456, MaxFinalizedTimestampValid: false, @@ -188,10 +158,6 @@ func NewInvalidParsedAttributedObservations() []testParsedAttributedObservation BenchmarkPrice: big.NewInt(456), BenchmarkPriceValid: false, - Bid: big.NewInt(450), - BidValid: false, - Ask: big.NewInt(460), - AskValid: false, MaxFinalizedTimestamp: 1679648456, MaxFinalizedTimestampValid: false, @@ -209,10 +175,6 @@ func NewInvalidParsedAttributedObservations() []testParsedAttributedObservation BenchmarkPrice: big.NewInt(789), BenchmarkPriceValid: false, - Bid: big.NewInt(780), - BidValid: false, - Ask: big.NewInt(800), - AskValid: false, MaxFinalizedTimestamp: 1679648456, MaxFinalizedTimestampValid: false, @@ -230,10 +192,6 @@ func NewInvalidParsedAttributedObservations() []testParsedAttributedObservation BenchmarkPrice: big.NewInt(456), BenchmarkPriceValid: true, - Bid: big.NewInt(450), - BidValid: true, - Ask: big.NewInt(460), - AskValid: true, MaxFinalizedTimestamp: 1679513477, MaxFinalizedTimestampValid: true, diff --git a/mercury/v4/mercury.go b/mercury/v4/mercury.go index 1326f09..299ee8d 100644 --- a/mercury/v4/mercury.go +++ b/mercury/v4/mercury.go @@ -135,7 +135,7 @@ func (rp *reportingPlugin) Observation(ctx context.Context, repts types.ReportTi p := MercuryObservationProto{Timestamp: uint32(observationTimestamp.Unix())} var obsErrors []error - var bpErr, bidErr, askErr error + var bpErr error if obs.BenchmarkPrice.Err != nil { bpErr = fmt.Errorf("failed to observe BenchmarkPrice: %w", obs.BenchmarkPrice.Err) obsErrors = append(obsErrors, bpErr) @@ -144,35 +144,7 @@ func (rp *reportingPlugin) Observation(ctx context.Context, repts types.ReportTi obsErrors = append(obsErrors, bpErr) } else { p.BenchmarkPrice = benchmarkPrice - } - - if obs.Bid.Err != nil { - bidErr = fmt.Errorf("failed to observe Bid: %w", obs.Bid.Err) - obsErrors = append(obsErrors, bidErr) - } else if bid, err := mercury.EncodeValueInt192(obs.Bid.Val); err != nil { - bidErr = fmt.Errorf("failed to encode Bid; val=%s: %w", obs.Bid.Val, err) - obsErrors = append(obsErrors, bidErr) - } else { - p.Bid = bid - } - - if obs.Ask.Err != nil { - askErr = fmt.Errorf("failed to observe Ask: %w", obs.Ask.Err) - obsErrors = append(obsErrors, askErr) - } else if ask, err := mercury.EncodeValueInt192(obs.Ask.Val); err != nil { - askErr = fmt.Errorf("failed to encode Ask; val=%s: %w", obs.Ask.Val, err) - obsErrors = append(obsErrors, askErr) - } else { - p.Ask = ask - } - - if bpErr == nil && bidErr == nil && askErr == nil { - if err := validatePrices(obs.Bid.Val, obs.BenchmarkPrice.Val, obs.Ask.Val); err != nil { - rp.logger.Errorw("Cannot generate price observation: invalid bid/mid/ask", "err", err) - p.PricesValid = false - } else { - p.PricesValid = true - } + p.PricesValid = true } var maxFinalizedTimestampErr error @@ -240,13 +212,6 @@ func (rp *reportingPlugin) Observation(ctx context.Context, repts types.ReportTi return proto.Marshal(&p) } -func validatePrices(bid, benchmarkPrice, ask *big.Int) error { - if bid.Cmp(benchmarkPrice) > 0 || benchmarkPrice.Cmp(ask) > 0 { - return fmt.Errorf("invariant violated: expected bid<=mid<=ask, got bid: %s, mid: %s, ask: %s", bid, benchmarkPrice, ask) - } - return nil -} - func parseAttributedObservation(ao types.AttributedObservation) (PAO, error) { var pao parsedAttributedObservation var obs MercuryObservationProto @@ -263,21 +228,6 @@ func parseAttributedObservation(ao types.AttributedObservation) (PAO, error) { if err != nil { return parsedAttributedObservation{}, fmt.Errorf("benchmarkPrice cannot be converted to big.Int: %s", err) } - pao.Bid, err = mercury.DecodeValueInt192(obs.Bid) - if err != nil { - return parsedAttributedObservation{}, fmt.Errorf("bid cannot be converted to big.Int: %s", err) - } - pao.Ask, err = mercury.DecodeValueInt192(obs.Ask) - if err != nil { - return parsedAttributedObservation{}, fmt.Errorf("ask cannot be converted to big.Int: %s", err) - } - if err := validatePrices(pao.Bid, pao.BenchmarkPrice, pao.Ask); err != nil { - // NOTE: since nodes themselves are not supposed to set - // PricesValid=true if this invariant is violated, this indicates a - // faulty/misbehaving node and the entire observation should be - // ignored - return parsedAttributedObservation{}, fmt.Errorf("observation claimed to be valid, but contains invalid prices: %w", err) - } pao.PricesValid = true } @@ -403,16 +353,6 @@ func (rp *reportingPlugin) buildReportFields(previousReport types.Report, paos [ merr = errors.Join(merr, fmt.Errorf("GetConsensusBenchmarkPrice failed: %w", err)) } - rf.Bid, err = mercury.GetConsensusBid(convertBid(paos), rp.f) - if err != nil { - merr = errors.Join(merr, fmt.Errorf("GetConsensusBid failed: %w", err)) - } - - rf.Ask, err = mercury.GetConsensusAsk(convertAsk(paos), rp.f) - if err != nil { - merr = errors.Join(merr, fmt.Errorf("GetConsensusAsk failed: %w", err)) - } - rf.LinkFee, err = mercury.GetConsensusLinkFee(convertLinkFee(paos), rp.f) if err != nil { // It is better to generate a report that will validate for free, @@ -448,8 +388,6 @@ func (rp *reportingPlugin) buildReportFields(previousReport types.Report, paos [ func (rp *reportingPlugin) validateReport(rf v4.ReportFields) error { return errors.Join( mercury.ValidateBetween("median benchmark price", rf.BenchmarkPrice, rp.onchainConfig.Min, rp.onchainConfig.Max), - mercury.ValidateBetween("median bid", rf.Bid, rp.onchainConfig.Min, rp.onchainConfig.Max), - mercury.ValidateBetween("median ask", rf.Ask, rp.onchainConfig.Min, rp.onchainConfig.Max), mercury.ValidateFee("median link fee", rf.LinkFee), mercury.ValidateFee("median native fee", rf.NativeFee), mercury.ValidateValidFromTimestamp(rf.Timestamp, rf.ValidFromTimestamp), @@ -475,18 +413,6 @@ func convertMaxFinalizedTimestamp(pao []PAO) (ret []mercury.PAOMaxFinalizedTimes } return ret } -func convertBid(pao []PAO) (ret []mercury.PAOBid) { - for _, v := range pao { - ret = append(ret, v) - } - return ret -} -func convertAsk(pao []PAO) (ret []mercury.PAOAsk) { - for _, v := range pao { - ret = append(ret, v) - } - return ret -} func convertLinkFee(pao []PAO) (ret []mercury.PAOLinkFee) { for _, v := range pao { ret = append(ret, v) diff --git a/mercury/v4/mercury_observation_v4.pb.go b/mercury/v4/mercury_observation_v4.pb.go index 11d429a..4cc042f 100644 --- a/mercury/v4/mercury_observation_v4.pb.go +++ b/mercury/v4/mercury_observation_v4.pb.go @@ -27,8 +27,6 @@ type MercuryObservationProto struct { Timestamp uint32 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` BenchmarkPrice []byte `protobuf:"bytes,2,opt,name=benchmarkPrice,proto3" json:"benchmarkPrice,omitempty"` - Bid []byte `protobuf:"bytes,3,opt,name=bid,proto3" json:"bid,omitempty"` - Ask []byte `protobuf:"bytes,4,opt,name=ask,proto3" json:"ask,omitempty"` PricesValid bool `protobuf:"varint,5,opt,name=pricesValid,proto3" json:"pricesValid,omitempty"` MaxFinalizedTimestamp int64 `protobuf:"varint,6,opt,name=maxFinalizedTimestamp,proto3" json:"maxFinalizedTimestamp,omitempty"` MaxFinalizedTimestampValid bool `protobuf:"varint,7,opt,name=maxFinalizedTimestampValid,proto3" json:"maxFinalizedTimestampValid,omitempty"` @@ -86,20 +84,6 @@ func (x *MercuryObservationProto) GetBenchmarkPrice() []byte { return nil } -func (x *MercuryObservationProto) GetBid() []byte { - if x != nil { - return x.Bid - } - return nil -} - -func (x *MercuryObservationProto) GetAsk() []byte { - if x != nil { - return x.Ask - } - return nil -} - func (x *MercuryObservationProto) GetPricesValid() bool { if x != nil { return x.PricesValid @@ -168,39 +152,37 @@ var File_mercury_observation_v4_proto protoreflect.FileDescriptor var file_mercury_observation_v4_proto_rawDesc = []byte{ 0x0a, 0x1c, 0x6d, 0x65, 0x72, 0x63, 0x75, 0x72, 0x79, 0x5f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x34, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, - 0x76, 0x34, 0x22, 0xf1, 0x03, 0x0a, 0x17, 0x4d, 0x65, 0x72, 0x63, 0x75, 0x72, 0x79, 0x4f, 0x62, + 0x76, 0x34, 0x22, 0xcd, 0x03, 0x0a, 0x17, 0x4d, 0x65, 0x72, 0x63, 0x75, 0x72, 0x79, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0e, 0x62, 0x65, 0x6e, 0x63, 0x68, 0x6d, 0x61, 0x72, 0x6b, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x03, 0x62, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x73, 0x6b, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x03, 0x61, 0x73, 0x6b, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x63, - 0x65, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x70, - 0x72, 0x69, 0x63, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x34, 0x0a, 0x15, 0x6d, 0x61, - 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x6d, 0x61, 0x78, 0x46, 0x69, - 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x12, 0x3e, 0x0a, 0x1a, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, - 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, - 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x09, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x12, 0x26, 0x0a, 0x0e, - 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x61, 0x72, 0x6b, - 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x6d, 0x61, 0x72, 0x6b, - 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x0d, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x11, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x76, 0x34, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x69, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x63, 0x65, + 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x34, 0x0a, 0x15, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, + 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3e, 0x0a, 0x1a, + 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1a, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x6c, 0x69, 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6c, + 0x69, 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x6b, 0x46, 0x65, + 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x69, + 0x6e, 0x6b, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, + 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x6e, + 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x6e, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0e, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x46, 0x65, 0x65, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x11, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x76, 0x34, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/mercury/v4/mercury_observation_v4.proto b/mercury/v4/mercury_observation_v4.proto index 74e79c9..598bcad 100644 --- a/mercury/v4/mercury_observation_v4.proto +++ b/mercury/v4/mercury_observation_v4.proto @@ -7,8 +7,6 @@ message MercuryObservationProto { uint32 timestamp = 1; bytes benchmarkPrice = 2; - bytes bid = 3; - bytes ask = 4; bool pricesValid = 5; int64 maxFinalizedTimestamp = 6; diff --git a/mercury/v4/mercury_test.go b/mercury/v4/mercury_test.go index d6b1f4b..0a51108 100644 --- a/mercury/v4/mercury_test.go +++ b/mercury/v4/mercury_test.go @@ -83,8 +83,6 @@ func newValidProtos() []*MercuryObservationProto { Timestamp: 42, BenchmarkPrice: mercury.MustEncodeValueInt192(big.NewInt(123)), - Bid: mercury.MustEncodeValueInt192(big.NewInt(120)), - Ask: mercury.MustEncodeValueInt192(big.NewInt(130)), PricesValid: true, MaxFinalizedTimestamp: 40, @@ -102,8 +100,6 @@ func newValidProtos() []*MercuryObservationProto { Timestamp: 45, BenchmarkPrice: mercury.MustEncodeValueInt192(big.NewInt(234)), - Bid: mercury.MustEncodeValueInt192(big.NewInt(230)), - Ask: mercury.MustEncodeValueInt192(big.NewInt(240)), PricesValid: true, MaxFinalizedTimestamp: 40, @@ -121,8 +117,6 @@ func newValidProtos() []*MercuryObservationProto { Timestamp: 47, BenchmarkPrice: mercury.MustEncodeValueInt192(big.NewInt(345)), - Bid: mercury.MustEncodeValueInt192(big.NewInt(340)), - Ask: mercury.MustEncodeValueInt192(big.NewInt(350)), PricesValid: true, MaxFinalizedTimestamp: 39, @@ -140,8 +134,6 @@ func newValidProtos() []*MercuryObservationProto { Timestamp: 39, BenchmarkPrice: mercury.MustEncodeValueInt192(big.NewInt(456)), - Bid: mercury.MustEncodeValueInt192(big.NewInt(450)), - Ask: mercury.MustEncodeValueInt192(big.NewInt(460)), PricesValid: true, MaxFinalizedTimestamp: 39, @@ -174,34 +166,6 @@ func newValidAos(t *testing.T, protos ...*MercuryObservationProto) (aos []types. return } -func Test_parseAttributedObservation(t *testing.T) { - t.Run("returns error if bid<=mid<=ask is violated, even if observation claims itself to be valid", func(t *testing.T) { - obs := &MercuryObservationProto{ - Timestamp: 42, - - BenchmarkPrice: mercury.MustEncodeValueInt192(big.NewInt(123)), - Bid: mercury.MustEncodeValueInt192(big.NewInt(130)), - Ask: mercury.MustEncodeValueInt192(big.NewInt(120)), - PricesValid: true, - - MaxFinalizedTimestamp: 40, - MaxFinalizedTimestampValid: true, - - LinkFee: mercury.MustEncodeValueInt192(big.NewInt(1.1e18)), - LinkFeeValid: true, - NativeFee: mercury.MustEncodeValueInt192(big.NewInt(2.1e18)), - NativeFeeValid: true, - } - - serialized, err := proto.Marshal(obs) - require.NoError(t, err) - - _, err = parseAttributedObservation(types.AttributedObservation{Observation: serialized, Observer: commontypes.OracleID(42)}) - require.Error(t, err) - assert.Equal(t, "observation claimed to be valid, but contains invalid prices: invariant violated: expected bid<=mid<=ask, got bid: 130, mid: 123, ask: 120", err.Error()) - }) -} - func Test_Plugin_Report(t *testing.T) { dataSource := &testDataSource{} codec := &testReportCodec{ @@ -255,8 +219,6 @@ func Test_Plugin_Report(t *testing.T) { LinkFee: big.NewInt(1300000000000000000), // 1.3e18 ExpiresAt: 46, BenchmarkPrice: big.NewInt(345), - Bid: big.NewInt(340), - Ask: big.NewInt(350), MarketStatus: 1, }, *codec.builtReportFields) }) @@ -279,8 +241,6 @@ func Test_Plugin_Report(t *testing.T) { LinkFee: big.NewInt(1300000000000000000), // 1.3e18 ExpiresAt: 46, BenchmarkPrice: big.NewInt(345), - Bid: big.NewInt(340), - Ask: big.NewInt(350), MarketStatus: 1, }, *codec.builtReportFields) }) @@ -303,8 +263,6 @@ func Test_Plugin_Report(t *testing.T) { LinkFee: big.NewInt(1300000000000000000), // 1.3e18 ExpiresAt: 46, BenchmarkPrice: big.NewInt(345), - Bid: big.NewInt(340), - Ask: big.NewInt(350), MarketStatus: 1, }, *codec.builtReportFields) }) @@ -326,8 +284,6 @@ func Test_Plugin_Report(t *testing.T) { LinkFee: big.NewInt(1300000000000000000), // 1.3e18 ExpiresAt: 46, BenchmarkPrice: big.NewInt(345), - Bid: big.NewInt(340), - Ask: big.NewInt(350), MarketStatus: 1, }, *codec.builtReportFields) }) @@ -361,8 +317,6 @@ func Test_Plugin_Report(t *testing.T) { LinkFee: big.NewInt(1300000000000000000), // 1.3e18 ExpiresAt: ts + 1, BenchmarkPrice: big.NewInt(345), - Bid: big.NewInt(340), - Ask: big.NewInt(350), MarketStatus: 1, }, *codec.builtReportFields) }) @@ -444,8 +398,6 @@ func Test_Plugin_validateReport(t *testing.T) { LinkFee: big.NewInt(50), ExpiresAt: 44, BenchmarkPrice: big.NewInt(150), - Bid: big.NewInt(140), - Ask: big.NewInt(160), } err := rp.validateReport(rf) require.NoError(t, err) @@ -457,12 +409,11 @@ func Test_Plugin_validateReport(t *testing.T) { LinkFee: big.NewInt(0), ExpiresAt: 42, BenchmarkPrice: big.NewInt(1), - Bid: big.NewInt(1), - Ask: big.NewInt(1), } err = rp.validateReport(rf) require.NoError(t, err) }) + t.Run("fails validation", func(t *testing.T) { rf := v4.ReportFields{ ValidFromTimestamp: 44, // later than timestamp not allowed @@ -471,15 +422,11 @@ func Test_Plugin_validateReport(t *testing.T) { LinkFee: big.NewInt(-1), // negative value not allowed ExpiresAt: 42, // before timestamp BenchmarkPrice: big.NewInt(150000), // exceeds max - Bid: big.NewInt(150000), // exceeds max - Ask: big.NewInt(150000), // exceeds max } err := rp.validateReport(rf) require.Error(t, err) assert.Contains(t, err.Error(), "median benchmark price (Value: 150000) is outside of allowable range (Min: 1, Max: 1000)") - assert.Contains(t, err.Error(), "median bid (Value: 150000) is outside of allowable range (Min: 1, Max: 1000)") - assert.Contains(t, err.Error(), "median ask (Value: 150000) is outside of allowable range (Min: 1, Max: 1000)") assert.Contains(t, err.Error(), "median link fee (Value: -1) is outside of allowable range (Min: 0, Max: 3138550867693340381917894711603833208051177722232017256447)") assert.Contains(t, err.Error(), "median native fee (Value: -1) is outside of allowable range (Min: 0, Max: 3138550867693340381917894711603833208051177722232017256447)") assert.Contains(t, err.Error(), "observationTimestamp (Value: 43) must be >= validFromTimestamp (Value: 44)") @@ -492,8 +439,6 @@ func Test_Plugin_validateReport(t *testing.T) { require.Error(t, err) assert.Contains(t, err.Error(), "median benchmark price: got nil value") - assert.Contains(t, err.Error(), "median bid: got nil value") - assert.Contains(t, err.Error(), "median ask: got nil value") assert.Contains(t, err.Error(), "median native fee: got nil value") assert.Contains(t, err.Error(), "median link fee: got nil value") }) @@ -515,8 +460,6 @@ func Test_Plugin_Observation(t *testing.T) { obs := MercuryObservationProto{ Timestamp: math.MaxUint32, BenchmarkPrice: make([]byte, 24), - Bid: make([]byte, 24), - Ask: make([]byte, 24), PricesValid: true, MaxFinalizedTimestamp: math.MaxUint32, MaxFinalizedTimestampValid: true, @@ -531,28 +474,20 @@ func Test_Plugin_Observation(t *testing.T) { // that increment the count below numFields := reflect.TypeOf(obs).NumField() //nolint:all // 3 fields internal to pbuf struct - require.Equal(t, 13, numFields-3) + require.Equal(t, 11, numFields-3) b, err := proto.Marshal(&obs) require.NoError(t, err) assert.LessOrEqual(t, len(b), maxObservationLength) }) - validBid := big.NewInt(rand.Int63() - 2) - validBenchmarkPrice := new(big.Int).Add(validBid, big.NewInt(1)) - validAsk := new(big.Int).Add(validBid, big.NewInt(2)) + validBenchmarkPrice := big.NewInt(rand.Int63() - 2) t.Run("all observations succeeded", func(t *testing.T) { obs := v4.Observation{ BenchmarkPrice: mercurytypes.ObsResult[*big.Int]{ Val: validBenchmarkPrice, }, - Bid: mercurytypes.ObsResult[*big.Int]{ - Val: validBid, - }, - Ask: mercurytypes.ObsResult[*big.Int]{ - Val: validAsk, - }, MaxFinalizedTimestamp: mercurytypes.ObsResult[int64]{ Val: rand.Int63(), }, @@ -652,13 +587,7 @@ func Test_Plugin_Observation(t *testing.T) { t.Run("all observations failed", func(t *testing.T) { obs := v4.Observation{ BenchmarkPrice: mercurytypes.ObsResult[*big.Int]{ - Err: errors.New("bechmarkPrice error"), - }, - Bid: mercurytypes.ObsResult[*big.Int]{ - Err: errors.New("bid error"), - }, - Ask: mercurytypes.ObsResult[*big.Int]{ - Err: errors.New("ask error"), + Err: errors.New("benchmarkPrice error"), }, MaxFinalizedTimestamp: mercurytypes.ObsResult[int64]{ Err: errors.New("maxFinalizedTimestamp error"), @@ -681,8 +610,6 @@ func Test_Plugin_Observation(t *testing.T) { assert.LessOrEqual(t, p.Timestamp, uint32(time.Now().Unix())) assert.Zero(t, p.BenchmarkPrice) - assert.Zero(t, p.Bid) - assert.Zero(t, p.Ask) assert.False(t, p.PricesValid) assert.Zero(t, p.MaxFinalizedTimestamp) assert.False(t, p.MaxFinalizedTimestampValid) @@ -725,12 +652,6 @@ func Test_Plugin_Observation(t *testing.T) { BenchmarkPrice: mercurytypes.ObsResult[*big.Int]{ Val: new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), }, - Bid: mercurytypes.ObsResult[*big.Int]{ - Val: new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), - }, - Ask: mercurytypes.ObsResult[*big.Int]{ - Val: new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), - }, MaxFinalizedTimestamp: mercurytypes.ObsResult[int64]{ Val: rand.Int63(), }, @@ -752,65 +673,8 @@ func Test_Plugin_Observation(t *testing.T) { require.NoError(t, proto.Unmarshal(parsedObs, &p)) assert.Zero(t, p.BenchmarkPrice) - assert.Zero(t, p.Bid) - assert.Zero(t, p.Ask) assert.False(t, p.PricesValid) }) - - t.Run("bid<=mid<=ask violation", func(t *testing.T) { - obs := v4.Observation{ - BenchmarkPrice: mercurytypes.ObsResult[*big.Int]{ - Val: big.NewInt(10), - }, - Bid: mercurytypes.ObsResult[*big.Int]{ - Val: big.NewInt(11), - }, - Ask: mercurytypes.ObsResult[*big.Int]{ - Val: big.NewInt(12), - }, - MaxFinalizedTimestamp: mercurytypes.ObsResult[int64]{ - Val: rand.Int63(), - }, - LinkPrice: mercurytypes.ObsResult[*big.Int]{ - Val: big.NewInt(rand.Int63()), - }, - NativePrice: mercurytypes.ObsResult[*big.Int]{ - Val: big.NewInt(rand.Int63()), - }, - } - dataSource.Obs = obs - - parsedObs, err := rp.Observation(context.Background(), types.ReportTimestamp{}, nil) - require.NoError(t, err) - - var p MercuryObservationProto - require.NoError(t, proto.Unmarshal(parsedObs, &p)) - - assert.LessOrEqual(t, p.Timestamp, uint32(time.Now().Unix())) - assert.Equal(t, obs.BenchmarkPrice.Val, mustDecodeBigInt(p.BenchmarkPrice)) - assert.False(t, p.PricesValid) // not valid! - - // other values passed through ok - assert.Equal(t, obs.MaxFinalizedTimestamp.Val, p.MaxFinalizedTimestamp) - assert.True(t, p.MaxFinalizedTimestampValid) - - fee := mercury.CalculateFee(obs.LinkPrice.Val, decimal.NewFromInt32(1)) - assert.Equal(t, fee, mustDecodeBigInt(p.LinkFee)) - assert.True(t, p.LinkFeeValid) - - fee = mercury.CalculateFee(obs.NativePrice.Val, decimal.NewFromInt32(1)) - assert.Equal(t, fee, mustDecodeBigInt(p.NativeFee)) - assert.True(t, p.NativeFeeValid) - - // test benchmark price higher than ask - obs.BenchmarkPrice.Val = big.NewInt(13) - dataSource.Obs = obs - - parsedObs, err = rp.Observation(context.Background(), types.ReportTimestamp{}, nil) - require.NoError(t, err) - require.NoError(t, proto.Unmarshal(parsedObs, &p)) - assert.False(t, p.PricesValid) // not valid! - }) } func newUnparseableAttributedObservation() types.AttributedObservation { diff --git a/mercury/v4/observation.go b/mercury/v4/observation.go index edbc0da..4ec9f79 100644 --- a/mercury/v4/observation.go +++ b/mercury/v4/observation.go @@ -10,8 +10,6 @@ import ( type PAO interface { mercury.PAO - GetBid() (*big.Int, bool) - GetAsk() (*big.Int, bool) GetMaxFinalizedTimestamp() (int64, bool) GetLinkFee() (*big.Int, bool) GetNativeFee() (*big.Int, bool) @@ -25,8 +23,6 @@ type parsedAttributedObservation struct { Observer commontypes.OracleID BenchmarkPrice *big.Int - Bid *big.Int - Ask *big.Int PricesValid bool MaxFinalizedTimestamp int64 @@ -43,7 +39,7 @@ type parsedAttributedObservation struct { } func NewParsedAttributedObservation(ts uint32, observer commontypes.OracleID, - bp *big.Int, bid *big.Int, ask *big.Int, pricesValid bool, mfts int64, + bp *big.Int, pricesValid bool, mfts int64, mftsValid bool, linkFee *big.Int, linkFeeValid bool, nativeFee *big.Int, nativeFeeValid bool, marketStatus uint32, marketStatusValid bool) PAO { return parsedAttributedObservation{ @@ -51,8 +47,6 @@ func NewParsedAttributedObservation(ts uint32, observer commontypes.OracleID, Observer: observer, BenchmarkPrice: bp, - Bid: bid, - Ask: ask, PricesValid: pricesValid, MaxFinalizedTimestamp: mfts, @@ -81,14 +75,6 @@ func (pao parsedAttributedObservation) GetBenchmarkPrice() (*big.Int, bool) { return pao.BenchmarkPrice, pao.PricesValid } -func (pao parsedAttributedObservation) GetBid() (*big.Int, bool) { - return pao.Bid, pao.PricesValid -} - -func (pao parsedAttributedObservation) GetAsk() (*big.Int, bool) { - return pao.Ask, pao.PricesValid -} - func (pao parsedAttributedObservation) GetMaxFinalizedTimestamp() (int64, bool) { if pao.MaxFinalizedTimestamp < -1 { // values below -1 are not valid