Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/mercury/config_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/llo-feeds/generated/verifier"
"github.com/smartcontractkit/chainlink-evm/pkg/logpoller"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
)

// FeedScopedConfigSet ConfigSet with FeedID for use with mercury (and multi-config DON)
Expand All @@ -39,7 +38,7 @@ func init() {
// FullConfigFromLog defines the contract config with the feedID
type FullConfigFromLog struct {
ocrtypes.ContractConfig
feedID utils.FeedID
feedID common.Hash
}

func unpackLogData(d []byte) (*verifier.VerifierConfigSet, error) {
Expand Down
99 changes: 0 additions & 99 deletions pkg/mercury/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mercury

import (
"encoding/base64"
"math/big"
"testing"
"time"
Expand All @@ -15,105 +14,16 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/libocr/offchainreporting2plus/chains/evmutil"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services/servicetest"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/llo-feeds/generated/verifier"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/llo-feeds/generated/verifier_proxy"
evmclient "github.com/smartcontractkit/chainlink-evm/pkg/client"
"github.com/smartcontractkit/chainlink-evm/pkg/heads/headstest"
"github.com/smartcontractkit/chainlink-evm/pkg/logpoller"
reportcodecv2 "github.com/smartcontractkit/chainlink-evm/pkg/mercury/v2/reportcodec"
reportcodecv3 "github.com/smartcontractkit/chainlink-evm/pkg/mercury/v3/reportcodec"
"github.com/smartcontractkit/chainlink-evm/pkg/testutils"
)

const sampleClientPubKey = "0x724ff6eae9e900270edfff233e16322a70ec06e1a6e62a81ef13921f398f6c93"

var sampleFeedID = [32]uint8{28, 145, 107, 74, 167, 229, 124, 167, 182, 138, 225, 191, 69, 101, 63, 86, 182, 86, 253, 58, 163, 53, 239, 127, 174, 105, 107, 102, 63, 27, 132, 114}

var sampleReports [][]byte

var (
sampleV2Report = buildSampleV2Report(242)
sampleV3Report = buildSampleV3Report(242)
sig2 = ocrtypes.AttributedOnchainSignature{Signature: mustDecodeBase64("kbeuRczizOJCxBzj7MUAFpz3yl2WRM6K/f0ieEBvA+oTFUaKslbQey10krumVjzAvlvKxMfyZo0WkOgNyfF6xwE="), Signer: 2}
sig3 = ocrtypes.AttributedOnchainSignature{Signature: mustDecodeBase64("9jz4b6Dh2WhXxQ97a6/S9UNjSfrEi9016XKTrfN0mLQFDiNuws23x7Z4n+6g0sqKH/hnxx1VukWUH/ohtw83/wE="), Signer: 3}
sampleSigs = []ocrtypes.AttributedOnchainSignature{sig2, sig3}
sampleReportContext = ocrtypes.ReportContext{
ReportTimestamp: ocrtypes.ReportTimestamp{
ConfigDigest: MustHexToConfigDigest("0x0006fc30092226b37f6924b464e16a54a7978a9a524519a73403af64d487dc45"),
Epoch: 6,
Round: 28,
},
ExtraHash: [32]uint8{27, 144, 106, 73, 166, 228, 123, 166, 179, 138, 225, 191, 69, 101, 63, 86, 182, 86, 253, 58, 163, 53, 239, 127, 174, 105, 107, 102, 63, 27, 132, 114},
}
)

func init() {
sampleReports = make([][]byte, 4)
for i := 0; i < len(sampleReports); i++ {
sampleReports[i] = buildSampleV2Report(int64(i))
}
}

func buildSampleV2Report(ts int64) []byte {
feedID := sampleFeedID
timestamp := uint32(ts)
bp := big.NewInt(242)
validFromTimestamp := uint32(123)
expiresAt := uint32(456)
linkFee := big.NewInt(3334455)
nativeFee := big.NewInt(556677)

b, err := reportcodecv2.ReportTypes.Pack(feedID, validFromTimestamp, timestamp, nativeFee, linkFee, expiresAt, bp)
if err != nil {
panic(err)
}
return b
}

func buildSampleV3Report(ts int64) []byte {
feedID := sampleFeedID
timestamp := uint32(ts)
bp := big.NewInt(242)
bid := big.NewInt(243)
ask := big.NewInt(244)
validFromTimestamp := uint32(123)
expiresAt := uint32(456)
linkFee := big.NewInt(3334455)
nativeFee := big.NewInt(556677)

b, err := reportcodecv3.ReportTypes.Pack(feedID, validFromTimestamp, timestamp, nativeFee, linkFee, expiresAt, bp, bid, ask)
if err != nil {
panic(err)
}
return b
}

func buildSamplePayload(report []byte) []byte {
var rs [][32]byte
var ss [][32]byte
var vs [32]byte
for i, as := range sampleSigs {
r, s, v, err := evmutil.SplitSignature(as.Signature)
if err != nil {
panic("eventTransmit(ev): error in SplitSignature")
}
rs = append(rs, r)
ss = append(ss, s)
vs[i] = v
}
rawReportCtx := evmutil.RawReportContext(sampleReportContext)
payload, err := PayloadTypes.Pack(rawReportCtx, report, rs, ss, vs)
if err != nil {
panic(err)
}
return payload
}

type TestHarness struct {
configPoller *ConfigPoller
user *bind.TransactOpts
Expand Down Expand Up @@ -175,12 +85,3 @@ func SetupTH(t *testing.T, feedID common.Hash) TestHarness {
logPoller: lp,
}
}

func mustDecodeBase64(s string) (b []byte) {
var err error
b, err = base64.StdEncoding.DecodeString(s)
if err != nil {
panic(err)
}
return
}
117 changes: 117 additions & 0 deletions pkg/mercury/moved/helpers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package moved

import (
"encoding/base64"
"math/big"

"github.com/ethereum/go-ethereum/common/hexutil"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2/types"
"github.com/smartcontractkit/libocr/offchainreporting2plus/chains/evmutil"
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"

"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/v2/reportcodec"
reportcodec2 "github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/v3/reportcodec"
)

const sampleClientPubKey = "0x724ff6eae9e900270edfff233e16322a70ec06e1a6e62a81ef13921f398f6c93"

var sampleFeedID = [32]uint8{28, 145, 107, 74, 167, 229, 124, 167, 182, 138, 225, 191, 69, 101, 63, 86, 182, 86, 253, 58, 163, 53, 239, 127, 174, 105, 107, 102, 63, 27, 132, 114}

var sampleReports [][]byte

var (
sampleV2Report = buildSampleV2Report(242)
sampleV3Report = buildSampleV3Report(242)
sig2 = types.AttributedOnchainSignature{Signature: mustDecodeBase64("kbeuRczizOJCxBzj7MUAFpz3yl2WRM6K/f0ieEBvA+oTFUaKslbQey10krumVjzAvlvKxMfyZo0WkOgNyfF6xwE="), Signer: 2}
sig3 = types.AttributedOnchainSignature{Signature: mustDecodeBase64("9jz4b6Dh2WhXxQ97a6/S9UNjSfrEi9016XKTrfN0mLQFDiNuws23x7Z4n+6g0sqKH/hnxx1VukWUH/ohtw83/wE="), Signer: 3}
sampleSigs = []types.AttributedOnchainSignature{sig2, sig3}
sampleReportContext = types.ReportContext{
ReportTimestamp: types.ReportTimestamp{
ConfigDigest: mustHexToConfigDigest("0x0006fc30092226b37f6924b464e16a54a7978a9a524519a73403af64d487dc45"),
Epoch: 6,
Round: 28,
},
ExtraHash: [32]uint8{27, 144, 106, 73, 166, 228, 123, 166, 179, 138, 225, 191, 69, 101, 63, 86, 182, 86, 253, 58, 163, 53, 239, 127, 174, 105, 107, 102, 63, 27, 132, 114},
}
)

func init() {
sampleReports = make([][]byte, 4)
for i := 0; i < len(sampleReports); i++ {
sampleReports[i] = buildSampleV2Report(int64(i))
}
}

func buildSampleV2Report(ts int64) []byte {
feedID := sampleFeedID
timestamp := uint32(ts)
bp := big.NewInt(242)
validFromTimestamp := uint32(123)
expiresAt := uint32(456)
linkFee := big.NewInt(3334455)
nativeFee := big.NewInt(556677)

b, err := reportcodec.ReportTypes.Pack(feedID, validFromTimestamp, timestamp, nativeFee, linkFee, expiresAt, bp)
if err != nil {
panic(err)
}
return b
}

func buildSampleV3Report(ts int64) []byte {
feedID := sampleFeedID
timestamp := uint32(ts)
bp := big.NewInt(242)
bid := big.NewInt(243)
ask := big.NewInt(244)
validFromTimestamp := uint32(123)
expiresAt := uint32(456)
linkFee := big.NewInt(3334455)
nativeFee := big.NewInt(556677)

b, err := reportcodec2.ReportTypes.Pack(feedID, validFromTimestamp, timestamp, nativeFee, linkFee, expiresAt, bp, bid, ask)
if err != nil {
panic(err)
}
return b
}

func buildSamplePayload(report []byte) []byte {
var rs [][32]byte
var ss [][32]byte
var vs [32]byte
for i, as := range sampleSigs {
r, s, v, err := evmutil.SplitSignature(as.Signature)
if err != nil {
panic("eventTransmit(ev): error in SplitSignature")
}
rs = append(rs, r)
ss = append(ss, s)
vs[i] = v
}
rawReportCtx := evmutil.RawReportContext(sampleReportContext)
payload, err := PayloadTypes.Pack(rawReportCtx, report, rs, ss, vs)
if err != nil {
panic(err)
}
return payload
}

func mustDecodeBase64(s string) (b []byte) {
var err error
b, err = base64.StdEncoding.DecodeString(s)
if err != nil {
panic(err)
}
return
}

func mustHexToConfigDigest(s string) (cd ocrtypes.ConfigDigest) {
b := hexutil.MustDecode(s)
var err error
cd, err = ocrtypes.BytesToConfigDigest(b)
if err != nil {
panic(err)
}
return
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/mercury/orm.go → pkg/mercury/moved/orm.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"context"
Expand All @@ -17,7 +17,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/pb"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/utils"
)

type ORM interface {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"math/rand/v2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"context"
Expand All @@ -10,7 +10,6 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"

"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/pb"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"math/rand/v2"
Expand Down
2 changes: 1 addition & 1 deletion pkg/mercury/queue.go → pkg/mercury/moved/queue.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"sync"
Expand All @@ -10,7 +10,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/pb"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/mocks"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/mocks"
)

type TestTransmissionWithReport struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"bytes"
Expand Down Expand Up @@ -32,7 +32,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/pb"
mercuryutils "github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
mercuryutils "github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/utils"
)

const (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mercury
package moved

import (
"context"
Expand All @@ -19,8 +19,8 @@ import (
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/mocks"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/pb"
mercurytypes "github.com/smartcontractkit/chainlink-evm/pkg/mercury/types"
mercuryutils "github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
mercurytypes "github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/types"
mercuryutils "github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/testutils"
"github.com/smartcontractkit/chainlink-evm/pkg/utils"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
v2 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v2"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/v2/types"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/v2/types"
)

var ReportTypes = reporttypes.GetSchema()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/logger"
v3 "github.com/smartcontractkit/chainlink-common/pkg/types/mercury/v3"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/v3/types"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/utils"
"github.com/smartcontractkit/chainlink-evm/pkg/mercury/moved/v3/types"
)

var ReportTypes = reporttypes.GetSchema()
Expand Down
File renamed without changes.
Loading
Loading