From 731d24bdcd408ccb809274ba6a7b3e06ee88ff5a Mon Sep 17 00:00:00 2001 From: ilija Date: Fri, 5 Jul 2024 16:52:13 +0200 Subject: [PATCH] Update common and use unfinalized confidence lvl for CR GetLatestValue --- go.mod | 3 +-- go.sum | 6 ++---- median/plugin.go | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 4d8cf45..3bf6818 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.3 require ( github.com/hashicorp/go-plugin v1.6.0 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240705131638-d7ffbef85d42 github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c github.com/stretchr/testify v1.9.0 ) @@ -64,7 +64,6 @@ require ( go.uber.org/zap v1.26.0 // indirect golang.org/x/crypto v0.18.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect - golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/go.sum b/go.sum index dee4b9e..60b815c 100644 --- a/go.sum +++ b/go.sum @@ -220,8 +220,8 @@ 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.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7 h1:od+11B83s0mQwAMPP3lhtb0nYz63pIKpJEKddfFpu/M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20240522203001-10ea0211efd7/go.mod h1:cFHRblGbGn/rFYOOGsNbtLicMc1+5YdN0KoebYr93pk= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240705131638-d7ffbef85d42 h1:fSieYWeYIVWs4Q7CmZsB2OAXmnzz5C25Hx/YkCu2LNU= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240705131638-d7ffbef85d42/go.mod h1:EWvSuqIJUYXZLEHewC7WCaPylM2jyjF3Q36BZPS4MoI= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo= github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= @@ -317,8 +317,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/median/plugin.go b/median/plugin.go index a89d9ab..3bdc790 100644 --- a/median/plugin.go +++ b/median/plugin.go @@ -13,6 +13,7 @@ import ( "github.com/smartcontractkit/chainlink-common/pkg/loop" "github.com/smartcontractkit/chainlink-common/pkg/services" "github.com/smartcontractkit/chainlink-common/pkg/types" + "github.com/smartcontractkit/chainlink-common/pkg/types/query/primitives" ) const contractName = "median" @@ -55,7 +56,7 @@ func (p *Plugin) NewMedianFactory(ctx context.Context, provider types.MedianProv } if cr := provider.ChainReader(); cr != nil { - factory.ContractTransmitter = &chainReaderContract{chainReader: cr, lggr: lggr} + factory.ContractTransmitter = &contractReaderContract{contractReader: cr, lggr: lggr} } else { factory.ContractTransmitter = provider.MedianContract() } @@ -100,10 +101,10 @@ func (r *reportingPluginFactoryService) HealthReport() map[string]error { return map[string]error{r.Name(): r.Healthy()} } -// chainReaderContract adapts a [types.ChainReader] to [median.MedianContract]. -type chainReaderContract struct { - chainReader types.ChainReader - lggr logger.Logger +// contractReaderContract adapts a [types.ContractReader] to [median.MedianContract]. +type contractReaderContract struct { + contractReader types.ContractReader + lggr logger.Logger } type latestTransmissionDetailsResponse struct { @@ -120,10 +121,10 @@ type latestRoundRequested struct { Round uint8 } -func (c *chainReaderContract) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, latestAnswer *big.Int, latestTimestamp time.Time, err error) { +func (c *contractReaderContract) LatestTransmissionDetails(ctx context.Context) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, latestAnswer *big.Int, latestTimestamp time.Time, err error) { var resp latestTransmissionDetailsResponse - err = c.chainReader.GetLatestValue(ctx, contractName, "LatestTransmissionDetails", nil, &resp) + err = c.contractReader.GetLatestValue(ctx, contractName, "LatestTransmissionDetails", primitives.Finalized, nil, &resp) if err != nil { if !errors.Is(err, types.ErrNotFound) { return @@ -134,7 +135,7 @@ func (c *chainReaderContract) LatestTransmissionDetails(ctx context.Context) (co c.lggr.Warn("LatestTransmissionDetails not found", "err", err) } - // Depending on if there is a LatestAnswer or not, and the implementation of the ChainReader, + // Depending on if there is a LatestAnswer or not, and the implementation of the ContractReader, // it's possible that this will be unset. The desired behaviour in that case is to have a zero value. if resp.LatestAnswer == nil { resp.LatestAnswer = new(big.Int) @@ -143,10 +144,10 @@ func (c *chainReaderContract) LatestTransmissionDetails(ctx context.Context) (co return resp.ConfigDigest, resp.Epoch, resp.Round, resp.LatestAnswer, resp.LatestTimestamp, nil } -func (c *chainReaderContract) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error) { +func (c *contractReaderContract) LatestRoundRequested(ctx context.Context, lookback time.Duration) (configDigest ocrtypes.ConfigDigest, epoch uint32, round uint8, err error) { var resp latestRoundRequested - err = c.chainReader.GetLatestValue(ctx, contractName, "LatestRoundRequested", nil, &resp) + err = c.contractReader.GetLatestValue(ctx, contractName, "LatestRoundRequested", primitives.Unconfirmed, nil, &resp) if err != nil { if !errors.Is(err, types.ErrNotFound) { return