From 0581e896410aeae750325ea8582642378cc6a580 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Wed, 20 Dec 2023 00:21:53 +0000 Subject: [PATCH 1/6] Remove the old types package --- pkg/v3/types/basetypes.go | 349 ----------- pkg/v3/types/basetypes_test.go | 588 ------------------ pkg/v3/types/interfaces.go | 109 ---- .../types/mocks/block_subscriber.generated.go | 75 --- .../conditionalupkeepprovider.generated.go | 56 -- pkg/v3/types/mocks/coordinator.generated.go | 136 ---- pkg/v3/types/mocks/encoder.generated.go | 86 --- .../types/mocks/logeventprovider.generated.go | 56 -- pkg/v3/types/mocks/metadatastore.generated.go | 117 ---- .../types/mocks/payloadbuilder.generated.go | 63 -- pkg/v3/types/mocks/ratio.generated.go | 39 -- .../mocks/recoverableprovider.generated.go | 56 -- pkg/v3/types/mocks/result_store.generated.go | 76 --- pkg/v3/types/mocks/runnable.generated.go | 63 -- .../transmit_event_provider.generated.go | 56 -- .../mocks/upkeep_state_updater.generated.go | 44 -- pkg/v3/types/trigger.go | 87 --- 17 files changed, 2056 deletions(-) delete mode 100644 pkg/v3/types/basetypes.go delete mode 100644 pkg/v3/types/basetypes_test.go delete mode 100644 pkg/v3/types/interfaces.go delete mode 100644 pkg/v3/types/mocks/block_subscriber.generated.go delete mode 100644 pkg/v3/types/mocks/conditionalupkeepprovider.generated.go delete mode 100644 pkg/v3/types/mocks/coordinator.generated.go delete mode 100644 pkg/v3/types/mocks/encoder.generated.go delete mode 100644 pkg/v3/types/mocks/logeventprovider.generated.go delete mode 100644 pkg/v3/types/mocks/metadatastore.generated.go delete mode 100644 pkg/v3/types/mocks/payloadbuilder.generated.go delete mode 100644 pkg/v3/types/mocks/ratio.generated.go delete mode 100644 pkg/v3/types/mocks/recoverableprovider.generated.go delete mode 100644 pkg/v3/types/mocks/result_store.generated.go delete mode 100644 pkg/v3/types/mocks/runnable.generated.go delete mode 100644 pkg/v3/types/mocks/transmit_event_provider.generated.go delete mode 100644 pkg/v3/types/mocks/upkeep_state_updater.generated.go delete mode 100644 pkg/v3/types/trigger.go diff --git a/pkg/v3/types/basetypes.go b/pkg/v3/types/basetypes.go deleted file mode 100644 index bee3a8cb..00000000 --- a/pkg/v3/types/basetypes.go +++ /dev/null @@ -1,349 +0,0 @@ -package types - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - "strings" - "time" -) - -const ( - checkResultDelimiter = 0x09 -) - -// checkResultStringTemplate is a JSON template, used for debugging purposes only. -var checkResultStringTemplate = `{ - "PipelineExecutionState":%d, - "Retryable":%v, - "Eligible":%v, - "IneligibilityReason":%d, - "UpkeepID":%s, - "Trigger":%s, - "WorkID":"%s", - "GasAllocated":%d, - "PerformData":"%s", - "FastGasWei":%s, - "LinkNative":%s, - "RetryInterval":%d -}` - -func init() { - checkResultStringTemplate = strings.Replace(checkResultStringTemplate, " ", "", -1) - checkResultStringTemplate = strings.Replace(checkResultStringTemplate, "\t", "", -1) - checkResultStringTemplate = strings.Replace(checkResultStringTemplate, "\n", "", -1) -} - -type UpkeepType uint8 - -const ( - // Exploratory AUTO 4335: add type for unknown - ConditionTrigger UpkeepType = iota - LogTrigger -) - -type TransmitEventType int - -const ( - UnknownEvent TransmitEventType = iota - PerformEvent - StaleReportEvent - ReorgReportEvent - InsufficientFundsReportEvent -) - -// UpkeepState is a final state of some unit of work. -type UpkeepState uint8 - -const ( - UnknownState UpkeepState = iota - // Performed means the upkeep was performed - Performed - // Ineligible means the upkeep was not eligible to be performed - Ineligible -) - -// UpkeepIdentifier is a unique identifier for the upkeep, represented as uint256 in the contract. -type UpkeepIdentifier [32]byte - -// String returns a base 10 numerical string representation of the upkeep identifier. -func (u UpkeepIdentifier) String() string { - return u.BigInt().String() -} - -func (u UpkeepIdentifier) BigInt() *big.Int { - return big.NewInt(0).SetBytes(u[:]) -} - -// FromBigInt sets the upkeep identifier from a big.Int, -// returning true if the big.Int is valid and false otherwise. -// in case of an invalid big.Int the upkeep identifier is set to 32 zeros. -func (u *UpkeepIdentifier) FromBigInt(i *big.Int) bool { - *u = [32]byte{} - if i.Cmp(big.NewInt(0)) == -1 { - return false - } - b := i.Bytes() - if len(b) == 0 { - return true - } - if len(b) <= 32 { - copy(u[32-len(b):], i.Bytes()) - return true - } - return false -} - -type BlockNumber uint64 - -// BlockKey represent a block (number and hash) -// NOTE: This struct is sent on the p2p network as part of observations to get quorum -// Any change here should be backwards compatible and should keep validation and -// quorum requirements in mind. Please ensure to get a proper review along with an -// upgrade plan before changing this -type BlockKey struct { - Number BlockNumber - Hash [32]byte -} - -type TransmitEvent struct { - // Type describes the type of event - Type TransmitEventType - // TransmitBlock is the block height of the transmit event - TransmitBlock BlockNumber - // Confirmations is the block height behind latest - Confirmations int64 - // TransactionHash is the hash for the transaction where the event originated - TransactionHash [32]byte - // UpkeepID uniquely identifies the upkeep in the registry - UpkeepID UpkeepIdentifier - // WorkID uniquely identifies the unit of work for the specified upkeep - WorkID string - // CheckBlock is the block value that the upkeep was originally checked at - CheckBlock BlockNumber -} - -// NOTE: This struct is sent on the p2p network as part of observations to get quorum -// Any change here should be backwards compatible and should keep validation and -// quorum requirements in mind. Any field that is needed to be encoded should be added -// as well to checkResultMsg struct, and to be encoded/decoded in the MarshalJSON and -// UnmarshalJSON functions. Please ensure to get a proper review along with an upgrade -// plan before changing this. -type CheckResult struct { - // zero if success, else indicates an error code - PipelineExecutionState uint8 - // if PipelineExecutionState is non zero, then retryable indicates that the same - // payload can be processed again in order to get a successful execution - Retryable bool - // Rest of these fields are only applicable if PipelineExecutionState is zero - // Eligible indicates whether this result is eligible to be performed - Eligible bool - // If result is not eligible then the reason it failed. Should be 0 if eligible - IneligibilityReason uint8 - // Upkeep is all the information that identifies the upkeep - UpkeepID UpkeepIdentifier - // Trigger is the event that triggered the upkeep to be checked - Trigger Trigger - // WorkID represents the unit of work for the check result - // Exploratory: Make workID an internal field and an external WorkID() function which generates WID - WorkID string - // GasAllocated is the gas to provide an upkeep in a report - GasAllocated uint64 - // PerformData is the raw data returned when simulating an upkeep perform - PerformData []byte - // FastGasWei is the fast gas price in wei when performing this upkeep - FastGasWei *big.Int - // Link to native ratio to be used when performing this upkeep - LinkNative *big.Int - // RetryInterval is the time interval after which the same payload can be retried. - // This field is used is special cases (such as mercury lookup), where we want to - // have a different retry interval than the default one (30s) - // NOTE: this field is not encoded in JSON and is only used internally - RetryInterval time.Duration -} - -// checkResultMsg is used for encoding and decoding check results. -type checkResultMsg struct { - PipelineExecutionState uint8 - Retryable bool - Eligible bool - IneligibilityReason uint8 - UpkeepID UpkeepIdentifier - Trigger Trigger - WorkID string - GasAllocated uint64 - PerformData []byte - FastGasWei *big.Int - LinkNative *big.Int -} - -// UniqueID returns a unique identifier for the check result. -// It is used to achieve quorum on results before being sent within a report. -func (r CheckResult) UniqueID() string { - var resultBytes []byte - - resultBytes = append(resultBytes, r.PipelineExecutionState) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, []byte(fmt.Sprintf("%+v", r.Retryable))...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, []byte(fmt.Sprintf("%+v", r.Eligible))...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, r.IneligibilityReason) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, r.UpkeepID[:]...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, r.Trigger.BlockHash[:]...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, big.NewInt(int64(r.Trigger.BlockNumber)).Bytes()...) - resultBytes = append(resultBytes, checkResultDelimiter) - - if r.Trigger.LogTriggerExtension != nil { - // Note: We encode the whole trigger extension so the behaiour of - // LogTriggerExtentsion.BlockNumber and LogTriggerExtentsion.BlockHash should be - // consistent across nodes when sending observations - resultBytes = append(resultBytes, []byte(fmt.Sprintf("%+v", r.Trigger.LogTriggerExtension))...) - } - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, r.WorkID[:]...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, big.NewInt(int64(r.GasAllocated)).Bytes()...) - resultBytes = append(resultBytes, checkResultDelimiter) - - resultBytes = append(resultBytes, r.PerformData[:]...) - resultBytes = append(resultBytes, checkResultDelimiter) - - if r.FastGasWei != nil { - resultBytes = append(resultBytes, r.FastGasWei.Bytes()...) - } - resultBytes = append(resultBytes, checkResultDelimiter) - - if r.LinkNative != nil { - resultBytes = append(resultBytes, r.LinkNative.Bytes()...) - } - resultBytes = append(resultBytes, checkResultDelimiter) - - return fmt.Sprintf("%x", resultBytes) -} - -// NOTE: this function is used for debugging purposes only. -// for encoding check results, please use the Encoder interface -func (r CheckResult) String() string { - return fmt.Sprintf( - checkResultStringTemplate, r.PipelineExecutionState, r.Retryable, r.Eligible, - r.IneligibilityReason, r.UpkeepID, r.Trigger, r.WorkID, r.GasAllocated, - hex.EncodeToString(r.PerformData), r.FastGasWei, r.LinkNative, r.RetryInterval, - ) -} - -func (r CheckResult) MarshalJSON() ([]byte, error) { - crm := &checkResultMsg{ - PipelineExecutionState: r.PipelineExecutionState, - Retryable: r.Retryable, - Eligible: r.Eligible, - IneligibilityReason: r.IneligibilityReason, - UpkeepID: r.UpkeepID, - Trigger: r.Trigger, - WorkID: r.WorkID, - GasAllocated: r.GasAllocated, - PerformData: r.PerformData, - FastGasWei: r.FastGasWei, - LinkNative: r.LinkNative, - } - - return json.Marshal(crm) -} - -func (r *CheckResult) UnmarshalJSON(data []byte) error { - var crm checkResultMsg - - if err := json.Unmarshal(data, &crm); err != nil { - return err - } - - r.PipelineExecutionState = crm.PipelineExecutionState - r.Retryable = crm.Retryable - r.Eligible = crm.Eligible - r.IneligibilityReason = crm.IneligibilityReason - r.UpkeepID = crm.UpkeepID - r.Trigger = crm.Trigger - r.WorkID = crm.WorkID - r.GasAllocated = crm.GasAllocated - r.PerformData = crm.PerformData - r.FastGasWei = crm.FastGasWei - r.LinkNative = crm.LinkNative - - return nil -} - -// BlockHistory is a list of block keys -type BlockHistory []BlockKey - -func (bh BlockHistory) Latest() (BlockKey, error) { - if len(bh) == 0 { - return BlockKey{}, fmt.Errorf("empty block history") - } - - return bh[0], nil -} - -type UpkeepPayload struct { - // Upkeep is all the information that identifies the upkeep - UpkeepID UpkeepIdentifier - // Trigger is the event that triggered the upkeep to be checked - Trigger Trigger - // WorkID uniquely identifies the unit of work for the specified upkeep - WorkID string - // CheckData is the data used to check the upkeep - CheckData []byte -} - -// Determines whether the payload is empty, used within filtering -func (p UpkeepPayload) IsEmpty() bool { - return p.WorkID == "" -} - -// CoordinatedBlockProposal is used to represent a unit of work that can be performed -// after a check block has been coordinated between nodes. -// NOTE: This struct is sent on the p2p network as part of observations to get quorum -// Any change here should be backwards compatible and should keep validation and -// quorum requirements in mind. Please ensure to get a proper review along with an -// upgrade plan before changing this -// NOTE: Only the trigger.BlockHash and trigger.BlockNumber are coordinated across -// the network to get a quorum. WorkID is guaranteed to be correctly generated. -// Rest of the fields here SHOULD NOT BE TRUSTED as they can be manipulated by -// a single malicious node. -type CoordinatedBlockProposal struct { - // UpkeepID is the id of the proposed upkeep - UpkeepID UpkeepIdentifier - // Trigger represents the event that triggered the upkeep to be checked - Trigger Trigger - // WorkID represents the unit of work for the coordinated proposal - WorkID string -} - -// ReportedUpkeep contains details of an upkeep for which a report was generated. -type ReportedUpkeep struct { - // UpkeepID id of the underlying upkeep - UpkeepID UpkeepIdentifier - // Trigger data for the upkeep - Trigger Trigger - // WorkID represents the unit of work for the reported upkeep - WorkID string -} - -// RetryRecord is a record of a payload that can be retried after a certain interval. -type RetryRecord struct { - // payload is the desired unit of work to be retried - Payload UpkeepPayload - // Interval is the time interval after which the same payload can be retried. - Interval time.Duration -} diff --git a/pkg/v3/types/basetypes_test.go b/pkg/v3/types/basetypes_test.go deleted file mode 100644 index 233b2890..00000000 --- a/pkg/v3/types/basetypes_test.go +++ /dev/null @@ -1,588 +0,0 @@ -package types - -import ( - "encoding/hex" - "encoding/json" - "fmt" - "math/big" - "reflect" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestTriggerUnmarshal(t *testing.T) { - input := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - } - - encoded, _ := json.Marshal(input) - - rawJSON := `{"BlockNumber":5,"BlockHash":[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4],"LogTriggerExtension":{"TxHash":[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4],"Index":99,"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],"BlockNumber":0}}` - - // the encoded value above should match the rawjson expected - assert.Equal(t, rawJSON, string(encoded), "encoded should match expected") - - // the plugin will decode and re-encode the trigger value at least once - // before some decoding might happen - var decodeOnce Trigger - _ = json.Unmarshal([]byte(rawJSON), &decodeOnce) - - encoded, _ = json.Marshal(decodeOnce) - - // used the re-encoded output to verify data integrity - var output Trigger - err := json.Unmarshal(encoded, &output) - - assert.NoError(t, err, "no error expected from decoding") - - expected := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - } - - assert.Equal(t, expected, output, "decoding should leave extension in its raw encoded state") -} - -func TestTriggerString(t *testing.T) { - input := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - } - - stringified := fmt.Sprintf("%v", input) - expected := ` - { - "BlockNumber":5, - "BlockHash":"0102030401020304010203040102030401020304010203040102030401020304", - "LogTriggerExtension": { - "BlockHash":"0000000000000000000000000000000000000000000000000000000000000000", - "BlockNumber":0, - "Index":99, - "TxHash":"0102030401020304010203040102030401020304010203040102030401020304" - } - }` - - assertJSONEqual(t, expected, stringified) - - input = Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - } - - stringified = fmt.Sprintf("%v", input) - expected = `{"BlockNumber":5,"BlockHash":"0102030401020304010203040102030401020304010203040102030401020304"}` - - assertJSONEqual(t, expected, stringified) -} - -func TestLogIdentifier(t *testing.T) { - input := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - }, - } - - logIdentifier := input.LogTriggerExtension.LogIdentifier() - assert.Equal(t, hex.EncodeToString(logIdentifier), "0102030401020304010203040102030401020304010203040102030401020304010203040102030401020304010203040102030401020304010203040102030400000063") -} - -func TestTriggerUnmarshal_EmptyExtension(t *testing.T) { - input := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - } - - encoded, _ := json.Marshal(input) - - rawJSON := `{"BlockNumber":5,"BlockHash":[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4],"LogTriggerExtension":null}` - - // the encoded value above should match the rawjson expected - assert.Equal(t, rawJSON, string(encoded), "encoded should match expected") - - // the plugin will decode and re-encode the trigger value at least once - // before some decoding might happen - var decodeOnce Trigger - _ = json.Unmarshal([]byte(rawJSON), &decodeOnce) - - encoded, _ = json.Marshal(decodeOnce) - - // used the re-encoded output to verify data integrity - var output Trigger - err := json.Unmarshal(encoded, &output) - - assert.NoError(t, err, "no error expected from decoding") - - expected := Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - } - - assert.Equal(t, expected, output, "decoding should leave extension in its raw encoded state") -} - -func TestUpkeepIdentifier_BigInt(t *testing.T) { - tests := []struct { - name string - id *big.Int - want string - ignoreConvert bool - }{ - { - name: "log trigger from decimal", - id: func() *big.Int { - id, _ := big.NewInt(0).SetString("32329108151019397958065800113404894502874153543356521479058624064899121404671", 10) - return id - }(), - want: "32329108151019397958065800113404894502874153543356521479058624064899121404671", - }, - { - name: "condition trigger from hex", - id: func() *big.Int { - id, _ := big.NewInt(0).SetString("4779a07400000000000000000000000042d780684c0bbe59fab87e6ea7f3daff", 16) - return id - }(), - want: "32329108151019397958065800113404894502533871176435583015595249457467353193215", - }, - { - name: "0 upkeep ID", - id: big.NewInt(0), - want: "0", - }, - { - name: "random upkeep ID", - id: func() *big.Int { - id, _ := big.NewInt(0).SetString("32329108151019423423423", 10) - return id - }(), - want: "32329108151019423423423", - }, - { - name: "negative upkeep ID", - id: big.NewInt(-10), - want: "0", - ignoreConvert: true, - }, - { - name: "max upkeep ID (2^256-1)", - id: func() *big.Int { - id, _ := big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639935", 10) - return id - }(), - want: "115792089237316195423570985008687907853269984665640564039457584007913129639935", - }, - { - name: "out of range upkeep ID (2^256)", - id: func() *big.Int { - id, _ := big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639936", 10) - return id - }(), - want: "0", - ignoreConvert: true, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - uid := new(UpkeepIdentifier) - ok := uid.FromBigInt(tc.id) - assert.Equal(t, !tc.ignoreConvert, ok) - assert.Equal(t, tc.want, uid.String()) - if !tc.ignoreConvert { - assert.Equal(t, tc.id.String(), uid.BigInt().String()) - } - }) - } -} - -func TestCheckResultEncoding(t *testing.T) { - tests := []struct { - name string - input CheckResult - expected string - decoded CheckResult - }{ - { - name: "check result with retry interval", - input: CheckResult{ - PipelineExecutionState: 1, - Retryable: true, - Eligible: true, - IneligibilityReason: 10, - UpkeepID: UpkeepIdentifier{1, 2, 3, 4, 5, 6, 7, 8}, - Trigger: Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - }, - WorkID: "work id", - GasAllocated: 1001, - PerformData: []byte{1, 2, 3, 4, 5, 6}, - FastGasWei: big.NewInt(12), - LinkNative: big.NewInt(13), - RetryInterval: 1, - }, - expected: `{"PipelineExecutionState":1,"Retryable":true,"Eligible":true,"IneligibilityReason":10,"UpkeepID":[1,2,3,4,5,6,7,8,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":5,"BlockHash":[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4],"LogTriggerExtension":{"TxHash":[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4],"Index":99,"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],"BlockNumber":0}},"WorkID":"work id","GasAllocated":1001,"PerformData":"AQIDBAUG","FastGasWei":12,"LinkNative":13}`, - decoded: CheckResult{ - PipelineExecutionState: 1, - Retryable: true, - Eligible: true, - IneligibilityReason: 10, - UpkeepID: UpkeepIdentifier{1, 2, 3, 4, 5, 6, 7, 8}, - Trigger: Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - }, - WorkID: "work id", - GasAllocated: 1001, - PerformData: []byte{1, 2, 3, 4, 5, 6}, - FastGasWei: big.NewInt(12), - LinkNative: big.NewInt(13), - }, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { - encoded, err := json.Marshal(tc.input) - require.NoError(t, err) - assert.Equal(t, tc.expected, string(encoded)) - - var decoded CheckResult - err = json.Unmarshal(encoded, &decoded) - require.NoError(t, err) - assert.True(t, reflect.DeepEqual(tc.decoded, decoded)) - }) - } -} - -func TestCheckResultString(t *testing.T) { - input := CheckResult{ - PipelineExecutionState: 1, - Retryable: true, - Eligible: true, - IneligibilityReason: 10, - UpkeepID: UpkeepIdentifier{1, 2, 3, 4, 5, 6, 7, 8}, - Trigger: Trigger{ - BlockNumber: 5, - BlockHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, - Index: 99, - }, - }, - WorkID: "work id", - GasAllocated: 1001, - PerformData: []byte{1, 2, 3, 4, 5, 6}, - FastGasWei: big.NewInt(12), - LinkNative: big.NewInt(13), - RetryInterval: 1, - } - - result := fmt.Sprintf("%v", input) - expected := ` - { - "PipelineExecutionState":1, - "Retryable":true, - "Eligible":true, - "IneligibilityReason":10, - "UpkeepID":455867356320691211288303676705517652851520854420902457558325773249309310976, - "Trigger": { - "BlockHash":"0102030401020304010203040102030401020304010203040102030401020304", - "BlockNumber":5, - "LogTriggerExtension": { - "BlockHash":"0000000000000000000000000000000000000000000000000000000000000000", - "BlockNumber":0, - "Index":99, - "TxHash":"0102030401020304010203040102030401020304010203040102030401020304" - } - }, - "WorkID":"work id", - "GasAllocated":1001, - "PerformData":"010203040506", - "FastGasWei":12, - "LinkNative":13, - "RetryInterval":1 - } - ` - assertJSONEqual(t, expected, result) - assertJSONContainsAllStructFields(t, result, input) -} - -func TestCheckResult_UniqueID(t *testing.T) { - for _, tc := range []struct { - name string - result CheckResult - wantID string - }{ - { - name: "empty check result", - result: CheckResult{ - PipelineExecutionState: 0, - Retryable: false, - Eligible: false, - IneligibilityReason: 0, - UpkeepID: UpkeepIdentifier{}, - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "000966616c73650966616c736509000900000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "errored execution state", - result: CheckResult{ - PipelineExecutionState: 1, - Retryable: false, - Eligible: false, - IneligibilityReason: 0, - UpkeepID: UpkeepIdentifier{}, - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "010966616c73650966616c736509000900000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "retryable errored execution state", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: false, - IneligibilityReason: 0, - UpkeepID: UpkeepIdentifier{}, - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "0209747275650966616c736509000900000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "retryable eligible errored execution state", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 0, - UpkeepID: UpkeepIdentifier{}, - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "020974727565097472756509000900000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "retryable eligible errored execution state with non zero ineligibilty reason", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier{}, - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "020974727565097472756509060900000000000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "retryable eligible errored execution state with non zero ineligibilty reason and upkeep ID", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier([32]byte{9, 9, 9, 9}), - Trigger: Trigger{}, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "020974727565097472756509060909090909000000000000000000000000000000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000909090909090909", - }, - { - name: "retryable eligible errored execution state with non zero ineligibilty reason, upkeep ID, and trigger", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier([32]byte{9, 9, 9, 9}), - Trigger: Trigger{ - BlockNumber: BlockNumber(44), - BlockHash: [32]byte{8, 8, 8, 8}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{7, 7, 7, 7}, - Index: 63, - BlockHash: [32]byte{6, 6, 6, 6}, - BlockNumber: BlockNumber(55), - }, - }, - WorkID: "", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "02097472756509747275650906090909090900000000000000000000000000000000000000000000000000000000090808080800000000000000000000000000000000000000000000000000000000092c097b22426c6f636b48617368223a2230363036303630363030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c22426c6f636b4e756d626572223a35352c22496e646578223a36332c22547848617368223a2230373037303730373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030227d090909090909", - }, - { - name: "retryable eligible errored execution state with non zero ineligibilty reason, upkeep ID, trigger, and workID", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier([32]byte{9, 9, 9, 9}), - Trigger: Trigger{ - BlockNumber: BlockNumber(44), - BlockHash: [32]byte{8, 8, 8, 8}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{7, 7, 7, 7}, - Index: 63, - BlockHash: [32]byte{6, 6, 6, 6}, - BlockNumber: BlockNumber(55), - }, - }, - WorkID: "abcdef", - GasAllocated: 0, - PerformData: nil, - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "02097472756509747275650906090909090900000000000000000000000000000000000000000000000000000000090808080800000000000000000000000000000000000000000000000000000000092c097b22426c6f636b48617368223a2230363036303630363030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c22426c6f636b4e756d626572223a35352c22496e646578223a36332c22547848617368223a2230373037303730373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030227d096162636465660909090909", - }, - { - name: "retryable eligible errored execution state with non zero ineligibilty reason, upkeep ID, trigger, and workID", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier([32]byte{9, 9, 9, 9}), - Trigger: Trigger{ - BlockNumber: BlockNumber(44), - BlockHash: [32]byte{8, 8, 8, 8}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{7, 7, 7, 7}, - Index: 63, - BlockHash: [32]byte{6, 6, 6, 6}, - BlockNumber: BlockNumber(55), - }, - }, - WorkID: "abcdef", - GasAllocated: 543, - PerformData: []byte("xyz"), - FastGasWei: nil, - LinkNative: nil, - }, - wantID: "02097472756509747275650906090909090900000000000000000000000000000000000000000000000000000000090808080800000000000000000000000000000000000000000000000000000000092c097b22426c6f636b48617368223a2230363036303630363030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c22426c6f636b4e756d626572223a35352c22496e646578223a36332c22547848617368223a2230373037303730373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030227d0961626364656609021f0978797a090909", - }, - { - name: "all fields", - result: CheckResult{ - PipelineExecutionState: 2, - Retryable: true, - Eligible: true, - IneligibilityReason: 6, - UpkeepID: UpkeepIdentifier([32]byte{9, 9, 9, 9}), - Trigger: Trigger{ - BlockNumber: BlockNumber(44), - BlockHash: [32]byte{8, 8, 8, 8}, - LogTriggerExtension: &LogTriggerExtension{ - TxHash: [32]byte{7, 7, 7, 7}, - Index: 63, - BlockHash: [32]byte{6, 6, 6, 6}, - BlockNumber: BlockNumber(55), - }, - }, - WorkID: "abcdef", - GasAllocated: 543, - PerformData: []byte("xyz"), - FastGasWei: big.NewInt(456), - LinkNative: big.NewInt(789), - }, - wantID: "02097472756509747275650906090909090900000000000000000000000000000000000000000000000000000000090808080800000000000000000000000000000000000000000000000000000000092c097b22426c6f636b48617368223a2230363036303630363030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c22426c6f636b4e756d626572223a35352c22496e646578223a36332c22547848617368223a2230373037303730373030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030227d0961626364656609021f0978797a0901c809031509", - }, - } { - t.Run(tc.name, func(t *testing.T) { - id := tc.result.UniqueID() - assert.Equal(t, tc.wantID, id) - }) - } -} - -func assertJSONEqual(t *testing.T, expected, actual string) { - var expectedMap, actualMap map[string]interface{} - require.NoError(t, json.Unmarshal([]byte(expected), &expectedMap), "expected is invalid json") - require.NoError(t, json.Unmarshal([]byte(actual), &actualMap), "actual is invalid json") - assert.True(t, reflect.DeepEqual(expectedMap, actualMap), "expected and result json strings do not match") -} - -func assertJSONContainsAllStructFields(t *testing.T, jsonString string, anyStruct interface{}) { - // if fields are added to the struct in the future, but omitted from the "pretty" string template, this test will fail - var jsonMap map[string]interface{} - var structMap map[string]interface{} - require.NoError(t, json.Unmarshal([]byte(jsonString), &jsonMap), "jsonString is invalid json") - structJson, err := json.Marshal(anyStruct) - require.NoError(t, err) - require.NoError(t, json.Unmarshal(structJson, &structMap)) - assertCongruentKeyStructure(t, structMap, jsonMap) -} - -func assertCongruentKeyStructure(t *testing.T, structMap, jsonMap map[string]interface{}) { - // this functions asserts that the two inputs have congruent key shapes, while disregarding - // the values - for k := range structMap { - assert.True(t, jsonMap[k] != nil, "json string does not contain field %s", k) - if nested1, ok := structMap[k].(map[string]interface{}); ok { - if nested2, ok := jsonMap[k].(map[string]interface{}); ok { - assertCongruentKeyStructure(t, nested1, nested2) - } else { - assert.Fail(t, "maps do not contain the same type for key %s", k) - } - } - } -} diff --git a/pkg/v3/types/interfaces.go b/pkg/v3/types/interfaces.go deleted file mode 100644 index 3b201133..00000000 --- a/pkg/v3/types/interfaces.go +++ /dev/null @@ -1,109 +0,0 @@ -package types - -import ( - "context" -) - -type UpkeepTypeGetter func(UpkeepIdentifier) UpkeepType -type WorkIDGenerator func(UpkeepIdentifier, Trigger) string - -//go:generate mockery --name Encoder --structname MockEncoder --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename encoder.generated.go -type Encoder interface { - Encode(...CheckResult) ([]byte, error) - Extract([]byte) ([]ReportedUpkeep, error) -} - -//go:generate mockery --name LogEventProvider --structname MockLogEventProvider --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename logeventprovider.generated.go -type LogEventProvider interface { - GetLatestPayloads(context.Context) ([]UpkeepPayload, error) -} - -//go:generate mockery --name RecoverableProvider --structname MockRecoverableProvider --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename recoverableprovider.generated.go -type RecoverableProvider interface { - GetRecoveryProposals(context.Context) ([]UpkeepPayload, error) -} - -//go:generate mockery --name TransmitEventProvider --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename transmit_event_provider.generated.go -type TransmitEventProvider interface { - GetLatestEvents(context.Context) ([]TransmitEvent, error) -} - -//go:generate mockery --name ConditionalUpkeepProvider --structname MockConditionalUpkeepProvider --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename conditionalupkeepprovider.generated.go -type ConditionalUpkeepProvider interface { - GetActiveUpkeeps(context.Context) ([]UpkeepPayload, error) -} - -//go:generate mockery --name PayloadBuilder --structname MockPayloadBuilder --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename payloadbuilder.generated.go -type PayloadBuilder interface { - // Can get payloads for a subset of proposals along with an error - BuildPayloads(context.Context, ...CoordinatedBlockProposal) ([]UpkeepPayload, error) -} - -//go:generate mockery --name Runnable --structname MockRunnable --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename runnable.generated.go -type Runnable interface { - // Can get results for a subset of payloads along with an error - CheckUpkeeps(context.Context, ...UpkeepPayload) ([]CheckResult, error) -} - -//go:generate mockery --name BlockSubscriber --structname MockBlockSubscriber --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename block_subscriber.generated.go -type BlockSubscriber interface { - // Subscribe provides an identifier integer, a new channel, and potentially an error - Subscribe() (int, chan BlockHistory, error) - // Unsubscribe requires an identifier integer and indicates the provided channel should be closed - Unsubscribe(int) error -} - -//go:generate mockery --name UpkeepStateUpdater --structname MockUpkeepStateUpdater --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename upkeep_state_updater.generated.go -type UpkeepStateUpdater interface { - SetUpkeepState(context.Context, CheckResult, UpkeepState) error -} - -type RetryQueue interface { - // Enqueue adds new items to the queue - Enqueue(items ...RetryRecord) error - // Dequeue returns the next n items in the queue, considering retry time schedules - Dequeue(n int) ([]UpkeepPayload, error) -} - -type ProposalQueue interface { - // Enqueue adds new items to the queue - Enqueue(items ...CoordinatedBlockProposal) error - // Dequeue returns the next n items in the queue, considering retry time schedules - Dequeue(t UpkeepType, n int) ([]CoordinatedBlockProposal, error) -} - -//go:generate mockery --name ResultStore --structname MockResultStore --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename result_store.generated.go -type ResultStore interface { - Add(...CheckResult) - Remove(...string) - View() ([]CheckResult, error) -} - -//go:generate mockery --name Coordinator --structname MockCoordinator --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename coordinator.generated.go -type Coordinator interface { - PreProcess(_ context.Context, payloads []UpkeepPayload) ([]UpkeepPayload, error) - - Accept(ReportedUpkeep) bool - ShouldTransmit(ReportedUpkeep) bool - FilterResults([]CheckResult) ([]CheckResult, error) - FilterProposals([]CoordinatedBlockProposal) ([]CoordinatedBlockProposal, error) -} - -//go:generate mockery --name MetadataStore --structname MockMetadataStore --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename metadatastore.generated.go -type MetadataStore interface { - SetBlockHistory(BlockHistory) - GetBlockHistory() BlockHistory - - AddProposals(proposals ...CoordinatedBlockProposal) - ViewProposals(utype UpkeepType) []CoordinatedBlockProposal - RemoveProposals(proposals ...CoordinatedBlockProposal) - - Start(context.Context) error - Close() error -} - -//go:generate mockery --name Ratio --structname MockRatio --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename ratio.generated.go -type Ratio interface { - // OfInt should return n out of x such that n/x ~ r (ratio) - OfInt(int) int -} diff --git a/pkg/v3/types/mocks/block_subscriber.generated.go b/pkg/v3/types/mocks/block_subscriber.generated.go deleted file mode 100644 index fa5cc972..00000000 --- a/pkg/v3/types/mocks/block_subscriber.generated.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockBlockSubscriber is an autogenerated mock type for the BlockSubscriber type -type MockBlockSubscriber struct { - mock.Mock -} - -// Subscribe provides a mock function with given fields: -func (_m *MockBlockSubscriber) Subscribe() (int, chan types.BlockHistory, error) { - ret := _m.Called() - - var r0 int - var r1 chan types.BlockHistory - var r2 error - if rf, ok := ret.Get(0).(func() (int, chan types.BlockHistory, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func() chan types.BlockHistory); ok { - r1 = rf() - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(chan types.BlockHistory) - } - } - - if rf, ok := ret.Get(2).(func() error); ok { - r2 = rf() - } else { - r2 = ret.Error(2) - } - - return r0, r1, r2 -} - -// Unsubscribe provides a mock function with given fields: _a0 -func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(int) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewMockBlockSubscriber interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go deleted file mode 100644 index 5c5ee43b..00000000 --- a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockConditionalUpkeepProvider is an autogenerated mock type for the ConditionalUpkeepProvider type -type MockConditionalUpkeepProvider struct { - mock.Mock -} - -// GetActiveUpkeeps provides a mock function with given fields: _a0 -func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ([]types.UpkeepPayload, error) { - ret := _m.Called(_a0) - - var r0 []types.UpkeepPayload - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]types.UpkeepPayload, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) []types.UpkeepPayload); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.UpkeepPayload) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockConditionalUpkeepProvider interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/coordinator.generated.go b/pkg/v3/types/mocks/coordinator.generated.go deleted file mode 100644 index b4a595f6..00000000 --- a/pkg/v3/types/mocks/coordinator.generated.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockCoordinator is an autogenerated mock type for the Coordinator type -type MockCoordinator struct { - mock.Mock -} - -// Accept provides a mock function with given fields: _a0 -func (_m *MockCoordinator) Accept(_a0 types.ReportedUpkeep) bool { - ret := _m.Called(_a0) - - var r0 bool - if rf, ok := ret.Get(0).(func(types.ReportedUpkeep) bool); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// FilterProposals provides a mock function with given fields: _a0 -func (_m *MockCoordinator) FilterProposals(_a0 []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { - ret := _m.Called(_a0) - - var r0 []types.CoordinatedBlockProposal - var r1 error - if rf, ok := ret.Get(0).(func([]types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func([]types.CoordinatedBlockProposal) []types.CoordinatedBlockProposal); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.CoordinatedBlockProposal) - } - } - - if rf, ok := ret.Get(1).(func([]types.CoordinatedBlockProposal) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// FilterResults provides a mock function with given fields: _a0 -func (_m *MockCoordinator) FilterResults(_a0 []types.CheckResult) ([]types.CheckResult, error) { - ret := _m.Called(_a0) - - var r0 []types.CheckResult - var r1 error - if rf, ok := ret.Get(0).(func([]types.CheckResult) ([]types.CheckResult, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func([]types.CheckResult) []types.CheckResult); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.CheckResult) - } - } - - if rf, ok := ret.Get(1).(func([]types.CheckResult) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// PreProcess provides a mock function with given fields: _a0, payloads -func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []types.UpkeepPayload) ([]types.UpkeepPayload, error) { - ret := _m.Called(_a0, payloads) - - var r0 []types.UpkeepPayload - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []types.UpkeepPayload) ([]types.UpkeepPayload, error)); ok { - return rf(_a0, payloads) - } - if rf, ok := ret.Get(0).(func(context.Context, []types.UpkeepPayload) []types.UpkeepPayload); ok { - r0 = rf(_a0, payloads) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.UpkeepPayload) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, []types.UpkeepPayload) error); ok { - r1 = rf(_a0, payloads) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ShouldTransmit provides a mock function with given fields: _a0 -func (_m *MockCoordinator) ShouldTransmit(_a0 types.ReportedUpkeep) bool { - ret := _m.Called(_a0) - - var r0 bool - if rf, ok := ret.Get(0).(func(types.ReportedUpkeep) bool); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -type mockConstructorTestingTNewMockCoordinator interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/encoder.generated.go b/pkg/v3/types/mocks/encoder.generated.go deleted file mode 100644 index a03acc92..00000000 --- a/pkg/v3/types/mocks/encoder.generated.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockEncoder is an autogenerated mock type for the Encoder type -type MockEncoder struct { - mock.Mock -} - -// Encode provides a mock function with given fields: _a0 -func (_m *MockEncoder) Encode(_a0 ...types.CheckResult) ([]byte, error) { - _va := make([]interface{}, len(_a0)) - for _i := range _a0 { - _va[_i] = _a0[_i] - } - var _ca []interface{} - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 []byte - var r1 error - if rf, ok := ret.Get(0).(func(...types.CheckResult) ([]byte, error)); ok { - return rf(_a0...) - } - if rf, ok := ret.Get(0).(func(...types.CheckResult) []byte); ok { - r0 = rf(_a0...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - if rf, ok := ret.Get(1).(func(...types.CheckResult) error); ok { - r1 = rf(_a0...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Extract provides a mock function with given fields: _a0 -func (_m *MockEncoder) Extract(_a0 []byte) ([]types.ReportedUpkeep, error) { - ret := _m.Called(_a0) - - var r0 []types.ReportedUpkeep - var r1 error - if rf, ok := ret.Get(0).(func([]byte) ([]types.ReportedUpkeep, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func([]byte) []types.ReportedUpkeep); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.ReportedUpkeep) - } - } - - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockEncoder interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/logeventprovider.generated.go b/pkg/v3/types/mocks/logeventprovider.generated.go deleted file mode 100644 index e671c4e6..00000000 --- a/pkg/v3/types/mocks/logeventprovider.generated.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockLogEventProvider is an autogenerated mock type for the LogEventProvider type -type MockLogEventProvider struct { - mock.Mock -} - -// GetLatestPayloads provides a mock function with given fields: _a0 -func (_m *MockLogEventProvider) GetLatestPayloads(_a0 context.Context) ([]types.UpkeepPayload, error) { - ret := _m.Called(_a0) - - var r0 []types.UpkeepPayload - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]types.UpkeepPayload, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) []types.UpkeepPayload); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.UpkeepPayload) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockLogEventProvider interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/metadatastore.generated.go b/pkg/v3/types/mocks/metadatastore.generated.go deleted file mode 100644 index e0c761ce..00000000 --- a/pkg/v3/types/mocks/metadatastore.generated.go +++ /dev/null @@ -1,117 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockMetadataStore is an autogenerated mock type for the MetadataStore type -type MockMetadataStore struct { - mock.Mock -} - -// AddProposals provides a mock function with given fields: proposals -func (_m *MockMetadataStore) AddProposals(proposals ...types.CoordinatedBlockProposal) { - _va := make([]interface{}, len(proposals)) - for _i := range proposals { - _va[_i] = proposals[_i] - } - var _ca []interface{} - _ca = append(_ca, _va...) - _m.Called(_ca...) -} - -// Close provides a mock function with given fields: -func (_m *MockMetadataStore) Close() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetBlockHistory provides a mock function with given fields: -func (_m *MockMetadataStore) GetBlockHistory() types.BlockHistory { - ret := _m.Called() - - var r0 types.BlockHistory - if rf, ok := ret.Get(0).(func() types.BlockHistory); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(types.BlockHistory) - } - } - - return r0 -} - -// RemoveProposals provides a mock function with given fields: proposals -func (_m *MockMetadataStore) RemoveProposals(proposals ...types.CoordinatedBlockProposal) { - _va := make([]interface{}, len(proposals)) - for _i := range proposals { - _va[_i] = proposals[_i] - } - var _ca []interface{} - _ca = append(_ca, _va...) - _m.Called(_ca...) -} - -// SetBlockHistory provides a mock function with given fields: _a0 -func (_m *MockMetadataStore) SetBlockHistory(_a0 types.BlockHistory) { - _m.Called(_a0) -} - -// Start provides a mock function with given fields: _a0 -func (_m *MockMetadataStore) Start(_a0 context.Context) error { - ret := _m.Called(_a0) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// ViewProposals provides a mock function with given fields: utype -func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []types.CoordinatedBlockProposal { - ret := _m.Called(utype) - - var r0 []types.CoordinatedBlockProposal - if rf, ok := ret.Get(0).(func(types.UpkeepType) []types.CoordinatedBlockProposal); ok { - r0 = rf(utype) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.CoordinatedBlockProposal) - } - } - - return r0 -} - -type mockConstructorTestingTNewMockMetadataStore interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/payloadbuilder.generated.go b/pkg/v3/types/mocks/payloadbuilder.generated.go deleted file mode 100644 index 9a3baa45..00000000 --- a/pkg/v3/types/mocks/payloadbuilder.generated.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockPayloadBuilder is an autogenerated mock type for the PayloadBuilder type -type MockPayloadBuilder struct { - mock.Mock -} - -// BuildPayloads provides a mock function with given fields: _a0, _a1 -func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...types.CoordinatedBlockProposal) ([]types.UpkeepPayload, error) { - _va := make([]interface{}, len(_a1)) - for _i := range _a1 { - _va[_i] = _a1[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 []types.UpkeepPayload - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, ...types.CoordinatedBlockProposal) ([]types.UpkeepPayload, error)); ok { - return rf(_a0, _a1...) - } - if rf, ok := ret.Get(0).(func(context.Context, ...types.CoordinatedBlockProposal) []types.UpkeepPayload); ok { - r0 = rf(_a0, _a1...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.UpkeepPayload) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, ...types.CoordinatedBlockProposal) error); ok { - r1 = rf(_a0, _a1...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockPayloadBuilder interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/ratio.generated.go b/pkg/v3/types/mocks/ratio.generated.go deleted file mode 100644 index 1f3b9eae..00000000 --- a/pkg/v3/types/mocks/ratio.generated.go +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import mock "github.com/stretchr/testify/mock" - -// MockRatio is an autogenerated mock type for the Ratio type -type MockRatio struct { - mock.Mock -} - -// OfInt provides a mock function with given fields: _a0 -func (_m *MockRatio) OfInt(_a0 int) int { - ret := _m.Called(_a0) - - var r0 int - if rf, ok := ret.Get(0).(func(int) int); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(int) - } - - return r0 -} - -type mockConstructorTestingTNewMockRatio interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/recoverableprovider.generated.go b/pkg/v3/types/mocks/recoverableprovider.generated.go deleted file mode 100644 index 1ae5dfc1..00000000 --- a/pkg/v3/types/mocks/recoverableprovider.generated.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockRecoverableProvider is an autogenerated mock type for the RecoverableProvider type -type MockRecoverableProvider struct { - mock.Mock -} - -// GetRecoveryProposals provides a mock function with given fields: _a0 -func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([]types.UpkeepPayload, error) { - ret := _m.Called(_a0) - - var r0 []types.UpkeepPayload - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]types.UpkeepPayload, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) []types.UpkeepPayload); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.UpkeepPayload) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockRecoverableProvider interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/result_store.generated.go b/pkg/v3/types/mocks/result_store.generated.go deleted file mode 100644 index 008d56e8..00000000 --- a/pkg/v3/types/mocks/result_store.generated.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockResultStore is an autogenerated mock type for the ResultStore type -type MockResultStore struct { - mock.Mock -} - -// Add provides a mock function with given fields: _a0 -func (_m *MockResultStore) Add(_a0 ...types.CheckResult) { - _va := make([]interface{}, len(_a0)) - for _i := range _a0 { - _va[_i] = _a0[_i] - } - var _ca []interface{} - _ca = append(_ca, _va...) - _m.Called(_ca...) -} - -// Remove provides a mock function with given fields: _a0 -func (_m *MockResultStore) Remove(_a0 ...string) { - _va := make([]interface{}, len(_a0)) - for _i := range _a0 { - _va[_i] = _a0[_i] - } - var _ca []interface{} - _ca = append(_ca, _va...) - _m.Called(_ca...) -} - -// View provides a mock function with given fields: -func (_m *MockResultStore) View() ([]types.CheckResult, error) { - ret := _m.Called() - - var r0 []types.CheckResult - var r1 error - if rf, ok := ret.Get(0).(func() ([]types.CheckResult, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() []types.CheckResult); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.CheckResult) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockResultStore interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/runnable.generated.go b/pkg/v3/types/mocks/runnable.generated.go deleted file mode 100644 index a95545c5..00000000 --- a/pkg/v3/types/mocks/runnable.generated.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockRunnable is an autogenerated mock type for the Runnable type -type MockRunnable struct { - mock.Mock -} - -// CheckUpkeeps provides a mock function with given fields: _a0, _a1 -func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...types.UpkeepPayload) ([]types.CheckResult, error) { - _va := make([]interface{}, len(_a1)) - for _i := range _a1 { - _va[_i] = _a1[_i] - } - var _ca []interface{} - _ca = append(_ca, _a0) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 []types.CheckResult - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, ...types.UpkeepPayload) ([]types.CheckResult, error)); ok { - return rf(_a0, _a1...) - } - if rf, ok := ret.Get(0).(func(context.Context, ...types.UpkeepPayload) []types.CheckResult); ok { - r0 = rf(_a0, _a1...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.CheckResult) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, ...types.UpkeepPayload) error); ok { - r1 = rf(_a0, _a1...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewMockRunnable interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/transmit_event_provider.generated.go b/pkg/v3/types/mocks/transmit_event_provider.generated.go deleted file mode 100644 index ad1c0a35..00000000 --- a/pkg/v3/types/mocks/transmit_event_provider.generated.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// TransmitEventProvider is an autogenerated mock type for the TransmitEventProvider type -type TransmitEventProvider struct { - mock.Mock -} - -// GetLatestEvents provides a mock function with given fields: _a0 -func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]types.TransmitEvent, error) { - ret := _m.Called(_a0) - - var r0 []types.TransmitEvent - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]types.TransmitEvent, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(context.Context) []types.TransmitEvent); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]types.TransmitEvent) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type mockConstructorTestingTNewTransmitEventProvider interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/mocks/upkeep_state_updater.generated.go b/pkg/v3/types/mocks/upkeep_state_updater.generated.go deleted file mode 100644 index 10d7d972..00000000 --- a/pkg/v3/types/mocks/upkeep_state_updater.generated.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. - -package mocks - -import ( - context "context" - - types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - mock "github.com/stretchr/testify/mock" -) - -// MockUpkeepStateUpdater is an autogenerated mock type for the UpkeepStateUpdater type -type MockUpkeepStateUpdater struct { - mock.Mock -} - -// SetUpkeepState provides a mock function with given fields: _a0, _a1, _a2 -func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 types.CheckResult, _a2 types.UpkeepState) error { - ret := _m.Called(_a0, _a1, _a2) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, types.CheckResult, types.UpkeepState) error); ok { - r0 = rf(_a0, _a1, _a2) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -type mockConstructorTestingTNewMockUpkeepStateUpdater interface { - mock.TestingT - Cleanup(func()) -} - -// 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) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/v3/types/trigger.go b/pkg/v3/types/trigger.go deleted file mode 100644 index f17b0725..00000000 --- a/pkg/v3/types/trigger.go +++ /dev/null @@ -1,87 +0,0 @@ -package types - -import ( - "bytes" - "encoding/binary" - "encoding/hex" - "fmt" -) - -// Trigger represents a trigger for an upkeep. -// It contains an extension per trigger type, and the block number + hash -// in which the trigger was checked. -// NOTE: This struct is sent on the p2p network as part of observations to get quorum -// Any change here should be backwards compatible and should keep validation and -// quorum requirements in mind. Please ensure to get a proper review along with an -// upgrade plan before changing this -type Trigger struct { - // BlockNumber is the block number in which the trigger was checked - BlockNumber BlockNumber - // BlockHash is the block hash in which the trigger was checked - BlockHash [32]byte - // LogTriggerExtension is the extension for log triggers - LogTriggerExtension *LogTriggerExtension -} - -func (r Trigger) String() string { - res := fmt.Sprintf(`{"BlockNumber":%d,"BlockHash":"%s"`, r.BlockNumber, hex.EncodeToString(r.BlockHash[:])) - if r.LogTriggerExtension != nil { - res += fmt.Sprintf(`,"LogTriggerExtension":%s`, r.LogTriggerExtension) - } - res += "}" - return res -} - -// NewTrigger returns a new basic trigger w/o extension -func NewTrigger(blockNumber BlockNumber, blockHash [32]byte) Trigger { - return Trigger{ - BlockNumber: blockNumber, - BlockHash: blockHash, - } -} - -func NewLogTrigger(blockNumber BlockNumber, blockHash [32]byte, logTriggerExtension *LogTriggerExtension) Trigger { - return Trigger{ - BlockNumber: blockNumber, - BlockHash: blockHash, - LogTriggerExtension: logTriggerExtension, - } -} - -// LogTriggerExtension is the extension used for log triggers, -// It contains information of the log event that was triggered. -// NOTE: This struct is sent on the p2p network as part of observations to get quorum -// Any change here should be backwards compatible and should keep validation and -// quorum requirements in mind. Please ensure to get a proper review along with an -// upgrade plan before changing this -type LogTriggerExtension struct { - // LogTxHash is the transaction hash of the log event - TxHash [32]byte - // Index is the index of the log event in the transaction - Index uint32 - // BlockHash is the block hash in which the event occurred - BlockHash [32]byte - // BlockNumber is the block number in which the event occurred - // NOTE: This field might be empty. If relying on this field check - // it is non empty, if it's empty derive from BlockHash - BlockNumber BlockNumber -} - -// LogIdentifier returns a unique identifier for the log event, -// composed of the transaction hash and the log index bytes. -func (e LogTriggerExtension) LogIdentifier() []byte { - indexBytes := make([]byte, 4) // uint32 is 4 bytes - binary.BigEndian.PutUint32(indexBytes, e.Index) - return bytes.Join([][]byte{ - e.BlockHash[:], - e.TxHash[:], - indexBytes, - }, []byte{}) -} - -func (e LogTriggerExtension) String() string { - return fmt.Sprintf( - `{"BlockHash":"%s","BlockNumber":%d,"Index":%d,"TxHash":"%s"}`, - hex.EncodeToString(e.BlockHash[:]), e.BlockNumber, e.Index, hex.EncodeToString(e.TxHash[:]), - ) -} From a8c9e2a769c95f242199092634982b978f320e44 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Wed, 20 Dec 2023 00:22:02 +0000 Subject: [PATCH 2/6] Add chainlink-common --- go.mod | 11 ++++++----- go.sum | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 8c2713ad..306693c3 100644 --- a/go.mod +++ b/go.mod @@ -11,14 +11,14 @@ require ( github.com/Maldris/mathparse v0.0.0-20170508133428-f0d009a7a773 github.com/ethereum/go-ethereum v1.12.0 github.com/go-echarts/go-echarts/v2 v2.2.6 - github.com/google/uuid v1.3.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/shopspring/decimal v1.3.1 - github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 + github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.9.0 + golang.org/x/crypto v0.14.0 gonum.org/v1/gonum v0.13.0 ) @@ -38,14 +38,15 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect - golang.org/x/sys v0.8.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + golang.org/x/sys v0.13.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 25be189c..df63346a 100644 --- a/go.sum +++ b/go.sum @@ -61,6 +61,7 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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= @@ -114,8 +115,11 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a h1:JlHDpfnKTKOrlUo7dRhvpi71jcVvVMxwGzNVC0jdg+I= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 h1:eSo9r53fARv2MnIO5pqYvQOXMBsTlAwhHyQ6BAVp6bY= github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= +github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= 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= @@ -145,6 +149,7 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= @@ -155,6 +160,7 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -163,6 +169,7 @@ 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +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= From 9f06e3319a2303384d58b8eca4faa7895ea6a984 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Wed, 20 Dec 2023 00:25:37 +0000 Subject: [PATCH 3/6] Use types from chainlink-common Fix import aliases --- pkg/v3/coordinator/coordinator.go | 2 +- pkg/v3/coordinator/coordinator_test.go | 2 +- pkg/v3/flows/conditional.go | 2 +- pkg/v3/flows/conditional_test.go | 4 ++-- pkg/v3/flows/factory.go | 2 +- pkg/v3/flows/factory_test.go | 2 +- pkg/v3/flows/logtrigger.go | 2 +- pkg/v3/flows/logtrigger_test.go | 4 ++-- pkg/v3/flows/recovery.go | 2 +- pkg/v3/flows/recovery_test.go | 4 ++-- pkg/v3/flows/retry.go | 2 +- pkg/v3/flows/retry_test.go | 4 ++-- pkg/v3/observation.go | 2 +- pkg/v3/observation_test.go | 2 +- pkg/v3/observer.go | 2 +- pkg/v3/observer_test.go | 2 +- pkg/v3/outcome.go | 2 +- pkg/v3/outcome_test.go | 2 +- pkg/v3/plugin/coordinated_block_proposals.go | 2 +- pkg/v3/plugin/coordinated_block_proposals_test.go | 2 +- pkg/v3/plugin/delegate.go | 2 +- pkg/v3/plugin/factory.go | 2 +- pkg/v3/plugin/hooks/add_block_history.go | 2 +- pkg/v3/plugin/hooks/add_block_history_test.go | 4 ++-- pkg/v3/plugin/hooks/add_conditional_proposals.go | 2 +- pkg/v3/plugin/hooks/add_conditional_proposals_test.go | 2 +- pkg/v3/plugin/hooks/add_from_staging.go | 4 ++-- pkg/v3/plugin/hooks/add_from_staging_test.go | 4 ++-- pkg/v3/plugin/hooks/add_log_proposals.go | 2 +- pkg/v3/plugin/hooks/add_log_proposals_test.go | 2 +- pkg/v3/plugin/hooks/add_to_proposalq.go | 2 +- pkg/v3/plugin/hooks/add_to_proposalq_test.go | 2 +- pkg/v3/plugin/hooks/remove_from_metadata.go | 2 +- pkg/v3/plugin/hooks/remove_from_metadata_test.go | 4 ++-- pkg/v3/plugin/hooks/remove_from_staging.go | 2 +- pkg/v3/plugin/hooks/remove_from_staging_test.go | 4 ++-- pkg/v3/plugin/ocr3.go | 2 +- pkg/v3/plugin/ocr3_test.go | 2 +- pkg/v3/plugin/performable.go | 2 +- pkg/v3/plugin/performable_test.go | 2 +- pkg/v3/plugin/plugin.go | 2 +- pkg/v3/postprocessors/combine.go | 2 +- pkg/v3/postprocessors/combine_test.go | 2 +- pkg/v3/postprocessors/eligible.go | 2 +- pkg/v3/postprocessors/eligible_test.go | 2 +- pkg/v3/postprocessors/ineligible.go | 2 +- pkg/v3/postprocessors/ineligible_test.go | 2 +- pkg/v3/postprocessors/metadata.go | 2 +- pkg/v3/postprocessors/metadata_test.go | 2 +- pkg/v3/postprocessors/retry.go | 2 +- pkg/v3/postprocessors/retry_test.go | 2 +- pkg/v3/preprocessors/proposal_filterer.go | 2 +- pkg/v3/preprocessors/proposal_filterer_test.go | 2 +- pkg/v3/runner/runner.go | 2 +- pkg/v3/runner/runner_test.go | 4 ++-- pkg/v3/stores/metadata_store.go | 2 +- pkg/v3/stores/metadata_store_test.go | 2 +- pkg/v3/stores/proposal_queue.go | 2 +- pkg/v3/stores/proposal_queue_test.go | 2 +- pkg/v3/stores/result_store.go | 2 +- pkg/v3/stores/result_store_test.go | 2 +- pkg/v3/stores/retry_queue.go | 2 +- pkg/v3/stores/retry_queue_test.go | 2 +- tools/simulator/node/stats.go | 2 +- tools/simulator/simulate/chain/generate.go | 2 +- tools/simulator/simulate/chain/history.go | 2 +- tools/simulator/simulate/db/upkeep.go | 2 +- tools/simulator/simulate/ocr/report.go | 2 +- tools/simulator/simulate/ocr/report_test.go | 2 +- tools/simulator/simulate/upkeep/active_test.go | 2 +- tools/simulator/simulate/upkeep/log_test.go | 2 +- tools/simulator/simulate/upkeep/perform.go | 2 +- tools/simulator/simulate/upkeep/perform_test.go | 2 +- tools/simulator/simulate/upkeep/pipeline.go | 2 +- tools/simulator/simulate/upkeep/pipeline_test.go | 2 +- tools/simulator/simulate/upkeep/source.go | 2 +- tools/simulator/simulate/upkeep/source_test.go | 2 +- tools/simulator/simulate/upkeep/util.go | 2 +- tools/simulator/simulate/upkeep/util_test.go | 2 +- tools/simulator/util/encode.go | 2 +- tools/testprotocol/modify/byte_test.go | 2 +- tools/testprotocol/modify/defaults.go | 2 +- tools/testprotocol/modify/struct.go | 4 ++-- 83 files changed, 94 insertions(+), 94 deletions(-) diff --git a/pkg/v3/coordinator/coordinator.go b/pkg/v3/coordinator/coordinator.go index 42c9c374..6667ac92 100644 --- a/pkg/v3/coordinator/coordinator.go +++ b/pkg/v3/coordinator/coordinator.go @@ -10,7 +10,7 @@ import ( internalutil "github.com/smartcontractkit/chainlink-automation/internal/util" "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/pkg/v3/coordinator/coordinator_test.go b/pkg/v3/coordinator/coordinator_test.go index c0781764..28d88607 100644 --- a/pkg/v3/coordinator/coordinator_test.go +++ b/pkg/v3/coordinator/coordinator_test.go @@ -16,7 +16,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestNewCoordinator(t *testing.T) { diff --git a/pkg/v3/flows/conditional.go b/pkg/v3/flows/conditional.go index 4093fd6b..a6672d14 100644 --- a/pkg/v3/flows/conditional.go +++ b/pkg/v3/flows/conditional.go @@ -13,7 +13,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/pkg/v3/flows/conditional_test.go b/pkg/v3/flows/conditional_test.go index be17bf38..7b09a82e 100644 --- a/pkg/v3/flows/conditional_test.go +++ b/pkg/v3/flows/conditional_test.go @@ -14,8 +14,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestConditionalFinalization(t *testing.T) { diff --git a/pkg/v3/flows/factory.go b/pkg/v3/flows/factory.go index f904ab43..4168f05b 100644 --- a/pkg/v3/flows/factory.go +++ b/pkg/v3/flows/factory.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func ConditionalTriggerFlows( diff --git a/pkg/v3/flows/factory_test.go b/pkg/v3/flows/factory_test.go index 3232b03d..ea27749a 100644 --- a/pkg/v3/flows/factory_test.go +++ b/pkg/v3/flows/factory_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestConditionalTriggerFlows(t *testing.T) { diff --git a/pkg/v3/flows/logtrigger.go b/pkg/v3/flows/logtrigger.go index c78f640c..728bd725 100644 --- a/pkg/v3/flows/logtrigger.go +++ b/pkg/v3/flows/logtrigger.go @@ -11,7 +11,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( diff --git a/pkg/v3/flows/logtrigger_test.go b/pkg/v3/flows/logtrigger_test.go index 1e025584..8457094d 100644 --- a/pkg/v3/flows/logtrigger_test.go +++ b/pkg/v3/flows/logtrigger_test.go @@ -14,8 +14,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestLogTriggerFlow(t *testing.T) { diff --git a/pkg/v3/flows/recovery.go b/pkg/v3/flows/recovery.go index f045b908..ca94d3ee 100644 --- a/pkg/v3/flows/recovery.go +++ b/pkg/v3/flows/recovery.go @@ -12,7 +12,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/pkg/v3/flows/recovery_test.go b/pkg/v3/flows/recovery_test.go index fe606ffe..434c8879 100644 --- a/pkg/v3/flows/recovery_test.go +++ b/pkg/v3/flows/recovery_test.go @@ -14,8 +14,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestRecoveryFinalization(t *testing.T) { diff --git a/pkg/v3/flows/retry.go b/pkg/v3/flows/retry.go index 4e0df9cb..0f41dc79 100644 --- a/pkg/v3/flows/retry.go +++ b/pkg/v3/flows/retry.go @@ -11,7 +11,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/pkg/v3/flows/retry_test.go b/pkg/v3/flows/retry_test.go index dc472665..08c8c4a9 100644 --- a/pkg/v3/flows/retry_test.go +++ b/pkg/v3/flows/retry_test.go @@ -10,8 +10,8 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/v3/observation.go b/pkg/v3/observation.go index 85cd11a1..6c8660b6 100644 --- a/pkg/v3/observation.go +++ b/pkg/v3/observation.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // NOTE: Any change to these values should keep backwards compatibility in mind diff --git a/pkg/v3/observation_test.go b/pkg/v3/observation_test.go index 75b5bfc3..80c3f078 100644 --- a/pkg/v3/observation_test.go +++ b/pkg/v3/observation_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var conditionalUpkeepID = [32]byte{1} diff --git a/pkg/v3/observer.go b/pkg/v3/observer.go index 3e611015..337495a3 100644 --- a/pkg/v3/observer.go +++ b/pkg/v3/observer.go @@ -6,7 +6,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // PreProcessor is the general interface for middleware used to filter, add, or modify upkeep diff --git a/pkg/v3/observer_test.go b/pkg/v3/observer_test.go index 24b254f7..b3d3a624 100644 --- a/pkg/v3/observer_test.go +++ b/pkg/v3/observer_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type mockTick struct { diff --git a/pkg/v3/outcome.go b/pkg/v3/outcome.go index d61d2fe8..6e88b777 100644 --- a/pkg/v3/outcome.go +++ b/pkg/v3/outcome.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // NOTE: Any change to these values should keep backwards compatibility in mind diff --git a/pkg/v3/outcome_test.go b/pkg/v3/outcome_test.go index 3e45101e..d93ae36a 100644 --- a/pkg/v3/outcome_test.go +++ b/pkg/v3/outcome_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var validOutcome = AutomationOutcome{ diff --git a/pkg/v3/plugin/coordinated_block_proposals.go b/pkg/v3/plugin/coordinated_block_proposals.go index 01e1ee1e..4df1ddaa 100644 --- a/pkg/v3/plugin/coordinated_block_proposals.go +++ b/pkg/v3/plugin/coordinated_block_proposals.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type coordinatedBlockProposals struct { diff --git a/pkg/v3/plugin/coordinated_block_proposals_test.go b/pkg/v3/plugin/coordinated_block_proposals_test.go index 2831c718..9d8b3f0c 100644 --- a/pkg/v3/plugin/coordinated_block_proposals_test.go +++ b/pkg/v3/plugin/coordinated_block_proposals_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func Test_newCoordinatedBlockProposals_add(t *testing.T) { diff --git a/pkg/v3/plugin/delegate.go b/pkg/v3/plugin/delegate.go index 789c027a..1300d84a 100644 --- a/pkg/v3/plugin/delegate.go +++ b/pkg/v3/plugin/delegate.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/runner" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( diff --git a/pkg/v3/plugin/factory.go b/pkg/v3/plugin/factory.go index d1254c45..07d81a59 100644 --- a/pkg/v3/plugin/factory.go +++ b/pkg/v3/plugin/factory.go @@ -12,7 +12,7 @@ import ( ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/runner" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type pluginFactory struct { diff --git a/pkg/v3/plugin/hooks/add_block_history.go b/pkg/v3/plugin/hooks/add_block_history.go index e1303c5f..a456a755 100644 --- a/pkg/v3/plugin/hooks/add_block_history.go +++ b/pkg/v3/plugin/hooks/add_block_history.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type AddBlockHistoryHook struct { diff --git a/pkg/v3/plugin/hooks/add_block_history_test.go b/pkg/v3/plugin/hooks/add_block_history_test.go index e38f7203..430cf46a 100644 --- a/pkg/v3/plugin/hooks/add_block_history_test.go +++ b/pkg/v3/plugin/hooks/add_block_history_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestAddBlockHistoryHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_conditional_proposals.go b/pkg/v3/plugin/hooks/add_conditional_proposals.go index 73b2cc12..b6fd7ed4 100644 --- a/pkg/v3/plugin/hooks/add_conditional_proposals.go +++ b/pkg/v3/plugin/hooks/add_conditional_proposals.go @@ -8,7 +8,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type AddConditionalProposalsHook struct { diff --git a/pkg/v3/plugin/hooks/add_conditional_proposals_test.go b/pkg/v3/plugin/hooks/add_conditional_proposals_test.go index 2b7c14b5..e57141cf 100644 --- a/pkg/v3/plugin/hooks/add_conditional_proposals_test.go +++ b/pkg/v3/plugin/hooks/add_conditional_proposals_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddConditionalSamplesHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_from_staging.go b/pkg/v3/plugin/hooks/add_from_staging.go index 4c8ebed2..1a0335ec 100644 --- a/pkg/v3/plugin/hooks/add_from_staging.go +++ b/pkg/v3/plugin/hooks/add_from_staging.go @@ -8,8 +8,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewAddFromStagingHook(store ocr2keepers.ResultStore, coord types.Coordinator, logger *log.Logger) AddFromStagingHook { diff --git a/pkg/v3/plugin/hooks/add_from_staging_test.go b/pkg/v3/plugin/hooks/add_from_staging_test.go index 877c7086..ba6ce52a 100644 --- a/pkg/v3/plugin/hooks/add_from_staging_test.go +++ b/pkg/v3/plugin/hooks/add_from_staging_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/mock" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestAddFromStagingHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_log_proposals.go b/pkg/v3/plugin/hooks/add_log_proposals.go index 755c9d14..d2bab052 100644 --- a/pkg/v3/plugin/hooks/add_log_proposals.go +++ b/pkg/v3/plugin/hooks/add_log_proposals.go @@ -8,7 +8,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type AddLogProposalsHook struct { diff --git a/pkg/v3/plugin/hooks/add_log_proposals_test.go b/pkg/v3/plugin/hooks/add_log_proposals_test.go index b8baaa02..0c5e82a2 100644 --- a/pkg/v3/plugin/hooks/add_log_proposals_test.go +++ b/pkg/v3/plugin/hooks/add_log_proposals_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_to_proposalq.go b/pkg/v3/plugin/hooks/add_to_proposalq.go index 856248fe..093ef093 100644 --- a/pkg/v3/plugin/hooks/add_to_proposalq.go +++ b/pkg/v3/plugin/hooks/add_to_proposalq.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewAddToProposalQHook(proposalQ ocr2keepers.ProposalQueue, logger *log.Logger) AddToProposalQHook { diff --git a/pkg/v3/plugin/hooks/add_to_proposalq_test.go b/pkg/v3/plugin/hooks/add_to_proposalq_test.go index b0818e7e..a9e05695 100644 --- a/pkg/v3/plugin/hooks/add_to_proposalq_test.go +++ b/pkg/v3/plugin/hooks/add_to_proposalq_test.go @@ -9,7 +9,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddToProposalQHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/remove_from_metadata.go b/pkg/v3/plugin/hooks/remove_from_metadata.go index 4a707b9b..71e48a45 100644 --- a/pkg/v3/plugin/hooks/remove_from_metadata.go +++ b/pkg/v3/plugin/hooks/remove_from_metadata.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewRemoveFromMetadataHook(ms types.MetadataStore, logger *log.Logger) RemoveFromMetadataHook { diff --git a/pkg/v3/plugin/hooks/remove_from_metadata_test.go b/pkg/v3/plugin/hooks/remove_from_metadata_test.go index fddd7bc8..27768cee 100644 --- a/pkg/v3/plugin/hooks/remove_from_metadata_test.go +++ b/pkg/v3/plugin/hooks/remove_from_metadata_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/mock" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestRemoveFromMetadataHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/remove_from_staging.go b/pkg/v3/plugin/hooks/remove_from_staging.go index 7bfa8959..62b44bea 100644 --- a/pkg/v3/plugin/hooks/remove_from_staging.go +++ b/pkg/v3/plugin/hooks/remove_from_staging.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewRemoveFromStagingHook(store types.ResultStore, logger *log.Logger) RemoveFromStagingHook { diff --git a/pkg/v3/plugin/hooks/remove_from_staging_test.go b/pkg/v3/plugin/hooks/remove_from_staging_test.go index 74e7facc..4f7a63f2 100644 --- a/pkg/v3/plugin/hooks/remove_from_staging_test.go +++ b/pkg/v3/plugin/hooks/remove_from_staging_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestRemoveFromStagingHook(t *testing.T) { diff --git a/pkg/v3/plugin/ocr3.go b/pkg/v3/plugin/ocr3.go index 31e33742..d2109f22 100644 --- a/pkg/v3/plugin/ocr3.go +++ b/pkg/v3/plugin/ocr3.go @@ -14,7 +14,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin/hooks" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type AutomationReportInfo struct{} diff --git a/pkg/v3/plugin/ocr3_test.go b/pkg/v3/plugin/ocr3_test.go index 6dc43dc2..db0477de 100644 --- a/pkg/v3/plugin/ocr3_test.go +++ b/pkg/v3/plugin/ocr3_test.go @@ -20,7 +20,7 @@ import ( ocr2keepers2 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin/hooks" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestOcr3Plugin_Query(t *testing.T) { diff --git a/pkg/v3/plugin/performable.go b/pkg/v3/plugin/performable.go index 64fc074d..c17884ff 100644 --- a/pkg/v3/plugin/performable.go +++ b/pkg/v3/plugin/performable.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type resultAndCount struct { diff --git a/pkg/v3/plugin/performable_test.go b/pkg/v3/plugin/performable_test.go index 502ab5a6..20573250 100644 --- a/pkg/v3/plugin/performable_test.go +++ b/pkg/v3/plugin/performable_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestPerformables(t *testing.T) { diff --git a/pkg/v3/plugin/plugin.go b/pkg/v3/plugin/plugin.go index ad48aa4d..c02a4d88 100644 --- a/pkg/v3/plugin/plugin.go +++ b/pkg/v3/plugin/plugin.go @@ -15,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func newPlugin( diff --git a/pkg/v3/postprocessors/combine.go b/pkg/v3/postprocessors/combine.go index 825947d4..e777d11c 100644 --- a/pkg/v3/postprocessors/combine.go +++ b/pkg/v3/postprocessors/combine.go @@ -4,7 +4,7 @@ import ( "context" "errors" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // CombinedPostprocessor ... diff --git a/pkg/v3/postprocessors/combine_test.go b/pkg/v3/postprocessors/combine_test.go index f4d104a3..b3b6cd80 100644 --- a/pkg/v3/postprocessors/combine_test.go +++ b/pkg/v3/postprocessors/combine_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/v3/postprocessors/eligible.go b/pkg/v3/postprocessors/eligible.go index 7b960cb4..d1d94b33 100644 --- a/pkg/v3/postprocessors/eligible.go +++ b/pkg/v3/postprocessors/eligible.go @@ -6,7 +6,7 @@ import ( "log" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // checkResultAdder is a general interface for a result store that accepts check results diff --git a/pkg/v3/postprocessors/eligible_test.go b/pkg/v3/postprocessors/eligible_test.go index d0696af6..7d874ab4 100644 --- a/pkg/v3/postprocessors/eligible_test.go +++ b/pkg/v3/postprocessors/eligible_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestNewEligiblePostProcessor(t *testing.T) { diff --git a/pkg/v3/postprocessors/ineligible.go b/pkg/v3/postprocessors/ineligible.go index 8d6236bb..efa3c2a0 100644 --- a/pkg/v3/postprocessors/ineligible.go +++ b/pkg/v3/postprocessors/ineligible.go @@ -7,7 +7,7 @@ import ( "log" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type ineligiblePostProcessor struct { diff --git a/pkg/v3/postprocessors/ineligible_test.go b/pkg/v3/postprocessors/ineligible_test.go index b3a87da0..2bf349f2 100644 --- a/pkg/v3/postprocessors/ineligible_test.go +++ b/pkg/v3/postprocessors/ineligible_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestNewIneligiblePostProcessor(t *testing.T) { diff --git a/pkg/v3/postprocessors/metadata.go b/pkg/v3/postprocessors/metadata.go index d5b2f946..02bfd5cd 100644 --- a/pkg/v3/postprocessors/metadata.go +++ b/pkg/v3/postprocessors/metadata.go @@ -3,7 +3,7 @@ package postprocessors import ( "context" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type addProposalToMetadataStore struct { diff --git a/pkg/v3/postprocessors/metadata_test.go b/pkg/v3/postprocessors/metadata_test.go index a13d0d43..6d0cddc2 100644 --- a/pkg/v3/postprocessors/metadata_test.go +++ b/pkg/v3/postprocessors/metadata_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestMetadataAddSamples(t *testing.T) { diff --git a/pkg/v3/postprocessors/retry.go b/pkg/v3/postprocessors/retry.go index 06a419c7..f0e628b0 100644 --- a/pkg/v3/postprocessors/retry.go +++ b/pkg/v3/postprocessors/retry.go @@ -7,7 +7,7 @@ import ( "log" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewRetryablePostProcessor(q ocr2keepers.RetryQueue, logger *log.Logger) *retryablePostProcessor { diff --git a/pkg/v3/postprocessors/retry_test.go b/pkg/v3/postprocessors/retry_test.go index 3e97775e..edf0da48 100644 --- a/pkg/v3/postprocessors/retry_test.go +++ b/pkg/v3/postprocessors/retry_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestRetryPostProcessor_PostProcess(t *testing.T) { diff --git a/pkg/v3/preprocessors/proposal_filterer.go b/pkg/v3/preprocessors/proposal_filterer.go index b83f4003..7e03fd03 100644 --- a/pkg/v3/preprocessors/proposal_filterer.go +++ b/pkg/v3/preprocessors/proposal_filterer.go @@ -4,7 +4,7 @@ import ( "context" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func NewProposalFilterer(metadata ocr2keepers.MetadataStore, upkeepType ocr2keepers.UpkeepType) ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload] { diff --git a/pkg/v3/preprocessors/proposal_filterer_test.go b/pkg/v3/preprocessors/proposal_filterer_test.go index f7355fb4..2d8336c5 100644 --- a/pkg/v3/preprocessors/proposal_filterer_test.go +++ b/pkg/v3/preprocessors/proposal_filterer_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestProposalFilterer_PreProcess(t *testing.T) { diff --git a/pkg/v3/runner/runner.go b/pkg/v3/runner/runner.go index 54426a2a..a5a7a008 100644 --- a/pkg/v3/runner/runner.go +++ b/pkg/v3/runner/runner.go @@ -11,7 +11,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/internal/util" pkgutil "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const WorkerBatchLimit int = 10 diff --git a/pkg/v3/runner/runner_test.go b/pkg/v3/runner/runner_test.go index 0bd9aeac..4cef8743 100644 --- a/pkg/v3/runner/runner_test.go +++ b/pkg/v3/runner/runner_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) var ( diff --git a/pkg/v3/stores/metadata_store.go b/pkg/v3/stores/metadata_store.go index 74045f93..627f3649 100644 --- a/pkg/v3/stores/metadata_store.go +++ b/pkg/v3/stores/metadata_store.go @@ -8,7 +8,7 @@ import ( "sync/atomic" "time" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/pkg/v3/stores/metadata_store_test.go b/pkg/v3/stores/metadata_store_test.go index fe528c6a..2049a780 100644 --- a/pkg/v3/stores/metadata_store_test.go +++ b/pkg/v3/stores/metadata_store_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestNewMetadataStore(t *testing.T) { diff --git a/pkg/v3/stores/proposal_queue.go b/pkg/v3/stores/proposal_queue.go index 06075dd7..7dde5fa7 100644 --- a/pkg/v3/stores/proposal_queue.go +++ b/pkg/v3/stores/proposal_queue.go @@ -4,7 +4,7 @@ import ( "sync" "time" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type proposalQueueRecord struct { diff --git a/pkg/v3/stores/proposal_queue_test.go b/pkg/v3/stores/proposal_queue_test.go index 6c1edc62..b6229f8f 100644 --- a/pkg/v3/stores/proposal_queue_test.go +++ b/pkg/v3/stores/proposal_queue_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestProposalQueue_Enqueue(t *testing.T) { diff --git a/pkg/v3/stores/result_store.go b/pkg/v3/stores/result_store.go index b9d9b7b4..d0c768c6 100644 --- a/pkg/v3/stores/result_store.go +++ b/pkg/v3/stores/result_store.go @@ -8,7 +8,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( diff --git a/pkg/v3/stores/result_store_test.go b/pkg/v3/stores/result_store_test.go index cd5cf6b2..70e3abdf 100644 --- a/pkg/v3/stores/result_store_test.go +++ b/pkg/v3/stores/result_store_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/stretchr/testify/assert" ) diff --git a/pkg/v3/stores/retry_queue.go b/pkg/v3/stores/retry_queue.go index 306d96d6..68a9e7b2 100644 --- a/pkg/v3/stores/retry_queue.go +++ b/pkg/v3/stores/retry_queue.go @@ -7,7 +7,7 @@ import ( "time" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( diff --git a/pkg/v3/stores/retry_queue_test.go b/pkg/v3/stores/retry_queue_test.go index 30f3983a..8c2dfe58 100644 --- a/pkg/v3/stores/retry_queue_test.go +++ b/pkg/v3/stores/retry_queue_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func overrideDefaults(expiration, retryInterval time.Duration) func() { diff --git a/tools/simulator/node/stats.go b/tools/simulator/node/stats.go index 5d2a7ea3..f8b99846 100644 --- a/tools/simulator/node/stats.go +++ b/tools/simulator/node/stats.go @@ -5,7 +5,7 @@ import ( "math/big" "sort" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" ) diff --git a/tools/simulator/simulate/chain/generate.go b/tools/simulator/simulate/chain/generate.go index 8269b598..b0091edc 100644 --- a/tools/simulator/simulate/chain/generate.go +++ b/tools/simulator/simulate/chain/generate.go @@ -8,7 +8,7 @@ import ( "github.com/Maldris/mathparse" "github.com/shopspring/decimal" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" ) diff --git a/tools/simulator/simulate/chain/history.go b/tools/simulator/simulate/chain/history.go index c868f41b..63376439 100644 --- a/tools/simulator/simulate/chain/history.go +++ b/tools/simulator/simulate/chain/history.go @@ -5,7 +5,7 @@ import ( "runtime" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/db/upkeep.go b/tools/simulator/simulate/db/upkeep.go index 1de9814d..9d4c1ce4 100644 --- a/tools/simulator/simulate/db/upkeep.go +++ b/tools/simulator/simulate/db/upkeep.go @@ -3,7 +3,7 @@ package db import ( "context" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type UpkeepStateDatabase struct { diff --git a/tools/simulator/simulate/ocr/report.go b/tools/simulator/simulate/ocr/report.go index c107478d..f1ca9b33 100644 --- a/tools/simulator/simulate/ocr/report.go +++ b/tools/simulator/simulate/ocr/report.go @@ -8,7 +8,7 @@ import ( "runtime" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/ocr/report_test.go b/tools/simulator/simulate/ocr/report_test.go index 89e4ebb7..df9f88f7 100644 --- a/tools/simulator/simulate/ocr/report_test.go +++ b/tools/simulator/simulate/ocr/report_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/ocr" diff --git a/tools/simulator/simulate/upkeep/active_test.go b/tools/simulator/simulate/upkeep/active_test.go index 9de71395..464db728 100644 --- a/tools/simulator/simulate/upkeep/active_test.go +++ b/tools/simulator/simulate/upkeep/active_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/log_test.go b/tools/simulator/simulate/upkeep/log_test.go index 0bf72539..aa9cf59c 100644 --- a/tools/simulator/simulate/upkeep/log_test.go +++ b/tools/simulator/simulate/upkeep/log_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/perform.go b/tools/simulator/simulate/upkeep/perform.go index b769a322..03ab1019 100644 --- a/tools/simulator/simulate/upkeep/perform.go +++ b/tools/simulator/simulate/upkeep/perform.go @@ -6,7 +6,7 @@ import ( "runtime" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/upkeep/perform_test.go b/tools/simulator/simulate/upkeep/perform_test.go index 601c34d7..870a81e5 100644 --- a/tools/simulator/simulate/upkeep/perform_test.go +++ b/tools/simulator/simulate/upkeep/perform_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/pipeline.go b/tools/simulator/simulate/upkeep/pipeline.go index c5d0733a..9826f5bd 100644 --- a/tools/simulator/simulate/upkeep/pipeline.go +++ b/tools/simulator/simulate/upkeep/pipeline.go @@ -6,7 +6,7 @@ import ( "math/big" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/net" ) diff --git a/tools/simulator/simulate/upkeep/pipeline_test.go b/tools/simulator/simulate/upkeep/pipeline_test.go index c7e0d47d..8cf8ae39 100644 --- a/tools/simulator/simulate/upkeep/pipeline_test.go +++ b/tools/simulator/simulate/upkeep/pipeline_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" diff --git a/tools/simulator/simulate/upkeep/source.go b/tools/simulator/simulate/upkeep/source.go index 65279093..f0b17cac 100644 --- a/tools/simulator/simulate/upkeep/source.go +++ b/tools/simulator/simulate/upkeep/source.go @@ -5,7 +5,7 @@ import ( "log" "math/big" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/upkeep/source_test.go b/tools/simulator/simulate/upkeep/source_test.go index 8fa0d852..24b10185 100644 --- a/tools/simulator/simulate/upkeep/source_test.go +++ b/tools/simulator/simulate/upkeep/source_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/util.go b/tools/simulator/simulate/upkeep/util.go index 25e2f04e..56af5276 100644 --- a/tools/simulator/simulate/upkeep/util.go +++ b/tools/simulator/simulate/upkeep/util.go @@ -3,7 +3,7 @@ package upkeep import ( "fmt" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/upkeep/util_test.go b/tools/simulator/simulate/upkeep/util_test.go index 4145bdd1..74e05741 100644 --- a/tools/simulator/simulate/upkeep/util_test.go +++ b/tools/simulator/simulate/upkeep/util_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" ) diff --git a/tools/simulator/util/encode.go b/tools/simulator/util/encode.go index b2c73903..7376a7c3 100644 --- a/tools/simulator/util/encode.go +++ b/tools/simulator/util/encode.go @@ -8,7 +8,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( diff --git a/tools/testprotocol/modify/byte_test.go b/tools/testprotocol/modify/byte_test.go index 70e925ad..9ba42ad4 100644 --- a/tools/testprotocol/modify/byte_test.go +++ b/tools/testprotocol/modify/byte_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - ocr2keeperstypes "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keeperstypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/testprotocol/modify" ) diff --git a/tools/testprotocol/modify/defaults.go b/tools/testprotocol/modify/defaults.go index 7d56b3b8..eb4fc73f 100644 --- a/tools/testprotocol/modify/defaults.go +++ b/tools/testprotocol/modify/defaults.go @@ -1,6 +1,6 @@ package modify -import "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" +import types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" var ( ObservationModifiers = []NamedModifier{ diff --git a/tools/testprotocol/modify/struct.go b/tools/testprotocol/modify/struct.go index 6cc4f9ea..08aea87c 100644 --- a/tools/testprotocol/modify/struct.go +++ b/tools/testprotocol/modify/struct.go @@ -5,8 +5,8 @@ import ( "fmt" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" - ocr2keeperstypes "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keeperstypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type NamedModifier func(context.Context, interface{}, error) (string, []byte, error) From 277c810affb616b99ff31789376527cb3cc58bd9 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Wed, 20 Dec 2023 02:06:17 +0000 Subject: [PATCH 4/6] Bump common and tests Update mock Update mocks bump --- go.mod | 2 +- go.sum | 50 +++++++++---------- pkg/v2/coordinator/mocks/encoder.generated.go | 23 ++++++--- .../mocks/log_provider.generated.go | 19 ++++--- pkg/v2/mocks/logger.generated.go | 11 ++-- pkg/v3/flows/factory_test.go | 8 +++ pkg/v3/postprocessors/metadata_test.go | 12 ++++- pkg/v3/stores/metadata_store_test.go | 8 +++ tools/simulator/simulate/chain/history.go | 11 +++- tools/simulator/simulate/upkeep/source.go | 10 +++- 10 files changed, 105 insertions(+), 49 deletions(-) diff --git a/go.mod b/go.mod index 306693c3..714cd358 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/jedib0t/go-pretty/v6 v6.4.7 github.com/pkg/errors v0.9.1 github.com/shopspring/decimal v1.3.1 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565 github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -38,7 +39,6 @@ require ( github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.1 // indirect diff --git a/go.sum b/go.sum index df63346a..0a40ce4f 100644 --- a/go.sum +++ b/go.sum @@ -52,15 +52,14 @@ 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.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +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.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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/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= @@ -99,14 +98,14 @@ github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdL github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= -github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM= +github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -115,10 +114,9 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a h1:JlHDpfnKTKOrlUo7dRhvpi71jcVvVMxwGzNVC0jdg+I= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231219235720-570e81c70a1a/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= -github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6 h1:eSo9r53fARv2MnIO5pqYvQOXMBsTlAwhHyQ6BAVp6bY= -github.com/smartcontractkit/libocr v0.0.0-20230922131214-122accb19ea6/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565 h1:5cZ5p0RXwxj4H/02/7ul/ysJ6y1jIqsXqXqYW1CfOWs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= +github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 h1:R9NkVN+1fooUJFsN9zj9gDY1B+zv54zNO785RQZRVfE= github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -147,28 +145,26 @@ github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFi github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= 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.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +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= diff --git a/pkg/v2/coordinator/mocks/encoder.generated.go b/pkg/v2/coordinator/mocks/encoder.generated.go index 07fe4cc6..aa1ab638 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.28.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -16,6 +16,10 @@ 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 { @@ -40,6 +44,10 @@ 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 { @@ -64,6 +72,10 @@ 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 @@ -93,13 +105,12 @@ func (_m *Encoder) SplitUpkeepKey(_a0 ocr2keepers.UpkeepKey) (ocr2keepers.BlockK return r0, r1, r2 } -type mockConstructorTestingTNewEncoder interface { +// 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 { mock.TestingT Cleanup(func()) -} - -// 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 { +}) *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 74458572..6dbaf7aa 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.28.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ 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 { @@ -45,6 +49,10 @@ 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 { @@ -67,13 +75,12 @@ func (_m *LogProvider) StaleReportLogs(_a0 context.Context) ([]ocr2keepers.Stale return r0, r1 } -type mockConstructorTestingTNewLogProvider interface { +// 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 { mock.TestingT Cleanup(func()) -} - -// 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 { +}) *LogProvider { mock := &LogProvider{} mock.Mock.Test(t) diff --git a/pkg/v2/mocks/logger.generated.go b/pkg/v2/mocks/logger.generated.go index a8176dd1..58976d4f 100644 --- a/pkg/v2/mocks/logger.generated.go +++ b/pkg/v2/mocks/logger.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.28.1. DO NOT EDIT. +// Code generated by mockery v2.38.0. DO NOT EDIT. package mocks @@ -42,13 +42,12 @@ func (_m *MockLogger) Warn(msg string, fields commontypes.LogFields) { _m.Called(msg, fields) } -type mockConstructorTestingTNewMockLogger interface { +// 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 { mock.TestingT Cleanup(func()) -} - -// 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 { +}) *MockLogger { mock := &MockLogger{} mock.Mock.Test(t) diff --git a/pkg/v3/flows/factory_test.go b/pkg/v3/flows/factory_test.go index ea27749a..bf5923b1 100644 --- a/pkg/v3/flows/factory_test.go +++ b/pkg/v3/flows/factory_test.go @@ -73,6 +73,8 @@ func (r *mockRunner) CheckUpkeeps(ctx context.Context, p ...ocr2keepers.UpkeepPa type mockSubscriber struct { SubscribeFn func() (int, chan ocr2keepers.BlockHistory, error) UnsubscribeFn func(int) error + StartFn func(ctx context.Context) error + CloseFn func() error } func (r *mockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, error) { @@ -81,3 +83,9 @@ func (r *mockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, error) func (r *mockSubscriber) Unsubscribe(i int) error { return r.UnsubscribeFn(i) } +func (r *mockSubscriber) Start(ctx context.Context) error { + return r.StartFn(ctx) +} +func (r *mockSubscriber) Close() error { + return r.CloseFn() +} diff --git a/pkg/v3/postprocessors/metadata_test.go b/pkg/v3/postprocessors/metadata_test.go index 6d0cddc2..a0ad00ec 100644 --- a/pkg/v3/postprocessors/metadata_test.go +++ b/pkg/v3/postprocessors/metadata_test.go @@ -57,7 +57,9 @@ func TestMetadataAddSamples(t *testing.T) { } type mockBlockSubscriber struct { - ch chan ocr2keepers.BlockHistory + ch chan ocr2keepers.BlockHistory + StartFn func(ctx context.Context) error + CloseFn func() error } func (_m *mockBlockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, error) { @@ -67,3 +69,11 @@ func (_m *mockBlockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, func (_m *mockBlockSubscriber) Unsubscribe(int) error { return nil } + +func (_m *mockBlockSubscriber) Start(ctx context.Context) error { + return _m.StartFn(ctx) +} + +func (_m *mockBlockSubscriber) Close() error { + return _m.CloseFn() +} diff --git a/pkg/v3/stores/metadata_store_test.go b/pkg/v3/stores/metadata_store_test.go index 2049a780..b9642d33 100644 --- a/pkg/v3/stores/metadata_store_test.go +++ b/pkg/v3/stores/metadata_store_test.go @@ -506,6 +506,8 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { type mockBlockSubscriber struct { SubscribeFn func() (int, chan types.BlockHistory, error) UnsubscribeFn func(int) error + StartFn func(ctx context.Context) error + CloseFn func() error } func (_m *mockBlockSubscriber) Subscribe() (int, chan types.BlockHistory, error) { @@ -515,3 +517,9 @@ func (_m *mockBlockSubscriber) Subscribe() (int, chan types.BlockHistory, error) func (_m *mockBlockSubscriber) Unsubscribe(i int) error { return _m.UnsubscribeFn(i) } +func (r *mockBlockSubscriber) Start(ctx context.Context) error { + return r.StartFn(ctx) +} +func (r *mockBlockSubscriber) Close() error { + return r.CloseFn() +} diff --git a/tools/simulator/simulate/chain/history.go b/tools/simulator/simulate/chain/history.go index 63376439..a30aa463 100644 --- a/tools/simulator/simulate/chain/history.go +++ b/tools/simulator/simulate/chain/history.go @@ -1,12 +1,13 @@ package chain import ( + "context" "log" "runtime" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( @@ -45,6 +46,14 @@ func NewBlockHistoryTracker(listener *Listener, logger *log.Logger) *BlockHistor return tracker } +func (src *BlockHistoryTracker) Close() error { + return nil +} + +func (src *BlockHistoryTracker) Start(_ context.Context) error { + return nil +} + // Subscribe provides an identifier integer, a new channel, and potentially an error func (ht *BlockHistoryTracker) Subscribe() (int, chan ocr2keepers.BlockHistory, error) { ht.mu.Lock() diff --git a/tools/simulator/simulate/upkeep/source.go b/tools/simulator/simulate/upkeep/source.go index f0b17cac..cb3aaf52 100644 --- a/tools/simulator/simulate/upkeep/source.go +++ b/tools/simulator/simulate/upkeep/source.go @@ -5,9 +5,9 @@ import ( "log" "math/big" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // Source maintains delivery of active upkeeps based on type and repeat @@ -38,6 +38,14 @@ func NewSource( } } +func (src *Source) Close() error { + return nil +} + +func (src *Source) Start(_ context.Context) error { + return nil +} + // GetActiveUpkeeps delivers all active conditional upkeep payloads. Payloads // returned should be at least once and only when active. func (src *Source) GetActiveUpkeeps(_ context.Context) ([]ocr2keepers.UpkeepPayload, error) { From f6cbafcfe251c942030d43a747019648f997bd02 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Mon, 8 Jan 2024 15:48:41 +0000 Subject: [PATCH 5/6] Keep mocks in automation Use mockery v2.28.1 Move some types back into automation, regenerate mocks Fix tests Update imports Generate Update imports Fix go version Bump to go 1.21 Clean up import aliases --- go.mod | 11 +- go.sum | 7 +- pkg/v2/coordinator/mocks/encoder.generated.go | 23 +- .../mocks/log_provider.generated.go | 19 +- pkg/v2/mocks/logger.generated.go | 11 +- pkg/v3/coordinator/coordinator.go | 48 +-- pkg/v3/coordinator/coordinator_test.go | 384 +++++++++--------- pkg/v3/flows/conditional.go | 46 ++- pkg/v3/flows/conditional_test.go | 52 +-- pkg/v3/flows/factory.go | 45 +- pkg/v3/flows/factory_test.go | 16 +- pkg/v3/flows/logtrigger.go | 19 +- pkg/v3/flows/logtrigger_test.go | 24 +- pkg/v3/flows/recovery.go | 46 ++- pkg/v3/flows/recovery_test.go | 53 +-- pkg/v3/flows/retry.go | 19 +- pkg/v3/flows/retry_test.go | 35 +- pkg/v3/observation.go | 20 +- pkg/v3/observation_test.go | 163 ++++---- pkg/v3/observer.go | 3 +- pkg/v3/observer_test.go | 3 +- pkg/v3/outcome.go | 5 +- pkg/v3/plugin/delegate.go | 30 +- pkg/v3/plugin/factory.go | 34 +- pkg/v3/plugin/hooks/add_block_history.go | 6 +- pkg/v3/plugin/hooks/add_block_history_test.go | 2 +- .../plugin/hooks/add_conditional_proposals.go | 2 +- .../hooks/add_conditional_proposals_test.go | 37 +- pkg/v3/plugin/hooks/add_from_staging.go | 7 +- pkg/v3/plugin/hooks/add_from_staging_test.go | 2 +- pkg/v3/plugin/hooks/add_log_proposals.go | 2 +- pkg/v3/plugin/hooks/add_log_proposals_test.go | 55 +-- pkg/v3/plugin/hooks/add_to_proposalq.go | 6 +- pkg/v3/plugin/hooks/add_to_proposalq_test.go | 11 +- pkg/v3/plugin/hooks/remove_from_metadata.go | 2 +- .../plugin/hooks/remove_from_metadata_test.go | 21 +- pkg/v3/plugin/hooks/remove_from_staging.go | 2 +- pkg/v3/plugin/ocr3.go | 28 +- pkg/v3/plugin/ocr3_test.go | 137 +++---- pkg/v3/plugin/plugin.go | 18 +- pkg/v3/postprocessors/eligible.go | 3 +- pkg/v3/postprocessors/eligible_test.go | 3 +- pkg/v3/postprocessors/ineligible.go | 3 +- pkg/v3/postprocessors/metadata.go | 5 +- pkg/v3/postprocessors/metadata_test.go | 7 +- pkg/v3/postprocessors/retry.go | 7 +- pkg/v3/postprocessors/retry_test.go | 3 +- pkg/v3/preprocessors/proposal_filterer.go | 7 +- .../preprocessors/proposal_filterer_test.go | 15 +- pkg/v3/runner/runner.go | 11 +- pkg/v3/runner/runner_test.go | 3 +- pkg/v3/stores/metadata_store.go | 41 +- pkg/v3/stores/metadata_store_test.go | 119 +++--- pkg/v3/stores/proposal_queue.go | 10 +- pkg/v3/stores/proposal_queue_test.go | 42 +- pkg/v3/stores/result_store.go | 7 +- pkg/v3/stores/retry_queue.go | 9 +- pkg/v3/stores/retry_queue_test.go | 5 +- pkg/v3/types/basetypes.go | 23 ++ pkg/v3/types/interfaces.go | 85 ++++ .../types/mocks/block_subscriber.generated.go | 106 +++++ .../conditionalupkeepprovider.generated.go | 57 +++ pkg/v3/types/mocks/coordinator.generated.go | 137 +++++++ pkg/v3/types/mocks/encoder.generated.go | 86 ++++ .../types/mocks/logeventprovider.generated.go | 85 ++++ pkg/v3/types/mocks/metadatastore.generated.go | 120 ++++++ .../types/mocks/payloadbuilder.generated.go | 64 +++ pkg/v3/types/mocks/ratio.generated.go | 39 ++ .../mocks/recoverableprovider.generated.go | 57 +++ pkg/v3/types/mocks/result_store.generated.go | 76 ++++ pkg/v3/types/mocks/runnable.generated.go | 64 +++ .../transmit_event_provider.generated.go | 57 +++ .../mocks/upkeep_state_updater.generated.go | 45 ++ tools/simulator/node/stats.go | 1 + tools/simulator/simulate/chain/generate.go | 6 +- tools/simulator/simulate/chain/history.go | 3 +- tools/simulator/simulate/ocr/report.go | 1 + tools/simulator/simulate/ocr/report_test.go | 5 +- .../simulator/simulate/upkeep/active_test.go | 6 +- tools/simulator/simulate/upkeep/log_test.go | 1 + tools/simulator/simulate/upkeep/perform.go | 4 +- .../simulator/simulate/upkeep/perform_test.go | 9 +- tools/simulator/simulate/upkeep/pipeline.go | 1 + .../simulate/upkeep/pipeline_test.go | 1 + tools/simulator/simulate/upkeep/source.go | 3 +- .../simulator/simulate/upkeep/source_test.go | 1 + tools/simulator/simulate/upkeep/util.go | 5 +- tools/simulator/simulate/upkeep/util_test.go | 1 + tools/simulator/util/encode.go | 8 +- tools/testprotocol/modify/byte_test.go | 3 +- tools/testprotocol/modify/struct.go | 3 +- 91 files changed, 2037 insertions(+), 880 deletions(-) create mode 100644 pkg/v3/types/basetypes.go create mode 100644 pkg/v3/types/interfaces.go create mode 100644 pkg/v3/types/mocks/block_subscriber.generated.go create mode 100644 pkg/v3/types/mocks/conditionalupkeepprovider.generated.go create mode 100644 pkg/v3/types/mocks/coordinator.generated.go create mode 100644 pkg/v3/types/mocks/encoder.generated.go create mode 100644 pkg/v3/types/mocks/logeventprovider.generated.go create mode 100644 pkg/v3/types/mocks/metadatastore.generated.go create mode 100644 pkg/v3/types/mocks/payloadbuilder.generated.go create mode 100644 pkg/v3/types/mocks/ratio.generated.go create mode 100644 pkg/v3/types/mocks/recoverableprovider.generated.go create mode 100644 pkg/v3/types/mocks/result_store.generated.go create mode 100644 pkg/v3/types/mocks/runnable.generated.go create mode 100644 pkg/v3/types/mocks/transmit_event_provider.generated.go create mode 100644 pkg/v3/types/mocks/upkeep_state_updater.generated.go diff --git a/go.mod b/go.mod index 714cd358..78adb67b 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/jedib0t/go-pretty/v6 v6.4.7 github.com/pkg/errors v0.9.1 github.com/shopspring/decimal v1.3.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565 + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -24,20 +24,27 @@ require ( ) require ( + github.com/beorn7/perks v1.0.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.3.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-stack/stack v1.8.1 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/holiman/uint256 v1.2.2 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.17.0 // indirect + github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/tklauser/go-sysconf v0.3.11 // indirect diff --git a/go.sum b/go.sum index 0a40ce4f..f96a912a 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,7 @@ github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= 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.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= @@ -114,8 +115,8 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565 h1:5cZ5p0RXwxj4H/02/7ul/ysJ6y1jIqsXqXqYW1CfOWs= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231220015308-39e566841565/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df h1:J5e8CK13znCyjn+en9TbN/2d1rLrYS9CA+jFspEgWmk= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 h1:R9NkVN+1fooUJFsN9zj9gDY1B+zv54zNO785RQZRVfE= github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -149,6 +150,7 @@ golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -164,6 +166,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T 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= diff --git a/pkg/v2/coordinator/mocks/encoder.generated.go b/pkg/v2/coordinator/mocks/encoder.generated.go index aa1ab638..07fe4cc6 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.38.0. 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 6dbaf7aa..74458572 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.38.0. 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/mocks/logger.generated.go b/pkg/v2/mocks/logger.generated.go index 58976d4f..a8176dd1 100644 --- a/pkg/v2/mocks/logger.generated.go +++ b/pkg/v2/mocks/logger.generated.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. 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/coordinator/coordinator.go b/pkg/v3/coordinator/coordinator.go index 6667ac92..dfc859f7 100644 --- a/pkg/v3/coordinator/coordinator.go +++ b/pkg/v3/coordinator/coordinator.go @@ -7,10 +7,12 @@ import ( "log" "time" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + internalutil "github.com/smartcontractkit/chainlink-automation/internal/util" "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) const ( @@ -22,8 +24,8 @@ type coordinator struct { closer internalutil.Closer logger *log.Logger - eventsProvider ocr2keepers.TransmitEventProvider - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter + eventsProvider types.TransmitEventProvider + upkeepTypeGetter types.UpkeepTypeGetter cache *util.Cache[record] visited *util.Cache[bool] @@ -32,16 +34,16 @@ type coordinator struct { performLockoutWindow time.Duration } -var _ ocr2keepers.Coordinator = (*coordinator)(nil) +var _ types.Coordinator = (*coordinator)(nil) type record struct { - checkBlockNumber ocr2keepers.BlockNumber + checkBlockNumber common.BlockNumber isTransmissionPending bool // false = transmitted - transmitType ocr2keepers.TransmitEventType - transmitBlockNumber ocr2keepers.BlockNumber + transmitType common.TransmitEventType + transmitBlockNumber common.BlockNumber } -func NewCoordinator(transmitEventProvider ocr2keepers.TransmitEventProvider, upkeepTypeGetter ocr2keepers.UpkeepTypeGetter, conf config.OffchainConfig, logger *log.Logger) *coordinator { +func NewCoordinator(transmitEventProvider types.TransmitEventProvider, upkeepTypeGetter types.UpkeepTypeGetter, conf config.OffchainConfig, logger *log.Logger) *coordinator { performLockoutWindow := time.Duration(conf.PerformLockoutWindow) * time.Millisecond return &coordinator{ logger: logger, @@ -54,7 +56,7 @@ func NewCoordinator(transmitEventProvider ocr2keepers.TransmitEventProvider, upk } } -func (c *coordinator) Accept(reportedUpkeep ocr2keepers.ReportedUpkeep) bool { +func (c *coordinator) Accept(reportedUpkeep common.ReportedUpkeep) bool { if v, ok := c.cache.Get(reportedUpkeep.WorkID); !ok { c.cache.Set(reportedUpkeep.WorkID, record{ checkBlockNumber: reportedUpkeep.Trigger.BlockNumber, @@ -72,7 +74,7 @@ func (c *coordinator) Accept(reportedUpkeep ocr2keepers.ReportedUpkeep) bool { return false } -func (c *coordinator) ShouldTransmit(reportedUpkeep ocr2keepers.ReportedUpkeep) bool { +func (c *coordinator) ShouldTransmit(reportedUpkeep common.ReportedUpkeep) bool { if v, ok := c.cache.Get(reportedUpkeep.WorkID); !ok { // We never saw this report, so don't try to transmit // Can happen in edge cases when plugin restarts after shouldAccept was called @@ -89,8 +91,8 @@ func (c *coordinator) ShouldTransmit(reportedUpkeep ocr2keepers.ReportedUpkeep) } } -func (c *coordinator) PreProcess(_ context.Context, payloads []ocr2keepers.UpkeepPayload) ([]ocr2keepers.UpkeepPayload, error) { - res := make([]ocr2keepers.UpkeepPayload, 0) +func (c *coordinator) PreProcess(_ context.Context, payloads []common.UpkeepPayload) ([]common.UpkeepPayload, error) { + res := make([]common.UpkeepPayload, 0) for _, payload := range payloads { if c.ShouldProcess(payload.WorkID, payload.UpkeepID, payload.Trigger) { res = append(res, payload) @@ -99,8 +101,8 @@ func (c *coordinator) PreProcess(_ context.Context, payloads []ocr2keepers.Upkee return res, nil } -func (c *coordinator) FilterResults(results []ocr2keepers.CheckResult) ([]ocr2keepers.CheckResult, error) { - res := make([]ocr2keepers.CheckResult, 0) +func (c *coordinator) FilterResults(results []common.CheckResult) ([]common.CheckResult, error) { + res := make([]common.CheckResult, 0) for _, result := range results { if c.ShouldProcess(result.WorkID, result.UpkeepID, result.Trigger) { res = append(res, result) @@ -109,14 +111,14 @@ func (c *coordinator) FilterResults(results []ocr2keepers.CheckResult) ([]ocr2ke return res, nil } -func (c *coordinator) FilterProposals(proposals []ocr2keepers.CoordinatedBlockProposal) ([]ocr2keepers.CoordinatedBlockProposal, error) { - res := make([]ocr2keepers.CoordinatedBlockProposal, 0) +func (c *coordinator) FilterProposals(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { + res := make([]common.CoordinatedBlockProposal, 0) for _, proposal := range proposals { if v, ok := c.cache.Get(proposal.WorkID); ok { if v.isTransmissionPending { // This workID has a pending transmit, should not process it continue - } else if c.upkeepTypeGetter(proposal.UpkeepID) == ocr2keepers.LogTrigger && v.transmitType == ocr2keepers.PerformEvent { + } else if c.upkeepTypeGetter(proposal.UpkeepID) == types.LogTrigger && v.transmitType == common.PerformEvent { // For log triggers if workID was performed then skip // However for conditional triggers, allow proposals to be made for newer check block numbers continue @@ -127,25 +129,25 @@ func (c *coordinator) FilterProposals(proposals []ocr2keepers.CoordinatedBlockPr return res, nil } -func (c *coordinator) ShouldProcess(workID string, upkeepID ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) bool { +func (c *coordinator) ShouldProcess(workID string, upkeepID common.UpkeepIdentifier, trigger common.Trigger) bool { if v, ok := c.cache.Get(workID); ok { if v.isTransmissionPending { // This workID has a pending transmit, should not process it return false } else { switch c.upkeepTypeGetter(upkeepID) { - case ocr2keepers.LogTrigger: + case types.LogTrigger: switch v.transmitType { - case ocr2keepers.PerformEvent: + case common.PerformEvent: // For log triggers, a particular workID should only ever be performed once return false default: // There was an attempt to perform this workID, but it failed, so should be processed again return true } - case ocr2keepers.ConditionTrigger: + case types.ConditionTrigger: switch v.transmitType { - case ocr2keepers.PerformEvent: + case common.PerformEvent: // For conditionals, a particular workID should only be checked after or on its last perform block return trigger.BlockNumber >= v.transmitBlockNumber default: @@ -265,6 +267,6 @@ func (c *coordinator) Close() error { return nil } -func (c *coordinator) visitedID(e ocr2keepers.TransmitEvent) string { +func (c *coordinator) visitedID(e common.TransmitEvent) string { return fmt.Sprintf("%s_%x_%d", e.WorkID, e.TransactionHash, e.TransmitBlock) } diff --git a/pkg/v3/coordinator/coordinator_test.go b/pkg/v3/coordinator/coordinator_test.go index 28d88607..56e05378 100644 --- a/pkg/v3/coordinator/coordinator_test.go +++ b/pkg/v3/coordinator/coordinator_test.go @@ -14,9 +14,11 @@ import ( "github.com/stretchr/testify/assert" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) func TestNewCoordinator(t *testing.T) { @@ -26,17 +28,17 @@ func TestNewCoordinator(t *testing.T) { fullRunComplete := make(chan struct{}, 1) // constructor dependencies - upkeepTypeGetter := func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter := func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger } eventProvider := &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { callCount++ if callCount > 1 { fullRunComplete <- struct{}{} } - return []ocr2keepers.TransmitEvent{}, nil + return []common.TransmitEvent{}, nil }, } @@ -62,12 +64,12 @@ func TestNewCoordinator(t *testing.T) { fullRunComplete := make(chan struct{}, 1) // constructor dependencies - upkeepTypeGetter := func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter := func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger } eventProvider := &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { callCount++ if callCount > 1 { fullRunComplete <- struct{}{} @@ -102,12 +104,12 @@ func TestNewCoordinator(t *testing.T) { fullRunComplete := make(chan struct{}, 1) // constructor dependencies - upkeepTypeGetter := func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter := func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger } eventProvider := &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { callCount++ if callCount > 1 { fullRunComplete <- struct{}{} @@ -115,7 +117,7 @@ func TestNewCoordinator(t *testing.T) { time.Sleep(cadence * 2) - return []ocr2keepers.TransmitEvent{}, nil + return []common.TransmitEvent{}, nil }, } @@ -161,8 +163,8 @@ func TestNewCoordinator(t *testing.T) { func TestNewCoordinator_checkEvents(t *testing.T) { for _, tc := range []struct { name string - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter - eventProvider ocr2keepers.TransmitEventProvider + upkeepTypeGetter types.UpkeepTypeGetter + eventProvider types.TransmitEventProvider cacheInit map[string]record visitedInit map[string]struct{} wantCache map[string]record @@ -174,7 +176,7 @@ func TestNewCoordinator_checkEvents(t *testing.T) { { name: "if GetLatestEvents errors, the error is returned", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { return nil, errors.New("get latest events boom") }, }, @@ -184,8 +186,8 @@ func TestNewCoordinator_checkEvents(t *testing.T) { { name: "if a transmit event has fewer than the required minimum confirmations, a message is logged", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { - return []ocr2keepers.TransmitEvent{ + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { + return []common.TransmitEvent{ { Confirmations: 1, }, @@ -198,12 +200,12 @@ func TestNewCoordinator_checkEvents(t *testing.T) { { name: "visited transmit events are skipped", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { - return []ocr2keepers.TransmitEvent{ + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { + return []common.TransmitEvent{ { Confirmations: 2, TransactionHash: [32]byte{1, 1, 1, 1}, - CheckBlock: ocr2keepers.BlockNumber(99), + CheckBlock: common.BlockNumber(99), WorkID: "workID1", }, }, nil @@ -218,11 +220,11 @@ func TestNewCoordinator_checkEvents(t *testing.T) { { name: "if a transmit event has a lower check block number than the corresponding record in the cache, a message is logged", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { - return []ocr2keepers.TransmitEvent{ + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { + return []common.TransmitEvent{ { Confirmations: 2, - CheckBlock: ocr2keepers.BlockNumber(99), + CheckBlock: common.BlockNumber(99), WorkID: "workID1", }, }, nil @@ -231,13 +233,13 @@ func TestNewCoordinator_checkEvents(t *testing.T) { cacheInit: map[string]record{ "workID1": { checkBlockNumber: 100, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, wantCache: map[string]record{ "workID1": { checkBlockNumber: 100, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, visitedInit: map[string]struct{}{}, @@ -246,65 +248,65 @@ func TestNewCoordinator_checkEvents(t *testing.T) { { name: "if a transmit event has a matching block number with the corresponding record in the cache, the record is updated", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { - return []ocr2keepers.TransmitEvent{ + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { + return []common.TransmitEvent{ { Confirmations: 2, - Type: ocr2keepers.PerformEvent, - CheckBlock: ocr2keepers.BlockNumber(100), + Type: common.PerformEvent, + CheckBlock: common.BlockNumber(100), WorkID: "workID1", - TransmitBlock: ocr2keepers.BlockNumber(99), + TransmitBlock: common.BlockNumber(99), }, }, nil }, }, cacheInit: map[string]record{ "workID1": { - checkBlockNumber: ocr2keepers.BlockNumber(100), - transmitType: ocr2keepers.PerformEvent, + checkBlockNumber: common.BlockNumber(100), + transmitType: common.PerformEvent, isTransmissionPending: false, - transmitBlockNumber: ocr2keepers.BlockNumber(99), + transmitBlockNumber: common.BlockNumber(99), }, }, wantCache: map[string]record{ "workID1": { - checkBlockNumber: ocr2keepers.BlockNumber(100), - transmitType: ocr2keepers.PerformEvent, + checkBlockNumber: common.BlockNumber(100), + transmitType: common.PerformEvent, isTransmissionPending: false, - transmitBlockNumber: ocr2keepers.BlockNumber(99), + transmitBlockNumber: common.BlockNumber(99), }, }, }, { name: "if a transmit event has a higher block number than the corresponding record in the cache, the record is completely reset with the transmit event data", eventProvider: &mockEventProvider{ - GetLatestEventsFn: func(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { - return []ocr2keepers.TransmitEvent{ + GetLatestEventsFn: func(ctx context.Context) ([]common.TransmitEvent, error) { + return []common.TransmitEvent{ { Confirmations: 2, TransactionHash: [32]byte{1, 1, 1, 1}, - Type: ocr2keepers.PerformEvent, - CheckBlock: ocr2keepers.BlockNumber(200), + Type: common.PerformEvent, + CheckBlock: common.BlockNumber(200), WorkID: "workID1", - TransmitBlock: ocr2keepers.BlockNumber(99), + TransmitBlock: common.BlockNumber(99), }, }, nil }, }, cacheInit: map[string]record{ "workID1": { - checkBlockNumber: ocr2keepers.BlockNumber(100), - transmitType: ocr2keepers.PerformEvent, + checkBlockNumber: common.BlockNumber(100), + transmitType: common.PerformEvent, isTransmissionPending: false, - transmitBlockNumber: ocr2keepers.BlockNumber(99), + transmitBlockNumber: common.BlockNumber(99), }, }, wantCache: map[string]record{ "workID1": { - checkBlockNumber: ocr2keepers.BlockNumber(200), - transmitType: ocr2keepers.PerformEvent, + checkBlockNumber: common.BlockNumber(200), + transmitType: common.PerformEvent, isTransmissionPending: false, - transmitBlockNumber: ocr2keepers.BlockNumber(99), + transmitBlockNumber: common.BlockNumber(99), }, }, }, @@ -349,15 +351,15 @@ func TestCoordinator_ShouldAccept(t *testing.T) { for _, tc := range []struct { name string cacheInit map[string]record - reportedUpkeep ocr2keepers.ReportedUpkeep + reportedUpkeep common.ReportedUpkeep shouldAccept bool wantCache map[string]record }{ { name: "if the given work ID does not exist in the cache, we should accept and update the cache", - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -375,13 +377,13 @@ func TestCoordinator_ShouldAccept(t *testing.T) { "workID1": { checkBlockNumber: 100, isTransmissionPending: true, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 99, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -399,13 +401,13 @@ func TestCoordinator_ShouldAccept(t *testing.T) { "workID1": { checkBlockNumber: 100, isTransmissionPending: true, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 99, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 99, }, }, @@ -414,7 +416,7 @@ func TestCoordinator_ShouldAccept(t *testing.T) { "workID1": { checkBlockNumber: 100, isTransmissionPending: true, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 99, }, }, @@ -425,13 +427,13 @@ func TestCoordinator_ShouldAccept(t *testing.T) { "workID1": { checkBlockNumber: 100, isTransmissionPending: true, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 99, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 100, }, }, @@ -440,7 +442,7 @@ func TestCoordinator_ShouldAccept(t *testing.T) { "workID1": { checkBlockNumber: 100, isTransmissionPending: true, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 99, }, }, @@ -472,14 +474,14 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { for _, tc := range []struct { name string cacheInit map[string]record - reportedUpkeep ocr2keepers.ReportedUpkeep + reportedUpkeep common.ReportedUpkeep expectsMessage bool wantMessage string shouldTransmit bool }{ { name: "if the given work ID does not exist in the cache, we should not transmit", - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", }, shouldTransmit: false, @@ -491,9 +493,9 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { checkBlockNumber: 200, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 100, }, }, @@ -507,9 +509,9 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { isTransmissionPending: true, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -523,9 +525,9 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { isTransmissionPending: false, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -538,9 +540,9 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { checkBlockNumber: 100, }, }, - reportedUpkeep: ocr2keepers.ReportedUpkeep{ + reportedUpkeep: common.ReportedUpkeep{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -569,21 +571,21 @@ func TestCoordinator_ShouldTransmit(t *testing.T) { func TestCoordinator_ShouldProcess(t *testing.T) { for _, tc := range []struct { name string - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter + upkeepTypeGetter types.UpkeepTypeGetter cacheInit map[string]record - payload ocr2keepers.UpkeepPayload + payload common.UpkeepPayload shouldProcess bool }{ { name: "if the given work ID does not exist in the cache, we should process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", }, shouldProcess: true, }, { name: "if the given work ID does exist in the cache, and is pending transmission, we should not process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", }, cacheInit: map[string]record{ @@ -595,51 +597,51 @@ func TestCoordinator_ShouldProcess(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, and upkeep is log trigger, we should not process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, shouldProcess: false, }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is log trigger, we should process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, shouldProcess: true, }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is greater than the cache transmit block, and upkeep is conditional, we should process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 100, }, }, @@ -647,19 +649,19 @@ func TestCoordinator_ShouldProcess(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is less than the cache transmit block, and upkeep is conditional, we should not process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 100, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 200, }, }, @@ -667,16 +669,16 @@ func TestCoordinator_ShouldProcess(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is conditional, we should process", - payload: ocr2keepers.UpkeepPayload{ + payload: common.UpkeepPayload{ WorkID: "workID1", }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, shouldProcess: true, @@ -697,19 +699,19 @@ func TestCoordinator_ShouldProcess(t *testing.T) { func TestNewCoordinator_Preprocess(t *testing.T) { for _, tc := range []struct { name string - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter + upkeepTypeGetter types.UpkeepTypeGetter cacheInit map[string]record - payloads []ocr2keepers.UpkeepPayload - wantPayloads []ocr2keepers.UpkeepPayload + payloads []common.UpkeepPayload + wantPayloads []common.UpkeepPayload }{ { name: "if the given work ID does not exist in the cache, we should process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ { WorkID: "workID1", }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{ + wantPayloads: []common.UpkeepPayload{ { WorkID: "workID1", }, @@ -717,12 +719,12 @@ func TestNewCoordinator_Preprocess(t *testing.T) { }, { name: "if the given work ID does exist in the cache, and is pending transmission, we should not process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ { WorkID: "workID1", }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{}, + wantPayloads: []common.UpkeepPayload{}, cacheInit: map[string]record{ "workID1": { isTransmissionPending: true, @@ -731,62 +733,62 @@ func TestNewCoordinator_Preprocess(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, and upkeep is log trigger, we should not process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ {WorkID: "workID1"}, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{}, + wantPayloads: []common.UpkeepPayload{}, }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is log trigger, we should process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ {WorkID: "workID1"}, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{ + wantPayloads: []common.UpkeepPayload{ {WorkID: "workID1"}, }, }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is greater than the cache transmit block, and upkeep is conditional, we should process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 100, }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{ + wantPayloads: []common.UpkeepPayload{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -794,42 +796,42 @@ func TestNewCoordinator_Preprocess(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is less than the cache transmit block, and upkeep is conditional, we should not process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 100, }, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 200, }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{}, + wantPayloads: []common.UpkeepPayload{}, }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is conditional, we should process", - payloads: []ocr2keepers.UpkeepPayload{ + payloads: []common.UpkeepPayload{ {WorkID: "workID1"}, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, - wantPayloads: []ocr2keepers.UpkeepPayload{ + wantPayloads: []common.UpkeepPayload{ {WorkID: "workID1"}, }, }, @@ -851,20 +853,20 @@ func TestNewCoordinator_Preprocess(t *testing.T) { func TestCoordinator_FilterResults(t *testing.T) { for _, tc := range []struct { name string - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter + upkeepTypeGetter types.UpkeepTypeGetter cacheInit map[string]record - results []ocr2keepers.CheckResult - wantResults []ocr2keepers.CheckResult + results []common.CheckResult + wantResults []common.CheckResult shouldProcess bool }{ { name: "if the given work ID does not exist in the cache, results are included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", }, }, - wantResults: []ocr2keepers.CheckResult{ + wantResults: []common.CheckResult{ { WorkID: "workID1", }, @@ -872,7 +874,7 @@ func TestCoordinator_FilterResults(t *testing.T) { }, { name: "if the given work ID does exist in the cache, and is pending transmission, results are not included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", }, @@ -882,41 +884,41 @@ func TestCoordinator_FilterResults(t *testing.T) { isTransmissionPending: true, }, }, - wantResults: []ocr2keepers.CheckResult{}, + wantResults: []common.CheckResult{}, }, { name: "work ID exists, is not pending transmission, transmit type is perform, and upkeep is log trigger, results are not included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ {WorkID: "workID1"}, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, - wantResults: []ocr2keepers.CheckResult{}, + wantResults: []common.CheckResult{}, }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is log trigger, results are included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, - wantResults: []ocr2keepers.CheckResult{ + wantResults: []common.CheckResult{ { WorkID: "workID1", }, @@ -924,28 +926,28 @@ func TestCoordinator_FilterResults(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is greater than the cache transmit block, and upkeep is conditional, results are included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 100, }, }, - wantResults: []ocr2keepers.CheckResult{ + wantResults: []common.CheckResult{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 200, }, }, @@ -953,43 +955,43 @@ func TestCoordinator_FilterResults(t *testing.T) { }, { name: "work ID exists, is not pending transmission, transmit type is perform, payload check block is less than the cache transmit block, and upkeep is conditional, results are not included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", - Trigger: ocr2keepers.Trigger{ + Trigger: common.Trigger{ BlockNumber: 100, }, }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, transmitBlockNumber: 200, }, }, - wantResults: []ocr2keepers.CheckResult{}, + wantResults: []common.CheckResult{}, }, { name: "work ID exists, is not pending transmission, transmit type is stale, and upkeep is conditional, results are included", - results: []ocr2keepers.CheckResult{ + results: []common.CheckResult{ { WorkID: "workID1", }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID1": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, - wantResults: []ocr2keepers.CheckResult{ + wantResults: []common.CheckResult{ { WorkID: "workID1", }, @@ -1012,20 +1014,20 @@ func TestCoordinator_FilterResults(t *testing.T) { func TestCoordinator_FilterProposals(t *testing.T) { for _, tc := range []struct { name string - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter + upkeepTypeGetter types.UpkeepTypeGetter cacheInit map[string]record - results []ocr2keepers.CoordinatedBlockProposal - wantResults []ocr2keepers.CoordinatedBlockProposal + results []common.CoordinatedBlockProposal + wantResults []common.CoordinatedBlockProposal shouldProcess bool }{ { name: "all proposals are included", - results: []ocr2keepers.CoordinatedBlockProposal{ + results: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - wantResults: []ocr2keepers.CoordinatedBlockProposal{ + wantResults: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1033,7 +1035,7 @@ func TestCoordinator_FilterProposals(t *testing.T) { }, { name: "proposals with pending transmission are excluded", - results: []ocr2keepers.CoordinatedBlockProposal{ + results: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1046,7 +1048,7 @@ func TestCoordinator_FilterProposals(t *testing.T) { isTransmissionPending: true, }, }, - wantResults: []ocr2keepers.CoordinatedBlockProposal{ + wantResults: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1054,7 +1056,7 @@ func TestCoordinator_FilterProposals(t *testing.T) { }, { name: "log proposals with a non pending transmission with a perform transmit type are excluded", - results: []ocr2keepers.CoordinatedBlockProposal{ + results: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1062,16 +1064,16 @@ func TestCoordinator_FilterProposals(t *testing.T) { WorkID: "workID2", }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID2": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, - wantResults: []ocr2keepers.CoordinatedBlockProposal{ + wantResults: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1079,7 +1081,7 @@ func TestCoordinator_FilterProposals(t *testing.T) { }, { name: "condition trigger proposals with a non pending transmission with a perform transmit type are included", - results: []ocr2keepers.CoordinatedBlockProposal{ + results: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1087,16 +1089,16 @@ func TestCoordinator_FilterProposals(t *testing.T) { WorkID: "workID2", }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, cacheInit: map[string]record{ "workID2": { isTransmissionPending: false, - transmitType: ocr2keepers.PerformEvent, + transmitType: common.PerformEvent, }, }, - wantResults: []ocr2keepers.CoordinatedBlockProposal{ + wantResults: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1107,7 +1109,7 @@ func TestCoordinator_FilterProposals(t *testing.T) { }, { name: "log proposals with a non pending transmission with a stale report transmit type are included", - results: []ocr2keepers.CoordinatedBlockProposal{ + results: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1115,16 +1117,16 @@ func TestCoordinator_FilterProposals(t *testing.T) { WorkID: "workID2", }, }, - upkeepTypeGetter: func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + upkeepTypeGetter: func(uid common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }, cacheInit: map[string]record{ "workID2": { isTransmissionPending: false, - transmitType: ocr2keepers.StaleReportEvent, + transmitType: common.StaleReportEvent, }, }, - wantResults: []ocr2keepers.CoordinatedBlockProposal{ + wantResults: []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -1148,9 +1150,9 @@ func TestCoordinator_FilterProposals(t *testing.T) { } type mockEventProvider struct { - GetLatestEventsFn func(context.Context) ([]ocr2keepers.TransmitEvent, error) + GetLatestEventsFn func(context.Context) ([]common.TransmitEvent, error) } -func (t *mockEventProvider) GetLatestEvents(ctx context.Context) ([]ocr2keepers.TransmitEvent, error) { +func (t *mockEventProvider) GetLatestEvents(ctx context.Context) ([]common.TransmitEvent, error) { return t.GetLatestEventsFn(ctx) } diff --git a/pkg/v3/flows/conditional.go b/pkg/v3/flows/conditional.go index a6672d14..db6f9136 100644 --- a/pkg/v3/flows/conditional.go +++ b/pkg/v3/flows/conditional.go @@ -6,6 +6,8 @@ import ( "log" "time" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/postprocessors" "github.com/smartcontractkit/chainlink-automation/pkg/v3/preprocessors" @@ -13,7 +15,7 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) const ( @@ -29,15 +31,15 @@ const ( ) func newSampleProposalFlow( - pre []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - ratio ocr2keepers.Ratio, - getter ocr2keepers.ConditionalUpkeepProvider, - ms ocr2keepers.MetadataStore, + pre []ocr2keepersv3.PreProcessor[common.UpkeepPayload], + ratio types.Ratio, + getter common.ConditionalUpkeepProvider, + ms types.MetadataStore, runner ocr2keepersv3.Runner, interval time.Duration, logger *log.Logger, ) service.Recoverable { - pre = append(pre, preprocessors.NewProposalFilterer(ms, ocr2keepers.LogTrigger)) + pre = append(pre, preprocessors.NewProposalFilterer(ms, types.LogTrigger)) postprocessors := postprocessors.NewAddProposalToMetadataStorePostprocessor(ms) observer := ocr2keepersv3.NewRunnableObserver( @@ -48,21 +50,21 @@ func newSampleProposalFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | sample-proposal-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - return tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](interval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + return tickers.NewTimeTicker[[]common.UpkeepPayload](interval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return NewSampler(ratio, getter, logger), nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | sample-proposal-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) } func NewSampler( - ratio ocr2keepers.Ratio, - getter ocr2keepers.ConditionalUpkeepProvider, + ratio types.Ratio, + getter common.ConditionalUpkeepProvider, logger *log.Logger, ) *sampler { return &sampler{ logger: logger, getter: getter, ratio: ratio, - shuffler: random.Shuffler[ocr2keepers.UpkeepPayload]{Source: random.NewCryptoRandSource()}, + shuffler: random.Shuffler[common.UpkeepPayload]{Source: random.NewCryptoRandSource()}, } } @@ -73,12 +75,12 @@ type shuffler[T any] interface { type sampler struct { logger *log.Logger - ratio ocr2keepers.Ratio - getter ocr2keepers.ConditionalUpkeepProvider - shuffler shuffler[ocr2keepers.UpkeepPayload] + ratio types.Ratio + getter common.ConditionalUpkeepProvider + shuffler shuffler[common.UpkeepPayload] } -func (s *sampler) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error) { +func (s *sampler) Value(ctx context.Context) ([]common.UpkeepPayload, error) { upkeeps, err := s.getter.GetActiveUpkeeps(ctx) if err != nil { return nil, err @@ -105,14 +107,14 @@ func (s *sampler) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error } func newFinalConditionalFlow( - preprocessors []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - resultStore ocr2keepers.ResultStore, + preprocessors []ocr2keepersv3.PreProcessor[common.UpkeepPayload], + resultStore types.ResultStore, runner ocr2keepersv3.Runner, interval time.Duration, - proposalQ ocr2keepers.ProposalQueue, - builder ocr2keepers.PayloadBuilder, - retryQ ocr2keepers.RetryQueue, - stateUpdater ocr2keepers.UpkeepStateUpdater, + proposalQ types.ProposalQueue, + builder common.PayloadBuilder, + retryQ types.RetryQueue, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) service.Recoverable { post := postprocessors.NewCombinedPostprocessor( @@ -130,12 +132,12 @@ func newFinalConditionalFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | conditional-final-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - ticker := tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](interval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + ticker := tickers.NewTimeTicker[[]common.UpkeepPayload](interval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return coordinatedProposalsTick{ logger: logger, builder: builder, q: proposalQ, - utype: ocr2keepers.ConditionTrigger, + utype: types.ConditionTrigger, batchSize: FinalConditionalBatchSize, }, nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | conditional-final-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) diff --git a/pkg/v3/flows/conditional_test.go b/pkg/v3/flows/conditional_test.go index 7b09a82e..cc9fb8d7 100644 --- a/pkg/v3/flows/conditional_test.go +++ b/pkg/v3/flows/conditional_test.go @@ -11,17 +11,19 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" ) func TestConditionalFinalization(t *testing.T) { - upkeepIDs := []ocr2keepers.UpkeepIdentifier{ - ocr2keepers.UpkeepIdentifier([32]byte{1}), - ocr2keepers.UpkeepIdentifier([32]byte{2}), + upkeepIDs := []common.UpkeepIdentifier{ + common.UpkeepIdentifier([32]byte{1}), + common.UpkeepIdentifier([32]byte{2}), } workIDs := []string{ "0x1", @@ -36,14 +38,14 @@ func TestConditionalFinalization(t *testing.T) { rStore := new(mocks.MockResultStore) coord := new(mocks.MockCoordinator) payloadBuilder := new(mocks.MockPayloadBuilder) - proposalQ := stores.NewProposalQueue(func(ui ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + proposalQ := stores.NewProposalQueue(func(ui common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }) upkeepStateUpdater := new(mocks.MockUpkeepStateUpdater) retryQ := stores.NewRetryQueue(logger) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -53,7 +55,7 @@ func TestConditionalFinalization(t *testing.T) { WorkID: workIDs[1], }, }, nil).Times(times) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -66,7 +68,7 @@ func TestConditionalFinalization(t *testing.T) { }, }, nil).Times(times) rStore.On("Add", mock.Anything).Times(times) - payloadBuilder.On("BuildPayloads", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + payloadBuilder.On("BuildPayloads", mock.Anything, mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -80,16 +82,16 @@ func TestConditionalFinalization(t *testing.T) { upkeepStateUpdater.On("SetUpkeepState", mock.Anything, mock.Anything, mock.Anything).Return(nil) // set the ticker time lower to reduce the test time interval := 50 * time.Millisecond - pre := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + pre := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} svc := newFinalConditionalFlow(pre, rStore, runner, interval, proposalQ, payloadBuilder, retryQ, upkeepStateUpdater, logger) var wg sync.WaitGroup wg.Add(1) - err := proposalQ.Enqueue(ocr2keepers.CoordinatedBlockProposal{ + err := proposalQ.Enqueue(common.CoordinatedBlockProposal{ UpkeepID: upkeepIDs[0], WorkID: workIDs[0], - }, ocr2keepers.CoordinatedBlockProposal{ + }, common.CoordinatedBlockProposal{ UpkeepID: upkeepIDs[1], WorkID: workIDs[1], }) @@ -110,10 +112,10 @@ func TestConditionalFinalization(t *testing.T) { } func TestSamplingProposal(t *testing.T) { - upkeepIDs := []ocr2keepers.UpkeepIdentifier{ - ocr2keepers.UpkeepIdentifier([32]byte{1}), - ocr2keepers.UpkeepIdentifier([32]byte{2}), - ocr2keepers.UpkeepIdentifier([32]byte{3}), + upkeepIDs := []common.UpkeepIdentifier{ + common.UpkeepIdentifier([32]byte{1}), + common.UpkeepIdentifier([32]byte{2}), + common.UpkeepIdentifier([32]byte{3}), } workIDs := []string{ "0x1", @@ -132,13 +134,13 @@ func TestSamplingProposal(t *testing.T) { ratio.On("OfInt", mock.Anything).Return(0, nil).Times(1) ratio.On("OfInt", mock.Anything).Return(1, nil).Times(1) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], }, }, nil).Times(1) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[1], WorkID: workIDs[1], @@ -146,14 +148,14 @@ func TestSamplingProposal(t *testing.T) { }, nil).Times(1) coord.On("PreProcess", mock.Anything, mock.Anything).Return(nil, nil) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], Eligible: true, }, }, nil).Times(1) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[1], WorkID: workIDs[1], @@ -162,7 +164,7 @@ func TestSamplingProposal(t *testing.T) { }, nil).Times(1) runner.On("CheckUpkeeps", mock.Anything).Return(nil, nil) - mStore.On("ViewProposals", mock.Anything).Return([]ocr2keepers.CoordinatedBlockProposal{ + mStore.On("ViewProposals", mock.Anything).Return([]common.CoordinatedBlockProposal{ { UpkeepID: upkeepIDs[2], WorkID: workIDs[2], @@ -170,7 +172,7 @@ func TestSamplingProposal(t *testing.T) { }, nil) mStore.On("AddProposals", mock.Anything).Return(nil).Times(2) - upkeepProvider.On("GetActiveUpkeeps", mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + upkeepProvider.On("GetActiveUpkeeps", mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -180,9 +182,9 @@ func TestSamplingProposal(t *testing.T) { WorkID: workIDs[1], }, }, nil).Times(2) - upkeepProvider.On("GetActiveUpkeeps", mock.Anything).Return([]ocr2keepers.UpkeepPayload{}, nil) + upkeepProvider.On("GetActiveUpkeeps", mock.Anything).Return([]common.UpkeepPayload{}, nil) // set the ticker time lower to reduce the test time - pre := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + pre := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} svc := newSampleProposalFlow(pre, ratio, upkeepProvider, mStore, runner, time.Millisecond*100, logger) var wg sync.WaitGroup diff --git a/pkg/v3/flows/factory.go b/pkg/v3/flows/factory.go index 4168f05b..d733b3ca 100644 --- a/pkg/v3/flows/factory.go +++ b/pkg/v3/flows/factory.go @@ -6,24 +6,25 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func ConditionalTriggerFlows( - coord ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - ratio ocr2keepers.Ratio, - getter ocr2keepers.ConditionalUpkeepProvider, - subscriber ocr2keepers.BlockSubscriber, - builder ocr2keepers.PayloadBuilder, - resultStore ocr2keepers.ResultStore, - metadataStore ocr2keepers.MetadataStore, + coord ocr2keepersv3.PreProcessor[common.UpkeepPayload], + ratio types.Ratio, + getter common.ConditionalUpkeepProvider, + subscriber common.BlockSubscriber, + builder common.PayloadBuilder, + resultStore types.ResultStore, + metadataStore types.MetadataStore, runner ocr2keepersv3.Runner, - proposalQ ocr2keepers.ProposalQueue, - retryQ ocr2keepers.RetryQueue, - stateUpdater ocr2keepers.UpkeepStateUpdater, + proposalQ types.ProposalQueue, + retryQ types.RetryQueue, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) []service.Recoverable { - preprocessors := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + preprocessors := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} // runs full check pipeline on a coordinated block with coordinated upkeeps conditionalFinal := newFinalConditionalFlow(preprocessors, resultStore, runner, FinalConditionalInterval, proposalQ, builder, retryQ, stateUpdater, logger) @@ -36,24 +37,24 @@ func ConditionalTriggerFlows( } func LogTriggerFlows( - coord ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - resultStore ocr2keepers.ResultStore, - metadataStore ocr2keepers.MetadataStore, + coord ocr2keepersv3.PreProcessor[common.UpkeepPayload], + resultStore types.ResultStore, + metadataStore types.MetadataStore, runner ocr2keepersv3.Runner, - logProvider ocr2keepers.LogEventProvider, - rp ocr2keepers.RecoverableProvider, - builder ocr2keepers.PayloadBuilder, + logProvider common.LogEventProvider, + rp common.RecoverableProvider, + builder common.PayloadBuilder, logInterval time.Duration, recoveryProposalInterval time.Duration, recoveryFinalInterval time.Duration, - retryQ ocr2keepers.RetryQueue, - proposals ocr2keepers.ProposalQueue, - stateUpdater ocr2keepers.UpkeepStateUpdater, + retryQ types.RetryQueue, + proposals types.ProposalQueue, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) []service.Recoverable { // all flows use the same preprocessor based on the coordinator // each flow can add preprocessors to this provided slice - preprocessors := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + preprocessors := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} // the recovery proposal flow is for nodes to surface payloads that should // be recovered. these values are passed to the network and the network diff --git a/pkg/v3/flows/factory_test.go b/pkg/v3/flows/factory_test.go index bf5923b1..d1363bfe 100644 --- a/pkg/v3/flows/factory_test.go +++ b/pkg/v3/flows/factory_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestConditionalTriggerFlows(t *testing.T) { @@ -18,7 +18,7 @@ func TestConditionalTriggerFlows(t *testing.T) { nil, nil, &mockSubscriber{ - SubscribeFn: func() (int, chan ocr2keepers.BlockHistory, error) { + SubscribeFn: func() (int, chan common.BlockHistory, error) { return 0, nil, nil }, }, @@ -26,7 +26,7 @@ func TestConditionalTriggerFlows(t *testing.T) { nil, nil, &mockRunner{ - CheckUpkeepsFn: func(ctx context.Context, payload ...ocr2keepers.UpkeepPayload) ([]ocr2keepers.CheckResult, error) { + CheckUpkeepsFn: func(ctx context.Context, payload ...common.UpkeepPayload) ([]common.CheckResult, error) { return nil, nil }, }, @@ -44,7 +44,7 @@ func TestLogTriggerFlows(t *testing.T) { nil, nil, &mockRunner{ - CheckUpkeepsFn: func(ctx context.Context, payload ...ocr2keepers.UpkeepPayload) ([]ocr2keepers.CheckResult, error) { + CheckUpkeepsFn: func(ctx context.Context, payload ...common.UpkeepPayload) ([]common.CheckResult, error) { return nil, nil }, }, @@ -63,21 +63,21 @@ func TestLogTriggerFlows(t *testing.T) { } type mockRunner struct { - CheckUpkeepsFn func(context.Context, ...ocr2keepers.UpkeepPayload) ([]ocr2keepers.CheckResult, error) + CheckUpkeepsFn func(context.Context, ...common.UpkeepPayload) ([]common.CheckResult, error) } -func (r *mockRunner) CheckUpkeeps(ctx context.Context, p ...ocr2keepers.UpkeepPayload) ([]ocr2keepers.CheckResult, error) { +func (r *mockRunner) CheckUpkeeps(ctx context.Context, p ...common.UpkeepPayload) ([]common.CheckResult, error) { return r.CheckUpkeepsFn(ctx, p...) } type mockSubscriber struct { - SubscribeFn func() (int, chan ocr2keepers.BlockHistory, error) + SubscribeFn func() (int, chan common.BlockHistory, error) UnsubscribeFn func(int) error StartFn func(ctx context.Context) error CloseFn func() error } -func (r *mockSubscriber) Subscribe() (int, chan ocr2keepers.BlockHistory, error) { +func (r *mockSubscriber) Subscribe() (int, chan common.BlockHistory, error) { return r.SubscribeFn() } func (r *mockSubscriber) Unsubscribe(i int) error { diff --git a/pkg/v3/flows/logtrigger.go b/pkg/v3/flows/logtrigger.go index 728bd725..bfbe127a 100644 --- a/pkg/v3/flows/logtrigger.go +++ b/pkg/v3/flows/logtrigger.go @@ -11,7 +11,8 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( @@ -29,13 +30,13 @@ const ( // log trigger flow is the happy path entry point for log triggered upkeeps func newLogTriggerFlow( - preprocessors []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - rs ocr2keepers.ResultStore, + preprocessors []ocr2keepersv3.PreProcessor[common.UpkeepPayload], + rs types.ResultStore, rn ocr2keepersv3.Runner, - logProvider ocr2keepers.LogEventProvider, + logProvider common.LogEventProvider, logInterval time.Duration, - retryQ ocr2keepers.RetryQueue, - stateUpdater ocr2keepers.UpkeepStateUpdater, + retryQ types.RetryQueue, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) service.Recoverable { post := postprocessors.NewCombinedPostprocessor( @@ -52,7 +53,7 @@ func newLogTriggerFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | log-trigger-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - timeTick := tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](logInterval, obs, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + timeTick := tickers.NewTimeTicker[[]common.UpkeepPayload](logInterval, obs, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return logTick{logger: logger, logProvider: logProvider}, nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | log-trigger-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) @@ -60,11 +61,11 @@ func newLogTriggerFlow( } type logTick struct { - logProvider ocr2keepers.LogEventProvider + logProvider common.LogEventProvider logger *log.Logger } -func (et logTick) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error) { +func (et logTick) Value(ctx context.Context) ([]common.UpkeepPayload, error) { if et.logProvider == nil { return nil, nil } diff --git a/pkg/v3/flows/logtrigger_test.go b/pkg/v3/flows/logtrigger_test.go index 8457094d..2cb6c6cd 100644 --- a/pkg/v3/flows/logtrigger_test.go +++ b/pkg/v3/flows/logtrigger_test.go @@ -14,8 +14,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestLogTriggerFlow(t *testing.T) { @@ -30,34 +30,34 @@ func TestLogTriggerFlow(t *testing.T) { upkeepStateUpdater := new(mocks.MockUpkeepStateUpdater) lp := new(mocks.MockLogEventProvider) - lp.On("GetLatestPayloads", mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + lp.On("GetLatestPayloads", mock.Anything).Return([]common.UpkeepPayload{ { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", }, { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", }, }, nil).Times(times) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", }, { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", }, }, nil).Times(times) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", Eligible: true, }, { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", Retryable: true, }, @@ -68,7 +68,7 @@ func TestLogTriggerFlow(t *testing.T) { // set the ticker time lower to reduce the test time logInterval := 50 * time.Millisecond - svc := newLogTriggerFlow([]ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord}, + svc := newLogTriggerFlow([]ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord}, rStore, runner, lp, logInterval, retryQ, upkeepStateUpdater, logger) var wg sync.WaitGroup diff --git a/pkg/v3/flows/recovery.go b/pkg/v3/flows/recovery.go index ca94d3ee..77e2529e 100644 --- a/pkg/v3/flows/recovery.go +++ b/pkg/v3/flows/recovery.go @@ -6,13 +6,15 @@ import ( "log" "time" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/postprocessors" "github.com/smartcontractkit/chainlink-automation/pkg/v3/preprocessors" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( @@ -26,14 +28,14 @@ const ( ) func newFinalRecoveryFlow( - preprocessors []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - resultStore ocr2keepers.ResultStore, + preprocessors []ocr2keepersv3.PreProcessor[common.UpkeepPayload], + resultStore types.ResultStore, runner ocr2keepersv3.Runner, - retryQ ocr2keepers.RetryQueue, + retryQ types.RetryQueue, recoveryFinalizationInterval time.Duration, - proposalQ ocr2keepers.ProposalQueue, - builder ocr2keepers.PayloadBuilder, - stateUpdater ocr2keepers.UpkeepStateUpdater, + proposalQ types.ProposalQueue, + builder common.PayloadBuilder, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) service.Recoverable { post := postprocessors.NewCombinedPostprocessor( @@ -52,12 +54,12 @@ func newFinalRecoveryFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | recovery-final-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - ticker := tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](recoveryFinalizationInterval, recoveryObserver, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + ticker := tickers.NewTimeTicker[[]common.UpkeepPayload](recoveryFinalizationInterval, recoveryObserver, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return coordinatedProposalsTick{ logger: logger, builder: builder, q: proposalQ, - utype: ocr2keepers.LogTrigger, + utype: types.LogTrigger, batchSize: FinalRecoveryBatchSize, }, nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | recovery-final-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) @@ -68,13 +70,13 @@ func newFinalRecoveryFlow( // coordinatedProposalsTick is used to push proposals from the proposal queue to some observer type coordinatedProposalsTick struct { logger *log.Logger - builder ocr2keepers.PayloadBuilder - q ocr2keepers.ProposalQueue - utype ocr2keepers.UpkeepType + builder common.PayloadBuilder + q types.ProposalQueue + utype types.UpkeepType batchSize int } -func (t coordinatedProposalsTick) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error) { +func (t coordinatedProposalsTick) Value(ctx context.Context) ([]common.UpkeepPayload, error) { if t.q == nil { return nil, nil } @@ -89,7 +91,7 @@ func (t coordinatedProposalsTick) Value(ctx context.Context) ([]ocr2keepers.Upke if err != nil { return nil, fmt.Errorf("failed to build payloads from proposals: %w", err) } - payloads := []ocr2keepers.UpkeepPayload{} + payloads := []common.UpkeepPayload{} filtered := 0 for _, p := range builtPayloads { if p.IsEmpty() { @@ -103,15 +105,15 @@ func (t coordinatedProposalsTick) Value(ctx context.Context) ([]ocr2keepers.Upke } func newRecoveryProposalFlow( - preProcessors []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], + preProcessors []ocr2keepersv3.PreProcessor[common.UpkeepPayload], runner ocr2keepersv3.Runner, - metadataStore ocr2keepers.MetadataStore, - recoverableProvider ocr2keepers.RecoverableProvider, + metadataStore types.MetadataStore, + recoverableProvider common.RecoverableProvider, recoveryInterval time.Duration, - stateUpdater ocr2keepers.UpkeepStateUpdater, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) service.Recoverable { - preProcessors = append(preProcessors, preprocessors.NewProposalFilterer(metadataStore, ocr2keepers.LogTrigger)) + preProcessors = append(preProcessors, preprocessors.NewProposalFilterer(metadataStore, types.LogTrigger)) postprocessors := postprocessors.NewCombinedPostprocessor( postprocessors.NewIneligiblePostProcessor(stateUpdater, logger), postprocessors.NewAddProposalToMetadataStorePostprocessor(metadataStore), @@ -125,17 +127,17 @@ func newRecoveryProposalFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | recovery-proposal-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - return tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](recoveryInterval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + return tickers.NewTimeTicker[[]common.UpkeepPayload](recoveryInterval, observer, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return logRecoveryTick{logger: logger, logRecoverer: recoverableProvider}, nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | recovery-proposal-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) } type logRecoveryTick struct { - logRecoverer ocr2keepers.RecoverableProvider + logRecoverer common.RecoverableProvider logger *log.Logger } -func (et logRecoveryTick) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error) { +func (et logRecoveryTick) Value(ctx context.Context) ([]common.UpkeepPayload, error) { if et.logRecoverer == nil { return nil, nil } diff --git a/pkg/v3/flows/recovery_test.go b/pkg/v3/flows/recovery_test.go index 434c8879..554c66d4 100644 --- a/pkg/v3/flows/recovery_test.go +++ b/pkg/v3/flows/recovery_test.go @@ -14,14 +14,15 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestRecoveryFinalization(t *testing.T) { - upkeepIDs := []ocr2keepers.UpkeepIdentifier{ - ocr2keepers.UpkeepIdentifier([32]byte{1}), - ocr2keepers.UpkeepIdentifier([32]byte{2}), + upkeepIDs := []common.UpkeepIdentifier{ + common.UpkeepIdentifier([32]byte{1}), + common.UpkeepIdentifier([32]byte{2}), } workIDs := []string{ "0x1", @@ -36,14 +37,14 @@ func TestRecoveryFinalization(t *testing.T) { rStore := new(mocks.MockResultStore) coord := new(mocks.MockCoordinator) payloadBuilder := new(mocks.MockPayloadBuilder) - proposalQ := stores.NewProposalQueue(func(ui ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.LogTrigger + proposalQ := stores.NewProposalQueue(func(ui common.UpkeepIdentifier) types.UpkeepType { + return types.LogTrigger }) upkeepStateUpdater := new(mocks.MockUpkeepStateUpdater) retryQ := stores.NewRetryQueue(logger) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -53,7 +54,7 @@ func TestRecoveryFinalization(t *testing.T) { WorkID: workIDs[1], }, }, nil).Times(times) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -66,7 +67,7 @@ func TestRecoveryFinalization(t *testing.T) { }, }, nil).Times(times) rStore.On("Add", mock.Anything).Times(times) - payloadBuilder.On("BuildPayloads", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + payloadBuilder.On("BuildPayloads", mock.Anything, mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], @@ -79,16 +80,16 @@ func TestRecoveryFinalization(t *testing.T) { upkeepStateUpdater.On("SetUpkeepState", mock.Anything, mock.Anything, mock.Anything).Return(nil) // set the ticker time lower to reduce the test time recFinalInterval := 50 * time.Millisecond - pre := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + pre := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} svc := newFinalRecoveryFlow(pre, rStore, runner, retryQ, recFinalInterval, proposalQ, payloadBuilder, upkeepStateUpdater, logger) var wg sync.WaitGroup wg.Add(1) - err := proposalQ.Enqueue(ocr2keepers.CoordinatedBlockProposal{ + err := proposalQ.Enqueue(common.CoordinatedBlockProposal{ UpkeepID: upkeepIDs[0], WorkID: workIDs[0], - }, ocr2keepers.CoordinatedBlockProposal{ + }, common.CoordinatedBlockProposal{ UpkeepID: upkeepIDs[1], WorkID: workIDs[1], }) @@ -112,10 +113,10 @@ func TestRecoveryFinalization(t *testing.T) { } func TestRecoveryProposal(t *testing.T) { - upkeepIDs := []ocr2keepers.UpkeepIdentifier{ - ocr2keepers.UpkeepIdentifier([32]byte{1}), - ocr2keepers.UpkeepIdentifier([32]byte{2}), - ocr2keepers.UpkeepIdentifier([32]byte{3}), + upkeepIDs := []common.UpkeepIdentifier{ + common.UpkeepIdentifier([32]byte{1}), + common.UpkeepIdentifier([32]byte{2}), + common.UpkeepIdentifier([32]byte{3}), } workIDs := []string{ "0x1", @@ -130,27 +131,27 @@ func TestRecoveryProposal(t *testing.T) { recoverer := new(mocks.MockRecoverableProvider) coord := new(mocks.MockCoordinator) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], }, }, nil).Times(1) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[1], WorkID: workIDs[1], }, }, nil).Times(1) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], Eligible: true, }, }, nil).Times(1) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { UpkeepID: upkeepIDs[1], WorkID: workIDs[1], @@ -158,7 +159,7 @@ func TestRecoveryProposal(t *testing.T) { }, }, nil).Times(1) - mStore.On("ViewProposals", mock.Anything).Return([]ocr2keepers.CoordinatedBlockProposal{ + mStore.On("ViewProposals", mock.Anything).Return([]common.CoordinatedBlockProposal{ { UpkeepID: upkeepIDs[2], WorkID: workIDs[2], @@ -166,13 +167,13 @@ func TestRecoveryProposal(t *testing.T) { }, nil).Times(2) mStore.On("AddProposals", mock.Anything).Return(nil).Times(2) - recoverer.On("GetRecoveryProposals", mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + recoverer.On("GetRecoveryProposals", mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[0], WorkID: workIDs[0], }, }, nil).Times(1) - recoverer.On("GetRecoveryProposals", mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + recoverer.On("GetRecoveryProposals", mock.Anything).Return([]common.UpkeepPayload{ { UpkeepID: upkeepIDs[1], WorkID: workIDs[1], @@ -180,7 +181,7 @@ func TestRecoveryProposal(t *testing.T) { }, nil).Times(1) // set the ticker time lower to reduce the test time interval := 50 * time.Millisecond - pre := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + pre := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} stateUpdater := &mockStateUpdater{} svc := newRecoveryProposalFlow(pre, runner, mStore, recoverer, interval, stateUpdater, logger) @@ -205,5 +206,5 @@ func TestRecoveryProposal(t *testing.T) { } type mockStateUpdater struct { - ocr2keepers.UpkeepStateUpdater + common.UpkeepStateUpdater } diff --git a/pkg/v3/flows/retry.go b/pkg/v3/flows/retry.go index 0f41dc79..200b094f 100644 --- a/pkg/v3/flows/retry.go +++ b/pkg/v3/flows/retry.go @@ -11,7 +11,8 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( @@ -22,15 +23,15 @@ const ( ) func NewRetryFlow( - coord ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload], - resultStore ocr2keepers.ResultStore, + coord ocr2keepersv3.PreProcessor[common.UpkeepPayload], + resultStore types.ResultStore, runner ocr2keepersv3.Runner, - retryQ ocr2keepers.RetryQueue, + retryQ types.RetryQueue, retryTickerInterval time.Duration, - stateUpdater ocr2keepers.UpkeepStateUpdater, + stateUpdater common.UpkeepStateUpdater, logger *log.Logger, ) service.Recoverable { - preprocessors := []ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload]{coord} + preprocessors := []ocr2keepersv3.PreProcessor[common.UpkeepPayload]{coord} post := postprocessors.NewCombinedPostprocessor( postprocessors.NewEligiblePostProcessor(resultStore, telemetry.WrapLogger(logger, "retry-eligible-postprocessor")), postprocessors.NewRetryablePostProcessor(retryQ, telemetry.WrapLogger(logger, "retry-retryable-postprocessor")), @@ -45,7 +46,7 @@ func NewRetryFlow( log.New(logger.Writer(), fmt.Sprintf("[%s | retry-observer]", telemetry.ServiceName), telemetry.LogPkgStdFlags), ) - timeTick := tickers.NewTimeTicker[[]ocr2keepers.UpkeepPayload](retryTickerInterval, obs, func(ctx context.Context, _ time.Time) (tickers.Tick[[]ocr2keepers.UpkeepPayload], error) { + timeTick := tickers.NewTimeTicker[[]common.UpkeepPayload](retryTickerInterval, obs, func(ctx context.Context, _ time.Time) (tickers.Tick[[]common.UpkeepPayload], error) { return retryTick{logger: logger, q: retryQ, batchSize: RetryBatchSize}, nil }, log.New(logger.Writer(), fmt.Sprintf("[%s | retry-ticker]", telemetry.ServiceName), telemetry.LogPkgStdFlags)) @@ -54,11 +55,11 @@ func NewRetryFlow( type retryTick struct { logger *log.Logger - q ocr2keepers.RetryQueue + q types.RetryQueue batchSize int } -func (t retryTick) Value(ctx context.Context) ([]ocr2keepers.UpkeepPayload, error) { +func (t retryTick) Value(ctx context.Context) ([]common.UpkeepPayload, error) { if t.q == nil { return nil, nil } diff --git a/pkg/v3/flows/retry_test.go b/pkg/v3/flows/retry_test.go index 08c8c4a9..fe5ef3eb 100644 --- a/pkg/v3/flows/retry_test.go +++ b/pkg/v3/flows/retry_test.go @@ -8,13 +8,14 @@ import ( "testing" "time" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestRetryFlow(t *testing.T) { @@ -28,24 +29,24 @@ func TestRetryFlow(t *testing.T) { upkeepStateUpdater := new(mocks.MockUpkeepStateUpdater) retryQ := stores.NewRetryQueue(logger) - coord.On("PreProcess", mock.Anything, mock.Anything).Return([]ocr2keepers.UpkeepPayload{ + coord.On("PreProcess", mock.Anything, mock.Anything).Return([]common.UpkeepPayload{ { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", }, { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", }, }, nil).Times(times) - runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]ocr2keepers.CheckResult{ + runner.On("CheckUpkeeps", mock.Anything, mock.Anything, mock.Anything).Return([]common.CheckResult{ { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", Eligible: true, }, { - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", Retryable: true, }, @@ -61,14 +62,14 @@ func TestRetryFlow(t *testing.T) { var wg sync.WaitGroup wg.Add(1) - err := retryQ.Enqueue(ocr2keepers.RetryRecord{ - Payload: ocr2keepers.UpkeepPayload{ - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{1}), + err := retryQ.Enqueue(types.RetryRecord{ + Payload: common.UpkeepPayload{ + UpkeepID: common.UpkeepIdentifier([32]byte{1}), WorkID: "0x1", }, - }, ocr2keepers.RetryRecord{ - Payload: ocr2keepers.UpkeepPayload{ - UpkeepID: ocr2keepers.UpkeepIdentifier([32]byte{2}), + }, types.RetryRecord{ + Payload: common.UpkeepPayload{ + UpkeepID: common.UpkeepIdentifier([32]byte{2}), WorkID: "0x2", }, }) diff --git a/pkg/v3/observation.go b/pkg/v3/observation.go index 6c8660b6..8a56697a 100644 --- a/pkg/v3/observation.go +++ b/pkg/v3/observation.go @@ -5,6 +5,8 @@ import ( "fmt" "math/big" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) @@ -45,7 +47,7 @@ func (observation AutomationObservation) Encode() ([]byte, error) { return json.Marshal(observation) } -func DecodeAutomationObservation(data []byte, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) (AutomationObservation, error) { +func DecodeAutomationObservation(data []byte, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) (AutomationObservation, error) { ao := AutomationObservation{} err := json.Unmarshal(data, &ao) if err != nil { @@ -58,7 +60,7 @@ func DecodeAutomationObservation(data []byte, utg ocr2keepers.UpkeepTypeGetter, return ao, nil } -func validateAutomationObservation(o AutomationObservation, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) error { +func validateAutomationObservation(o AutomationObservation, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) error { // Validate Block History if len(o.BlockHistory) > ObservationBlockHistoryLimit { return fmt.Errorf("block history length cannot be greater than %d", ObservationBlockHistoryLimit) @@ -103,9 +105,9 @@ func validateAutomationObservation(o AutomationObservation, utg ocr2keepers.Upke return fmt.Errorf("proposals cannot have duplicate workIDs") } seenProposals[proposal.WorkID] = true - if utg(proposal.UpkeepID) == ocr2keepers.ConditionTrigger { + if utg(proposal.UpkeepID) == types.ConditionTrigger { conditionalProposalCount++ - } else if utg(proposal.UpkeepID) == ocr2keepers.LogTrigger { + } else if utg(proposal.UpkeepID) == types.LogTrigger { logProposalCount++ } } @@ -120,7 +122,7 @@ func validateAutomationObservation(o AutomationObservation, utg ocr2keepers.Upke } // Validates the check result fields sent within an observation -func validateCheckResult(r ocr2keepers.CheckResult, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) error { +func validateCheckResult(r ocr2keepers.CheckResult, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) error { if r.PipelineExecutionState != 0 || r.Retryable { return fmt.Errorf("check result cannot have failed execution state") } @@ -154,7 +156,7 @@ func validateCheckResult(r ocr2keepers.CheckResult, utg ocr2keepers.UpkeepTypeGe return nil } -func validateUpkeepProposal(p ocr2keepers.CoordinatedBlockProposal, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) error { +func validateUpkeepProposal(p ocr2keepers.CoordinatedBlockProposal, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) error { // No validation is done on Trigger.BlockNumber and Trigger.BlockHash because those // get updated with a coordinated quorum block ut := utg(p.UpkeepID) @@ -168,13 +170,13 @@ func validateUpkeepProposal(p ocr2keepers.CoordinatedBlockProposal, utg ocr2keep } // Validate validates the trigger fields, and any extensions if present. -func validateTriggerExtensionType(t ocr2keepers.Trigger, ut ocr2keepers.UpkeepType) error { +func validateTriggerExtensionType(t ocr2keepers.Trigger, ut types.UpkeepType) error { switch ut { - case ocr2keepers.ConditionTrigger: + case types.ConditionTrigger: if t.LogTriggerExtension != nil { return fmt.Errorf("log trigger extension cannot be present for condition upkeep") } - case ocr2keepers.LogTrigger: + case types.LogTrigger: if t.LogTriggerExtension == nil { return fmt.Errorf("log trigger extension cannot be empty for log upkeep") } diff --git a/pkg/v3/observation_test.go b/pkg/v3/observation_test.go index 80c3f078..3665efd7 100644 --- a/pkg/v3/observation_test.go +++ b/pkg/v3/observation_test.go @@ -9,26 +9,27 @@ import ( "github.com/stretchr/testify/assert" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var conditionalUpkeepID = [32]byte{1} var logUpkeepID = [32]byte{2} -var conditionalTrigger = types.Trigger{ +var conditionalTrigger = commontypes.Trigger{ BlockNumber: 10, BlockHash: [32]byte{1}, } -var logTrigger = types.Trigger{ +var logTrigger = commontypes.Trigger{ BlockNumber: 10, BlockHash: [32]byte{1}, - LogTriggerExtension: &types.LogTriggerExtension{ + LogTriggerExtension: &commontypes.LogTriggerExtension{ TxHash: [32]byte{1}, Index: 0, BlockHash: [32]byte{1}, BlockNumber: 5, }, } -var validConditionalResult = types.CheckResult{ +var validConditionalResult = commontypes.CheckResult{ PipelineExecutionState: 0, Retryable: false, Eligible: true, @@ -41,7 +42,7 @@ var validConditionalResult = types.CheckResult{ FastGasWei: big.NewInt(100), LinkNative: big.NewInt(100), } -var validLogResult = types.CheckResult{ +var validLogResult = commontypes.CheckResult{ PipelineExecutionState: 0, Retryable: false, Eligible: true, @@ -54,25 +55,25 @@ var validLogResult = types.CheckResult{ FastGasWei: big.NewInt(100), LinkNative: big.NewInt(100), } -var validConditionalProposal = types.CoordinatedBlockProposal{ +var validConditionalProposal = commontypes.CoordinatedBlockProposal{ UpkeepID: conditionalUpkeepID, Trigger: conditionalTrigger, WorkID: mockWorkIDGenerator(conditionalUpkeepID, conditionalTrigger), } -var validLogProposal = types.CoordinatedBlockProposal{ +var validLogProposal = commontypes.CoordinatedBlockProposal{ UpkeepID: logUpkeepID, Trigger: logTrigger, WorkID: mockWorkIDGenerator(logUpkeepID, logTrigger), } -var validBlockHistory = types.BlockHistory{ +var validBlockHistory = commontypes.BlockHistory{ { Number: 10, Hash: [32]byte{1}, }, } var validObservation = AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } var expectedEncodedObservation []byte @@ -113,13 +114,13 @@ func TestAutomationObservationEncodeBackwardsCompatibility(t *testing.T) { func TestLargeBlockHistory(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, - BlockHistory: types.BlockHistory{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + BlockHistory: commontypes.BlockHistory{}, } for i := 0; i < ObservationBlockHistoryLimit+1; i++ { - ao.BlockHistory = append(ao.BlockHistory, types.BlockKey{ - Number: types.BlockNumber(i + 1), + ao.BlockHistory = append(ao.BlockHistory, commontypes.BlockKey{ + Number: commontypes.BlockNumber(i + 1), Hash: [32]byte{1}, }) } @@ -133,13 +134,13 @@ func TestLargeBlockHistory(t *testing.T) { func TestDuplicateBlockHistory(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, - BlockHistory: types.BlockHistory{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + BlockHistory: commontypes.BlockHistory{}, } for i := 0; i < 2; i++ { - ao.BlockHistory = append(ao.BlockHistory, types.BlockKey{ - Number: types.BlockNumber(1), + ao.BlockHistory = append(ao.BlockHistory, commontypes.BlockKey{ + Number: commontypes.BlockNumber(1), Hash: [32]byte{uint8(i)}, }) } @@ -153,13 +154,13 @@ func TestDuplicateBlockHistory(t *testing.T) { func TestLargePerformable(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } for i := 0; i < ObservationPerformablesLimit+1; i++ { newConditionalResult := validConditionalResult - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1))) newConditionalResult.UpkeepID = uid newConditionalResult.WorkID = mockWorkIDGenerator(newConditionalResult.UpkeepID, newConditionalResult.Trigger) @@ -175,8 +176,8 @@ func TestLargePerformable(t *testing.T) { func TestDuplicatePerformable(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } for i := 0; i < 2; i++ { @@ -192,13 +193,13 @@ func TestDuplicatePerformable(t *testing.T) { func TestLargeProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } for i := 0; i < ObservationConditionalsProposalsLimit+ObservationLogRecoveryProposalsLimit+1; i++ { newProposal := validConditionalProposal - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1))) newProposal.UpkeepID = uid newProposal.WorkID = mockWorkIDGenerator(newProposal.UpkeepID, newProposal.Trigger) @@ -214,13 +215,13 @@ func TestLargeProposal(t *testing.T) { func TestLargeConditionalProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } for i := 0; i < ObservationConditionalsProposalsLimit+1; i++ { newProposal := validConditionalProposal - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1))) newProposal.UpkeepID = uid newProposal.WorkID = mockWorkIDGenerator(newProposal.UpkeepID, newProposal.Trigger) @@ -236,13 +237,13 @@ func TestLargeConditionalProposal(t *testing.T) { func TestLargeLogProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } for i := 0; i < ObservationLogRecoveryProposalsLimit+1; i++ { newProposal := validLogProposal - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1001))) newProposal.UpkeepID = uid newProposal.WorkID = mockWorkIDGenerator(newProposal.UpkeepID, newProposal.Trigger) @@ -258,8 +259,8 @@ func TestLargeLogProposal(t *testing.T) { func TestDuplicateProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } for i := 0; i < 2; i++ { @@ -276,8 +277,8 @@ func TestDuplicateProposal(t *testing.T) { func TestInvalidPipelineExecutionState(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validConditionalResult @@ -293,8 +294,8 @@ func TestInvalidPipelineExecutionState(t *testing.T) { func TestInvalidRetryable(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validConditionalResult @@ -310,8 +311,8 @@ func TestInvalidRetryable(t *testing.T) { func TestInvalidEligibility(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validConditionalResult @@ -327,8 +328,8 @@ func TestInvalidEligibility(t *testing.T) { func TestInvalidIneligibilityReason(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validConditionalResult @@ -344,8 +345,8 @@ func TestInvalidIneligibilityReason(t *testing.T) { func TestInvalidTriggerTypeConditional(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validConditionalResult @@ -361,8 +362,8 @@ func TestInvalidTriggerTypeConditional(t *testing.T) { func TestInvalidTriggerTypeLog(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -378,8 +379,8 @@ func TestInvalidTriggerTypeLog(t *testing.T) { func TestInvalidWorkID(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -395,8 +396,8 @@ func TestInvalidWorkID(t *testing.T) { func TestInvalidGasAllocated(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -412,8 +413,8 @@ func TestInvalidGasAllocated(t *testing.T) { func TestNilFastGas(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -429,8 +430,8 @@ func TestNilFastGas(t *testing.T) { func TestInvalidFastGasNegative(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -446,8 +447,8 @@ func TestInvalidFastGasNegative(t *testing.T) { func TestInvalidFastGasTooBig(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -463,8 +464,8 @@ func TestInvalidFastGasTooBig(t *testing.T) { func TestNilLinkNative(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -480,8 +481,8 @@ func TestNilLinkNative(t *testing.T) { func TestInvalidLinkNativeNegative(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -497,8 +498,8 @@ func TestInvalidLinkNativeNegative(t *testing.T) { func TestInvalidLinkNativeTooBig(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{validConditionalProposal, validLogProposal}, BlockHistory: validBlockHistory, } invalidPerformable := validLogResult @@ -514,8 +515,8 @@ func TestInvalidLinkNativeTooBig(t *testing.T) { func TestInvalidWorkIDProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } invalidProposal := validLogProposal @@ -531,8 +532,8 @@ func TestInvalidWorkIDProposal(t *testing.T) { func TestInvalidConditionalProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } invalidProposal := validConditionalProposal @@ -548,8 +549,8 @@ func TestInvalidConditionalProposal(t *testing.T) { func TestInvalidLogProposal(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{validConditionalResult, validLogResult}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, + Performable: []commontypes.CheckResult{validConditionalResult, validLogResult}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, BlockHistory: validBlockHistory, } invalidProposal := validLogProposal @@ -565,20 +566,20 @@ func TestInvalidLogProposal(t *testing.T) { func TestLargeObservationSize(t *testing.T) { ao := AutomationObservation{ - Performable: []types.CheckResult{}, - UpkeepProposals: []types.CoordinatedBlockProposal{}, - BlockHistory: types.BlockHistory{}, + Performable: []commontypes.CheckResult{}, + UpkeepProposals: []commontypes.CoordinatedBlockProposal{}, + BlockHistory: commontypes.BlockHistory{}, } for i := 0; i < ObservationBlockHistoryLimit; i++ { - ao.BlockHistory = append(ao.BlockHistory, types.BlockKey{ - Number: types.BlockNumber(i + 1), + ao.BlockHistory = append(ao.BlockHistory, commontypes.BlockKey{ + Number: commontypes.BlockNumber(i + 1), Hash: [32]byte{1}, }) } largePerformData := [10001]byte{} for i := 0; i < ObservationPerformablesLimit; i++ { newResult := validLogResult - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 10001))) newResult.UpkeepID = uid newResult.WorkID = mockWorkIDGenerator(newResult.UpkeepID, newResult.Trigger) @@ -587,7 +588,7 @@ func TestLargeObservationSize(t *testing.T) { } for i := 0; i < ObservationConditionalsProposalsLimit; i++ { newProposal := validConditionalProposal - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1))) newProposal.UpkeepID = uid newProposal.WorkID = mockWorkIDGenerator(newProposal.UpkeepID, newProposal.Trigger) @@ -595,7 +596,7 @@ func TestLargeObservationSize(t *testing.T) { } for i := 0; i < ObservationLogRecoveryProposalsLimit; i++ { newProposal := validLogProposal - uid := types.UpkeepIdentifier{} + uid := commontypes.UpkeepIdentifier{} uid.FromBigInt(big.NewInt(int64(i + 1001))) newProposal.UpkeepID = uid newProposal.WorkID = mockWorkIDGenerator(newProposal.UpkeepID, newProposal.Trigger) @@ -611,7 +612,7 @@ func TestLargeObservationSize(t *testing.T) { assert.Less(t, len(encoded), MaxObservationLength, "encoded observation should be less than maxObservationSize") } -func mockUpkeepTypeGetter(id types.UpkeepIdentifier) types.UpkeepType { +func mockUpkeepTypeGetter(id commontypes.UpkeepIdentifier) types.UpkeepType { if id == conditionalUpkeepID { return types.ConditionTrigger } @@ -621,7 +622,7 @@ func mockUpkeepTypeGetter(id types.UpkeepIdentifier) types.UpkeepType { return types.LogTrigger } -func mockWorkIDGenerator(id types.UpkeepIdentifier, trigger types.Trigger) string { +func mockWorkIDGenerator(id commontypes.UpkeepIdentifier, trigger commontypes.Trigger) string { wid := id.String() if trigger.LogTriggerExtension != nil { wid += string(trigger.LogTriggerExtension.LogIdentifier()) diff --git a/pkg/v3/observer.go b/pkg/v3/observer.go index 337495a3..4fc926a8 100644 --- a/pkg/v3/observer.go +++ b/pkg/v3/observer.go @@ -5,8 +5,9 @@ import ( "log" "time" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" ) // PreProcessor is the general interface for middleware used to filter, add, or modify upkeep diff --git a/pkg/v3/observer_test.go b/pkg/v3/observer_test.go index b3d3a624..f1b75d0c 100644 --- a/pkg/v3/observer_test.go +++ b/pkg/v3/observer_test.go @@ -12,8 +12,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/tickers" ) type mockTick struct { diff --git a/pkg/v3/outcome.go b/pkg/v3/outcome.go index 6e88b777..05963a58 100644 --- a/pkg/v3/outcome.go +++ b/pkg/v3/outcome.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) @@ -51,7 +52,7 @@ type AutomationOutcome struct { } // ValidateAutomationOutcome validates individual values in an AutomationOutcome -func validateAutomationOutcome(o AutomationOutcome, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) error { +func validateAutomationOutcome(o AutomationOutcome, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) error { // Validate AgreedPerformables if (len(o.AgreedPerformables)) > OutcomeAgreedPerformablesLimit { return fmt.Errorf("outcome performable length cannot be greater than %d", OutcomeAgreedPerformablesLimit) @@ -98,7 +99,7 @@ func (outcome AutomationOutcome) Encode() ([]byte, error) { // DecodeAutomationOutcome decodes an AutomationOutcome from an encoded array // of bytes. Possible errors come from the encoding/json package -func DecodeAutomationOutcome(data []byte, utg ocr2keepers.UpkeepTypeGetter, wg ocr2keepers.WorkIDGenerator) (AutomationOutcome, error) { +func DecodeAutomationOutcome(data []byte, utg types.UpkeepTypeGetter, wg types.WorkIDGenerator) (AutomationOutcome, error) { ao := AutomationOutcome{} err := json.Unmarshal(data, &ao) if err != nil { diff --git a/pkg/v3/plugin/delegate.go b/pkg/v3/plugin/delegate.go index 1300d84a..40108a97 100644 --- a/pkg/v3/plugin/delegate.go +++ b/pkg/v3/plugin/delegate.go @@ -6,15 +6,15 @@ import ( "log" "time" - "github.com/smartcontractkit/libocr/commontypes" - offchainreporting "github.com/smartcontractkit/libocr/offchainreporting2plus" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/runner" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/libocr/commontypes" + offchainreporting "github.com/smartcontractkit/libocr/offchainreporting2plus" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ) var ( @@ -29,26 +29,26 @@ type oracle interface { // DelegateConfig provides a single configuration struct for all options // to be passed to the oracle, oracle factory, and underlying plugin/services. type DelegateConfig struct { - BinaryNetworkEndpointFactory types.BinaryNetworkEndpointFactory + BinaryNetworkEndpointFactory ocr2plustypes.BinaryNetworkEndpointFactory V2Bootstrappers []commontypes.BootstrapperLocator - ContractConfigTracker types.ContractConfigTracker + ContractConfigTracker ocr2plustypes.ContractConfigTracker ContractTransmitter ocr3types.ContractTransmitter[AutomationReportInfo] KeepersDatabase ocr3types.Database Logger commontypes.Logger MonitoringEndpoint commontypes.MonitoringEndpoint - OffchainConfigDigester types.OffchainConfigDigester - OffchainKeyring types.OffchainKeyring + OffchainConfigDigester ocr2plustypes.OffchainConfigDigester + OffchainKeyring ocr2plustypes.OffchainKeyring OnchainKeyring ocr3types.OnchainKeyring[AutomationReportInfo] - LocalConfig types.LocalConfig + LocalConfig ocr2plustypes.LocalConfig // LogProvider allows reads on the latest log events ready to be processed LogProvider ocr2keepers.LogEventProvider // EventProvider allows reads on latest transmit events - EventProvider ocr2keepers.TransmitEventProvider + EventProvider types.TransmitEventProvider // Runnable is a check pipeline runner - Runnable ocr2keepers.Runnable + Runnable types.Runnable // Encoder provides methods to encode/decode reports Encoder ocr2keepers.Encoder @@ -72,8 +72,8 @@ type DelegateConfig struct { UpkeepStateUpdater ocr2keepers.UpkeepStateUpdater // Methods passed from core - UpkeepTypeGetter ocr2keepers.UpkeepTypeGetter - WorkIDGenerator ocr2keepers.WorkIDGenerator + UpkeepTypeGetter types.UpkeepTypeGetter + WorkIDGenerator types.WorkIDGenerator // CacheExpiration is the duration of time a cached key is available. Use // this value to balance memory usage and RPC calls. A new set of keys is @@ -140,7 +140,7 @@ func NewDelegate(c DelegateConfig) (*Delegate, error) { } // the log wrapper is to be able to use a log.Logger everywhere instead of - // a variety of logger types. all logs write to the Debug method. + // a variety of logger ocr2plustypes. all logs write to the Debug method. wrapper := &logWriter{l: c.Logger} l := log.New(wrapper, fmt.Sprintf("[%s] ", telemetry.ServiceName), log.Lshortfile) diff --git a/pkg/v3/plugin/factory.go b/pkg/v3/plugin/factory.go index 07d81a59..225b6d1e 100644 --- a/pkg/v3/plugin/factory.go +++ b/pkg/v3/plugin/factory.go @@ -7,43 +7,43 @@ import ( "math/cmplx" "strconv" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/runner" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" ) type pluginFactory struct { - logProvider types.LogEventProvider + logProvider commontypes.LogEventProvider events types.TransmitEventProvider - blocks types.BlockSubscriber - rp types.RecoverableProvider - builder types.PayloadBuilder - getter types.ConditionalUpkeepProvider + blocks commontypes.BlockSubscriber + rp commontypes.RecoverableProvider + builder commontypes.PayloadBuilder + getter commontypes.ConditionalUpkeepProvider runnable types.Runnable runnerConf runner.RunnerConfig - encoder types.Encoder + encoder commontypes.Encoder upkeepTypeGetter types.UpkeepTypeGetter workIDGenerator types.WorkIDGenerator - upkeepStateUpdater types.UpkeepStateUpdater + upkeepStateUpdater commontypes.UpkeepStateUpdater logger *log.Logger } func NewReportingPluginFactory( - logProvider types.LogEventProvider, + logProvider commontypes.LogEventProvider, events types.TransmitEventProvider, - blocks types.BlockSubscriber, - rp types.RecoverableProvider, - builder types.PayloadBuilder, - getter types.ConditionalUpkeepProvider, + blocks commontypes.BlockSubscriber, + rp commontypes.RecoverableProvider, + builder commontypes.PayloadBuilder, + getter commontypes.ConditionalUpkeepProvider, runnable types.Runnable, runnerConf runner.RunnerConfig, - encoder types.Encoder, + encoder commontypes.Encoder, upkeepTypeGetter types.UpkeepTypeGetter, workIDGenerator types.WorkIDGenerator, - upkeepStateUpdater types.UpkeepStateUpdater, + upkeepStateUpdater commontypes.UpkeepStateUpdater, logger *log.Logger, ) ocr3types.ReportingPluginFactory[AutomationReportInfo] { return &pluginFactory{ diff --git a/pkg/v3/plugin/hooks/add_block_history.go b/pkg/v3/plugin/hooks/add_block_history.go index a456a755..8145c5d2 100644 --- a/pkg/v3/plugin/hooks/add_block_history.go +++ b/pkg/v3/plugin/hooks/add_block_history.go @@ -6,15 +6,15 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) type AddBlockHistoryHook struct { - metadata ocr2keepers.MetadataStore + metadata types.MetadataStore logger *log.Logger } -func NewAddBlockHistoryHook(ms ocr2keepers.MetadataStore, logger *log.Logger) AddBlockHistoryHook { +func NewAddBlockHistoryHook(ms types.MetadataStore, logger *log.Logger) AddBlockHistoryHook { return AddBlockHistoryHook{ metadata: ms, logger: log.New(logger.Writer(), fmt.Sprintf("[%s | build hook:add-block-history]", telemetry.ServiceName), telemetry.LogPkgStdFlags)} diff --git a/pkg/v3/plugin/hooks/add_block_history_test.go b/pkg/v3/plugin/hooks/add_block_history_test.go index 430cf46a..5502f781 100644 --- a/pkg/v3/plugin/hooks/add_block_history_test.go +++ b/pkg/v3/plugin/hooks/add_block_history_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/assert" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestAddBlockHistoryHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_conditional_proposals.go b/pkg/v3/plugin/hooks/add_conditional_proposals.go index b6fd7ed4..73b2cc12 100644 --- a/pkg/v3/plugin/hooks/add_conditional_proposals.go +++ b/pkg/v3/plugin/hooks/add_conditional_proposals.go @@ -8,7 +8,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) type AddConditionalProposalsHook struct { diff --git a/pkg/v3/plugin/hooks/add_conditional_proposals_test.go b/pkg/v3/plugin/hooks/add_conditional_proposals_test.go index e57141cf..34fa3ad0 100644 --- a/pkg/v3/plugin/hooks/add_conditional_proposals_test.go +++ b/pkg/v3/plugin/hooks/add_conditional_proposals_test.go @@ -9,7 +9,8 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + common "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddConditionalSamplesHook_RunHook(t *testing.T) { @@ -17,7 +18,7 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { name string metadata types.MetadataStore coordinator types.Coordinator - proposals []types.CoordinatedBlockProposal + proposals []common.CoordinatedBlockProposal limit int src [16]byte wantNumProposals int @@ -27,8 +28,8 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { { name: "proposals aren't filtered and are added to the observation", metadata: &mockMetadataStore{ - ViewConditionalProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewConditionalProposalFn: func() []common.CoordinatedBlockProposal { + return []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -36,7 +37,7 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { assert.Equal(t, 1, len(proposals)) return proposals, nil }, @@ -48,8 +49,8 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { { name: "proposals are filtered and are added to the observation", metadata: &mockMetadataStore{ - ViewConditionalProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewConditionalProposalFn: func() []common.CoordinatedBlockProposal { + return []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -60,7 +61,7 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { assert.Equal(t, 2, len(proposals)) return proposals[:1], nil }, @@ -72,8 +73,8 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { { name: "proposals are appended to the existing proposals in observation", metadata: &mockMetadataStore{ - ViewConditionalProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewConditionalProposalFn: func() []common.CoordinatedBlockProposal { + return []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -81,12 +82,12 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { assert.Equal(t, 1, len(proposals)) return proposals, nil }, }, - proposals: []types.CoordinatedBlockProposal{{WorkID: "workID2"}}, + proposals: []common.CoordinatedBlockProposal{{WorkID: "workID2"}}, limit: 5, src: [16]byte{1}, wantNumProposals: 2, @@ -94,8 +95,8 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { { name: "proposals aren't filtered but are limited and are added to the observation", metadata: &mockMetadataStore{ - ViewConditionalProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewConditionalProposalFn: func() []common.CoordinatedBlockProposal { + return []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -112,7 +113,7 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { assert.Equal(t, 4, len(proposals)) return proposals, nil }, @@ -124,8 +125,8 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { { name: "if an error is encountered filtering proposals, an error is returned", metadata: &mockMetadataStore{ - ViewConditionalProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewConditionalProposalFn: func() []common.CoordinatedBlockProposal { + return []common.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -142,7 +143,7 @@ func TestAddConditionalSamplesHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []common.CoordinatedBlockProposal) ([]common.CoordinatedBlockProposal, error) { return nil, errors.New("filter proposals boom") }, }, diff --git a/pkg/v3/plugin/hooks/add_from_staging.go b/pkg/v3/plugin/hooks/add_from_staging.go index 1a0335ec..6655e016 100644 --- a/pkg/v3/plugin/hooks/add_from_staging.go +++ b/pkg/v3/plugin/hooks/add_from_staging.go @@ -8,11 +8,10 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) -func NewAddFromStagingHook(store ocr2keepers.ResultStore, coord types.Coordinator, logger *log.Logger) AddFromStagingHook { +func NewAddFromStagingHook(store types.ResultStore, coord types.Coordinator, logger *log.Logger) AddFromStagingHook { return AddFromStagingHook{ store: store, coord: coord, @@ -21,7 +20,7 @@ func NewAddFromStagingHook(store ocr2keepers.ResultStore, coord types.Coordinato } type AddFromStagingHook struct { - store ocr2keepers.ResultStore + store types.ResultStore logger *log.Logger coord types.Coordinator } diff --git a/pkg/v3/plugin/hooks/add_from_staging_test.go b/pkg/v3/plugin/hooks/add_from_staging_test.go index ba6ce52a..a24cfd9d 100644 --- a/pkg/v3/plugin/hooks/add_from_staging_test.go +++ b/pkg/v3/plugin/hooks/add_from_staging_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/mock" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" ) func TestAddFromStagingHook_RunHook(t *testing.T) { diff --git a/pkg/v3/plugin/hooks/add_log_proposals.go b/pkg/v3/plugin/hooks/add_log_proposals.go index d2bab052..755c9d14 100644 --- a/pkg/v3/plugin/hooks/add_log_proposals.go +++ b/pkg/v3/plugin/hooks/add_log_proposals.go @@ -8,7 +8,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) type AddLogProposalsHook struct { diff --git a/pkg/v3/plugin/hooks/add_log_proposals_test.go b/pkg/v3/plugin/hooks/add_log_proposals_test.go index 0c5e82a2..508d98dd 100644 --- a/pkg/v3/plugin/hooks/add_log_proposals_test.go +++ b/pkg/v3/plugin/hooks/add_log_proposals_test.go @@ -9,7 +9,8 @@ import ( "github.com/stretchr/testify/assert" ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { @@ -17,7 +18,7 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { name string metadata types.MetadataStore coordinator types.Coordinator - proposals []types.CoordinatedBlockProposal + proposals []commontypes.CoordinatedBlockProposal limit int src [16]byte wantNumProposals int @@ -27,8 +28,8 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { { name: "proposals aren't filtered and are added to the observation", metadata: &mockMetadataStore{ - ViewLogRecoveryProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewLogRecoveryProposalFn: func() []commontypes.CoordinatedBlockProposal { + return []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -36,7 +37,7 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) { assert.Equal(t, 1, len(proposals)) return proposals, nil }, @@ -48,8 +49,8 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { { name: "proposals are filtered and are added to the observation", metadata: &mockMetadataStore{ - ViewLogRecoveryProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewLogRecoveryProposalFn: func() []commontypes.CoordinatedBlockProposal { + return []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -60,7 +61,7 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) { assert.Equal(t, 2, len(proposals)) return proposals[:1], nil }, @@ -72,8 +73,8 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { { name: "proposals aren't filtered but are limited and are added to the observation", metadata: &mockMetadataStore{ - ViewLogRecoveryProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewLogRecoveryProposalFn: func() []commontypes.CoordinatedBlockProposal { + return []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -90,7 +91,7 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) { assert.Equal(t, 4, len(proposals)) return proposals, nil }, @@ -102,8 +103,8 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { { name: "if an error is encountered filtering proposals, an error is returned", metadata: &mockMetadataStore{ - ViewLogRecoveryProposalFn: func() []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewLogRecoveryProposalFn: func() []commontypes.CoordinatedBlockProposal { + return []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -120,7 +121,7 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { }, }, coordinator: &mockCoordinator{ - FilterProposalsFn: func(proposals []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { + FilterProposalsFn: func(proposals []commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) { return nil, errors.New("filter proposals boom") }, }, @@ -152,12 +153,12 @@ func TestAddLogRecoveryProposalsHook_RunHook(t *testing.T) { type mockMetadataStore struct { types.MetadataStore - ViewLogRecoveryProposalFn func() []types.CoordinatedBlockProposal - ViewConditionalProposalFn func() []types.CoordinatedBlockProposal - GetBlockHistoryFn func() types.BlockHistory + ViewLogRecoveryProposalFn func() []commontypes.CoordinatedBlockProposal + ViewConditionalProposalFn func() []commontypes.CoordinatedBlockProposal + GetBlockHistoryFn func() commontypes.BlockHistory } -func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []types.CoordinatedBlockProposal { +func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []commontypes.CoordinatedBlockProposal { switch utype { case types.LogTrigger: return s.ViewLogRecoveryProposalFn() @@ -168,30 +169,30 @@ func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []types.Coordi } } -func (s *mockMetadataStore) GetBlockHistory() types.BlockHistory { +func (s *mockMetadataStore) GetBlockHistory() commontypes.BlockHistory { return s.GetBlockHistoryFn() } type mockCoordinator struct { types.Coordinator - FilterProposalsFn func([]types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) - FilterResultsFn func([]types.CheckResult) ([]types.CheckResult, error) - ShouldAcceptFn func(types.ReportedUpkeep) bool - ShouldTransmitFn func(types.ReportedUpkeep) bool + FilterProposalsFn func([]commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) + FilterResultsFn func([]commontypes.CheckResult) ([]commontypes.CheckResult, error) + ShouldAcceptFn func(commontypes.ReportedUpkeep) bool + ShouldTransmitFn func(commontypes.ReportedUpkeep) bool } -func (s *mockCoordinator) FilterProposals(p []types.CoordinatedBlockProposal) ([]types.CoordinatedBlockProposal, error) { +func (s *mockCoordinator) FilterProposals(p []commontypes.CoordinatedBlockProposal) ([]commontypes.CoordinatedBlockProposal, error) { return s.FilterProposalsFn(p) } -func (s *mockCoordinator) FilterResults(res []types.CheckResult) ([]types.CheckResult, error) { +func (s *mockCoordinator) FilterResults(res []commontypes.CheckResult) ([]commontypes.CheckResult, error) { return s.FilterResultsFn(res) } -func (s *mockCoordinator) ShouldAccept(upkeep types.ReportedUpkeep) bool { +func (s *mockCoordinator) ShouldAccept(upkeep commontypes.ReportedUpkeep) bool { return s.ShouldAcceptFn(upkeep) } -func (s *mockCoordinator) ShouldTransmit(upkeep types.ReportedUpkeep) bool { +func (s *mockCoordinator) ShouldTransmit(upkeep commontypes.ReportedUpkeep) bool { return s.ShouldTransmitFn(upkeep) } diff --git a/pkg/v3/plugin/hooks/add_to_proposalq.go b/pkg/v3/plugin/hooks/add_to_proposalq.go index 093ef093..8f04d1c2 100644 --- a/pkg/v3/plugin/hooks/add_to_proposalq.go +++ b/pkg/v3/plugin/hooks/add_to_proposalq.go @@ -6,10 +6,10 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) -func NewAddToProposalQHook(proposalQ ocr2keepers.ProposalQueue, logger *log.Logger) AddToProposalQHook { +func NewAddToProposalQHook(proposalQ types.ProposalQueue, logger *log.Logger) AddToProposalQHook { return AddToProposalQHook{ proposalQ: proposalQ, logger: log.New(logger.Writer(), fmt.Sprintf("[%s | pre-build hook:add-to-proposalq]", telemetry.ServiceName), telemetry.LogPkgStdFlags), @@ -17,7 +17,7 @@ func NewAddToProposalQHook(proposalQ ocr2keepers.ProposalQueue, logger *log.Logg } type AddToProposalQHook struct { - proposalQ ocr2keepers.ProposalQueue + proposalQ types.ProposalQueue logger *log.Logger } diff --git a/pkg/v3/plugin/hooks/add_to_proposalq_test.go b/pkg/v3/plugin/hooks/add_to_proposalq_test.go index a9e05695..005d331f 100644 --- a/pkg/v3/plugin/hooks/add_to_proposalq_test.go +++ b/pkg/v3/plugin/hooks/add_to_proposalq_test.go @@ -9,7 +9,8 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestAddToProposalQHook_RunHook(t *testing.T) { @@ -22,7 +23,7 @@ func TestAddToProposalQHook_RunHook(t *testing.T) { { name: "Happy path add proposals to queue", automationOutcome: ocr2keepersv3.AutomationOutcome{ - SurfacedProposals: [][]types.CoordinatedBlockProposal{ + SurfacedProposals: [][]commontypes.CoordinatedBlockProposal{ {{WorkID: "1"}, {WorkID: "2"}}, {{WorkID: "3"}}, }, @@ -33,7 +34,7 @@ func TestAddToProposalQHook_RunHook(t *testing.T) { { name: "Empty automation outcome", automationOutcome: ocr2keepersv3.AutomationOutcome{ - SurfacedProposals: [][]types.CoordinatedBlockProposal{}, + SurfacedProposals: [][]commontypes.CoordinatedBlockProposal{}, }, expectedQueueSize: 0, expectedLog: "Added 0 proposals from outcome", @@ -41,7 +42,7 @@ func TestAddToProposalQHook_RunHook(t *testing.T) { { name: "Multiple rounds with proposals", automationOutcome: ocr2keepersv3.AutomationOutcome{ - SurfacedProposals: [][]types.CoordinatedBlockProposal{ + SurfacedProposals: [][]commontypes.CoordinatedBlockProposal{ {{WorkID: "1"}, {WorkID: "2"}}, {{WorkID: "3"}}, {{WorkID: "4"}, {WorkID: "5"}, {WorkID: "6"}}, @@ -54,7 +55,7 @@ func TestAddToProposalQHook_RunHook(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - upkeepTypeGetter := func(uid types.UpkeepIdentifier) types.UpkeepType { + upkeepTypeGetter := func(uid commontypes.UpkeepIdentifier) types.UpkeepType { return types.UpkeepType(uid[15]) } proposalQ := stores.NewProposalQueue(upkeepTypeGetter) diff --git a/pkg/v3/plugin/hooks/remove_from_metadata.go b/pkg/v3/plugin/hooks/remove_from_metadata.go index 71e48a45..4a707b9b 100644 --- a/pkg/v3/plugin/hooks/remove_from_metadata.go +++ b/pkg/v3/plugin/hooks/remove_from_metadata.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) func NewRemoveFromMetadataHook(ms types.MetadataStore, logger *log.Logger) RemoveFromMetadataHook { diff --git a/pkg/v3/plugin/hooks/remove_from_metadata_test.go b/pkg/v3/plugin/hooks/remove_from_metadata_test.go index 27768cee..a4a47400 100644 --- a/pkg/v3/plugin/hooks/remove_from_metadata_test.go +++ b/pkg/v3/plugin/hooks/remove_from_metadata_test.go @@ -8,23 +8,24 @@ import ( "github.com/stretchr/testify/mock" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestRemoveFromMetadataHook_RunHook(t *testing.T) { - var uid1 types.UpkeepIdentifier = [32]byte{1} - var uid2 types.UpkeepIdentifier = [32]byte{2} - var uid3 types.UpkeepIdentifier = [32]byte{3} + var uid1 commontypes.UpkeepIdentifier = [32]byte{1} + var uid2 commontypes.UpkeepIdentifier = [32]byte{2} + var uid3 commontypes.UpkeepIdentifier = [32]byte{3} tests := []struct { name string - surfacedProposals [][]types.CoordinatedBlockProposal - upkeepTypeGetter map[types.UpkeepIdentifier]types.UpkeepType + surfacedProposals [][]commontypes.CoordinatedBlockProposal + upkeepTypeGetter map[commontypes.UpkeepIdentifier]types.UpkeepType expectedRemovals int }{ { name: "Remove proposals from metadata store", - surfacedProposals: [][]types.CoordinatedBlockProposal{ + surfacedProposals: [][]commontypes.CoordinatedBlockProposal{ { {UpkeepID: uid1, WorkID: "1"}, {UpkeepID: uid2, WorkID: "2"}, @@ -33,7 +34,7 @@ func TestRemoveFromMetadataHook_RunHook(t *testing.T) { {UpkeepID: uid3, WorkID: "3"}, }, }, - upkeepTypeGetter: map[types.UpkeepIdentifier]types.UpkeepType{ + upkeepTypeGetter: map[commontypes.UpkeepIdentifier]types.UpkeepType{ uid1: types.ConditionTrigger, uid2: types.LogTrigger, uid3: types.ConditionTrigger, @@ -42,7 +43,7 @@ func TestRemoveFromMetadataHook_RunHook(t *testing.T) { }, { name: "No proposals to remove", - surfacedProposals: [][]types.CoordinatedBlockProposal{ + surfacedProposals: [][]commontypes.CoordinatedBlockProposal{ {}, {}, }, diff --git a/pkg/v3/plugin/hooks/remove_from_staging.go b/pkg/v3/plugin/hooks/remove_from_staging.go index 62b44bea..7bfa8959 100644 --- a/pkg/v3/plugin/hooks/remove_from_staging.go +++ b/pkg/v3/plugin/hooks/remove_from_staging.go @@ -6,7 +6,7 @@ import ( ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ) func NewRemoveFromStagingHook(store types.ResultStore, logger *log.Logger) RemoveFromStagingHook { diff --git a/pkg/v3/plugin/ocr3.go b/pkg/v3/plugin/ocr3.go index d2109f22..2a61be29 100644 --- a/pkg/v3/plugin/ocr3.go +++ b/pkg/v3/plugin/ocr3.go @@ -6,25 +6,25 @@ import ( "fmt" "log" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin/hooks" "github.com/smartcontractkit/chainlink-automation/pkg/v3/random" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ) type AutomationReportInfo struct{} type ocr3Plugin struct { - ConfigDigest types.ConfigDigest + ConfigDigest ocr2plustypes.ConfigDigest ReportEncoder ocr2keepers.Encoder - Coordinator ocr2keepers.Coordinator - UpkeepTypeGetter ocr2keepers.UpkeepTypeGetter - WorkIDGenerator ocr2keepers.WorkIDGenerator + Coordinator types.Coordinator + UpkeepTypeGetter types.UpkeepTypeGetter + WorkIDGenerator types.WorkIDGenerator RemoveFromStagingHook hooks.RemoveFromStagingHook RemoveFromMetadataHook hooks.RemoveFromMetadataHook AddToProposalQHook hooks.AddToProposalQHook @@ -38,11 +38,11 @@ type ocr3Plugin struct { Logger *log.Logger } -func (plugin *ocr3Plugin) Query(ctx context.Context, outctx ocr3types.OutcomeContext) (types.Query, error) { +func (plugin *ocr3Plugin) Query(ctx context.Context, outctx ocr3types.OutcomeContext) (ocr2plustypes.Query, error) { return nil, nil } -func (plugin *ocr3Plugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContext, query types.Query) (types.Observation, error) { +func (plugin *ocr3Plugin) Observation(ctx context.Context, outctx ocr3types.OutcomeContext, query ocr2plustypes.Query) (ocr2plustypes.Observation, error) { plugin.Logger.Printf("inside Observation for seqNr %d", outctx.SeqNr) // first round outcome will be nil or empty so no processing should be done if outctx.PreviousOutcome != nil || len(outctx.PreviousOutcome) != 0 { @@ -78,17 +78,17 @@ func (plugin *ocr3Plugin) Observation(ctx context.Context, outctx ocr3types.Outc return observation.Encode() } -func (plugin *ocr3Plugin) ObservationQuorum(outctx ocr3types.OutcomeContext, query types.Query) (ocr3types.Quorum, error) { +func (plugin *ocr3Plugin) ObservationQuorum(outctx ocr3types.OutcomeContext, query ocr2plustypes.Query) (ocr3types.Quorum, error) { return ocr3types.QuorumTwoFPlusOne, nil } -func (plugin *ocr3Plugin) ValidateObservation(outctx ocr3types.OutcomeContext, query types.Query, ao types.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(outctx ocr3types.OutcomeContext, query types.Query, attributedObservations []types.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) @@ -255,13 +255,13 @@ func (plugin *ocr3Plugin) startServices() { func (plugin *ocr3Plugin) getReportFromPerformables(toPerform []ocr2keepers.CheckResult) (ocr3types.ReportWithInfo[AutomationReportInfo], error) { encoded, err := plugin.ReportEncoder.Encode(toPerform...) return ocr3types.ReportWithInfo[AutomationReportInfo]{ - Report: types.Report(encoded), + Report: ocr2plustypes.Report(encoded), }, err } // Generates a randomness source derived from the config and seq # so // that it's the same across the network for the same round. // similar key building as libocr transmit selector. -func getRandomKeySource(cd types.ConfigDigest, seqNr uint64) [16]byte { +func getRandomKeySource(cd ocr2plustypes.ConfigDigest, seqNr uint64) [16]byte { return random.GetRandomKeySource(cd[:], seqNr) } diff --git a/pkg/v3/plugin/ocr3_test.go b/pkg/v3/plugin/ocr3_test.go index db0477de..7c27dc45 100644 --- a/pkg/v3/plugin/ocr3_test.go +++ b/pkg/v3/plugin/ocr3_test.go @@ -13,14 +13,15 @@ import ( "testing" "github.com/ethereum/go-ethereum/crypto" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/stretchr/testify/assert" ocr2keepers2 "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/pkg/v3/plugin/hooks" "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ) func TestOcr3Plugin_Query(t *testing.T) { @@ -46,7 +47,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{ { WorkID: "workID1", @@ -93,9 +94,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: nil, } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Nil(t, err) - assert.Equal(t, types.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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"},{"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"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), observation) + assert.Equal(t, ocr2plustypes.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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"},{"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"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), observation) assert.True(t, strings.Contains(logBuf.String(), "built an observation in sequence nr 0 with 2 performables, 2 upkeep proposals and 2 block history")) }) @@ -117,7 +118,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{ { WorkID: "workID2", @@ -168,9 +169,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: nil, } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Nil(t, err) - assert.Equal(t, types.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID3","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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":"workID2"},{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]},{"Number":3,"Hash":[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]}]}`), observation) + assert.Equal(t, ocr2plustypes.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID3","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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":"workID2"},{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]},{"Number":3,"Hash":[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]}]}`), observation) assert.True(t, strings.Contains(logBuf.String(), "built an observation in sequence nr 0 with 3 performables, 2 upkeep proposals and 3 block history")) }) @@ -192,7 +193,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, } @@ -240,9 +241,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: nil, } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Nil(t, err) - assert.Equal(t, types.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"IneligibilityReason":1,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID3","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]},{"Number":3,"Hash":[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]}]}`), observation) + assert.Equal(t, ocr2plustypes.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"IneligibilityReason":1,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID2","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":"workID3","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]},{"Number":3,"Hash":[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]}]}`), observation) assert.True(t, strings.Contains(logBuf.String(), "built an observation in sequence nr 0 with 3 performables, 0 upkeep proposals and 3 block history")) }) @@ -264,7 +265,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, } @@ -339,7 +340,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - _, err = plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + _, err = plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Error(t, err) assert.Equal(t, "check result cannot be ineligible", err.Error()) }) @@ -362,7 +363,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, RemoveProposalsFn: func(proposal ...ocr2keepers.CoordinatedBlockProposal) { @@ -451,9 +452,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.NoError(t, err) - assert.Equal(t, types.Observation(`{"Performable":[{"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":"workID5","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"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":"workID6","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":3,"Hash":[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]},{"Number":4,"Hash":[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]},{"Number":5,"Hash":[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]}]}`), observation) + assert.Equal(t, ocr2plustypes.Observation(`{"Performable":[{"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":"workID5","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null},{"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":"workID6","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":3,"Hash":[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]},{"Number":4,"Hash":[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]},{"Number":5,"Hash":[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]}]}`), observation) assert.True(t, strings.Contains(logBuf.String(), "built an observation in sequence nr 0 with 2 performables, 0 upkeep proposals and 3 block history")) }) @@ -475,7 +476,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, RemoveProposalsFn: func(proposal ...ocr2keepers.CoordinatedBlockProposal) { @@ -565,9 +566,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.NoError(t, err) - assert.Equal(t, types.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":true,"IneligibilityReason":1,"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":"workID5","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":3,"Hash":[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]},{"Number":4,"Hash":[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]},{"Number":5,"Hash":[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]}]}`), observation) + assert.Equal(t, ocr2plustypes.Observation(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":true,"IneligibilityReason":1,"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":"workID5","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":null,"BlockHistory":[{"Number":3,"Hash":[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]},{"Number":4,"Hash":[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]},{"Number":5,"Hash":[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]}]}`), observation) assert.True(t, strings.Contains(logBuf.String(), "built an observation in sequence nr 0 with 1 performables, 0 upkeep proposals and 3 block history")) }) @@ -589,7 +590,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, RemoveProposalsFn: func(proposal ...ocr2keepers.CoordinatedBlockProposal) { @@ -667,7 +668,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - _, err = plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + _, err = plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Error(t, err) assert.Equal(t, "result store view boom", err.Error()) }) @@ -690,7 +691,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return []ocr2keepers.CoordinatedBlockProposal{} }, RemoveProposalsFn: func(proposal ...ocr2keepers.CoordinatedBlockProposal) { @@ -780,7 +781,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - _, err = plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + _, err = plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Error(t, err) assert.Equal(t, "filter proposals error", err.Error()) }) @@ -803,9 +804,9 @@ func TestOcr3Plugin_Observation(t *testing.T) { }, } }, - ViewProposalsFn: func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { + ViewProposalsFn: func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { switch upkeepType { - case ocr2keepers.ConditionTrigger: + case types.ConditionTrigger: return []ocr2keepers.CoordinatedBlockProposal{ { UpkeepID: [32]byte{1}, @@ -909,7 +910,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(previousOutcomeBytes), } - _, err = plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + _, err = plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Error(t, err) assert.Equal(t, "filter proposals error", err.Error()) }) @@ -923,7 +924,7 @@ func TestOcr3Plugin_Observation(t *testing.T) { PreviousOutcome: ocr3types.Outcome(`invalid`), } - observation, err := plugin.Observation(context.Background(), outcomeCtx, types.Query{}) + observation, err := plugin.Observation(context.Background(), outcomeCtx, ocr2plustypes.Query{}) assert.Error(t, err) assert.Nil(t, observation) }) @@ -932,14 +933,14 @@ func TestOcr3Plugin_Observation(t *testing.T) { func TestOcr3Plugin_ValidateObservation(t *testing.T) { for _, tc := range []struct { name string - observation types.AttributedObservation - wg ocr2keepers.WorkIDGenerator + observation ocr2plustypes.AttributedObservation + wg types.WorkIDGenerator expectsErr bool wantErr error }{ { name: "validating an empty observation returns an error", - observation: types.AttributedObservation{}, + observation: ocr2plustypes.AttributedObservation{}, expectsErr: true, wantErr: errors.New("unexpected end of JSON input"), }, @@ -948,13 +949,13 @@ func TestOcr3Plugin_ValidateObservation(t *testing.T) { wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" }, - observation: types.AttributedObservation{ + observation: ocr2plustypes.AttributedObservation{ Observation: []byte(`{"Performable":[{"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":10,"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,1],"LogTriggerExtension":null},"WorkID":"workID1","GasAllocated":1,"PerformData":null,"FastGasWei":10,"LinkNative":10}],"UpkeepProposals":[{"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"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, }, { name: "gas allocated cannot be zero", - observation: types.AttributedObservation{ + observation: ocr2plustypes.AttributedObservation{ Observation: []byte(`{"Performable":[{"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":10,"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,1],"LogTriggerExtension":null},"WorkID":"workID1","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { @@ -965,7 +966,7 @@ func TestOcr3Plugin_ValidateObservation(t *testing.T) { }, { name: "mismatch in generated work ID", - observation: types.AttributedObservation{ + observation: ocr2plustypes.AttributedObservation{ Observation: []byte(`{"Performable":[{"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":10,"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,1],"LogTriggerExtension":null},"WorkID":"workID1","GasAllocated":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { @@ -976,7 +977,7 @@ func TestOcr3Plugin_ValidateObservation(t *testing.T) { }, { name: "check result cannot be ineligible and have no ineligibility reason", - observation: types.AttributedObservation{ + observation: ocr2plustypes.AttributedObservation{ Observation: []byte(`{"Performable":[{"PipelineExecutionState":0,"Retryable":false,"Eligible":false,"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":0,"PerformData":null,"FastGasWei":null,"LinkNative":null}],"UpkeepProposals":[{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, expectsErr: true, @@ -1003,21 +1004,21 @@ func TestOcr3Plugin_ValidateObservation(t *testing.T) { func TestOcr3Plugin_Outcome(t *testing.T) { for _, tc := range []struct { name string - observations []types.AttributedObservation + observations []ocr2plustypes.AttributedObservation prevOutcome ocr3types.Outcome - wg ocr2keepers.WorkIDGenerator + wg types.WorkIDGenerator wantOutcome ocr3types.Outcome expectsErr bool wantErr error }{ { name: "processing an empty list of observations generates an empty outcome", - observations: []types.AttributedObservation{}, + observations: []ocr2plustypes.AttributedObservation{}, wantOutcome: ocr3types.Outcome([]byte(`{"AgreedPerformables":[],"SurfacedProposals":[]}`)), }, { name: "processing a well formed observation with a previous outcome generates an new outcome", - observations: []types.AttributedObservation{ + observations: []ocr2plustypes.AttributedObservation{ { Observation: []byte(`{"Performable":[{"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":0,"LinkNative":0}],"UpkeepProposals":[],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, @@ -1030,7 +1031,7 @@ func TestOcr3Plugin_Outcome(t *testing.T) { }, { name: "processing a malformed observation with a previous outcome generates an new outcome", - observations: []types.AttributedObservation{ + observations: []ocr2plustypes.AttributedObservation{ { Observation: []byte(`invalid`), }, @@ -1043,7 +1044,7 @@ func TestOcr3Plugin_Outcome(t *testing.T) { }, { name: "processing an invalid observation with a previous outcome generates an new outcome", - observations: []types.AttributedObservation{ + observations: []ocr2plustypes.AttributedObservation{ { Observation: []byte(`{"Performable":[{"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":0,"PerformData":null,"FastGasWei":0,"LinkNative":0}],"UpkeepProposals":[{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, @@ -1056,7 +1057,7 @@ func TestOcr3Plugin_Outcome(t *testing.T) { }, { name: "processing an valid observation with a malformed previous outcome returns an error", - observations: []types.AttributedObservation{ + observations: []ocr2plustypes.AttributedObservation{ { Observation: []byte(`{"Performable":[{"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":0,"LinkNative":0}],"UpkeepProposals":[{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, @@ -1070,7 +1071,7 @@ func TestOcr3Plugin_Outcome(t *testing.T) { }, { name: "processing an valid observation with an invalid previous outcome returns an error", - observations: []types.AttributedObservation{ + observations: []ocr2plustypes.AttributedObservation{ { Observation: []byte(`{"Performable":[{"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":0,"LinkNative":0}],"UpkeepProposals":[{"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":"workID2"}],"BlockHistory":[{"Number":1,"Hash":[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]},{"Number":2,"Hash":[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]}]}`), }, @@ -1115,8 +1116,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { outcome ocr3types.Outcome wantReportsWithInfo []ocr3types.ReportWithInfo[AutomationReportInfo] encoder ocr2keepers.Encoder - utg ocr2keepers.UpkeepTypeGetter - wg ocr2keepers.WorkIDGenerator + utg types.UpkeepTypeGetter + wg types.WorkIDGenerator expectsErr bool wantErr error }{ @@ -1154,8 +1155,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return json.Marshal(result) }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "invalid work ID" @@ -1172,8 +1173,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return json.Marshal(result) }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" @@ -1190,8 +1191,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return json.Marshal(result) }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" @@ -1214,8 +1215,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return json.Marshal(result) }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" @@ -1232,8 +1233,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return nil, errors.New("encode boom") }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" @@ -1253,8 +1254,8 @@ func TestOcr3Plugin_Reports(t *testing.T) { return nil, errors.New("encode boom") }, }, - utg: func(identifier ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + utg: func(identifier ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }, wg: func(identifier ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { return "workID1" @@ -1291,7 +1292,7 @@ func TestOcr3Plugin_ShouldAcceptAttestedReport(t *testing.T) { sequenceNumber uint64 reportWithInfo ocr3types.ReportWithInfo[AutomationReportInfo] encoder ocr2keepers.Encoder - coordinator ocr2keepers.Coordinator + coordinator types.Coordinator expectsErr bool wantErr error wantOK bool @@ -1392,7 +1393,7 @@ func TestOcr3Plugin_ShouldTransmitAcceptedReport(t *testing.T) { sequenceNumber uint64 reportWithInfo ocr3types.ReportWithInfo[AutomationReportInfo] encoder ocr2keepers.Encoder - coordinator ocr2keepers.Coordinator + coordinator types.Coordinator expectsErr bool wantErr error wantOK bool @@ -1519,7 +1520,7 @@ func TestOcr3Plugin_startServices(t *testing.T) { } type mockResultStore struct { - ocr2keepers.ResultStore + types.ResultStore ViewFn func() ([]ocr2keepers.CheckResult, error) RemoveFn func(...string) } @@ -1534,14 +1535,14 @@ func (s *mockResultStore) Remove(r ...string) { type mockProposalQueue struct { EnqueueFn func(items ...ocr2keepers.CoordinatedBlockProposal) error - DequeueFn func(t ocr2keepers.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) + DequeueFn func(t types.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) } func (s *mockProposalQueue) Enqueue(items ...ocr2keepers.CoordinatedBlockProposal) error { return s.EnqueueFn(items...) } -func (s *mockProposalQueue) Dequeue(t ocr2keepers.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) { +func (s *mockProposalQueue) Dequeue(t types.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) { return s.DequeueFn(t, n) } @@ -1572,13 +1573,13 @@ func (e *mockRecoverable) Close() error { } type mockMetadataStore struct { - ocr2keepers.MetadataStore - ViewProposalsFn func(upkeepType ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal + types.MetadataStore + ViewProposalsFn func(upkeepType types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal GetBlockHistoryFn func() ocr2keepers.BlockHistory RemoveProposalsFn func(...ocr2keepers.CoordinatedBlockProposal) } -func (s *mockMetadataStore) ViewProposals(utype ocr2keepers.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { +func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []ocr2keepers.CoordinatedBlockProposal { return s.ViewProposalsFn(utype) } @@ -1592,7 +1593,7 @@ func (s *mockMetadataStore) RemoveProposals(p ...ocr2keepers.CoordinatedBlockPro } type mockCoordinator struct { - ocr2keepers.Coordinator + types.Coordinator FilterProposalsFn func([]ocr2keepers.CoordinatedBlockProposal) ([]ocr2keepers.CoordinatedBlockProposal, error) FilterResultsFn func([]ocr2keepers.CheckResult) ([]ocr2keepers.CheckResult, error) ShouldAcceptFn func(ocr2keepers.ReportedUpkeep) bool @@ -1628,9 +1629,9 @@ func mockWorkIDGenerator(id ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Tr return wid } -func mockUpkeepTypeGetter(id ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { +func mockUpkeepTypeGetter(id ocr2keepers.UpkeepIdentifier) types.UpkeepType { if id.BigInt().Int64() < 10 { - return ocr2keepers.ConditionTrigger + return types.ConditionTrigger } - return ocr2keepers.LogTrigger + return types.LogTrigger } diff --git a/pkg/v3/plugin/plugin.go b/pkg/v3/plugin/plugin.go index c02a4d88..6ebb74a1 100644 --- a/pkg/v3/plugin/plugin.go +++ b/pkg/v3/plugin/plugin.go @@ -4,9 +4,6 @@ import ( "fmt" "log" - "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" - "github.com/smartcontractkit/libocr/offchainreporting2plus/types" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/config" "github.com/smartcontractkit/chainlink-automation/pkg/v3/coordinator" "github.com/smartcontractkit/chainlink-automation/pkg/v3/flows" @@ -15,23 +12,26 @@ import ( "github.com/smartcontractkit/chainlink-automation/pkg/v3/service" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocr2plustypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" ) func newPlugin( - digest types.ConfigDigest, + digest ocr2plustypes.ConfigDigest, logProvider ocr2keepers.LogEventProvider, - events ocr2keepers.TransmitEventProvider, + events types.TransmitEventProvider, blockSource ocr2keepers.BlockSubscriber, recoverablesProvider ocr2keepers.RecoverableProvider, builder ocr2keepers.PayloadBuilder, - ratio ocr2keepers.Ratio, + ratio types.Ratio, getter ocr2keepers.ConditionalUpkeepProvider, encoder ocr2keepers.Encoder, - upkeepTypeGetter ocr2keepers.UpkeepTypeGetter, - workIDGenerator ocr2keepers.WorkIDGenerator, + upkeepTypeGetter types.UpkeepTypeGetter, + workIDGenerator types.WorkIDGenerator, upkeepStateUpdater ocr2keepers.UpkeepStateUpdater, - runnable ocr2keepers.Runnable, + runnable types.Runnable, rConf runner.RunnerConfig, conf config.OffchainConfig, f int, diff --git a/pkg/v3/postprocessors/eligible.go b/pkg/v3/postprocessors/eligible.go index d1d94b33..f5cbc8b7 100644 --- a/pkg/v3/postprocessors/eligible.go +++ b/pkg/v3/postprocessors/eligible.go @@ -5,8 +5,9 @@ import ( "fmt" "log" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" ) // checkResultAdder is a general interface for a result store that accepts check results diff --git a/pkg/v3/postprocessors/eligible_test.go b/pkg/v3/postprocessors/eligible_test.go index 7d874ab4..5699f5f9 100644 --- a/pkg/v3/postprocessors/eligible_test.go +++ b/pkg/v3/postprocessors/eligible_test.go @@ -9,8 +9,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" ) func TestNewEligiblePostProcessor(t *testing.T) { diff --git a/pkg/v3/postprocessors/ineligible.go b/pkg/v3/postprocessors/ineligible.go index efa3c2a0..f2a7be28 100644 --- a/pkg/v3/postprocessors/ineligible.go +++ b/pkg/v3/postprocessors/ineligible.go @@ -6,8 +6,9 @@ import ( "fmt" "log" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" ) type ineligiblePostProcessor struct { diff --git a/pkg/v3/postprocessors/metadata.go b/pkg/v3/postprocessors/metadata.go index 02bfd5cd..bba4a81f 100644 --- a/pkg/v3/postprocessors/metadata.go +++ b/pkg/v3/postprocessors/metadata.go @@ -3,14 +3,15 @@ package postprocessors import ( "context" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) type addProposalToMetadataStore struct { - metadataStore ocr2keepers.MetadataStore + metadataStore types.MetadataStore } -func NewAddProposalToMetadataStorePostprocessor(store ocr2keepers.MetadataStore) *addProposalToMetadataStore { +func NewAddProposalToMetadataStorePostprocessor(store types.MetadataStore) *addProposalToMetadataStore { return &addProposalToMetadataStore{metadataStore: store} } diff --git a/pkg/v3/postprocessors/metadata_test.go b/pkg/v3/postprocessors/metadata_test.go index a0ad00ec..a11d5a2c 100644 --- a/pkg/v3/postprocessors/metadata_test.go +++ b/pkg/v3/postprocessors/metadata_test.go @@ -7,13 +7,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestMetadataAddSamples(t *testing.T) { ch := make(chan ocr2keepers.BlockHistory) - ms, err := stores.NewMetadataStore(&mockBlockSubscriber{ch: ch}, func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.ConditionTrigger + ms, err := stores.NewMetadataStore(&mockBlockSubscriber{ch: ch}, func(uid ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.ConditionTrigger }) assert.NoError(t, err) @@ -53,7 +54,7 @@ func TestMetadataAddSamples(t *testing.T) { assert.NoError(t, err, "no error expected from post processor") - assert.Equal(t, 2, len(ms.ViewProposals(ocr2keepers.ConditionTrigger))) + assert.Equal(t, 2, len(ms.ViewProposals(types.ConditionTrigger))) } type mockBlockSubscriber struct { diff --git a/pkg/v3/postprocessors/retry.go b/pkg/v3/postprocessors/retry.go index f0e628b0..ed9757f0 100644 --- a/pkg/v3/postprocessors/retry.go +++ b/pkg/v3/postprocessors/retry.go @@ -7,10 +7,11 @@ import ( "log" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) -func NewRetryablePostProcessor(q ocr2keepers.RetryQueue, logger *log.Logger) *retryablePostProcessor { +func NewRetryablePostProcessor(q types.RetryQueue, logger *log.Logger) *retryablePostProcessor { return &retryablePostProcessor{ logger: log.New(logger.Writer(), fmt.Sprintf("[%s | retryable-post-processor]", telemetry.ServiceName), telemetry.LogPkgStdFlags), q: q, @@ -19,7 +20,7 @@ func NewRetryablePostProcessor(q ocr2keepers.RetryQueue, logger *log.Logger) *re type retryablePostProcessor struct { logger *log.Logger - q ocr2keepers.RetryQueue + q types.RetryQueue } var _ PostProcessor = (*retryablePostProcessor)(nil) @@ -29,7 +30,7 @@ func (p *retryablePostProcessor) PostProcess(_ context.Context, results []ocr2ke retryable := 0 for i, res := range results { if res.PipelineExecutionState != 0 && res.Retryable { - e := p.q.Enqueue(ocr2keepers.RetryRecord{ + e := p.q.Enqueue(types.RetryRecord{ Payload: payloads[i], Interval: res.RetryInterval, }) diff --git a/pkg/v3/postprocessors/retry_test.go b/pkg/v3/postprocessors/retry_test.go index edf0da48..9023f2dd 100644 --- a/pkg/v3/postprocessors/retry_test.go +++ b/pkg/v3/postprocessors/retry_test.go @@ -6,10 +6,9 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/stores" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/stretchr/testify/assert" ) func TestRetryPostProcessor_PostProcess(t *testing.T) { diff --git a/pkg/v3/preprocessors/proposal_filterer.go b/pkg/v3/preprocessors/proposal_filterer.go index 7e03fd03..89472f26 100644 --- a/pkg/v3/preprocessors/proposal_filterer.go +++ b/pkg/v3/preprocessors/proposal_filterer.go @@ -4,10 +4,11 @@ import ( "context" ocr2keepersv3 "github.com/smartcontractkit/chainlink-automation/pkg/v3" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) -func NewProposalFilterer(metadata ocr2keepers.MetadataStore, upkeepType ocr2keepers.UpkeepType) ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload] { +func NewProposalFilterer(metadata types.MetadataStore, upkeepType types.UpkeepType) ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload] { return &proposalFilterer{ upkeepType: upkeepType, metadata: metadata, @@ -15,8 +16,8 @@ func NewProposalFilterer(metadata ocr2keepers.MetadataStore, upkeepType ocr2keep } type proposalFilterer struct { - metadata ocr2keepers.MetadataStore - upkeepType ocr2keepers.UpkeepType + metadata types.MetadataStore + upkeepType types.UpkeepType } var _ ocr2keepersv3.PreProcessor[ocr2keepers.UpkeepPayload] = (*proposalFilterer)(nil) diff --git a/pkg/v3/preprocessors/proposal_filterer_test.go b/pkg/v3/preprocessors/proposal_filterer_test.go index 2d8336c5..3eb64bf2 100644 --- a/pkg/v3/preprocessors/proposal_filterer_test.go +++ b/pkg/v3/preprocessors/proposal_filterer_test.go @@ -6,13 +6,14 @@ import ( "github.com/stretchr/testify/assert" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestProposalFilterer_PreProcess(t *testing.T) { metadata := &mockMetadataStore{ - ViewProposalsFn: func(utype types.UpkeepType) []types.CoordinatedBlockProposal { - return []types.CoordinatedBlockProposal{ + ViewProposalsFn: func(utype types.UpkeepType) []commontypes.CoordinatedBlockProposal { + return []commontypes.CoordinatedBlockProposal{ { WorkID: "workID2", }, @@ -23,7 +24,7 @@ func TestProposalFilterer_PreProcess(t *testing.T) { metadata: metadata, upkeepType: types.LogTrigger, } - payloads, err := filterer.PreProcess(context.Background(), []types.UpkeepPayload{ + payloads, err := filterer.PreProcess(context.Background(), []commontypes.UpkeepPayload{ { WorkID: "workID1", }, @@ -35,14 +36,14 @@ func TestProposalFilterer_PreProcess(t *testing.T) { }, }) assert.Nil(t, err) - assert.Equal(t, []types.UpkeepPayload{{WorkID: "workID1"}, {WorkID: "workID3"}}, payloads) + assert.Equal(t, []commontypes.UpkeepPayload{{WorkID: "workID1"}, {WorkID: "workID3"}}, payloads) } type mockMetadataStore struct { types.MetadataStore - ViewProposalsFn func(utype types.UpkeepType) []types.CoordinatedBlockProposal + ViewProposalsFn func(utype types.UpkeepType) []commontypes.CoordinatedBlockProposal } -func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []types.CoordinatedBlockProposal { +func (s *mockMetadataStore) ViewProposals(utype types.UpkeepType) []commontypes.CoordinatedBlockProposal { return s.ViewProposalsFn(utype) } diff --git a/pkg/v3/runner/runner.go b/pkg/v3/runner/runner.go index a5a7a008..668f51fb 100644 --- a/pkg/v3/runner/runner.go +++ b/pkg/v3/runner/runner.go @@ -8,10 +8,13 @@ import ( "sync/atomic" "time" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/internal/util" pkgutil "github.com/smartcontractkit/chainlink-automation/pkg/util" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const WorkerBatchLimit int = 10 @@ -20,7 +23,7 @@ var ErrTooManyErrors = fmt.Errorf("too many errors in parallel worker process") // ensure that the runner implements the same interface it consumes to indicate // the runner simply wraps the underlying runnable with extra features -var _ ocr2keepers.Runnable = &Runner{} +var _ types.Runnable = &Runner{} // Runner is a component that parallelizes calls to the provided runnable both // by batching tasks to individual calls as well as using parallel threads to @@ -33,7 +36,7 @@ var _ ocr2keepers.Runnable = &Runner{} type Runner struct { // injected dependencies logger *log.Logger - runnable ocr2keepers.Runnable + runnable types.Runnable // initialized by the constructor workers *pkgutil.WorkerGroup[[]ocr2keepers.CheckResult] // parallelizer cache *pkgutil.Cache[ocr2keepers.CheckResult] // result cache @@ -57,7 +60,7 @@ type RunnerConfig struct { // NewRunner provides a new configured runner func NewRunner( logger *log.Logger, - runnable ocr2keepers.Runnable, + runnable types.Runnable, conf RunnerConfig, ) (*Runner, error) { return &Runner{ diff --git a/pkg/v3/runner/runner_test.go b/pkg/v3/runner/runner_test.go index 4cef8743..2aca5a88 100644 --- a/pkg/v3/runner/runner_test.go +++ b/pkg/v3/runner/runner_test.go @@ -15,7 +15,8 @@ import ( "github.com/stretchr/testify/mock" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" - "github.com/smartcontractkit/chainlink-common/pkg/types/automation/mocks" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types/mocks" ) var ( diff --git a/pkg/v3/stores/metadata_store.go b/pkg/v3/stores/metadata_store.go index 627f3649..2d0239a3 100644 --- a/pkg/v3/stores/metadata_store.go +++ b/pkg/v3/stores/metadata_store.go @@ -8,7 +8,8 @@ import ( "sync/atomic" "time" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) const ( @@ -22,7 +23,7 @@ var ( type expiringRecord struct { createdAt time.Time - proposal types.CoordinatedBlockProposal + proposal commontypes.CoordinatedBlockProposal } func (r expiringRecord) expired(expr time.Duration) bool { @@ -31,9 +32,9 @@ func (r expiringRecord) expired(expr time.Duration) bool { type metadataStore struct { chID int - ch chan types.BlockHistory - subscriber types.BlockSubscriber - blockHistory types.BlockHistory + ch chan commontypes.BlockHistory + subscriber commontypes.BlockSubscriber + blockHistory commontypes.BlockHistory blockHistoryMutex sync.RWMutex conditionalProposals orderedMap conditionalMutex sync.RWMutex @@ -45,7 +46,7 @@ type metadataStore struct { typeGetter types.UpkeepTypeGetter } -func NewMetadataStore(subscriber types.BlockSubscriber, typeGetter types.UpkeepTypeGetter) (*metadataStore, error) { +func NewMetadataStore(subscriber commontypes.BlockSubscriber, typeGetter types.UpkeepTypeGetter) (*metadataStore, error) { chID, ch, err := subscriber.Subscribe() if err != nil { return nil, err @@ -55,7 +56,7 @@ func NewMetadataStore(subscriber types.BlockSubscriber, typeGetter types.UpkeepT chID: chID, ch: ch, subscriber: subscriber, - blockHistory: types.BlockHistory{}, + blockHistory: commontypes.BlockHistory{}, conditionalProposals: newOrderedMap(), logRecoveryProposals: newOrderedMap(), stopCh: make(chan struct{}, 1), @@ -63,21 +64,21 @@ func NewMetadataStore(subscriber types.BlockSubscriber, typeGetter types.UpkeepT }, nil } -func (m *metadataStore) SetBlockHistory(blockHistory types.BlockHistory) { +func (m *metadataStore) SetBlockHistory(blockHistory commontypes.BlockHistory) { m.blockHistoryMutex.Lock() defer m.blockHistoryMutex.Unlock() m.blockHistory = blockHistory } -func (m *metadataStore) GetBlockHistory() types.BlockHistory { +func (m *metadataStore) GetBlockHistory() commontypes.BlockHistory { m.blockHistoryMutex.RLock() defer m.blockHistoryMutex.RUnlock() return m.blockHistory } -func (m *metadataStore) AddProposals(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) AddProposals(proposals ...commontypes.CoordinatedBlockProposal) { for _, proposal := range proposals { switch m.typeGetter(proposal.UpkeepID) { case types.LogTrigger: @@ -88,7 +89,7 @@ func (m *metadataStore) AddProposals(proposals ...types.CoordinatedBlockProposal } } -func (m *metadataStore) ViewProposals(utype types.UpkeepType) []types.CoordinatedBlockProposal { +func (m *metadataStore) ViewProposals(utype types.UpkeepType) []commontypes.CoordinatedBlockProposal { switch utype { case types.LogTrigger: return m.viewLogRecoveryProposal() @@ -99,7 +100,7 @@ func (m *metadataStore) ViewProposals(utype types.UpkeepType) []types.Coordinate } } -func (m *metadataStore) RemoveProposals(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) RemoveProposals(proposals ...commontypes.CoordinatedBlockProposal) { for _, proposal := range proposals { switch m.typeGetter(proposal.UpkeepID) { case types.LogTrigger: @@ -144,7 +145,7 @@ func (m *metadataStore) Close() error { return nil } -func (m *metadataStore) addLogRecoveryProposal(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) addLogRecoveryProposal(proposals ...commontypes.CoordinatedBlockProposal) { m.logRecoveryMutex.Lock() defer m.logRecoveryMutex.Unlock() @@ -156,12 +157,12 @@ func (m *metadataStore) addLogRecoveryProposal(proposals ...types.CoordinatedBlo } } -func (m *metadataStore) viewLogRecoveryProposal() []types.CoordinatedBlockProposal { +func (m *metadataStore) viewLogRecoveryProposal() []commontypes.CoordinatedBlockProposal { // We also remove expired items in this function, hence take Lock() instead of RLock() m.logRecoveryMutex.Lock() defer m.logRecoveryMutex.Unlock() - res := make([]types.CoordinatedBlockProposal, 0) + res := make([]commontypes.CoordinatedBlockProposal, 0) for _, key := range m.logRecoveryProposals.Keys() { record := m.logRecoveryProposals.Get(key) @@ -175,7 +176,7 @@ func (m *metadataStore) viewLogRecoveryProposal() []types.CoordinatedBlockPropos return res } -func (m *metadataStore) removeLogRecoveryProposal(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) removeLogRecoveryProposal(proposals ...commontypes.CoordinatedBlockProposal) { m.logRecoveryMutex.Lock() defer m.logRecoveryMutex.Unlock() @@ -184,7 +185,7 @@ func (m *metadataStore) removeLogRecoveryProposal(proposals ...types.Coordinated } } -func (m *metadataStore) addConditionalProposal(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) addConditionalProposal(proposals ...commontypes.CoordinatedBlockProposal) { m.conditionalMutex.Lock() defer m.conditionalMutex.Unlock() @@ -196,12 +197,12 @@ func (m *metadataStore) addConditionalProposal(proposals ...types.CoordinatedBlo } } -func (m *metadataStore) viewConditionalProposal() []types.CoordinatedBlockProposal { +func (m *metadataStore) viewConditionalProposal() []commontypes.CoordinatedBlockProposal { // We also remove expired items in this function, hence take Lock() instead of RLock() m.conditionalMutex.Lock() defer m.conditionalMutex.Unlock() - res := make([]types.CoordinatedBlockProposal, 0) + res := make([]commontypes.CoordinatedBlockProposal, 0) for _, key := range m.conditionalProposals.Keys() { record := m.conditionalProposals.Get(key) @@ -216,7 +217,7 @@ func (m *metadataStore) viewConditionalProposal() []types.CoordinatedBlockPropos } -func (m *metadataStore) removeConditionalProposal(proposals ...types.CoordinatedBlockProposal) { +func (m *metadataStore) removeConditionalProposal(proposals ...commontypes.CoordinatedBlockProposal) { m.conditionalMutex.Lock() defer m.conditionalMutex.Unlock() diff --git a/pkg/v3/stores/metadata_store_test.go b/pkg/v3/stores/metadata_store_test.go index b9642d33..93a6a396 100644 --- a/pkg/v3/stores/metadata_store_test.go +++ b/pkg/v3/stores/metadata_store_test.go @@ -8,13 +8,14 @@ import ( "github.com/stretchr/testify/assert" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestNewMetadataStore(t *testing.T) { t.Run("creating the metadata store errors when subscribing to the block subscriber errors", func(t *testing.T) { blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 0, nil, errors.New("subscribe boom") }, } @@ -28,9 +29,9 @@ func TestNewMetadataStore(t *testing.T) { t.Run("the metadata store starts, reads from the block ticker, and stops without erroring", func(t *testing.T) { canClose := make(chan struct{}, 1) finished := make(chan struct{}, 1) - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, UnsubscribeFn: func(i int) error { @@ -39,11 +40,11 @@ func TestNewMetadataStore(t *testing.T) { } go func() { - ch <- types.BlockHistory{ - types.BlockKey{ + ch <- commontypes.BlockHistory{ + commontypes.BlockKey{ Number: 4, }, - types.BlockKey{ + commontypes.BlockKey{ Number: 3, }, } @@ -77,9 +78,9 @@ func TestNewMetadataStore(t *testing.T) { }) t.Run("closing the metadata store errors when unsubscribing from the block subscriber errors", func(t *testing.T) { - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, UnsubscribeFn: func(i int) error { @@ -101,9 +102,9 @@ func TestNewMetadataStore(t *testing.T) { t.Run("the metadata store starts, reads from the block ticker, and stops via a cancelled context without erroring", func(t *testing.T) { canClose := make(chan struct{}, 1) finished := make(chan struct{}, 1) - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, UnsubscribeFn: func(i int) error { @@ -112,11 +113,11 @@ func TestNewMetadataStore(t *testing.T) { } go func() { - ch <- types.BlockHistory{ - types.BlockKey{ + ch <- commontypes.BlockHistory{ + commontypes.BlockKey{ Number: 4, }, - types.BlockKey{ + commontypes.BlockKey{ Number: 3, }, } @@ -150,9 +151,9 @@ func TestNewMetadataStore(t *testing.T) { }) t.Run("starting an already started metadata store returns an error", func(t *testing.T) { - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, } @@ -163,9 +164,9 @@ func TestNewMetadataStore(t *testing.T) { }) t.Run("closing an already closed metadata store returns an error", func(t *testing.T) { - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, } @@ -179,15 +180,15 @@ func TestNewMetadataStore(t *testing.T) { func TestMetadataStore_AddConditionalProposal(t *testing.T) { for _, tc := range []struct { name string - addProposals [][]types.CoordinatedBlockProposal - afterAdd []types.CoordinatedBlockProposal - deleteProposals []types.CoordinatedBlockProposal - afterDelete []types.CoordinatedBlockProposal + addProposals [][]commontypes.CoordinatedBlockProposal + afterAdd []commontypes.CoordinatedBlockProposal + deleteProposals []commontypes.CoordinatedBlockProposal + afterDelete []commontypes.CoordinatedBlockProposal timeFn func() time.Time }{ { name: "all unique proposals are added and retrieved, existent keys are successfully deleted", - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -205,7 +206,7 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -219,7 +220,7 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { WorkID: "workID4", }, }, - deleteProposals: []types.CoordinatedBlockProposal{ + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -230,7 +231,7 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { WorkID: "workID5", }, }, - afterDelete: []types.CoordinatedBlockProposal{ + afterDelete: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID2", }, @@ -242,7 +243,7 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { }, { name: "duplicate proposals aren't returned, existent keys are successfully deleted", - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -260,22 +261,22 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - deleteProposals: []types.CoordinatedBlockProposal{ + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - afterDelete: []types.CoordinatedBlockProposal{}, + afterDelete: []commontypes.CoordinatedBlockProposal{}, timeFn: time.Now, }, { name: "proposals added three days ago aren't returned, non existent keys result in a no op delete", - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -293,13 +294,13 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{}, - deleteProposals: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{}, + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - afterDelete: []types.CoordinatedBlockProposal{}, + afterDelete: []commontypes.CoordinatedBlockProposal{}, timeFn: func() time.Time { return time.Now().Add(-72 * time.Hour) }, @@ -312,9 +313,9 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { timeFn = oldTimeFn }() - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, } @@ -338,19 +339,19 @@ func TestMetadataStore_AddConditionalProposal(t *testing.T) { func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { for _, tc := range []struct { name string - addProposals [][]types.CoordinatedBlockProposal - afterAdd []types.CoordinatedBlockProposal - deleteProposals []types.CoordinatedBlockProposal - afterDelete []types.CoordinatedBlockProposal + addProposals [][]commontypes.CoordinatedBlockProposal + afterAdd []commontypes.CoordinatedBlockProposal + deleteProposals []commontypes.CoordinatedBlockProposal + afterDelete []commontypes.CoordinatedBlockProposal timeFn func() time.Time typeGetter types.UpkeepTypeGetter }{ { name: "all unique proposals are added and retrieved, existent keys are successfully deleted", - typeGetter: func(identifier types.UpkeepIdentifier) types.UpkeepType { + typeGetter: func(identifier commontypes.UpkeepIdentifier) types.UpkeepType { return types.LogTrigger }, - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -368,7 +369,7 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -382,7 +383,7 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { WorkID: "workID4", }, }, - deleteProposals: []types.CoordinatedBlockProposal{ + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, @@ -393,7 +394,7 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { WorkID: "workID5", }, }, - afterDelete: []types.CoordinatedBlockProposal{ + afterDelete: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID2", }, @@ -405,10 +406,10 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { }, { name: "duplicate proposals aren't returned, existent keys are successfully deleted", - typeGetter: func(identifier types.UpkeepIdentifier) types.UpkeepType { + typeGetter: func(identifier commontypes.UpkeepIdentifier) types.UpkeepType { return types.LogTrigger }, - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -426,25 +427,25 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - deleteProposals: []types.CoordinatedBlockProposal{ + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - afterDelete: []types.CoordinatedBlockProposal{}, + afterDelete: []commontypes.CoordinatedBlockProposal{}, timeFn: time.Now, }, { name: "proposals added three days ago aren't returned, non existent keys result in a no op delete", - typeGetter: func(identifier types.UpkeepIdentifier) types.UpkeepType { + typeGetter: func(identifier commontypes.UpkeepIdentifier) types.UpkeepType { return types.LogTrigger }, - addProposals: [][]types.CoordinatedBlockProposal{ + addProposals: [][]commontypes.CoordinatedBlockProposal{ { { WorkID: "workID1", @@ -462,13 +463,13 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { }, }, }, - afterAdd: []types.CoordinatedBlockProposal{}, - deleteProposals: []types.CoordinatedBlockProposal{ + afterAdd: []commontypes.CoordinatedBlockProposal{}, + deleteProposals: []commontypes.CoordinatedBlockProposal{ { WorkID: "workID1", }, }, - afterDelete: []types.CoordinatedBlockProposal{}, + afterDelete: []commontypes.CoordinatedBlockProposal{}, timeFn: func() time.Time { return time.Now().Add(-72 * time.Hour) }, @@ -480,9 +481,9 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { defer func() { timeFn = oldTimeFn }() - ch := make(chan types.BlockHistory) + ch := make(chan commontypes.BlockHistory) blockSubscriber := &mockBlockSubscriber{ - SubscribeFn: func() (int, chan types.BlockHistory, error) { + SubscribeFn: func() (int, chan commontypes.BlockHistory, error) { return 1, ch, nil }, } @@ -504,13 +505,13 @@ func TestMetadataStore_AddLogRecoveryProposal(t *testing.T) { } type mockBlockSubscriber struct { - SubscribeFn func() (int, chan types.BlockHistory, error) + SubscribeFn func() (int, chan commontypes.BlockHistory, error) UnsubscribeFn func(int) error StartFn func(ctx context.Context) error CloseFn func() error } -func (_m *mockBlockSubscriber) Subscribe() (int, chan types.BlockHistory, error) { +func (_m *mockBlockSubscriber) Subscribe() (int, chan commontypes.BlockHistory, error) { return _m.SubscribeFn() } diff --git a/pkg/v3/stores/proposal_queue.go b/pkg/v3/stores/proposal_queue.go index 7dde5fa7..79996464 100644 --- a/pkg/v3/stores/proposal_queue.go +++ b/pkg/v3/stores/proposal_queue.go @@ -4,6 +4,8 @@ import ( "sync" "time" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) @@ -30,12 +32,12 @@ type proposalQueue struct { lock sync.RWMutex records map[string]proposalQueueRecord - typeGetter ocr2keepers.UpkeepTypeGetter + typeGetter types.UpkeepTypeGetter } -var _ ocr2keepers.ProposalQueue = &proposalQueue{} +var _ types.ProposalQueue = &proposalQueue{} -func NewProposalQueue(typeGetter ocr2keepers.UpkeepTypeGetter) *proposalQueue { +func NewProposalQueue(typeGetter types.UpkeepTypeGetter) *proposalQueue { return &proposalQueue{ records: map[string]proposalQueueRecord{}, typeGetter: typeGetter, @@ -62,7 +64,7 @@ func (pq *proposalQueue) Enqueue(newProposals ...ocr2keepers.CoordinatedBlockPro return nil } -func (pq *proposalQueue) Dequeue(t ocr2keepers.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) { +func (pq *proposalQueue) Dequeue(t types.UpkeepType, n int) ([]ocr2keepers.CoordinatedBlockProposal, error) { pq.lock.Lock() defer pq.lock.Unlock() diff --git a/pkg/v3/stores/proposal_queue_test.go b/pkg/v3/stores/proposal_queue_test.go index b6229f8f..6b680407 100644 --- a/pkg/v3/stores/proposal_queue_test.go +++ b/pkg/v3/stores/proposal_queue_test.go @@ -3,6 +3,8 @@ package stores import ( "testing" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -21,7 +23,7 @@ func TestProposalQueue_Enqueue(t *testing.T) { []ocr2keepers.CoordinatedBlockProposal{}, []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, }, @@ -31,13 +33,13 @@ func TestProposalQueue_Enqueue(t *testing.T) { "add to non-empty queue", []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, }, []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x2}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x2}), WorkID: "0x2", }, }, @@ -47,13 +49,13 @@ func TestProposalQueue_Enqueue(t *testing.T) { "add existing", []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, }, []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, }, @@ -63,8 +65,8 @@ func TestProposalQueue_Enqueue(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - q := NewProposalQueue(func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.UpkeepType(uid[15]) + q := NewProposalQueue(func(uid ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.UpkeepType(uid[15]) }) require.NoError(t, q.Enqueue(tc.initials...)) @@ -78,14 +80,14 @@ func TestProposalQueue_Dequeue(t *testing.T) { tests := []struct { name string toEnqueue []ocr2keepers.CoordinatedBlockProposal - dequeueType ocr2keepers.UpkeepType + dequeueType types.UpkeepType dequeueCount int expected []ocr2keepers.CoordinatedBlockProposal }{ { "empty queue", []ocr2keepers.CoordinatedBlockProposal{}, - ocr2keepers.LogTrigger, + types.LogTrigger, 1, []ocr2keepers.CoordinatedBlockProposal{}, }, @@ -93,19 +95,19 @@ func TestProposalQueue_Dequeue(t *testing.T) { "happy path log trigger", []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, { - UpkeepID: upkeepId(ocr2keepers.ConditionTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.ConditionTrigger, []byte{0x1}), WorkID: "0x2", }, }, - ocr2keepers.LogTrigger, + types.LogTrigger, 2, []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, }, @@ -114,19 +116,19 @@ func TestProposalQueue_Dequeue(t *testing.T) { "happy path log trigger", []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.LogTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.LogTrigger, []byte{0x1}), WorkID: "0x1", }, { - UpkeepID: upkeepId(ocr2keepers.ConditionTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.ConditionTrigger, []byte{0x1}), WorkID: "0x2", }, }, - ocr2keepers.ConditionTrigger, + types.ConditionTrigger, 2, []ocr2keepers.CoordinatedBlockProposal{ { - UpkeepID: upkeepId(ocr2keepers.ConditionTrigger, []byte{0x1}), + UpkeepID: upkeepId(types.ConditionTrigger, []byte{0x1}), WorkID: "0x2", }, }, @@ -135,8 +137,8 @@ func TestProposalQueue_Dequeue(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - q := NewProposalQueue(func(uid ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { - return ocr2keepers.UpkeepType(uid[15]) + q := NewProposalQueue(func(uid ocr2keepers.UpkeepIdentifier) types.UpkeepType { + return types.UpkeepType(uid[15]) }) for _, p := range tc.toEnqueue { err := q.Enqueue(p) @@ -153,7 +155,7 @@ func TestProposalQueue_Dequeue(t *testing.T) { } } -func upkeepId(utype ocr2keepers.UpkeepType, rand []byte) ocr2keepers.UpkeepIdentifier { +func upkeepId(utype types.UpkeepType, rand []byte) ocr2keepers.UpkeepIdentifier { id := [32]byte{} id[15] = byte(utype) copy(id[16:], rand) diff --git a/pkg/v3/stores/result_store.go b/pkg/v3/stores/result_store.go index d0c768c6..056e6131 100644 --- a/pkg/v3/stores/result_store.go +++ b/pkg/v3/stores/result_store.go @@ -7,8 +7,11 @@ import ( "sync" "time" - "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" ) var ( @@ -33,7 +36,7 @@ type resultStore struct { lock sync.RWMutex } -var _ ocr2keepers.ResultStore = (*resultStore)(nil) +var _ types.ResultStore = (*resultStore)(nil) func New(lggr *log.Logger) *resultStore { return &resultStore{ diff --git a/pkg/v3/stores/retry_queue.go b/pkg/v3/stores/retry_queue.go index 68a9e7b2..54b595e9 100644 --- a/pkg/v3/stores/retry_queue.go +++ b/pkg/v3/stores/retry_queue.go @@ -7,7 +7,8 @@ import ( "time" "github.com/smartcontractkit/chainlink-automation/pkg/v3/telemetry" - types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( @@ -19,7 +20,7 @@ var ( type retryQueueRecord struct { // payload is the desired unit of work to be retried - payload types.UpkeepPayload + payload commontypes.UpkeepPayload // interval is the retry interval for the payload interval time.Duration // pending is true if the item is currently being retried @@ -101,13 +102,13 @@ func (q *retryQueue) Enqueue(records ...types.RetryRecord) error { // Returns only non-pending items that are within their retry interval. // // NOTE: Items that are expired are removed from the queue. -func (q *retryQueue) Dequeue(n int) ([]types.UpkeepPayload, error) { +func (q *retryQueue) Dequeue(n int) ([]commontypes.UpkeepPayload, error) { q.lock.Lock() defer q.lock.Unlock() now := time.Now() - var results []types.UpkeepPayload + var results []commontypes.UpkeepPayload for k, record := range q.records { if record.expired(now, q.expiration) { q.lggr.Printf("removing expired record %s", k) diff --git a/pkg/v3/stores/retry_queue_test.go b/pkg/v3/stores/retry_queue_test.go index 8c2dfe58..5c7d65c5 100644 --- a/pkg/v3/stores/retry_queue_test.go +++ b/pkg/v3/stores/retry_queue_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) @@ -113,8 +114,8 @@ func TestRetryQueue_Expiration(t *testing.T) { }) } -func newRetryRecord(payload ocr2keepers.UpkeepPayload, interval time.Duration) ocr2keepers.RetryRecord { - return ocr2keepers.RetryRecord{ +func newRetryRecord(payload ocr2keepers.UpkeepPayload, interval time.Duration) types.RetryRecord { + return types.RetryRecord{ Payload: payload, Interval: interval, } diff --git a/pkg/v3/types/basetypes.go b/pkg/v3/types/basetypes.go new file mode 100644 index 00000000..62c667dd --- /dev/null +++ b/pkg/v3/types/basetypes.go @@ -0,0 +1,23 @@ +package types + +import ( + "time" + + "github.com/smartcontractkit/chainlink-common/pkg/types/automation" +) + +type UpkeepType uint8 + +const ( + // Exploratory AUTO 4335: add type for unknown + ConditionTrigger UpkeepType = iota + LogTrigger +) + +// RetryRecord is a record of a payload that can be retried after a certain interval. +type RetryRecord struct { + // payload is the desired unit of work to be retried + Payload automation.UpkeepPayload + // Interval is the time interval after which the same payload can be retried. + Interval time.Duration +} diff --git a/pkg/v3/types/interfaces.go b/pkg/v3/types/interfaces.go new file mode 100644 index 00000000..8deeb48d --- /dev/null +++ b/pkg/v3/types/interfaces.go @@ -0,0 +1,85 @@ +package types + +import ( + "context" + + "github.com/smartcontractkit/chainlink-common/pkg/types/automation" +) + +//go:generate mockery --name Encoder --structname MockEncoder --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename encoder.generated.go + +//go:generate mockery --name LogEventProvider --structname MockLogEventProvider --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename logeventprovider.generated.go + +//go:generate mockery --name RecoverableProvider --structname MockRecoverableProvider --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename recoverableprovider.generated.go + +//go:generate mockery --name ConditionalUpkeepProvider --structname MockConditionalUpkeepProvider --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename conditionalupkeepprovider.generated.go + +//go:generate mockery --name PayloadBuilder --structname MockPayloadBuilder --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename payloadbuilder.generated.go + +//go:generate mockery --name BlockSubscriber --structname MockBlockSubscriber --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename block_subscriber.generated.go + +//go:generate mockery --name UpkeepStateUpdater --structname MockUpkeepStateUpdater --srcpkg "github.com/smartcontractkit/chainlink-common/pkg/types/automation" --case underscore --filename upkeep_state_updater.generated.go + +type UpkeepTypeGetter func(automation.UpkeepIdentifier) UpkeepType +type WorkIDGenerator func(automation.UpkeepIdentifier, automation.Trigger) string + +type RetryQueue interface { + // Enqueue adds new items to the queue + Enqueue(items ...RetryRecord) error + // Dequeue returns the next n items in the queue, considering retry time schedules + Dequeue(n int) ([]automation.UpkeepPayload, error) +} + +type ProposalQueue interface { + // Enqueue adds new items to the queue + Enqueue(items ...automation.CoordinatedBlockProposal) error + // Dequeue returns the next n items in the queue, considering retry time schedules + Dequeue(t UpkeepType, n int) ([]automation.CoordinatedBlockProposal, error) +} + +//go:generate mockery --name TransmitEventProvider --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename transmit_event_provider.generated.go +type TransmitEventProvider interface { + GetLatestEvents(context.Context) ([]automation.TransmitEvent, error) +} + +//go:generate mockery --name Runnable --structname MockRunnable --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename runnable.generated.go +type Runnable interface { + // Can get results for a subset of payloads along with an error + CheckUpkeeps(context.Context, ...automation.UpkeepPayload) ([]automation.CheckResult, error) +} + +//go:generate mockery --name ResultStore --structname MockResultStore --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename result_store.generated.go +type ResultStore interface { + Add(...automation.CheckResult) + Remove(...string) + View() ([]automation.CheckResult, error) +} + +//go:generate mockery --name Coordinator --structname MockCoordinator --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename coordinator.generated.go +type Coordinator interface { + PreProcess(_ context.Context, payloads []automation.UpkeepPayload) ([]automation.UpkeepPayload, error) + + Accept(automation.ReportedUpkeep) bool + ShouldTransmit(automation.ReportedUpkeep) bool + FilterResults([]automation.CheckResult) ([]automation.CheckResult, error) + FilterProposals([]automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error) +} + +//go:generate mockery --name MetadataStore --structname MockMetadataStore --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename metadatastore.generated.go +type MetadataStore interface { + SetBlockHistory(automation.BlockHistory) + GetBlockHistory() automation.BlockHistory + + AddProposals(proposals ...automation.CoordinatedBlockProposal) + ViewProposals(utype UpkeepType) []automation.CoordinatedBlockProposal + RemoveProposals(proposals ...automation.CoordinatedBlockProposal) + + Start(context.Context) error + Close() error +} + +//go:generate mockery --name Ratio --structname MockRatio --srcpkg "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" --case underscore --filename ratio.generated.go +type Ratio interface { + // OfInt should return n out of x such that n/x ~ r (ratio) + OfInt(int) int +} diff --git a/pkg/v3/types/mocks/block_subscriber.generated.go b/pkg/v3/types/mocks/block_subscriber.generated.go new file mode 100644 index 00000000..df80b6ec --- /dev/null +++ b/pkg/v3/types/mocks/block_subscriber.generated.go @@ -0,0 +1,106 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockBlockSubscriber is an autogenerated mock type for the BlockSubscriber type +type MockBlockSubscriber struct { + mock.Mock +} + +// Close provides a mock function with given fields: +func (_m *MockBlockSubscriber) Close() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Start provides a mock function with given fields: _a0 +func (_m *MockBlockSubscriber) Start(_a0 context.Context) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Subscribe provides a mock function with given fields: +func (_m *MockBlockSubscriber) Subscribe() (int, chan automation.BlockHistory, error) { + ret := _m.Called() + + var r0 int + var r1 chan automation.BlockHistory + var r2 error + if rf, ok := ret.Get(0).(func() (int, chan automation.BlockHistory, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() int); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func() chan automation.BlockHistory); ok { + r1 = rf() + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(chan automation.BlockHistory) + } + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// Unsubscribe provides a mock function with given fields: _a0 +func (_m *MockBlockSubscriber) Unsubscribe(_a0 int) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(int) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewMockBlockSubscriber interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go new file mode 100644 index 00000000..fa2cd835 --- /dev/null +++ b/pkg/v3/types/mocks/conditionalupkeepprovider.generated.go @@ -0,0 +1,57 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockConditionalUpkeepProvider is an autogenerated mock type for the ConditionalUpkeepProvider type +type MockConditionalUpkeepProvider struct { + mock.Mock +} + +// GetActiveUpkeeps provides a mock function with given fields: _a0 +func (_m *MockConditionalUpkeepProvider) GetActiveUpkeeps(_a0 context.Context) ([]automation.UpkeepPayload, error) { + ret := _m.Called(_a0) + + var r0 []automation.UpkeepPayload + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(context.Context) []automation.UpkeepPayload); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.UpkeepPayload) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockConditionalUpkeepProvider interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/coordinator.generated.go b/pkg/v3/types/mocks/coordinator.generated.go new file mode 100644 index 00000000..5bdf782d --- /dev/null +++ b/pkg/v3/types/mocks/coordinator.generated.go @@ -0,0 +1,137 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockCoordinator is an autogenerated mock type for the Coordinator type +type MockCoordinator struct { + mock.Mock +} + +// Accept provides a mock function with given fields: _a0 +func (_m *MockCoordinator) Accept(_a0 automation.ReportedUpkeep) bool { + ret := _m.Called(_a0) + + var r0 bool + if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FilterProposals provides a mock function with given fields: _a0 +func (_m *MockCoordinator) FilterProposals(_a0 []automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error) { + ret := _m.Called(_a0) + + var r0 []automation.CoordinatedBlockProposal + var r1 error + if rf, ok := ret.Get(0).(func([]automation.CoordinatedBlockProposal) ([]automation.CoordinatedBlockProposal, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func([]automation.CoordinatedBlockProposal) []automation.CoordinatedBlockProposal); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.CoordinatedBlockProposal) + } + } + + if rf, ok := ret.Get(1).(func([]automation.CoordinatedBlockProposal) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FilterResults provides a mock function with given fields: _a0 +func (_m *MockCoordinator) FilterResults(_a0 []automation.CheckResult) ([]automation.CheckResult, error) { + ret := _m.Called(_a0) + + var r0 []automation.CheckResult + var r1 error + if rf, ok := ret.Get(0).(func([]automation.CheckResult) ([]automation.CheckResult, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func([]automation.CheckResult) []automation.CheckResult); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.CheckResult) + } + } + + if rf, ok := ret.Get(1).(func([]automation.CheckResult) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// PreProcess provides a mock function with given fields: _a0, payloads +func (_m *MockCoordinator) PreProcess(_a0 context.Context, payloads []automation.UpkeepPayload) ([]automation.UpkeepPayload, error) { + ret := _m.Called(_a0, payloads) + + var r0 []automation.UpkeepPayload + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []automation.UpkeepPayload) ([]automation.UpkeepPayload, error)); ok { + return rf(_a0, payloads) + } + if rf, ok := ret.Get(0).(func(context.Context, []automation.UpkeepPayload) []automation.UpkeepPayload); ok { + r0 = rf(_a0, payloads) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.UpkeepPayload) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []automation.UpkeepPayload) error); ok { + r1 = rf(_a0, payloads) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ShouldTransmit provides a mock function with given fields: _a0 +func (_m *MockCoordinator) ShouldTransmit(_a0 automation.ReportedUpkeep) bool { + ret := _m.Called(_a0) + + var r0 bool + if rf, ok := ret.Get(0).(func(automation.ReportedUpkeep) bool); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +type mockConstructorTestingTNewMockCoordinator interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/encoder.generated.go b/pkg/v3/types/mocks/encoder.generated.go new file mode 100644 index 00000000..a8538f9e --- /dev/null +++ b/pkg/v3/types/mocks/encoder.generated.go @@ -0,0 +1,86 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + mock "github.com/stretchr/testify/mock" +) + +// MockEncoder is an autogenerated mock type for the Encoder type +type MockEncoder struct { + mock.Mock +} + +// Encode provides a mock function with given fields: _a0 +func (_m *MockEncoder) Encode(_a0 ...automation.CheckResult) ([]byte, error) { + _va := make([]interface{}, len(_a0)) + for _i := range _a0 { + _va[_i] = _a0[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(...automation.CheckResult) ([]byte, error)); ok { + return rf(_a0...) + } + if rf, ok := ret.Get(0).(func(...automation.CheckResult) []byte); ok { + r0 = rf(_a0...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(...automation.CheckResult) error); ok { + r1 = rf(_a0...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Extract provides a mock function with given fields: _a0 +func (_m *MockEncoder) Extract(_a0 []byte) ([]automation.ReportedUpkeep, error) { + ret := _m.Called(_a0) + + var r0 []automation.ReportedUpkeep + var r1 error + if rf, ok := ret.Get(0).(func([]byte) ([]automation.ReportedUpkeep, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func([]byte) []automation.ReportedUpkeep); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.ReportedUpkeep) + } + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockEncoder interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/logeventprovider.generated.go b/pkg/v3/types/mocks/logeventprovider.generated.go new file mode 100644 index 00000000..1f4ffc22 --- /dev/null +++ b/pkg/v3/types/mocks/logeventprovider.generated.go @@ -0,0 +1,85 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockLogEventProvider is an autogenerated mock type for the LogEventProvider type +type MockLogEventProvider struct { + mock.Mock +} + +// Close provides a mock function with given fields: +func (_m *MockLogEventProvider) Close() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetLatestPayloads provides a mock function with given fields: _a0 +func (_m *MockLogEventProvider) GetLatestPayloads(_a0 context.Context) ([]automation.UpkeepPayload, error) { + ret := _m.Called(_a0) + + var r0 []automation.UpkeepPayload + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(context.Context) []automation.UpkeepPayload); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.UpkeepPayload) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Start provides a mock function with given fields: _a0 +func (_m *MockLogEventProvider) Start(_a0 context.Context) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewMockLogEventProvider interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/metadatastore.generated.go b/pkg/v3/types/mocks/metadatastore.generated.go new file mode 100644 index 00000000..33f33640 --- /dev/null +++ b/pkg/v3/types/mocks/metadatastore.generated.go @@ -0,0 +1,120 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" + + types "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" +) + +// MockMetadataStore is an autogenerated mock type for the MetadataStore type +type MockMetadataStore struct { + mock.Mock +} + +// AddProposals provides a mock function with given fields: proposals +func (_m *MockMetadataStore) AddProposals(proposals ...automation.CoordinatedBlockProposal) { + _va := make([]interface{}, len(proposals)) + for _i := range proposals { + _va[_i] = proposals[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// Close provides a mock function with given fields: +func (_m *MockMetadataStore) Close() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetBlockHistory provides a mock function with given fields: +func (_m *MockMetadataStore) GetBlockHistory() automation.BlockHistory { + ret := _m.Called() + + var r0 automation.BlockHistory + if rf, ok := ret.Get(0).(func() automation.BlockHistory); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(automation.BlockHistory) + } + } + + return r0 +} + +// RemoveProposals provides a mock function with given fields: proposals +func (_m *MockMetadataStore) RemoveProposals(proposals ...automation.CoordinatedBlockProposal) { + _va := make([]interface{}, len(proposals)) + for _i := range proposals { + _va[_i] = proposals[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// SetBlockHistory provides a mock function with given fields: _a0 +func (_m *MockMetadataStore) SetBlockHistory(_a0 automation.BlockHistory) { + _m.Called(_a0) +} + +// Start provides a mock function with given fields: _a0 +func (_m *MockMetadataStore) Start(_a0 context.Context) error { + ret := _m.Called(_a0) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = rf(_a0) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ViewProposals provides a mock function with given fields: utype +func (_m *MockMetadataStore) ViewProposals(utype types.UpkeepType) []automation.CoordinatedBlockProposal { + ret := _m.Called(utype) + + var r0 []automation.CoordinatedBlockProposal + if rf, ok := ret.Get(0).(func(types.UpkeepType) []automation.CoordinatedBlockProposal); ok { + r0 = rf(utype) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.CoordinatedBlockProposal) + } + } + + return r0 +} + +type mockConstructorTestingTNewMockMetadataStore interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/payloadbuilder.generated.go b/pkg/v3/types/mocks/payloadbuilder.generated.go new file mode 100644 index 00000000..7fdd9e6a --- /dev/null +++ b/pkg/v3/types/mocks/payloadbuilder.generated.go @@ -0,0 +1,64 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockPayloadBuilder is an autogenerated mock type for the PayloadBuilder type +type MockPayloadBuilder struct { + mock.Mock +} + +// BuildPayloads provides a mock function with given fields: _a0, _a1 +func (_m *MockPayloadBuilder) BuildPayloads(_a0 context.Context, _a1 ...automation.CoordinatedBlockProposal) ([]automation.UpkeepPayload, error) { + _va := make([]interface{}, len(_a1)) + for _i := range _a1 { + _va[_i] = _a1[_i] + } + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 []automation.UpkeepPayload + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ...automation.CoordinatedBlockProposal) ([]automation.UpkeepPayload, error)); ok { + return rf(_a0, _a1...) + } + if rf, ok := ret.Get(0).(func(context.Context, ...automation.CoordinatedBlockProposal) []automation.UpkeepPayload); ok { + r0 = rf(_a0, _a1...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.UpkeepPayload) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, ...automation.CoordinatedBlockProposal) error); ok { + r1 = rf(_a0, _a1...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockPayloadBuilder interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/ratio.generated.go b/pkg/v3/types/mocks/ratio.generated.go new file mode 100644 index 00000000..1f3b9eae --- /dev/null +++ b/pkg/v3/types/mocks/ratio.generated.go @@ -0,0 +1,39 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockRatio is an autogenerated mock type for the Ratio type +type MockRatio struct { + mock.Mock +} + +// OfInt provides a mock function with given fields: _a0 +func (_m *MockRatio) OfInt(_a0 int) int { + ret := _m.Called(_a0) + + var r0 int + if rf, ok := ret.Get(0).(func(int) int); ok { + r0 = rf(_a0) + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + +type mockConstructorTestingTNewMockRatio interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/recoverableprovider.generated.go b/pkg/v3/types/mocks/recoverableprovider.generated.go new file mode 100644 index 00000000..d181d81c --- /dev/null +++ b/pkg/v3/types/mocks/recoverableprovider.generated.go @@ -0,0 +1,57 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockRecoverableProvider is an autogenerated mock type for the RecoverableProvider type +type MockRecoverableProvider struct { + mock.Mock +} + +// GetRecoveryProposals provides a mock function with given fields: _a0 +func (_m *MockRecoverableProvider) GetRecoveryProposals(_a0 context.Context) ([]automation.UpkeepPayload, error) { + ret := _m.Called(_a0) + + var r0 []automation.UpkeepPayload + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]automation.UpkeepPayload, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(context.Context) []automation.UpkeepPayload); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.UpkeepPayload) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockRecoverableProvider interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/result_store.generated.go b/pkg/v3/types/mocks/result_store.generated.go new file mode 100644 index 00000000..5e8024d5 --- /dev/null +++ b/pkg/v3/types/mocks/result_store.generated.go @@ -0,0 +1,76 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + mock "github.com/stretchr/testify/mock" +) + +// MockResultStore is an autogenerated mock type for the ResultStore type +type MockResultStore struct { + mock.Mock +} + +// Add provides a mock function with given fields: _a0 +func (_m *MockResultStore) Add(_a0 ...automation.CheckResult) { + _va := make([]interface{}, len(_a0)) + for _i := range _a0 { + _va[_i] = _a0[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// Remove provides a mock function with given fields: _a0 +func (_m *MockResultStore) Remove(_a0 ...string) { + _va := make([]interface{}, len(_a0)) + for _i := range _a0 { + _va[_i] = _a0[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + _m.Called(_ca...) +} + +// View provides a mock function with given fields: +func (_m *MockResultStore) View() ([]automation.CheckResult, error) { + ret := _m.Called() + + var r0 []automation.CheckResult + var r1 error + if rf, ok := ret.Get(0).(func() ([]automation.CheckResult, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []automation.CheckResult); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.CheckResult) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockResultStore interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/runnable.generated.go b/pkg/v3/types/mocks/runnable.generated.go new file mode 100644 index 00000000..13952d52 --- /dev/null +++ b/pkg/v3/types/mocks/runnable.generated.go @@ -0,0 +1,64 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockRunnable is an autogenerated mock type for the Runnable type +type MockRunnable struct { + mock.Mock +} + +// CheckUpkeeps provides a mock function with given fields: _a0, _a1 +func (_m *MockRunnable) CheckUpkeeps(_a0 context.Context, _a1 ...automation.UpkeepPayload) ([]automation.CheckResult, error) { + _va := make([]interface{}, len(_a1)) + for _i := range _a1 { + _va[_i] = _a1[_i] + } + var _ca []interface{} + _ca = append(_ca, _a0) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 []automation.CheckResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ...automation.UpkeepPayload) ([]automation.CheckResult, error)); ok { + return rf(_a0, _a1...) + } + if rf, ok := ret.Get(0).(func(context.Context, ...automation.UpkeepPayload) []automation.CheckResult); ok { + r0 = rf(_a0, _a1...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.CheckResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, ...automation.UpkeepPayload) error); ok { + r1 = rf(_a0, _a1...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewMockRunnable interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/transmit_event_provider.generated.go b/pkg/v3/types/mocks/transmit_event_provider.generated.go new file mode 100644 index 00000000..4f0b67d8 --- /dev/null +++ b/pkg/v3/types/mocks/transmit_event_provider.generated.go @@ -0,0 +1,57 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// TransmitEventProvider is an autogenerated mock type for the TransmitEventProvider type +type TransmitEventProvider struct { + mock.Mock +} + +// GetLatestEvents provides a mock function with given fields: _a0 +func (_m *TransmitEventProvider) GetLatestEvents(_a0 context.Context) ([]automation.TransmitEvent, error) { + ret := _m.Called(_a0) + + var r0 []automation.TransmitEvent + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]automation.TransmitEvent, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(context.Context) []automation.TransmitEvent); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]automation.TransmitEvent) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewTransmitEventProvider interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/v3/types/mocks/upkeep_state_updater.generated.go b/pkg/v3/types/mocks/upkeep_state_updater.generated.go new file mode 100644 index 00000000..0949d8a4 --- /dev/null +++ b/pkg/v3/types/mocks/upkeep_state_updater.generated.go @@ -0,0 +1,45 @@ +// Code generated by mockery v2.28.1. DO NOT EDIT. + +package mocks + +import ( + context "context" + + automation "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + mock "github.com/stretchr/testify/mock" +) + +// MockUpkeepStateUpdater is an autogenerated mock type for the UpkeepStateUpdater type +type MockUpkeepStateUpdater struct { + mock.Mock +} + +// SetUpkeepState provides a mock function with given fields: _a0, _a1, _a2 +func (_m *MockUpkeepStateUpdater) SetUpkeepState(_a0 context.Context, _a1 automation.CheckResult, _a2 automation.UpkeepState) error { + ret := _m.Called(_a0, _a1, _a2) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, automation.CheckResult, automation.UpkeepState) error); ok { + r0 = rf(_a0, _a1, _a2) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type mockConstructorTestingTNewMockUpkeepStateUpdater interface { + mock.TestingT + Cleanup(func()) +} + +// 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) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/tools/simulator/node/stats.go b/tools/simulator/node/stats.go index f8b99846..8929cf8e 100644 --- a/tools/simulator/node/stats.go +++ b/tools/simulator/node/stats.go @@ -6,6 +6,7 @@ import ( "sort" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" ) diff --git a/tools/simulator/simulate/chain/generate.go b/tools/simulator/simulate/chain/generate.go index b0091edc..f074f0c9 100644 --- a/tools/simulator/simulate/chain/generate.go +++ b/tools/simulator/simulate/chain/generate.go @@ -8,7 +8,7 @@ import ( "github.com/Maldris/mathparse" "github.com/shopspring/decimal" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" ) @@ -143,9 +143,9 @@ func generateEligibilityFuncSimulatedUpkeeps(event config.GenerateUpkeepEvent, s func getTriggerType(configType config.UpkeepType) (UpkeepType, uint8, error) { switch configType { case config.ConditionalUpkeepType: - return ConditionalType, uint8(ocr2keepers.ConditionTrigger), nil + return ConditionalType, uint8(types.ConditionTrigger), nil case config.LogTriggerUpkeepType: - return LogTriggerType, uint8(ocr2keepers.LogTrigger), nil + return LogTriggerType, uint8(types.LogTrigger), nil default: return 0, 0, fmt.Errorf("%w: trigger type '%s' unrecognized", ErrUpkeepGeneration, configType) } diff --git a/tools/simulator/simulate/chain/history.go b/tools/simulator/simulate/chain/history.go index a30aa463..03cb4e0d 100644 --- a/tools/simulator/simulate/chain/history.go +++ b/tools/simulator/simulate/chain/history.go @@ -6,8 +6,9 @@ import ( "runtime" "sync" - "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) const ( diff --git a/tools/simulator/simulate/ocr/report.go b/tools/simulator/simulate/ocr/report.go index f1ca9b33..0e6fe38c 100644 --- a/tools/simulator/simulate/ocr/report.go +++ b/tools/simulator/simulate/ocr/report.go @@ -9,6 +9,7 @@ import ( "sync" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) diff --git a/tools/simulator/simulate/ocr/report_test.go b/tools/simulator/simulate/ocr/report_test.go index df9f88f7..ffc43ea0 100644 --- a/tools/simulator/simulate/ocr/report_test.go +++ b/tools/simulator/simulate/ocr/report_test.go @@ -11,11 +11,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/ocr" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestReportTracker(t *testing.T) { @@ -29,7 +30,7 @@ func TestReportTracker(t *testing.T) { Duration: 10, } - upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(ocr2keepers.ConditionTrigger)) + upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(types.ConditionTrigger)) workID := util.UpkeepWorkID( upkeepID, ocr2keepers.NewLogTrigger( diff --git a/tools/simulator/simulate/upkeep/active_test.go b/tools/simulator/simulate/upkeep/active_test.go index 464db728..04adaa12 100644 --- a/tools/simulator/simulate/upkeep/active_test.go +++ b/tools/simulator/simulate/upkeep/active_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" @@ -30,13 +30,13 @@ func TestActiveTracker(t *testing.T) { upkeep1 := chain.SimulatedUpkeep{ ID: big.NewInt(8), - UpkeepID: util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(ocr2keepers.ConditionTrigger)), + UpkeepID: util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(types.ConditionTrigger)), Type: chain.ConditionalType, } upkeep2 := chain.SimulatedUpkeep{ ID: big.NewInt(10), - UpkeepID: util.NewUpkeepID(big.NewInt(10).Bytes(), uint8(ocr2keepers.LogTrigger)), + UpkeepID: util.NewUpkeepID(big.NewInt(10).Bytes(), uint8(types.LogTrigger)), Type: chain.LogTriggerType, } diff --git a/tools/simulator/simulate/upkeep/log_test.go b/tools/simulator/simulate/upkeep/log_test.go index aa9cf59c..882eb4bc 100644 --- a/tools/simulator/simulate/upkeep/log_test.go +++ b/tools/simulator/simulate/upkeep/log_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/perform.go b/tools/simulator/simulate/upkeep/perform.go index 03ab1019..1574597a 100644 --- a/tools/simulator/simulate/upkeep/perform.go +++ b/tools/simulator/simulate/upkeep/perform.go @@ -6,7 +6,7 @@ import ( "runtime" "sync" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" ) @@ -101,7 +101,7 @@ func (pt *PerformTracker) registerTransmitted(transmits ...chain.TransmitEvent) pt.performed[result.WorkID] = true - if util.GetUpkeepType(result.UpkeepID) == ocr2keepers.ConditionTrigger { + if util.GetUpkeepType(result.UpkeepID) == types.ConditionTrigger { performs, ok := pt.conditionals[key] if !ok { performs = []*big.Int{} diff --git a/tools/simulator/simulate/upkeep/perform_test.go b/tools/simulator/simulate/upkeep/perform_test.go index 870a81e5..bf26344f 100644 --- a/tools/simulator/simulate/upkeep/perform_test.go +++ b/tools/simulator/simulate/upkeep/perform_test.go @@ -10,11 +10,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) func TestPerformTracker_LogTrigger(t *testing.T) { @@ -28,7 +29,7 @@ func TestPerformTracker_LogTrigger(t *testing.T) { Duration: 10, } - upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(ocr2keepers.LogTrigger)) + upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(types.LogTrigger)) workID := util.UpkeepWorkID( upkeepID, @@ -80,7 +81,7 @@ func TestPerformTracker_Conditional(t *testing.T) { Duration: 10, } - upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(ocr2keepers.ConditionTrigger)) + upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(types.ConditionTrigger)) workID := util.UpkeepWorkID( upkeepID, ocr2keepers.NewLogTrigger( @@ -130,7 +131,7 @@ func TestPerformTracker_DecodeReportFailure(t *testing.T) { Duration: 10, } - upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(ocr2keepers.ConditionTrigger)) + upkeepID := util.NewUpkeepID(big.NewInt(8).Bytes(), uint8(types.ConditionTrigger)) workID := util.UpkeepWorkID( upkeepID, ocr2keepers.NewLogTrigger( diff --git a/tools/simulator/simulate/upkeep/pipeline.go b/tools/simulator/simulate/upkeep/pipeline.go index 9826f5bd..4120ee02 100644 --- a/tools/simulator/simulate/upkeep/pipeline.go +++ b/tools/simulator/simulate/upkeep/pipeline.go @@ -7,6 +7,7 @@ import ( "sync" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/net" ) diff --git a/tools/simulator/simulate/upkeep/pipeline_test.go b/tools/simulator/simulate/upkeep/pipeline_test.go index 8cf8ae39..6c3d1999 100644 --- a/tools/simulator/simulate/upkeep/pipeline_test.go +++ b/tools/simulator/simulate/upkeep/pipeline_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" diff --git a/tools/simulator/simulate/upkeep/source.go b/tools/simulator/simulate/upkeep/source.go index cb3aaf52..937561b3 100644 --- a/tools/simulator/simulate/upkeep/source.go +++ b/tools/simulator/simulate/upkeep/source.go @@ -5,9 +5,10 @@ import ( "log" "math/big" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) // Source maintains delivery of active upkeeps based on type and repeat diff --git a/tools/simulator/simulate/upkeep/source_test.go b/tools/simulator/simulate/upkeep/source_test.go index 24b10185..ad85ae0a 100644 --- a/tools/simulator/simulate/upkeep/source_test.go +++ b/tools/simulator/simulate/upkeep/source_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/config" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/chain" "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" diff --git a/tools/simulator/simulate/upkeep/util.go b/tools/simulator/simulate/upkeep/util.go index 56af5276..134d1122 100644 --- a/tools/simulator/simulate/upkeep/util.go +++ b/tools/simulator/simulate/upkeep/util.go @@ -3,8 +3,9 @@ package upkeep import ( "fmt" - ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" "github.com/smartcontractkit/chainlink-automation/tools/simulator/util" + ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" ) var ( @@ -38,7 +39,7 @@ func (u Util) Extract(b []byte) ([]ocr2keepers.ReportedUpkeep, error) { } // GetType returns the upkeep type from an identifier. -func (u Util) GetType(id ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { +func (u Util) GetType(id ocr2keepers.UpkeepIdentifier) types.UpkeepType { return util.GetUpkeepType(id) } diff --git a/tools/simulator/simulate/upkeep/util_test.go b/tools/simulator/simulate/upkeep/util_test.go index 74e05741..0e99b213 100644 --- a/tools/simulator/simulate/upkeep/util_test.go +++ b/tools/simulator/simulate/upkeep/util_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + "github.com/smartcontractkit/chainlink-automation/tools/simulator/simulate/upkeep" ) diff --git a/tools/simulator/util/encode.go b/tools/simulator/util/encode.go index 7376a7c3..1448ac91 100644 --- a/tools/simulator/util/encode.go +++ b/tools/simulator/util/encode.go @@ -6,6 +6,8 @@ import ( "encoding/json" "fmt" + "github.com/smartcontractkit/chainlink-automation/pkg/v3/types" + "github.com/ethereum/go-ethereum/crypto" ocr2keepers "github.com/smartcontractkit/chainlink-common/pkg/types/automation" @@ -53,16 +55,16 @@ func DecodeCheckResultsFromReportBytes(bts []byte) ([]ocr2keepers.CheckResult, e // GetUpkeepType returns the upkeep type from the given ID. // it follows the same logic as the contract, but performs it locally. -func GetUpkeepType(id ocr2keepers.UpkeepIdentifier) ocr2keepers.UpkeepType { +func GetUpkeepType(id ocr2keepers.UpkeepIdentifier) types.UpkeepType { for i := upkeepTypeStartIndex; i < upkeepTypeByteIndex; i++ { if id[i] != 0 { // old id - return ocr2keepers.ConditionTrigger + return types.ConditionTrigger } } typeByte := id[upkeepTypeByteIndex] - return ocr2keepers.UpkeepType(typeByte) + return types.UpkeepType(typeByte) } func UpkeepWorkID(uid ocr2keepers.UpkeepIdentifier, trigger ocr2keepers.Trigger) string { diff --git a/tools/testprotocol/modify/byte_test.go b/tools/testprotocol/modify/byte_test.go index 9ba42ad4..92d0e980 100644 --- a/tools/testprotocol/modify/byte_test.go +++ b/tools/testprotocol/modify/byte_test.go @@ -7,8 +7,9 @@ import ( "github.com/stretchr/testify/assert" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" ocr2keeperstypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" "github.com/smartcontractkit/chainlink-automation/tools/testprotocol/modify" ) diff --git a/tools/testprotocol/modify/struct.go b/tools/testprotocol/modify/struct.go index 08aea87c..fb65e539 100644 --- a/tools/testprotocol/modify/struct.go +++ b/tools/testprotocol/modify/struct.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" ocr2keeperstypes "github.com/smartcontractkit/chainlink-common/pkg/types/automation" types "github.com/smartcontractkit/chainlink-common/pkg/types/automation" + + ocr2keepers "github.com/smartcontractkit/chainlink-automation/pkg/v3" ) type NamedModifier func(context.Context, interface{}, error) (string, []byte, error) From 3448e7f6143cb56432500b9f774ff18a0673bc96 Mon Sep 17 00:00:00 2001 From: Fergal Gribben Date: Thu, 18 Jan 2024 01:24:55 +0000 Subject: [PATCH 6/6] Bump common --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 78adb67b..e199774f 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/jedib0t/go-pretty/v6 v6.4.7 github.com/pkg/errors v0.9.1 github.com/shopspring/decimal v1.3.1 - github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df + github.com/smartcontractkit/chainlink-common v0.1.7-0.20240118012339-4864e2306bb1 github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index f96a912a..10556f63 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df h1:J5e8CK13znCyjn+en9TbN/2d1rLrYS9CA+jFspEgWmk= github.com/smartcontractkit/chainlink-common v0.1.7-0.20240112182818-306f99b807df/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240118012339-4864e2306bb1 h1:3cWO2/lFVDul5SVTgl4/RX/GXcT8Zq5NGMPeNEz09tY= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20240118012339-4864e2306bb1/go.mod h1:f+0ei9N4PlTJHu7pbGzEjTnBUr45syPdGFu5+31lS5Q= github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 h1:R9NkVN+1fooUJFsN9zj9gDY1B+zv54zNO785RQZRVfE= github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8/go.mod h1:2lyRkw/qLQgUWlrWWmq5nj0y90rWeO6Y+v+fCakRgb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=