Skip to content

Commit d067fdf

Browse files
authored
Merge pull request #113 from smartcontractkit/vrf-perf-metrics
Per request id metrics for VRF/Runlog tests
2 parents 4145e54 + 3632951 commit d067fdf

25 files changed

+1094
-203
lines changed

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ test_keeper: ## run keeper tests
6464
test_ocr: ## run ocr tests
6565
ginkgo -r --focus=@ocr
6666

67+
.PHONY: test_flux_perf
68+
test_flux_perf: ## run Flux perf test
69+
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@perf-flux"
70+
6771
.PHONY: test_ocr_soak
6872
test_ocr_soak: ## run OCR soak test
6973
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@soak-ocr"
@@ -72,6 +76,10 @@ test_ocr_soak: ## run OCR soak test
7276
test_runlog_soak: ## run Runlog soak test
7377
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@soak-runlog"
7478

79+
.PHONY: test_runlog_perf
80+
test_runlog_perf: ## run Runlog perf test
81+
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@perf-runlog"
82+
7583
.PHONY: test_keeper_soak
7684
test_keeper_soak: ## run Keeper soak/performance test
7785
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@performance-keeper"
@@ -80,6 +88,10 @@ test_keeper_soak: ## run Keeper soak/performance test
8088
test_vrf_soak: ## run VRF soak test
8189
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@soak-vrf"
8290

91+
.PHONY: test_vrf_perf
92+
test_vrf_perf: ## run VRF perf test
93+
NETWORK="ethereum_geth_performance" ginkgo -r --focus="@perf-vrf"
94+
8395
.PHONY: test_runlog
8496
test_runlog: ## run runlog tests
8597
ginkgo -r --focus=@runlog

actions/actions.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package actions
22

33
import (
4+
"encoding/json"
45
"github.com/ethereum/go-ethereum/common"
56
"github.com/pkg/errors"
67
"github.com/satori/go.uuid"
@@ -57,6 +58,22 @@ func EncodeOnChainExternalJobID(jobID uuid.UUID) [32]byte {
5758
return ji
5859
}
5960

61+
// ExtractRequestIDFromJobRun extracts RequestID from job runs response
62+
func ExtractRequestIDFromJobRun(jobDecodeData client.RunsResponseData) ([]byte, error) {
63+
var taskRun client.TaskRun
64+
for _, tr := range jobDecodeData.Attributes.TaskRuns {
65+
if tr.Type == "ethabidecodelog" {
66+
taskRun = tr
67+
}
68+
}
69+
var decodeLogTaskRun *client.DecodeLogTaskRun
70+
if err := json.Unmarshal([]byte(taskRun.Output), &decodeLogTaskRun); err != nil {
71+
return nil, err
72+
}
73+
rqInts := decodeLogTaskRun.RequestID
74+
return rqInts, nil
75+
}
76+
6077
// EncodeOnChainVRFProvingKey encodes uncompressed public VRF key to on-chain representation
6178
func EncodeOnChainVRFProvingKey(vrfKey client.VRFKey) ([2]*big.Int, error) {
6279
uncompressed := vrfKey.Attributes.Uncompressed

client/chainlink_models.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,31 @@ type RunsAttributesResponse struct {
4343
Meta interface{} `json:"meta"`
4444
Errors []interface{} `json:"errors"`
4545
Inputs RunInputs `json:"inputs"`
46+
TaskRuns []TaskRun `json:"taskRuns"`
4647
CreatedAt time.Time `json:"createdAt"`
4748
FinishedAt time.Time `json:"finishedAt"`
4849
}
4950

51+
//DecodeLogTaskRun is "ethabidecodelog" task run info,
52+
// also used for "RequestID" tracing in perf tests
53+
type DecodeLogTaskRun struct {
54+
Fee int `json:"fee"`
55+
JobID []int `json:"jobID"`
56+
KeyHash []int `json:"keyHash"`
57+
RequestID []byte `json:"requestID"`
58+
Sender string `json:"sender"`
59+
}
60+
61+
//TaskRun is pipeline task run info
62+
type TaskRun struct {
63+
Type string `json:"type"`
64+
CreatedAt time.Time `json:"createdAt"`
65+
FinishedAt time.Time `json:"finishedAt"`
66+
Output string `json:"output"`
67+
Error interface{} `json:"error"`
68+
DotID string `json:"dotId"`
69+
}
70+
5071
// RunInputs run inputs (value)
5172
type RunInputs struct {
5273
Parse int `json:"parse"`

contracts/contract_models.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ type APIConsumer interface {
143143
path string,
144144
times *big.Int,
145145
) error
146+
WatchPerfEvents(ctx context.Context, eventChan chan<- *PerfEvent) error
146147
}
147148

148149
type Storage interface {
@@ -263,6 +264,7 @@ type VRFConsumer interface {
263264
RequestRandomness(fromWallet client.BlockchainWallet, hash [32]byte, fee *big.Int) error
264265
CurrentRoundID(ctx context.Context) (*big.Int, error)
265266
RandomnessOutput(ctx context.Context) (*big.Int, error)
267+
WatchPerfEvents(ctx context.Context, eventChan chan<- *PerfEvent) error
266268
Fund(fromWallet client.BlockchainWallet, ethAmount, linkAmount *big.Float) error
267269
}
268270

@@ -292,3 +294,12 @@ type Flags interface {
292294
type DeviationFlaggingValidator interface {
293295
Address() string
294296
}
297+
298+
// PerfEvent is used to get some metrics for contracts,
299+
// it contrains roundID for Keeper/OCR/Flux tests and request id for VRF/Runlog
300+
type PerfEvent struct {
301+
Contract DeviationFlaggingValidator
302+
Round *big.Int
303+
RequestID [32]byte
304+
BlockTimestamp *big.Int
305+
}

contracts/ethereum/APIConsumer.go

Lines changed: 169 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/ethereum/VRFConsumer.go

Lines changed: 138 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/ethereum/v0.6/abi/APIConsumer.abi

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,31 @@
6868
"name": "OwnershipTransferred",
6969
"type": "event"
7070
},
71+
{
72+
"anonymous": false,
73+
"inputs": [
74+
{
75+
"indexed": false,
76+
"internalType": "uint256",
77+
"name": "roundID",
78+
"type": "uint256"
79+
},
80+
{
81+
"indexed": false,
82+
"internalType": "bytes32",
83+
"name": "requestId",
84+
"type": "bytes32"
85+
},
86+
{
87+
"indexed": false,
88+
"internalType": "uint256",
89+
"name": "timestamp",
90+
"type": "uint256"
91+
}
92+
],
93+
"name": "PerfMetricsEvent",
94+
"type": "event"
95+
},
7196
{
7297
"inputs": [
7398
{
@@ -140,6 +165,19 @@
140165
"stateMutability": "nonpayable",
141166
"type": "function"
142167
},
168+
{
169+
"inputs": [],
170+
"name": "currentRoundID",
171+
"outputs": [
172+
{
173+
"internalType": "uint256",
174+
"name": "",
175+
"type": "uint256"
176+
}
177+
],
178+
"stateMutability": "view",
179+
"type": "function"
180+
},
143181
{
144182
"inputs": [],
145183
"name": "data",
@@ -210,19 +248,6 @@
210248
"stateMutability": "view",
211249
"type": "function"
212250
},
213-
{
214-
"inputs": [],
215-
"name": "roundID",
216-
"outputs": [
217-
{
218-
"internalType": "uint256",
219-
"name": "",
220-
"type": "uint256"
221-
}
222-
],
223-
"stateMutability": "view",
224-
"type": "function"
225-
},
226251
{
227252
"inputs": [],
228253
"name": "selector",

0 commit comments

Comments
 (0)