From 24275a6120d3f1587c53d19bc721fe3ac7f10afe Mon Sep 17 00:00:00 2001 From: raghu0891 Date: Tue, 26 Nov 2024 07:03:15 +0100 Subject: [PATCH] Base 2 commit for v0.0.1-beta --- .github/workflows/go.yml | 2 +- .tool-versions | 2 +- Automation_Grants.md | 2 +- LICENSE | 2 + docs/PROTOCOL_v21.md | 2 +- go.mod | 49 +++++----- go.sum | 89 +++++++++---------- internal/util/closer.go | 34 +++++++ internal/util/closer_test.go | 29 ++++++ pkg/v2/coordinator/coordinator.go | 17 ++-- pkg/v2/coordinator/mocks/encoder.generated.go | 23 ++--- .../mocks/log_provider.generated.go | 19 ++-- pkg/v2/delegate_test.go | 6 +- pkg/v2/factory.go | 3 +- pkg/v2/mocks/logger.generated.go | 11 +-- pkg/v3/LICENSE | 2 + pkg/v3/coordinator/coordinator.go | 45 ++++------ pkg/v3/coordinator/coordinator_test.go | 13 +++ pkg/v3/flows/conditional_test.go | 23 +++-- pkg/v3/plugin/factory.go | 7 +- pkg/v3/plugin/ocr3.go | 21 ++--- pkg/v3/plugin/ocr3_test.go | 27 +++--- pkg/v3/plugin/plugin.go | 7 +- pkg/v3/tickers/time.go | 34 +++---- pkg/v3/tickers/time_test.go | 4 +- .../types/mocks/block_subscriber.generated.go | 27 ++---- .../conditionalupkeepprovider.generated.go | 15 ++-- pkg/v3/types/mocks/coordinator.generated.go | 31 ++----- pkg/v3/types/mocks/encoder.generated.go | 19 ++-- .../types/mocks/logeventprovider.generated.go | 23 ++--- pkg/v3/types/mocks/metadatastore.generated.go | 27 ++---- .../types/mocks/payloadbuilder.generated.go | 15 ++-- pkg/v3/types/mocks/ratio.generated.go | 15 ++-- .../mocks/recoverableprovider.generated.go | 15 ++-- pkg/v3/types/mocks/result_store.generated.go | 15 ++-- pkg/v3/types/mocks/runnable.generated.go | 15 ++-- .../transmit_event_provider.generated.go | 15 ++-- .../mocks/upkeep_state_updater.generated.go | 15 ++-- sonar-project.properties | 2 +- tools/simulator/node/add.go | 2 - tools/simulator/simulate/loader/ocr3config.go | 32 ++++--- .../simulate/loader/ocr3config_test.go | 3 +- tools/simulator/simulate/ocr/transmit.go | 2 +- 43 files changed, 345 insertions(+), 416 deletions(-) create mode 100644 internal/util/closer.go create mode 100644 internal/util/closer_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b85eb28..b323e74 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -49,7 +49,7 @@ jobs: go-version-file: "go.mod" - name: Run Unit Tests - run: go test ./... -coverpkg=./... -coverprofile=coverage.txt + run: go test -v ./... -coverpkg=./... -coverprofile=coverage.txt - name: Upload Go test results if: always() diff --git a/.tool-versions b/.tool-versions index 7d9a0e5..5c14e0c 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ golang 1.20 -mockery 2.43.2 +mockery 2.12.1 diff --git a/Automation_Grants.md b/Automation_Grants.md index c28f70c..5aa57d5 100644 --- a/Automation_Grants.md +++ b/Automation_Grants.md @@ -2,4 +2,4 @@ Automation-License-grants Additional Use Grant(s): -You may make use of plugin Automation (which is available subject to the license here the “Licensed Work”) solely for purposes listed below: +You may make use of Plugin Automation (which is available subject to the license here the “Licensed Work”) solely for purposes listed below: diff --git a/LICENSE b/LICENSE index 890c005..c611f9e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,6 @@ +Copyright (c) 2023 SmartContract Plugin Limited SEZC + Portions of this software are licensed as follows: *All content residing under (1) https://github.com/goplugin/pluginv3.0/tree/develop/contracts/src/v0.8/automation/2_1; (2) https://github.com/goplugin/plugin-automation/tree/main/pkg/v3 are licensed under “Business Source License 1.1” with a Change Date of September 12, 2027 and Change License to “MIT License” diff --git a/docs/PROTOCOL_v21.md b/docs/PROTOCOL_v21.md index e4936da..c20127b 100644 --- a/docs/PROTOCOL_v21.md +++ b/docs/PROTOCOL_v21.md @@ -37,7 +37,7 @@ This document aims to give a high level overview of the protocol for Automation ## Abstract -plugin Automation is a decentralized execution engine for automating smart contracts, +Plugin Automation is a decentralized execution engine for automating smart contracts, with a generic and extensible triggering mechanism. The protocol is implemented using the OCR3 interface, which is a decentralized consensus framework for off-chain computation. diff --git a/go.mod b/go.mod index e26d8ae..4f7d9bf 100644 --- a/go.mod +++ b/go.mod @@ -1,27 +1,30 @@ module github.com/goplugin/plugin-automation -go 1.22.0 +go 1.21 -toolchain go1.22.5 +replace ( + github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.3 + golang/github.com/gogo/protobuf => golang/github.com/gogo/protobuf v1.3.3 +) require ( github.com/Maldris/mathparse v0.0.0-20170508133428-f0d009a7a773 github.com/ethereum/go-ethereum v1.13.8 github.com/go-echarts/go-echarts/v2 v2.2.6 github.com/goccy/go-json v0.10.2 - github.com/google/uuid v1.6.0 + github.com/google/uuid v1.3.1 github.com/jedib0t/go-pretty/v6 v6.4.7 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.17.0 - github.com/shopspring/decimal v1.4.0 - //github.com/goplugin/plugin-common v0.0.1 - //github.com/goplugin/plugin-libocr v0.0.0-20241007185508-adbe57025f12 - github.com/goplugin/plugin-common v0.0.1 - github.com/goplugin/plugin-libocr v0.1.1 + github.com/shopspring/decimal v1.3.1 + github.com/goplugin/plugin-common v0.0.1-beta// plugin update changes + //github.com/goplugin/plugin-common v0.1.7-0.20240401172519-4bfc659b80bf + github.com/goplugin/plugin-libocr v0.1.1-beta + //github.com/goplugin/plugin-libocr v0.0.0-20240326191951-2bbe9382d052 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - golang.org/x/crypto v0.27.0 - gonum.org/v1/gonum v0.15.0 + golang.org/x/crypto v0.18.0 + gonum.org/v1/gonum v0.13.0 ) require ( @@ -29,8 +32,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect @@ -39,10 +41,8 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/holiman/uint256 v1.2.4 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect @@ -60,19 +60,16 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect - go.opentelemetry.io/otel v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect - golang.org/x/mod v0.21.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/tools v0.25.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + go.uber.org/zap v1.26.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/tools v0.15.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) -retract [v1.0.0-0, v1.0.5] // reverting to v0 +exclude golang/github.com/influxdata/influxdb v1.8.3 diff --git a/go.sum b/go.sum index 8f503ec..7367d25 100644 --- a/go.sum +++ b/go.sum @@ -10,14 +10,15 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd v0.23.3 h1:4KH/JKy9WiCd+iUS9Mu0Zp7Dnj17TGdKrg9xc/FGj24= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 h1:SDlJ7bAm4ewvrmZtR0DaiYbQGdKPeaaIm7bM+qRhFeU= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/cespare/cp v1.1.1 h1:nCb6ZLdB7NRaqsm91JtQTAme2SKJzXVsdPIPkyJr1MU= github.com/cespare/cp v1.1.1/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cinar/indicator v1.2.24/go.mod h1:5eX8f1PG9g3RKSoHsoQxKd8bIN97Cf/gbgxXjihROpI= github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= @@ -61,11 +62,6 @@ github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkN github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= github.com/go-echarts/go-echarts/v2 v2.2.6 h1:Gg4SXDxFwi/KzRvBuH6ed89b6bqP4F7ysANDdWiziBY= github.com/go-echarts/go-echarts/v2 v2.2.6/go.mod h1:IN5P8jIRZKENmAJf2lHXBzv8U9YwdVnY9urdzGkEDA0= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -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-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= @@ -75,17 +71,19 @@ github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14j github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= @@ -142,12 +140,12 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= -github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= -github.com/goplugin/plugin-common v0.3.0 h1:mUXHBzzw2qPKyw6gPAC8JhO+ryT8maY+rBi9NFtqEy0= -github.com/goplugin/plugin-common v0.3.0/go.mod h1:tsGgeEJc5SUSlfVGSX0wR0EkRU3pM58D6SKF97V68ko= -github.com/goplugin/plugin-libocr v0.0.0-20241007185508-adbe57025f12 h1:NzZGjaqez21I3DU7objl3xExTH4fxYvzTqar8DC6360= -github.com/goplugin/plugin-libocr v0.0.0-20241007185508-adbe57025f12/go.mod h1:fb1ZDVXACvu4frX3APHZaEBp0xi1DIm34DcA0CwTsZM= +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/goplugin/plugin-common v0.1.7-0.20240401172519-4bfc659b80bf h1:yW8rTFycozLVnXRyOgZWGktnmzoFLxSWh1xPJXsp7vg= +github.com/goplugin/plugin-common v0.1.7-0.20240401172519-4bfc659b80bf/go.mod h1:kstYjAGqBswdZpl7YkSPeXBDVwaY1VaR6tUMPWl8ykA= +github.com/goplugin/plugin-libocr v0.0.0-20240326191951-2bbe9382d052 h1:1WFjrrVrWoQ9UpVMh7Mx4jDpzhmo1h8hFUKd9awIhIU= +github.com/goplugin/plugin-libocr v0.0.0-20240326191951-2bbe9382d052/go.mod h1:SJEZCHgMCAzzBvo9vMV2DQ9onfEcIJCYSViyP4JI6c4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= @@ -173,42 +171,39 @@ github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2n github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +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/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= -golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= -gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= -gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= +gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= diff --git a/internal/util/closer.go b/internal/util/closer.go new file mode 100644 index 0000000..8667417 --- /dev/null +++ b/internal/util/closer.go @@ -0,0 +1,34 @@ +package util + +import ( + "context" + "sync" +) + +type Closer struct { + cancel context.CancelFunc + lock sync.Mutex +} + +func (c *Closer) Store(cancel context.CancelFunc) bool { + c.lock.Lock() + defer c.lock.Unlock() + + if c.cancel != nil { + return false + } + c.cancel = cancel + return true +} + +func (c *Closer) Close() bool { + c.lock.Lock() + defer c.lock.Unlock() + + if c.cancel != nil { + c.cancel() + c.cancel = nil + return true + } + return false +} diff --git a/internal/util/closer_test.go b/internal/util/closer_test.go new file mode 100644 index 0000000..54cba4f --- /dev/null +++ b/internal/util/closer_test.go @@ -0,0 +1,29 @@ +package util + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCloser(t *testing.T) { + called := false + cancelFn := func() { + called = true + } + closer := &Closer{} + + ok := closer.Close() + assert.False(t, ok) + + ok = closer.Store(cancelFn) + assert.True(t, ok) + + ok = closer.Store(cancelFn) + assert.False(t, ok) + + ok = closer.Close() + assert.True(t, ok) + + assert.True(t, called) +} diff --git a/pkg/v2/coordinator/coordinator.go b/pkg/v2/coordinator/coordinator.go index 37ac183..5e0652d 100644 --- a/pkg/v2/coordinator/coordinator.go +++ b/pkg/v2/coordinator/coordinator.go @@ -32,7 +32,6 @@ import ( "github.com/goplugin/plugin-automation/pkg/util" ocr2keepers "github.com/goplugin/plugin-automation/pkg/v2" - "github.com/goplugin/plugin-common/pkg/services" ) var ( @@ -75,7 +74,7 @@ type reportCoordinator struct { // run state data running atomic.Bool - chStop services.StopChan + chStop chan struct{} } // NewReportCoordinator provides a new report coordinator. The coordinator @@ -229,7 +228,7 @@ func (rc *reportCoordinator) checkLogs(ctx context.Context) error { } } - staleReportLogs, err = rc.logs.StaleReportLogs(ctx) + staleReportLogs, err = rc.logs.StaleReportLogs(context.Background()) // It can happen that in between the time the report is generated and it gets // confirmed on chain something changes and it becomes stale. Current scenarios are: // - Another report for the upkeep is transmitted making this report stale @@ -387,20 +386,13 @@ func (rc *reportCoordinator) Close() error { func (rc *reportCoordinator) run() { cadence := time.Second timer := time.NewTimer(cadence) - defer timer.Stop() - - ctx, cancel := rc.chStop.NewCtx() - defer cancel() for { select { case <-timer.C: startTime := time.Now() - if err := rc.checkLogs(ctx); err != nil { - if ctx.Err() != nil { - return - } + if err := rc.checkLogs(context.Background()); err != nil { rc.logger.Printf("failed to check perform and stale report logs: %s", err) } @@ -415,7 +407,8 @@ func (rc *reportCoordinator) run() { // wait the difference between the cadence and the time taken timer.Reset(cadence - diff) } - case <-ctx.Done(): + case <-rc.chStop: + timer.Stop() return } } diff --git a/pkg/v2/coordinator/mocks/encoder.generated.go b/pkg/v2/coordinator/mocks/encoder.generated.go index eba999f..4d71728 100644 --- a/pkg/v2/coordinator/mocks/encoder.generated.go +++ b/pkg/v2/coordinator/mocks/encoder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -16,10 +16,6 @@ type Encoder struct { func (_m *Encoder) After(_a0 ocr2keepers.BlockKey, _a1 ocr2keepers.BlockKey) (bool, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for After") - } - var r0 bool var r1 error if rf, ok := ret.Get(0).(func(ocr2keepers.BlockKey, ocr2keepers.BlockKey) (bool, error)); ok { @@ -44,10 +40,6 @@ func (_m *Encoder) After(_a0 ocr2keepers.BlockKey, _a1 ocr2keepers.BlockKey) (bo func (_m *Encoder) Increment(_a0 ocr2keepers.BlockKey) (ocr2keepers.BlockKey, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Increment") - } - var r0 ocr2keepers.BlockKey var r1 error if rf, ok := ret.Get(0).(func(ocr2keepers.BlockKey) (ocr2keepers.BlockKey, error)); ok { @@ -72,10 +64,6 @@ func (_m *Encoder) Increment(_a0 ocr2keepers.BlockKey) (ocr2keepers.BlockKey, er func (_m *Encoder) SplitUpkeepKey(_a0 ocr2keepers.UpkeepKey) (ocr2keepers.BlockKey, ocr2keepers.UpkeepIdentifier, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for SplitUpkeepKey") - } - var r0 ocr2keepers.BlockKey var r1 ocr2keepers.UpkeepIdentifier var r2 error @@ -105,12 +93,13 @@ func (_m *Encoder) SplitUpkeepKey(_a0 ocr2keepers.UpkeepKey) (ocr2keepers.BlockK return r0, r1, r2 } -// NewEncoder creates a new instance of Encoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewEncoder(t interface { +type mockConstructorTestingTNewEncoder interface { mock.TestingT Cleanup(func()) -}) *Encoder { +} + +// NewEncoder creates a new instance of Encoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewEncoder(t mockConstructorTestingTNewEncoder) *Encoder { mock := &Encoder{} mock.Mock.Test(t) diff --git a/pkg/v2/coordinator/mocks/log_provider.generated.go b/pkg/v2/coordinator/mocks/log_provider.generated.go index 885c043..f484c5c 100644 --- a/pkg/v2/coordinator/mocks/log_provider.generated.go +++ b/pkg/v2/coordinator/mocks/log_provider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type LogProvider struct { func (_m *LogProvider) PerformLogs(_a0 context.Context) ([]ocr2keepers.PerformLog, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for PerformLogs") - } - var r0 []ocr2keepers.PerformLog var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]ocr2keepers.PerformLog, error)); ok { @@ -49,10 +45,6 @@ func (_m *LogProvider) PerformLogs(_a0 context.Context) ([]ocr2keepers.PerformLo func (_m *LogProvider) StaleReportLogs(_a0 context.Context) ([]ocr2keepers.StaleReportLog, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for StaleReportLogs") - } - var r0 []ocr2keepers.StaleReportLog var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]ocr2keepers.StaleReportLog, error)); ok { @@ -75,12 +67,13 @@ func (_m *LogProvider) StaleReportLogs(_a0 context.Context) ([]ocr2keepers.Stale return r0, r1 } -// NewLogProvider creates a new instance of LogProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewLogProvider(t interface { +type mockConstructorTestingTNewLogProvider interface { mock.TestingT Cleanup(func()) -}) *LogProvider { +} + +// NewLogProvider creates a new instance of LogProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewLogProvider(t mockConstructorTestingTNewLogProvider) *LogProvider { mock := &LogProvider{} mock.Mock.Test(t) diff --git a/pkg/v2/delegate_test.go b/pkg/v2/delegate_test.go index d67d9b8..13fe17c 100644 --- a/pkg/v2/delegate_test.go +++ b/pkg/v2/delegate_test.go @@ -23,7 +23,7 @@ func TestStart(t *testing.T) { Logger: logger, }) - assert.Equal(t, "bad local config while creating new oracle: blockchain timeout must be between 1s and 20s, but is currently 0s; contract config tracker poll interval must be between 1s and 2m0s, but is currently 0s; contract config load timeout must be between 1s and 1h0m0s, but is currently 0s; contract transmitter transmit timeout must be between 1s and 1m0s, but is currently 0s; database timeout must be between 100ms and 10s, but is currently 0s; DefaultMaxDurationInitialization must be between 1s and 1h0m0s, but is currently 0s; contract config block-depth confirmation threshold must be between 1 and 100, but is currently 0: failed to create new OCR oracle", err.Error()) + assert.Equal(t, err.Error(), "bad local config while creating new oracle: blockchain timeout must be between 1s and 20s, but is currently 0s; contract config tracker poll interval must be between 15s and 2m0s, but is currently 0s; contract transmitter transmit timeout must be between 1s and 1m0s, but is currently 0s; database timeout must be between 100ms and 10s, but is currently 0s; contract config block-depth confirmation threshold must be between 1 and 100, but is currently 0: failed to create new OCR oracle") }) t.Run("creates the delegate with the provided config", func(t *testing.T) { @@ -33,9 +33,7 @@ func TestStart(t *testing.T) { _, err := NewDelegate(DelegateConfig{ Logger: logger, LocalConfig: types.LocalConfig{ - DefaultMaxDurationInitialization: 30 * time.Second, BlockchainTimeout: 1 * time.Second, - ContractConfigLoadTimeout: 1 * time.Second, ContractConfigTrackerPollInterval: 15 * time.Second, ContractTransmitterTransmitTimeout: 1 * time.Second, DatabaseTimeout: 100 * time.Millisecond, @@ -92,9 +90,7 @@ func TestClose(t *testing.T) { d, err := NewDelegate(DelegateConfig{ Logger: mockLogger, LocalConfig: types.LocalConfig{ - DefaultMaxDurationInitialization: 30 * time.Second, BlockchainTimeout: 1 * time.Second, - ContractConfigLoadTimeout: 1 * time.Second, ContractConfigTrackerPollInterval: 15 * time.Second, ContractTransmitterTransmitTimeout: 1 * time.Second, DatabaseTimeout: 100 * time.Millisecond, diff --git a/pkg/v2/factory.go b/pkg/v2/factory.go index f326e03..b360c4c 100644 --- a/pkg/v2/factory.go +++ b/pkg/v2/factory.go @@ -1,7 +1,6 @@ package ocr2keepers import ( - "context" "fmt" "log" @@ -59,7 +58,7 @@ type pluginFactory struct { logger *log.Logger } -func (f *pluginFactory) NewReportingPlugin(ctx context.Context, c types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { +func (f *pluginFactory) NewReportingPlugin(c types.ReportingPluginConfig) (types.ReportingPlugin, types.ReportingPluginInfo, error) { f.logger.Printf("creating new reporting plugin instance") offChainCfg, err := config.DecodeOffchainConfig(c.OffchainConfig) diff --git a/pkg/v2/mocks/logger.generated.go b/pkg/v2/mocks/logger.generated.go index 583cf0d..bbc98fd 100644 --- a/pkg/v2/mocks/logger.generated.go +++ b/pkg/v2/mocks/logger.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -42,12 +42,13 @@ func (_m *MockLogger) Warn(msg string, fields commontypes.LogFields) { _m.Called(msg, fields) } -// NewMockLogger creates a new instance of MockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockLogger(t interface { +type mockConstructorTestingTNewMockLogger interface { mock.TestingT Cleanup(func()) -}) *MockLogger { +} + +// NewMockLogger creates a new instance of MockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockLogger(t mockConstructorTestingTNewMockLogger) *MockLogger { mock := &MockLogger{} mock.Mock.Test(t) diff --git a/pkg/v3/LICENSE b/pkg/v3/LICENSE index df78372..4128d13 100644 --- a/pkg/v3/LICENSE +++ b/pkg/v3/LICENSE @@ -7,8 +7,10 @@ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. Parameters +Licensor: SmartContract Plugin Limited SEZC Licensed Work: Automation v2.1 +The Licensed Work is (c) 2023 SmartContract Plugin Limited SEZC Additional Use Grant: Any uses listed and defined at https://github.com/goplugin/plugin-automation/tree/main/pkg/v3/Automation_v2.1_Grants.md diff --git a/pkg/v3/coordinator/coordinator.go b/pkg/v3/coordinator/coordinator.go index fb90e52..bec4f38 100644 --- a/pkg/v3/coordinator/coordinator.go +++ b/pkg/v3/coordinator/coordinator.go @@ -7,9 +7,9 @@ import ( "log" "time" - "github.com/goplugin/plugin-common/pkg/services" common "github.com/goplugin/plugin-common/pkg/types/automation" + internalutil "github.com/goplugin/plugin-automation/internal/util" "github.com/goplugin/plugin-automation/pkg/util" "github.com/goplugin/plugin-automation/pkg/v3/config" "github.com/goplugin/plugin-automation/pkg/v3/types" @@ -21,9 +21,7 @@ const ( ) type coordinator struct { - services.StateMachine - stopCh services.StopChan - done chan struct{} + closer internalutil.Closer logger *log.Logger eventsProvider types.TransmitEventProvider @@ -48,8 +46,6 @@ type record struct { func NewCoordinator(transmitEventProvider types.TransmitEventProvider, upkeepTypeGetter types.UpkeepTypeGetter, conf config.OffchainConfig, logger *log.Logger) *coordinator { performLockoutWindow := time.Duration(conf.PerformLockoutWindow) * time.Millisecond return &coordinator{ - stopCh: make(chan struct{}), - done: make(chan struct{}), logger: logger, eventsProvider: transmitEventProvider, upkeepTypeGetter: upkeepTypeGetter, @@ -212,24 +208,16 @@ func (c *coordinator) checkEvents(ctx context.Context) error { return nil } -func (c *coordinator) run() { - defer close(c.done) - +func (c *coordinator) run(ctx context.Context) { timer := time.NewTimer(cadence) defer timer.Stop() - ctx, cancel := c.stopCh.NewCtx() - defer cancel() - for { select { case <-timer.C: startTime := time.Now() - if err := c.checkEvents(ctx); err != nil { - if ctx.Err() != nil { - return - } + if err := c.checkEvents(context.Background()); err != nil { c.logger.Printf("failed to check for transmit events: %s", err) } @@ -251,29 +239,32 @@ func (c *coordinator) run() { } // Start starts all subprocesses -func (c *coordinator) Start(_ context.Context) error { - if err := c.StateMachine.StartOnce("Coordinator", func() error { return nil }); err != nil { - return err +func (c *coordinator) Start(pctx context.Context) error { + ctx, cancel := context.WithCancel(pctx) + defer cancel() + + if !c.closer.Store(cancel) { + return fmt.Errorf("process already running") } go c.cache.Start(defaultCacheClean) go c.visited.Start(defaultCacheClean) - c.run() + c.run(ctx) + return nil } // Close terminates all subprocesses func (c *coordinator) Close() error { - return c.StateMachine.StopOnce("Coordinator", func() error { - close(c.stopCh) - <-c.done + if !c.closer.Close() { + return fmt.Errorf("process not running") + } - c.cache.Stop() - c.visited.Stop() + c.cache.Stop() + c.visited.Stop() - return nil - }) + return nil } func (c *coordinator) visitedID(e common.TransmitEvent) string { diff --git a/pkg/v3/coordinator/coordinator_test.go b/pkg/v3/coordinator/coordinator_test.go index 694e7a2..59ae8c6 100644 --- a/pkg/v3/coordinator/coordinator_test.go +++ b/pkg/v3/coordinator/coordinator_test.go @@ -145,6 +145,19 @@ func TestNewCoordinator(t *testing.T) { wg.Wait() assert.True(t, strings.Contains(memLog.String(), "check database indexes and other performance improvements")) }) + + t.Run("starting an already started coordinator returns an error", func(t *testing.T) { + c := NewCoordinator(nil, nil, config.OffchainConfig{PerformLockoutWindow: 3600 * 1000, MinConfirmations: 2}, nil) + c.closer.Store(context.CancelFunc(func() {})) + err := c.Start(context.Background()) + assert.Error(t, err) + }) + + t.Run("closing an already closed coordinator returns an error", func(t *testing.T) { + c := NewCoordinator(nil, nil, config.OffchainConfig{PerformLockoutWindow: 3600 * 1000, MinConfirmations: 2}, nil) + err := c.Close() + assert.Error(t, err) + }) } func TestNewCoordinator_checkEvents(t *testing.T) { diff --git a/pkg/v3/flows/conditional_test.go b/pkg/v3/flows/conditional_test.go index 23ba521..78a5896 100644 --- a/pkg/v3/flows/conditional_test.go +++ b/pkg/v3/flows/conditional_test.go @@ -125,11 +125,11 @@ func TestSamplingProposal(t *testing.T) { logger := log.New(io.Discard, "", log.LstdFlags) - runner := mocks.NewMockRunnable(t) - mStore := mocks.NewMockMetadataStore(t) - upkeepProvider := mocks.NewMockConditionalUpkeepProvider(t) - ratio := mocks.NewMockRatio(t) - coord := mocks.NewMockCoordinator(t) + runner := new(mocks.MockRunnable) + mStore := new(mocks.MockMetadataStore) + upkeepProvider := new(mocks.MockConditionalUpkeepProvider) + ratio := new(mocks.MockRatio) + coord := new(mocks.MockCoordinator) ratio.On("OfInt", mock.Anything).Return(0, nil).Times(1) ratio.On("OfInt", mock.Anything).Return(1, nil).Times(1) @@ -193,11 +193,18 @@ func TestSamplingProposal(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - go func(ctx context.Context) { + go func(svc service.Recoverable, ctx context.Context) { defer wg.Done() assert.NoError(t, svc.Start(ctx)) - }(ctx) - t.Cleanup(func() { assert.NoError(t, svc.Close()) }) + }(svc, ctx) + + assert.NoError(t, svc.Close(), "no error expected on shut down") wg.Wait() + + mStore.AssertExpectations(t) + upkeepProvider.AssertExpectations(t) + coord.AssertExpectations(t) + runner.AssertExpectations(t) + // ratio.AssertExpectations(t) } diff --git a/pkg/v3/plugin/factory.go b/pkg/v3/plugin/factory.go index e76c510..46b829d 100644 --- a/pkg/v3/plugin/factory.go +++ b/pkg/v3/plugin/factory.go @@ -1,20 +1,18 @@ package plugin import ( - "context" "fmt" "log" "math" "math/cmplx" "strconv" - "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" - ocr2keepers "github.com/goplugin/plugin-automation/pkg/v3" "github.com/goplugin/plugin-automation/pkg/v3/config" "github.com/goplugin/plugin-automation/pkg/v3/runner" "github.com/goplugin/plugin-automation/pkg/v3/types" commontypes "github.com/goplugin/plugin-common/pkg/types/automation" + "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" ) type pluginFactory struct { @@ -65,7 +63,7 @@ func NewReportingPluginFactory( } } -func (factory *pluginFactory) NewReportingPlugin(ctx context.Context, c ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[AutomationReportInfo], ocr3types.ReportingPluginInfo, error) { +func (factory *pluginFactory) NewReportingPlugin(c ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[AutomationReportInfo], ocr3types.ReportingPluginInfo, error) { info := ocr3types.ReportingPluginInfo{ Name: fmt.Sprintf("Oracle: %d: Automation Plugin Instance w/ Digest '%s'", c.OracleID, c.ConfigDigest), Limits: ocr3types.ReportingPluginLimits{ @@ -115,7 +113,6 @@ func (factory *pluginFactory) NewReportingPlugin(ctx context.Context, c ocr3type factory.runnable, factory.runnerConf, conf, - c.N, c.F, factory.logger, ) diff --git a/pkg/v3/plugin/ocr3.go b/pkg/v3/plugin/ocr3.go index b9b8b6f..60a6d21 100644 --- a/pkg/v3/plugin/ocr3.go +++ b/pkg/v3/plugin/ocr3.go @@ -6,11 +6,9 @@ import ( "fmt" "log" + ocr2keepers "github.com/goplugin/plugin-common/pkg/types/automation" "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" ocr2plustypes "github.com/goplugin/plugin-libocr/offchainreporting2plus/types" - "github.com/goplugin/plugin-libocr/quorumhelper" - - ocr2keepers "github.com/goplugin/plugin-common/pkg/types/automation" ocr2keepersv3 "github.com/goplugin/plugin-automation/pkg/v3" "github.com/goplugin/plugin-automation/pkg/v3/config" @@ -38,7 +36,6 @@ type ocr3Plugin struct { AddLogProposalsHook hooks.AddLogProposalsHook Services []service.Recoverable Config config.OffchainConfig - N int F int Logger *log.Logger } @@ -93,17 +90,17 @@ func (plugin *ocr3Plugin) Observation(ctx context.Context, outctx ocr3types.Outc return observation.Encode() } -func (plugin *ocr3Plugin) ObservationQuorum(ctx context.Context, outctx ocr3types.OutcomeContext, query ocr2plustypes.Query, aos []ocr2plustypes.AttributedObservation) (bool, error) { - return quorumhelper.ObservationCountReachesObservationQuorum(quorumhelper.QuorumTwoFPlusOne, plugin.N, plugin.F, aos), nil +func (plugin *ocr3Plugin) ObservationQuorum(outctx ocr3types.OutcomeContext, query ocr2plustypes.Query) (ocr3types.Quorum, error) { + return ocr3types.QuorumTwoFPlusOne, nil } -func (plugin *ocr3Plugin) ValidateObservation(ctx context.Context, outctx ocr3types.OutcomeContext, query ocr2plustypes.Query, ao ocr2plustypes.AttributedObservation) error { +func (plugin *ocr3Plugin) ValidateObservation(outctx ocr3types.OutcomeContext, query ocr2plustypes.Query, ao ocr2plustypes.AttributedObservation) error { plugin.Logger.Printf("inside ValidateObservation for seqNr %d", outctx.SeqNr) _, err := ocr2keepersv3.DecodeAutomationObservation(ao.Observation, plugin.UpkeepTypeGetter, plugin.WorkIDGenerator) return err } -func (plugin *ocr3Plugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeContext, query ocr2plustypes.Query, attributedObservations []ocr2plustypes.AttributedObservation) (ocr3types.Outcome, error) { +func (plugin *ocr3Plugin) Outcome(outctx ocr3types.OutcomeContext, query ocr2plustypes.Query, attributedObservations []ocr2plustypes.AttributedObservation) (ocr3types.Outcome, error) { plugin.Logger.Printf("inside Outcome for seqNr %d", outctx.SeqNr) p := newPerformables(plugin.F+1, ocr2keepersv3.OutcomeAgreedPerformablesLimit, getRandomKeySource(plugin.ConfigDigest, outctx.SeqNr), plugin.Logger) c := newCoordinatedBlockProposals(plugin.F+1, ocr2keepersv3.OutcomeSurfacedProposalsRoundHistoryLimit, ocr2keepersv3.OutcomeSurfacedProposalsLimit, getRandomKeySource(plugin.ConfigDigest, outctx.SeqNr), plugin.Logger) @@ -151,10 +148,10 @@ func (plugin *ocr3Plugin) Outcome(ctx context.Context, outctx ocr3types.OutcomeC return outcome.Encode() } -func (plugin *ocr3Plugin) Reports(ctx context.Context, seqNr uint64, raw ocr3types.Outcome) ([]ocr3types.ReportPlus[AutomationReportInfo], error) { +func (plugin *ocr3Plugin) Reports(seqNr uint64, raw ocr3types.Outcome) ([]ocr3types.ReportWithInfo[AutomationReportInfo], error) { plugin.Logger.Printf("inside Reports for seqNr %d", seqNr) var ( - reports []ocr3types.ReportPlus[AutomationReportInfo] + reports []ocr3types.ReportWithInfo[AutomationReportInfo] outcome ocr2keepersv3.AutomationOutcome err error ) @@ -183,7 +180,7 @@ func (plugin *ocr3Plugin) Reports(ctx context.Context, seqNr uint64, raw ocr3typ return reports, fmt.Errorf("error encountered while encoding: %w", err) } // append to reports and reset collection - reports = append(reports, ocr3types.ReportPlus[AutomationReportInfo]{ReportWithInfo: report}) + reports = append(reports, report) performablesAdded += len(toPerform) toPerform = []ocr2keepers.CheckResult{} gasUsed = 0 @@ -204,7 +201,7 @@ func (plugin *ocr3Plugin) Reports(ctx context.Context, seqNr uint64, raw ocr3typ prommetrics.AutomationPluginPerformables.WithLabelValues(prommetrics.PluginStepReports).Set(0) return reports, fmt.Errorf("error encountered while encoding: %w", err) } - reports = append(reports, ocr3types.ReportPlus[AutomationReportInfo]{ReportWithInfo: report}) + reports = append(reports, report) performablesAdded += len(toPerform) } diff --git a/pkg/v3/plugin/ocr3_test.go b/pkg/v3/plugin/ocr3_test.go index b725de7..2481d6e 100644 --- a/pkg/v3/plugin/ocr3_test.go +++ b/pkg/v3/plugin/ocr3_test.go @@ -13,15 +13,14 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/goccy/go-json" - "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" - ocr2plustypes "github.com/goplugin/plugin-libocr/offchainreporting2plus/types" - "github.com/stretchr/testify/assert" - ocr2keepers2 "github.com/goplugin/plugin-automation/pkg/v3" "github.com/goplugin/plugin-automation/pkg/v3/plugin/hooks" "github.com/goplugin/plugin-automation/pkg/v3/service" "github.com/goplugin/plugin-automation/pkg/v3/types" ocr2keepers "github.com/goplugin/plugin-common/pkg/types/automation" + "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/goplugin/plugin-libocr/offchainreporting2plus/types" + "github.com/stretchr/testify/assert" ) func TestOcr3Plugin_Query(t *testing.T) { @@ -992,7 +991,7 @@ func TestOcr3Plugin_ValidateObservation(t *testing.T) { UpkeepTypeGetter: mockUpkeepTypeGetter, WorkIDGenerator: tc.wg, } - err := plugin.ValidateObservation(context.Background(), ocr3types.OutcomeContext{}, nil, tc.observation) + err := plugin.ValidateObservation(ocr3types.OutcomeContext{}, nil, tc.observation) if tc.expectsErr { assert.Error(t, err) assert.Equal(t, err.Error(), tc.wantErr.Error()) @@ -1095,7 +1094,7 @@ func TestOcr3Plugin_Outcome(t *testing.T) { WorkIDGenerator: tc.wg, Logger: logger, } - outcome, err := plugin.Outcome(context.Background(), ocr3types.OutcomeContext{ + outcome, err := plugin.Outcome(ocr3types.OutcomeContext{ PreviousOutcome: tc.prevOutcome, }, nil, tc.observations) if tc.expectsErr { @@ -1116,7 +1115,7 @@ func TestOcr3Plugin_Reports(t *testing.T) { name string sequenceNumber uint64 outcome ocr3types.Outcome - wantReportsWithInfo []ocr3types.ReportPlus[AutomationReportInfo] + wantReportsWithInfo []ocr3types.ReportWithInfo[AutomationReportInfo] encoder ocr2keepers.Encoder utg types.UpkeepTypeGetter wg types.WorkIDGenerator @@ -1134,7 +1133,7 @@ func TestOcr3Plugin_Reports(t *testing.T) { name: "an empty json object generates a nil report", sequenceNumber: 5, outcome: ocr3types.Outcome([]byte(`{}`)), - wantReportsWithInfo: []ocr3types.ReportPlus[AutomationReportInfo](nil), + wantReportsWithInfo: []ocr3types.ReportWithInfo[AutomationReportInfo](nil), }, { name: "a well formed but invalid outcome returns an error", @@ -1199,13 +1198,13 @@ func TestOcr3Plugin_Reports(t *testing.T) { wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" }, - wantReportsWithInfo: []ocr3types.ReportPlus[AutomationReportInfo]{ - {ReportWithInfo: ocr3types.ReportWithInfo[AutomationReportInfo]{ + wantReportsWithInfo: []ocr3types.ReportWithInfo[AutomationReportInfo]{ + { Report: []byte(`[]`), - }}, - {ReportWithInfo: ocr3types.ReportWithInfo[AutomationReportInfo]{ + }, + { Report: []byte(`[{"PipelineExecutionState":0,"Retryable":false,"Eligible":true,"IneligibilityReason":0,"UpkeepID":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Trigger":{"BlockNumber":0,"BlockHash":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"LogTriggerExtension":null},"WorkID":"workID1","GasAllocated":1,"PerformData":null,"FastGasWei":1,"LinkNative":2}]`), - }}, + }, }, }, { @@ -1276,7 +1275,7 @@ func TestOcr3Plugin_Reports(t *testing.T) { UpkeepTypeGetter: tc.utg, WorkIDGenerator: tc.wg, } - reportsWithInfo, err := plugin.Reports(context.Background(), tc.sequenceNumber, tc.outcome) + reportsWithInfo, err := plugin.Reports(tc.sequenceNumber, tc.outcome) if tc.expectsErr { assert.Error(t, err) assert.Equal(t, err.Error(), tc.wantErr.Error()) diff --git a/pkg/v3/plugin/plugin.go b/pkg/v3/plugin/plugin.go index 4d6fc5b..2623853 100644 --- a/pkg/v3/plugin/plugin.go +++ b/pkg/v3/plugin/plugin.go @@ -4,9 +4,6 @@ import ( "fmt" "log" - "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" - ocr2plustypes "github.com/goplugin/plugin-libocr/offchainreporting2plus/types" - "github.com/goplugin/plugin-automation/pkg/v3/config" "github.com/goplugin/plugin-automation/pkg/v3/coordinator" "github.com/goplugin/plugin-automation/pkg/v3/flows" @@ -17,6 +14,8 @@ import ( "github.com/goplugin/plugin-automation/pkg/v3/telemetry" "github.com/goplugin/plugin-automation/pkg/v3/types" ocr2keepers "github.com/goplugin/plugin-common/pkg/types/automation" + "github.com/goplugin/plugin-libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/goplugin/plugin-libocr/offchainreporting2plus/types" ) func newPlugin( @@ -35,7 +34,6 @@ func newPlugin( runnable types.Runnable, rConf runner.RunnerConfig, conf config.OffchainConfig, - n int, f int, logger *log.Logger, ) (ocr3types.ReportingPlugin[AutomationReportInfo], error) { @@ -129,7 +127,6 @@ func newPlugin( AddLogProposalsHook: hooks.NewAddLogProposalsHook(metadataStore, coord, logger), Services: recoverSvcs, Config: conf, - N: n, F: f, Logger: log.New(logger.Writer(), fmt.Sprintf("[%s | plugin]", telemetry.ServiceName), telemetry.LogPkgStdFlags), } diff --git a/pkg/v3/tickers/time.go b/pkg/v3/tickers/time.go index c45ab98..3a9599c 100644 --- a/pkg/v3/tickers/time.go +++ b/pkg/v3/tickers/time.go @@ -2,10 +2,11 @@ package tickers import ( "context" + "fmt" "log" "time" - "github.com/goplugin/plugin-common/pkg/services" + "github.com/goplugin/plugin-automation/internal/util" ) type observer[T any] interface { @@ -15,13 +16,12 @@ type observer[T any] interface { type getterFunc[T any] func(context.Context, time.Time) (Tick[T], error) type timeTicker[T any] struct { - services.StateMachine + closer util.Closer + interval time.Duration observer observer[T] getterFn getterFunc[T] logger *log.Logger - done chan struct{} - stopCh services.StopChan } func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn getterFunc[T], logger *log.Logger) *timeTicker[T] { @@ -30,8 +30,6 @@ func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn observer: observer, getterFn: getterFn, logger: logger, - done: make(chan struct{}), - stopCh: make(chan struct{}), } return t @@ -40,14 +38,14 @@ func NewTimeTicker[T any](interval time.Duration, observer observer[T], getterFn // Start uses the provided context for each call to the getter function with the // configured interval as a timeout. This function blocks until Close is called // or the parent context is cancelled. -func (t *timeTicker[T]) Start(ctx context.Context) error { - if err := t.StartOnce("timeTicker", func() error { return nil }); err != nil { - return err - } - defer close(t.done) - ctx, cancel := t.stopCh.Ctx(ctx) +func (t *timeTicker[T]) Start(pctx context.Context) error { + ctx, cancel := context.WithCancel(pctx) defer cancel() + if !t.closer.Store(cancel) { + return fmt.Errorf("already running") + } + t.logger.Printf("starting ticker service") defer t.logger.Printf("ticker service stopped") @@ -56,8 +54,6 @@ func (t *timeTicker[T]) Start(ctx context.Context) error { for { select { - case <-ctx.Done(): - return nil case tm := <-ticker.C: if t.getterFn == nil { continue @@ -65,7 +61,6 @@ func (t *timeTicker[T]) Start(ctx context.Context) error { tick, err := t.getterFn(ctx, tm) if err != nil { t.logger.Printf("error fetching tick: %s", err.Error()) - continue } // observer.Process can be a heavy call taking upto ObservationProcessLimit seconds // so it is run in a separate goroutine to not block further ticks @@ -75,14 +70,13 @@ func (t *timeTicker[T]) Start(ctx context.Context) error { l.Printf("error processing observer: %s", err.Error()) } }(ctx, tick, t.observer, t.logger) + case <-ctx.Done(): + return nil } } } func (t *timeTicker[T]) Close() error { - return t.StopOnce("timeTicker", func() error { - close(t.stopCh) - <-t.done - return nil - }) + _ = t.closer.Close() + return nil } diff --git a/pkg/v3/tickers/time_test.go b/pkg/v3/tickers/time_test.go index 1efb7fd..e8b4fcd 100644 --- a/pkg/v3/tickers/time_test.go +++ b/pkg/v3/tickers/time_test.go @@ -131,7 +131,7 @@ func TestNewTimeTicker(t *testing.T) { } getFn := func(ctx context.Context, t time.Time) (Tick[[]int], error) { - return nil, errors.New("test error") + return nil, errors.New("error fetching tick") } ticker := NewTimeTicker[[]int](100*time.Millisecond, observr, getFn, log.New(msg, "", log.LstdFlags)) @@ -150,7 +150,7 @@ func TestNewTimeTicker(t *testing.T) { wg.Wait() - assert.Contains(t, msg.String(), "error fetching tick: test error") + assert.Contains(t, msg.String(), "error processing observer: boom") }) t.Run("creates a ticker with an observer that errors on processing", func(t *testing.T) { diff --git a/pkg/v3/types/mocks/block_subscriber.generated.go b/pkg/v3/types/mocks/block_subscriber.generated.go index 49aad4b..3135ffa 100644 --- a/pkg/v3/types/mocks/block_subscriber.generated.go +++ b/pkg/v3/types/mocks/block_subscriber.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockBlockSubscriber struct { func (_m *MockBlockSubscriber) Close() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Close") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -37,10 +33,6 @@ func (_m *MockBlockSubscriber) Close() error { func (_m *MockBlockSubscriber) Start(_a0 context.Context) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Start") - } - var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -55,10 +47,6 @@ func (_m *MockBlockSubscriber) Start(_a0 context.Context) error { func (_m *MockBlockSubscriber) Subscribe() (int, chan automation.BlockHistory, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Subscribe") - } - var r0 int var r1 chan automation.BlockHistory var r2 error @@ -92,10 +80,6 @@ func (_m *MockBlockSubscriber) Subscribe() (int, chan automation.BlockHistory, e func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Unsubscribe") - } - var r0 error if rf, ok := ret.Get(0).(func(int) error); ok { r0 = rf(_a0) @@ -106,12 +90,13 @@ func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { return r0 } -// NewMockBlockSubscriber creates a new instance of MockBlockSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockBlockSubscriber(t interface { +type mockConstructorTestingTNewMockBlockSubscriber interface { mock.TestingT Cleanup(func()) -}) *MockBlockSubscriber { +} + +// NewMockBlockSubscriber creates a new instance of MockBlockSubscriber. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockBlockSubscriber(t mockConstructorTestingTNewMockBlockSubscriber) *MockBlockSubscriber { mock := &MockBlockSubscriber{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go index bfe1110..6ab3592 100644 --- a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go +++ b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockConditionalUpkeepProvider struct { func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for GetActiveUpkeeps") - } - var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -45,12 +41,13 @@ func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ( return r0, r1 } -// NewMockConditionalUpkeepProvider creates a new instance of MockConditionalUpkeepProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockConditionalUpkeepProvider(t interface { +type mockConstructorTestingTNewMockConditionalUpkeepProvider interface { mock.TestingT Cleanup(func()) -}) *MockConditionalUpkeepProvider { +} + +// NewMockConditionalUpkeepProvider creates a new instance of MockConditionalUpkeepProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockConditionalUpkeepProvider(t mockConstructorTestingTNewMockConditionalUpkeepProvider) *MockConditionalUpkeepProvider { mock := &MockConditionalUpkeepProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/coordinator.generated.go b/pkg/v3/types/mocks/coordinator.generated.go index 0c2ba34..ce0eb3f 100644 --- a/pkg/v3/types/mocks/coordinator.generated.go +++ b/pkg/v3/types/mocks/coordinator.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockCoordinator struct { func (_m *MockCoordinator) Accept(_a0 automation.ReportedUpkeep) bool { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Accept") - } - var r0 bool if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { r0 = rf(_a0) @@ -37,10 +33,6 @@ func (_m *MockCoordinator) Accept(_a0 automation.ReportedUpkeep) bool { func (_m *MockCoordinator) FilterProposals(_a0 []automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for FilterProposals") - } - var r0 []automation.CoordinatedBlockProposal var r1 error if rf, ok := ret.Get(0).(func([]automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error)); ok { @@ -67,10 +59,6 @@ func (_m *MockCoordinator) FilterProposals(_a0 []automation.CoordinatedBlockProp func (_m *MockCoordinator) FilterResults(_a0 []automation.CheckResult) ([]automation.CheckResult, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for FilterResults") - } - var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func([]automation.CheckResult) ([]automation.CheckResult, error)); ok { @@ -97,10 +85,6 @@ func (_m *MockCoordinator) FilterResults(_a0 []automation.CheckResult) ([]automa func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []automation.UpkeepPayload) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0, payloads) - if len(ret) == 0 { - panic("no return value specified for PreProcess") - } - var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context, []automation.UpkeepPayload) ([]automation.UpkeepPayload, error)); ok { @@ -127,10 +111,6 @@ func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []automation func (_m *MockCoordinator) ShouldTransmit(_a0 automation.ReportedUpkeep) bool { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for ShouldTransmit") - } - var r0 bool if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { r0 = rf(_a0) @@ -141,12 +121,13 @@ func (_m *MockCoordinator) ShouldTransmit(_a0 automation.ReportedUpkeep) bool { return r0 } -// NewMockCoordinator creates a new instance of MockCoordinator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockCoordinator(t interface { +type mockConstructorTestingTNewMockCoordinator interface { mock.TestingT Cleanup(func()) -}) *MockCoordinator { +} + +// NewMockCoordinator creates a new instance of MockCoordinator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockCoordinator(t mockConstructorTestingTNewMockCoordinator) *MockCoordinator { mock := &MockCoordinator{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/encoder.generated.go b/pkg/v3/types/mocks/encoder.generated.go index 8e84e28..d4f1425 100644 --- a/pkg/v3/types/mocks/encoder.generated.go +++ b/pkg/v3/types/mocks/encoder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -22,10 +22,6 @@ func (_m *MockEncoder) Encode(_a0 ...automation.CheckResult) ([]byte, error) { _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for Encode") - } - var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(...automation.CheckResult) ([]byte, error)); ok { @@ -52,10 +48,6 @@ func (_m *MockEncoder) Encode(_a0 ...automation.CheckResult) ([]byte, error) { func (_m *MockEncoder) Extract(_a0 []byte) ([]automation.ReportedUpkeep, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Extract") - } - var r0 []automation.ReportedUpkeep var r1 error if rf, ok := ret.Get(0).(func([]byte) ([]automation.ReportedUpkeep, error)); ok { @@ -78,12 +70,13 @@ func (_m *MockEncoder) Extract(_a0 []byte) ([]automation.ReportedUpkeep, error) return r0, r1 } -// NewMockEncoder creates a new instance of MockEncoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockEncoder(t interface { +type mockConstructorTestingTNewMockEncoder interface { mock.TestingT Cleanup(func()) -}) *MockEncoder { +} + +// NewMockEncoder creates a new instance of MockEncoder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockEncoder(t mockConstructorTestingTNewMockEncoder) *MockEncoder { mock := &MockEncoder{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/logeventprovider.generated.go b/pkg/v3/types/mocks/logeventprovider.generated.go index 68a48a9..cfb3f00 100644 --- a/pkg/v3/types/mocks/logeventprovider.generated.go +++ b/pkg/v3/types/mocks/logeventprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockLogEventProvider struct { func (_m *MockLogEventProvider) Close() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Close") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -37,10 +33,6 @@ func (_m *MockLogEventProvider) Close() error { func (_m *MockLogEventProvider) GetLatestPayloads(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for GetLatestPayloads") - } - var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -72,10 +64,6 @@ func (_m *MockLogEventProvider) SetConfig(_a0 automation.LogEventProviderConfig) func (_m *MockLogEventProvider) Start(_a0 context.Context) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Start") - } - var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -86,12 +74,13 @@ func (_m *MockLogEventProvider) Start(_a0 context.Context) error { return r0 } -// NewMockLogEventProvider creates a new instance of MockLogEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockLogEventProvider(t interface { +type mockConstructorTestingTNewMockLogEventProvider interface { mock.TestingT Cleanup(func()) -}) *MockLogEventProvider { +} + +// NewMockLogEventProvider creates a new instance of MockLogEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockLogEventProvider(t mockConstructorTestingTNewMockLogEventProvider) *MockLogEventProvider { mock := &MockLogEventProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/metadatastore.generated.go b/pkg/v3/types/mocks/metadatastore.generated.go index 23fc8fe..513e2db 100644 --- a/pkg/v3/types/mocks/metadatastore.generated.go +++ b/pkg/v3/types/mocks/metadatastore.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -32,10 +32,6 @@ func (_m *MockMetadataStore) AddProposals(proposals ...automation.CoordinatedBlo func (_m *MockMetadataStore) Close() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Close") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -50,10 +46,6 @@ func (_m *MockMetadataStore) Close() error { func (_m *MockMetadataStore) GetBlockHistory() automation.BlockHistory { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for GetBlockHistory") - } - var r0 automation.BlockHistory if rf, ok := ret.Get(0).(func() automation.BlockHistory); ok { r0 = rf() @@ -86,10 +78,6 @@ func (_m *MockMetadataStore) SetBlockHistory(_a0 automation.BlockHistory) { func (_m *MockMetadataStore) Start(_a0 context.Context) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Start") - } - var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(_a0) @@ -104,10 +92,6 @@ func (_m *MockMetadataStore) Start(_a0 context.Context) error { func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []automation.CoordinatedBlockProposal { ret := _m.Called(utype) - if len(ret) == 0 { - panic("no return value specified for ViewProposals") - } - var r0 []automation.CoordinatedBlockProposal if rf, ok := ret.Get(0).(func(types.UpkeepType) []automation.CoordinatedBlockProposal); ok { r0 = rf(utype) @@ -120,12 +104,13 @@ func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []automation. return r0 } -// NewMockMetadataStore creates a new instance of MockMetadataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockMetadataStore(t interface { +type mockConstructorTestingTNewMockMetadataStore interface { mock.TestingT Cleanup(func()) -}) *MockMetadataStore { +} + +// NewMockMetadataStore creates a new instance of MockMetadataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockMetadataStore(t mockConstructorTestingTNewMockMetadataStore) *MockMetadataStore { mock := &MockMetadataStore{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/payloadbuilder.generated.go b/pkg/v3/types/mocks/payloadbuilder.generated.go index f79f3cf..0822516 100644 --- a/pkg/v3/types/mocks/payloadbuilder.generated.go +++ b/pkg/v3/types/mocks/payloadbuilder.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -26,10 +26,6 @@ func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...automati _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for BuildPayloads") - } - var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context, ...automation.CoordinatedBlockProposal) ([]automation.UpkeepPayload, error)); ok { @@ -52,12 +48,13 @@ func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...automati return r0, r1 } -// NewMockPayloadBuilder creates a new instance of MockPayloadBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockPayloadBuilder(t interface { +type mockConstructorTestingTNewMockPayloadBuilder interface { mock.TestingT Cleanup(func()) -}) *MockPayloadBuilder { +} + +// NewMockPayloadBuilder creates a new instance of MockPayloadBuilder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockPayloadBuilder(t mockConstructorTestingTNewMockPayloadBuilder) *MockPayloadBuilder { mock := &MockPayloadBuilder{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/ratio.generated.go b/pkg/v3/types/mocks/ratio.generated.go index 6da99e0..1f3b9ea 100644 --- a/pkg/v3/types/mocks/ratio.generated.go +++ b/pkg/v3/types/mocks/ratio.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -13,10 +13,6 @@ type MockRatio struct { func (_m *MockRatio) OfInt(_a0 int) int { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for OfInt") - } - var r0 int if rf, ok := ret.Get(0).(func(int) int); ok { r0 = rf(_a0) @@ -27,12 +23,13 @@ func (_m *MockRatio) OfInt(_a0 int) int { return r0 } -// NewMockRatio creates a new instance of MockRatio. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockRatio(t interface { +type mockConstructorTestingTNewMockRatio interface { mock.TestingT Cleanup(func()) -}) *MockRatio { +} + +// NewMockRatio creates a new instance of MockRatio. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRatio(t mockConstructorTestingTNewMockRatio) *MockRatio { mock := &MockRatio{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/recoverableprovider.generated.go b/pkg/v3/types/mocks/recoverableprovider.generated.go index d445e9d..6c41976 100644 --- a/pkg/v3/types/mocks/recoverableprovider.generated.go +++ b/pkg/v3/types/mocks/recoverableprovider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockRecoverableProvider struct { func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([]automation.UpkeepPayload, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for GetRecoveryProposals") - } - var r0 []automation.UpkeepPayload var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { @@ -45,12 +41,13 @@ func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([] return r0, r1 } -// NewMockRecoverableProvider creates a new instance of MockRecoverableProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockRecoverableProvider(t interface { +type mockConstructorTestingTNewMockRecoverableProvider interface { mock.TestingT Cleanup(func()) -}) *MockRecoverableProvider { +} + +// NewMockRecoverableProvider creates a new instance of MockRecoverableProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRecoverableProvider(t mockConstructorTestingTNewMockRecoverableProvider) *MockRecoverableProvider { mock := &MockRecoverableProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/result_store.generated.go b/pkg/v3/types/mocks/result_store.generated.go index c44b4a2..49fa90c 100644 --- a/pkg/v3/types/mocks/result_store.generated.go +++ b/pkg/v3/types/mocks/result_store.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -38,10 +38,6 @@ func (_m *MockResultStore) Remove(_a0 ...string) { func (_m *MockResultStore) View() ([]automation.CheckResult, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for View") - } - var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func() ([]automation.CheckResult, error)); ok { @@ -64,12 +60,13 @@ func (_m *MockResultStore) View() ([]automation.CheckResult, error) { return r0, r1 } -// NewMockResultStore creates a new instance of MockResultStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockResultStore(t interface { +type mockConstructorTestingTNewMockResultStore interface { mock.TestingT Cleanup(func()) -}) *MockResultStore { +} + +// NewMockResultStore creates a new instance of MockResultStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockResultStore(t mockConstructorTestingTNewMockResultStore) *MockResultStore { mock := &MockResultStore{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/runnable.generated.go b/pkg/v3/types/mocks/runnable.generated.go index 794d7b6..368966e 100644 --- a/pkg/v3/types/mocks/runnable.generated.go +++ b/pkg/v3/types/mocks/runnable.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -26,10 +26,6 @@ func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...automation.Upke _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for CheckUpkeeps") - } - var r0 []automation.CheckResult var r1 error if rf, ok := ret.Get(0).(func(context.Context, ...automation.UpkeepPayload) ([]automation.CheckResult, error)); ok { @@ -52,12 +48,13 @@ func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...automation.Upke return r0, r1 } -// NewMockRunnable creates a new instance of MockRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockRunnable(t interface { +type mockConstructorTestingTNewMockRunnable interface { mock.TestingT Cleanup(func()) -}) *MockRunnable { +} + +// NewMockRunnable creates a new instance of MockRunnable. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockRunnable(t mockConstructorTestingTNewMockRunnable) *MockRunnable { mock := &MockRunnable{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/transmit_event_provider.generated.go b/pkg/v3/types/mocks/transmit_event_provider.generated.go index a3640df..827dd68 100644 --- a/pkg/v3/types/mocks/transmit_event_provider.generated.go +++ b/pkg/v3/types/mocks/transmit_event_provider.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type TransmitEventProvider struct { func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]automation.TransmitEvent, error) { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for GetLatestEvents") - } - var r0 []automation.TransmitEvent var r1 error if rf, ok := ret.Get(0).(func(context.Context) ([]automation.TransmitEvent, error)); ok { @@ -45,12 +41,13 @@ func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]automat return r0, r1 } -// NewTransmitEventProvider creates a new instance of TransmitEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewTransmitEventProvider(t interface { +type mockConstructorTestingTNewTransmitEventProvider interface { mock.TestingT Cleanup(func()) -}) *TransmitEventProvider { +} + +// NewTransmitEventProvider creates a new instance of TransmitEventProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewTransmitEventProvider(t mockConstructorTestingTNewTransmitEventProvider) *TransmitEventProvider { mock := &TransmitEventProvider{} mock.Mock.Test(t) diff --git a/pkg/v3/types/mocks/upkeep_state_updater.generated.go b/pkg/v3/types/mocks/upkeep_state_updater.generated.go index 6747afe..0bb139a 100644 --- a/pkg/v3/types/mocks/upkeep_state_updater.generated.go +++ b/pkg/v3/types/mocks/upkeep_state_updater.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.28.1. DO NOT EDIT. package mocks @@ -19,10 +19,6 @@ type MockUpkeepStateUpdater struct { func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 automation.CheckResult, _a2 automation.UpkeepState) error { ret := _m.Called(_a0, _a1, _a2) - if len(ret) == 0 { - panic("no return value specified for SetUpkeepState") - } - var r0 error if rf, ok := ret.Get(0).(func(context.Context, automation.CheckResult, automation.UpkeepState) error); ok { r0 = rf(_a0, _a1, _a2) @@ -33,12 +29,13 @@ func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 automa return r0 } -// NewMockUpkeepStateUpdater creates a new instance of MockUpkeepStateUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockUpkeepStateUpdater(t interface { +type mockConstructorTestingTNewMockUpkeepStateUpdater interface { mock.TestingT Cleanup(func()) -}) *MockUpkeepStateUpdater { +} + +// NewMockUpkeepStateUpdater creates a new instance of MockUpkeepStateUpdater. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewMockUpkeepStateUpdater(t mockConstructorTestingTNewMockUpkeepStateUpdater) *MockUpkeepStateUpdater { mock := &MockUpkeepStateUpdater{} mock.Mock.Test(t) diff --git a/sonar-project.properties b/sonar-project.properties index 57e8e8d..352a773 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -10,4 +10,4 @@ sonar.coverage.exclusions=**/*.test.ts, **/*_test.go, **/contracts/test/**/*, ** # Tests' root folder, inclusions (tests to check and count) and exclusions sonar.tests=. -sonar.test.inclusions=**/*_test.go +sonar.test.inclusions=**/*_test.go \ No newline at end of file diff --git a/tools/simulator/node/add.go b/tools/simulator/node/add.go index fb0a201..eff3c1e 100644 --- a/tools/simulator/node/add.go +++ b/tools/simulator/node/add.go @@ -72,9 +72,7 @@ func (g *Group) Add(conf config.Node) { BinaryNetworkEndpointFactory: simNet, V2Bootstrappers: []commontypes.BootstrapperLocator{}, LocalConfig: types.LocalConfig{ - DefaultMaxDurationInitialization: 30 * time.Second, BlockchainTimeout: time.Second, - ContractConfigLoadTimeout: time.Second, ContractConfigConfirmations: 1, SkipContractConfigConfirmations: false, ContractConfigTrackerPollInterval: 15 * time.Second, diff --git a/tools/simulator/simulate/loader/ocr3config.go b/tools/simulator/simulate/loader/ocr3config.go index f3bcfe1..0d3e81d 100644 --- a/tools/simulator/simulate/loader/ocr3config.go +++ b/tools/simulator/simulate/loader/ocr3config.go @@ -1,7 +1,6 @@ package loader import ( - "context" "log" "sync" @@ -28,7 +27,7 @@ type OffchainKeySourcer interface { } type Digester interface { - ConfigDigest(ctx context.Context, config types.ContractConfig) (types.ConfigDigest, error) + ConfigDigest(config types.ContractConfig) (types.ConfigDigest, error) } type ProgressTelemetry interface { @@ -80,7 +79,7 @@ func (l *OCR3ConfigLoader) Load(block *chain.Block) { // check if new block indicates a new config event should be loaded if evt, ok := l.events[block.Number.String()]; ok { - conf, err := buildConfig(context.Background(), evt, l.oracles, l.digest, l.count+1) + conf, err := buildConfig(evt, l.oracles, l.digest, l.count+1) if err != nil { l.logger.Printf("error building config: %s", err) @@ -118,7 +117,7 @@ func (l *OCR3ConfigLoader) AddSigner(id string, onKey KeySourcer, offKey Offchai l.oracles = append(l.oracles, newOracle) } -func buildConfig(ctx context.Context, conf config.OCR3ConfigEvent, oracles []ocr2config.OracleIdentityExtra, digester Digester, count uint64) (types.ContractConfig, error) { +func buildConfig(conf config.OCR3ConfigEvent, oracles []ocr2config.OracleIdentityExtra, digester Digester, count uint64) (types.ContractConfig, error) { // S is a slice of values that indicate the number of oracles involved // in attempting to transmit. For the simulator, all nodes will be involved // in transmit attempts. @@ -128,18 +127,17 @@ func buildConfig(ctx context.Context, conf config.OCR3ConfigEvent, oracles []ocr } signerOnchainPublicKeys, transmitterAccounts, f, onchainConfig, offchainConfigVersion, offchainConfig, err := ocr3confighelper.ContractSetConfigArgsForTests( - conf.DeltaProgress.Value(), // deltaProgress time.Duratioonfn, - conf.DeltaResend.Value(), // deltaResend time.Duration, - conf.DeltaInitial.Value(), // deltaInitial time.Duration - conf.DeltaRound.Value(), // deltaRound time.Duration, - conf.DeltaGrace.Value(), // deltaGrace time.Duration, - conf.DeltaRequest.Value(), // deltaCertifiedCommitRequest time.Duration - conf.DeltaStage.Value(), // deltaStage time.Duration - conf.Rmax, // rMax uint64 - S, // s []int, - oracles, // oracles []OracleIdentityExtra, - []byte(conf.Offchain), // reportingPluginConfig []byte, - nil, + conf.DeltaProgress.Value(), // deltaProgress time.Duratioonfn, + conf.DeltaResend.Value(), // deltaResend time.Duration, + conf.DeltaInitial.Value(), // deltaInitial time.Duration + conf.DeltaRound.Value(), // deltaRound time.Duration, + conf.DeltaGrace.Value(), // deltaGrace time.Duration, + conf.DeltaRequest.Value(), // deltaCertifiedCommitRequest time.Duration + conf.DeltaStage.Value(), // deltaStage time.Duration + conf.Rmax, // rMax uint64 + S, // s []int, + oracles, // oracles []OracleIdentityExtra, + []byte(conf.Offchain), // reportingPluginConfig []byte, conf.MaxQuery.Value(), // maxDurationQuery time.Duration, conf.MaxObservation.Value(), // maxDurationObservation time.Duration, conf.MaxAccept.Value(), // maxDurationShouldAcceptAttestedReport time.Duration @@ -161,7 +159,7 @@ func buildConfig(ctx context.Context, conf config.OCR3ConfigEvent, oracles []ocr OffchainConfig: offchainConfig, } - digest, _ := digester.ConfigDigest(ctx, contractConf) + digest, _ := digester.ConfigDigest(contractConf) contractConf.ConfigDigest = digest return contractConf, nil diff --git a/tools/simulator/simulate/loader/ocr3config_test.go b/tools/simulator/simulate/loader/ocr3config_test.go index d84b7c2..e1c940f 100644 --- a/tools/simulator/simulate/loader/ocr3config_test.go +++ b/tools/simulator/simulate/loader/ocr3config_test.go @@ -1,7 +1,6 @@ package loader_test import ( - "context" "crypto/rand" "crypto/sha256" "fmt" @@ -60,7 +59,7 @@ type mockDigester struct { mock.Mock } -func (_m *mockDigester) ConfigDigest(ctx context.Context, config types.ContractConfig) (types.ConfigDigest, error) { +func (_m *mockDigester) ConfigDigest(config types.ContractConfig) (types.ConfigDigest, error) { req := _m.Called(config) hash := sha256.Sum256([]byte(fmt.Sprintf("%+v", config))) diff --git a/tools/simulator/simulate/ocr/transmit.go b/tools/simulator/simulate/ocr/transmit.go index c900cf7..ebfb0c4 100644 --- a/tools/simulator/simulate/ocr/transmit.go +++ b/tools/simulator/simulate/ocr/transmit.go @@ -41,7 +41,7 @@ func (tr *OCR3Transmitter) Transmit( } // Account from which the transmitter invokes the contract -func (tr *OCR3Transmitter) FromAccount(ctx context.Context) (types.Account, error) { +func (tr *OCR3Transmitter) FromAccount() (types.Account, error) { tr.mu.RLock() defer tr.mu.RUnlock()