From aad9974398086f485485309577ee40b210ddcf86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 11 Jul 2023 17:42:53 +0900 Subject: [PATCH 01/11] Use latest upstream sdk: starknet.go --- integration-tests/common/common.go | 2 +- integration-tests/common/test_common.go | 49 ++++++---- integration-tests/go.mod | 9 ++ integration-tests/go.sum | 18 ++-- monitoring/go.mod | 7 +- monitoring/go.sum | 34 ------- monitoring/pkg/monitoring/source_envelope.go | 40 ++++++-- .../pkg/monitoring/source_envelope_test.go | 14 ++- monitoring/pkg/monitoring/source_proxy.go | 17 +++- monitoring/pkg/monitoring/source_txresults.go | 17 +++- ops/devnet/devnet.go | 6 +- ops/go.mod | 4 +- ops/go.sum | 28 ------ relayer/go.mod | 6 +- relayer/go.sum | 22 +---- relayer/pkg/chainlink/ocr2/client.go | 94 +++++++++---------- relayer/pkg/chainlink/ocr2/client_test.go | 23 +++-- relayer/pkg/chainlink/ocr2/config_digester.go | 4 +- relayer/pkg/chainlink/ocr2/contract_reader.go | 12 ++- .../chainlink/ocr2/contract_transmitter.go | 32 +++++-- relayer/pkg/chainlink/ocr2/events.go | 70 ++++++-------- relayer/pkg/chainlink/ocr2/events_test.go | 14 +-- .../ocr2/medianreport/onchainconfig.go | 17 +--- .../pkg/chainlink/ocr2/medianreport/report.go | 57 +++++++---- .../ocr2/medianreport/report_test.go | 5 +- .../pkg/chainlink/ocr2/mocks/OCR2Reader.go | 60 ++++++------ relayer/pkg/chainlink/ocr2/types.go | 28 +++--- relayer/pkg/chainlink/ocr2/types_test.go | 13 +-- relayer/pkg/chainlink/txm/keystore.go | 4 +- .../txm/mocks/nonce_manager_client.go | 12 +-- relayer/pkg/chainlink/txm/nonce.go | 18 ++-- relayer/pkg/chainlink/txm/nonce_test.go | 14 ++- relayer/pkg/chainlink/txm/test_helpers.go | 8 +- relayer/pkg/chainlink/txm/txm.go | 44 +++++---- relayer/pkg/chainlink/txm/txm_test.go | 44 +++++---- relayer/pkg/chainlink/txm/txstore.go | 20 ++-- relayer/pkg/chainlink/txm/txstore_test.go | 29 +++--- relayer/pkg/starknet/client.go | 58 ++++++------ relayer/pkg/starknet/client_test.go | 8 +- relayer/pkg/starknet/mocks/Reader.go | 84 ++++++++--------- relayer/pkg/starknet/types.go | 8 +- relayer/pkg/starknet/utils.go | 33 +------ relayer/pkg/starknet/utils_test.go | 24 ----- 43 files changed, 550 insertions(+), 560 deletions(-) diff --git a/integration-tests/common/common.go b/integration-tests/common/common.go index 64d4248d8..b4e00cf32 100644 --- a/integration-tests/common/common.go +++ b/integration-tests/common/common.go @@ -13,7 +13,7 @@ import ( "github.com/rs/zerolog/log" "gopkg.in/guregu/null.v4" - "github.com/smartcontractkit/caigo/gateway" + "github.com/NethermindEth/starknet.go/gateway" "github.com/smartcontractkit/chainlink-starknet/ops/devnet" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" diff --git a/integration-tests/common/test_common.go b/integration-tests/common/test_common.go index d3ec5d8c2..a0d5175b7 100644 --- a/integration-tests/common/test_common.go +++ b/integration-tests/common/test_common.go @@ -10,8 +10,10 @@ import ( "testing" "time" - "github.com/smartcontractkit/caigo" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" + caigo "github.com/NethermindEth/starknet.go" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -266,20 +268,28 @@ func (testState *Test) ValidateRounds(rounds int, isSoak bool) error { var positive bool // validate balance in aggregator + linkContractAddress, err := starknetutils.HexToFelt(testState.LinkTokenAddr) + if err != nil { + return err + } + contractAddress, err := starknetutils.HexToFelt(testState.OCRAddr) + if err != nil { + return err + } resLINK, errLINK := testState.Starknet.CallContract(ctx, starknet.CallOps{ - ContractAddress: caigotypes.StrToFelt(testState.LinkTokenAddr), - Selector: "balance_of", - Calldata: []string{testState.OCRAddr}, + ContractAddress: linkContractAddress, + Selector: starknettypes.GetSelectorFromNameFelt("balance_of"), + Calldata: []*felt.Felt{contractAddress}, }) - require.NoError(testState.T, errLINK, "Reader balance from LINK contract should not fail") + require.NoError(testState.T, errLINK, "Reader balance from LINK contract should not fail", "err", errLINK) resAgg, errAgg := testState.Starknet.CallContract(ctx, starknet.CallOps{ - ContractAddress: caigotypes.StrToFelt(testState.OCRAddr), - Selector: "link_available_for_payment", + ContractAddress: contractAddress, + Selector: starknettypes.GetSelectorFromNameFelt("link_available_for_payment"), }) - require.NoError(testState.T, errAgg, "Reader balance from LINK contract should not fail") - balLINK, _ := new(big.Int).SetString(resLINK[0], 0) - balAgg, _ := new(big.Int).SetString(resAgg[1], 0) - isNegative, _ := new(big.Int).SetString(resAgg[0], 0) + require.NoError(testState.T, errAgg, "link_available_for_payment should not fail", "err", errAgg) + balLINK := resLINK[0].BigInt(big.NewInt(0)) + balAgg := resAgg[1].BigInt(big.NewInt(0)) + isNegative := resAgg[0].BigInt(big.NewInt(0)) if isNegative.Sign() > 0 { balAgg = new(big.Int).Neg(balAgg) } @@ -289,8 +299,8 @@ func (testState *Test) ValidateRounds(rounds int, isSoak bool) error { for start := time.Now(); time.Since(start) < testState.Common.TestDuration; { l.Info().Msg(fmt.Sprintf("Elapsed time: %s, Round wait: %s ", time.Since(start), testState.Common.TestDuration)) - res, err := testState.OCR2Client.LatestTransmissionDetails(ctx, caigotypes.StrToFelt(testState.OCRAddr)) - require.NoError(testState.T, err, "Failed to get latest transmission details") + res, err2 := testState.OCR2Client.LatestTransmissionDetails(ctx, contractAddress) + require.NoError(testState.T, err2, "Failed to get latest transmission details") // end condition: enough rounds have occurred if !isSoak && increasing >= rounds && positive { break @@ -361,15 +371,20 @@ func (testState *Test) ValidateRounds(rounds int, isSoak bool) error { // Test proxy reading // TODO: would be good to test proxy switching underlying feeds + + proxyAddress, err := starknetutils.HexToFelt(testState.ProxyAddr) + if err != nil { + return err + } roundDataRaw, err := testState.Starknet.CallContract(ctx, starknet.CallOps{ - ContractAddress: caigotypes.StrToFelt(testState.ProxyAddr), - Selector: "latest_round_data", + ContractAddress: proxyAddress, + Selector: starknettypes.GetSelectorFromNameFelt("latest_round_data"), }) if !isSoak { require.NoError(testState.T, err, "Reading round data from proxy should not fail") assert.Equal(testState.T, len(roundDataRaw), 5, "Round data from proxy should match expected size") } - valueBig, err := starknet.HexToUnsignedBig(roundDataRaw[1]) + valueBig := roundDataRaw[1].BigInt(big.NewInt(0)) require.NoError(testState.T, err) value := valueBig.Int64() if value < 0 { diff --git a/integration-tests/go.mod b/integration-tests/go.mod index f7b100400..5ec709e49 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -5,6 +5,8 @@ go 1.21.4 require ( github.com/google/uuid v1.4.0 github.com/lib/pq v1.10.9 + github.com/NethermindEth/juno v0.3.1 + github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 github.com/rs/zerolog v1.30.0 github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 @@ -18,6 +20,13 @@ require ( gopkg.in/guregu/null.v4 v4.0.0 ) +require ( + github.com/bits-and-blooms/bitset v1.7.0 // indirect + github.com/consensys/gnark-crypto v0.11.0 // indirect + github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect + github.com/test-go/testify v1.1.4 // indirect +) + require ( contrib.go.opencensus.io/exporter/stackdriver v0.13.5 // indirect cosmossdk.io/api v0.3.1 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 60b3e67a8..10f17e971 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -127,6 +127,10 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPxFbA= github.com/Microsoft/hcsshim v0.11.1/go.mod h1:nFJmaO4Zr5Y7eADdFOpYswDDlNVbvcIJJNJLECr5JQg= +github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA= +github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q= +github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 h1:SAE7oDXo82lT+arBtg6sozPMt9bNSkXY1A2TxlCGRw4= +github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -193,6 +197,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= @@ -265,24 +271,12 @@ github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+ github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 h1:T+Np/xtzIjYM/P5NAw0e2Rf1FGvzDau1h54MKvx8G7w= -github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7HpxfjgkzCGz6s= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= -github.com/containerd/containerd v1.7.7 h1:QOC2K4A42RQpcrZyptP6z9EJZnlHfHJUfZrAAHe15q4= -github.com/containerd/containerd v1.7.7/go.mod h1:3c4XZv6VeT9qgf9GMTxNTMFxGJrGpI2vz1yk4ye+YY8= -github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= -github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= -github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= -github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= diff --git a/monitoring/go.mod b/monitoring/go.mod index d0d07b813..df3e77955 100644 --- a/monitoring/go.mod +++ b/monitoring/go.mod @@ -6,7 +6,8 @@ toolchain go1.21.1 require ( github.com/prometheus/client_golang v1.17.0 - github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 + github.com/NethermindEth/juno v0.3.1 + github.com/NethermindEth/starknet.go v0.4.2-0.20230804102546-d30334cf21f3 github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.0-20230508053614-9f2fd5fd4ff1 github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 @@ -17,11 +18,13 @@ require ( require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/confluentinc/confluent-kafka-go/v2 v2.3.0 // indirect + github.com/consensys/gnark-crypto v0.11.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect @@ -30,6 +33,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 // indirect + github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -64,6 +68,7 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/stretchr/objx v0.5.0 // indirect + github.com/test-go/testify v1.1.4 // indirect github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/numcpus v0.5.0 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/monitoring/go.sum b/monitoring/go.sum index 2faaa3853..18e5c61f2 100644 --- a/monitoring/go.sum +++ b/monitoring/go.sum @@ -41,11 +41,6 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg6 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= -github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/hcsshim v0.9.4 h1:mnUj0ivWy6UzbB1uLFqKR6F+ZyiDc7j4iGgHTpO+5+I= -github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -74,17 +69,7 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/confluentinc/confluent-kafka-go/v2 v2.3.0 h1:icCHutJouWlQREayFwCc7lxDAhws08td+W3/gdqgZts= -github.com/confluentinc/confluent-kafka-go/v2 v2.3.0/go.mod h1:/VTy8iEpe6mD9pkCH5BhijlUl8ulUXymKv1Qig5Rgb8= -github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA= -github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO4JTrUzo6IA= -github.com/containerd/containerd v1.6.8 h1:h4dOFDwzHmqFEP754PgfgTeVXFnLiRc6kiqC7tplDJs= -github.com/containerd/containerd v1.6.8/go.mod h1:By6p5KqPK0/7/CgO/A6t/Gz+CUYUu2zf1hUaaymVXB0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -118,8 +103,6 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= -github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= @@ -248,7 +231,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/linkedin/goavro/v2 v2.9.7/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linkedin/goavro/v2 v2.12.0 h1:rIQQSj8jdAUlKQh6DttK8wCRv4t4QO09g1C4aBWXslg= github.com/linkedin/goavro/v2 v2.12.0/go.mod h1:KXx+erlq+RPlGSPmLF7xGo6SAbh8sCQ53x064+ioxhk= @@ -318,18 +300,6 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 h1:WCcC4vZDS1tYNxjWlwRJZQy28r8CM github.com/santhosh-tekuri/jsonschema/v5 v5.2.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumvbfM1u/etVq42Afwq/jtNSBSOA8n5jntnNPo= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= -github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= -github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= -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/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -347,16 +317,12 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/testcontainers/testcontainers-go v0.14.0 h1:h0D5GaYG9mhOWr2qHdEKDXpkce/VlvaYOCzTRi6UBi8= -github.com/testcontainers/testcontainers-go v0.14.0/go.mod h1:hSRGJ1G8Q5Bw2gXgPulJOLlEBaYJHeBSOkQM5JLG+JQ= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A= github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/monitoring/pkg/monitoring/source_envelope.go b/monitoring/pkg/monitoring/source_envelope.go index 85c7322d3..d8fca6f2a 100644 --- a/monitoring/pkg/monitoring/source_envelope.go +++ b/monitoring/pkg/monitoring/source_envelope.go @@ -6,7 +6,19 @@ import ( "math/big" "sync" +<<<<<<< HEAD caigotypes "github.com/smartcontractkit/caigo/types" +||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) + caigotypes "github.com/smartcontractkit/caigo/types" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" + relayUtils "github.com/smartcontractkit/chainlink-relay/pkg/utils" +======= + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" + relayUtils "github.com/smartcontractkit/chainlink-relay/pkg/utils" +>>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/libocr/offchainreporting2/types" "go.uber.org/multierr" @@ -37,9 +49,17 @@ func (s *envelopeSourceFactory) NewSource( if !ok { return nil, fmt.Errorf("expected feedConfig to be of type StarknetFeedConfig not %T", feedConfig) } + contractAddress, err := starknetutils.HexToFelt(feedConfig.GetContractAddress()) + if err != nil { + return nil, err + } + linkTokenAddress, err := starknetutils.HexToFelt(starknetChainConfig.GetLinkTokenAddress()) + if err != nil { + return nil, err + } return &envelopeSource{ - caigotypes.StrToFelt(feedConfig.GetContractAddress()), - caigotypes.StrToFelt(starknetChainConfig.GetLinkTokenAddress()), + contractAddress, + linkTokenAddress, s.ocr2Reader, }, nil } @@ -49,8 +69,8 @@ func (s *envelopeSourceFactory) GetType() string { } type envelopeSource struct { - contractAddress caigotypes.Felt - linkTokenAddress caigotypes.Felt + contractAddress *felt.Felt + linkTokenAddress *felt.Felt ocr2Reader ocr2.OCR2Reader } @@ -116,7 +136,7 @@ func (s *envelopeSource) Fetch(ctx context.Context) (interface{}, error) { return envelope, envelopeErr } -func (s *envelopeSource) fetchLatestNewTransmissionEvent(ctx context.Context, contractAddress caigotypes.Felt) ( +func (s *envelopeSource) fetchLatestNewTransmissionEvent(ctx context.Context, contractAddress *felt.Felt) ( latestRound ocr2.RoundData, transmission ocr2.NewTransmissionEvent, err error, @@ -142,7 +162,7 @@ func (s *envelopeSource) fetchLatestNewTransmissionEvent(ctx context.Context, co return latestRound, transmission, fmt.Errorf("no new_trasmission event found to correspond with the round id %d in block %d", latestRound.RoundID, latestRound.BlockNumber) } -func (s *envelopeSource) fetchContractConfig(ctx context.Context, contractAddress caigotypes.Felt) (config ocr2.ContractConfig, err error) { +func (s *envelopeSource) fetchContractConfig(ctx context.Context, contractAddress *felt.Felt) (config ocr2.ContractConfig, err error) { configDetails, err := s.ocr2Reader.LatestConfigDetails(ctx, contractAddress) if err != nil { return config, fmt.Errorf("couldn't fetch latest config details for contract '%s': %w", contractAddress, err) @@ -156,11 +176,11 @@ func (s *envelopeSource) fetchContractConfig(ctx context.Context, contractAddres var zeroBigInt = big.NewInt(0) -func (s *envelopeSource) fetchLinkBalance(ctx context.Context, linkTokenAddress, contractAddress caigotypes.Felt) (*big.Int, error) { +func (s *envelopeSource) fetchLinkBalance(ctx context.Context, linkTokenAddress, contractAddress *felt.Felt) (*big.Int, error) { results, err := s.ocr2Reader.BaseReader().CallContract(ctx, starknet.CallOps{ ContractAddress: linkTokenAddress, - Selector: "balanceOf", - Calldata: []string{contractAddress.String()}, + Selector: starknettypes.GetSelectorFromNameFelt("balanceOf"), + Calldata: []*felt.Felt{contractAddress}, }) if err != nil { return nil, fmt.Errorf("failed call to ECR20 contract, balanceOf method: %w", err) @@ -168,7 +188,7 @@ func (s *envelopeSource) fetchLinkBalance(ctx context.Context, linkTokenAddress, if len(results) < 1 { return nil, fmt.Errorf("insufficient data from balanceOf '%v': %w", results, err) } - linkBalance := caigotypes.HexToBN(results[0]) + linkBalance := results[0].BigInt(big.NewInt(0)) if linkBalance.Cmp(zeroBigInt) == 0 { return nil, fmt.Errorf("contract's LINK balance should not be zero") } diff --git a/monitoring/pkg/monitoring/source_envelope_test.go b/monitoring/pkg/monitoring/source_envelope_test.go index 6d60c5437..188551025 100644 --- a/monitoring/pkg/monitoring/source_envelope_test.go +++ b/monitoring/pkg/monitoring/source_envelope_test.go @@ -6,8 +6,18 @@ import ( "testing" "time" +<<<<<<< HEAD "github.com/smartcontractkit/caigo" caigotypes "github.com/smartcontractkit/caigo/types" +||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) + "github.com/smartcontractkit/caigo" + caigotypes "github.com/smartcontractkit/caigo/types" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +======= + "github.com/NethermindEth/starknet.go" + starknettypes "github.com/NethermindEth/starknet.go/types" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +>>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/libocr/offchainreporting2/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -66,7 +76,7 @@ func TestEnvelopeSource(t *testing.T) { ContractAddress: chainConfig.GetLinkTokenAddress(), Selector: "balanceOf", Calldata: []string{ - caigo.HexToBN(feedConfig.ContractAddress).String(), + starknetgo.HexToBN(feedConfig.ContractAddress).String(), }, }, ).Return(starknetReaderCallContractBalanceOfResponse, nil) @@ -94,7 +104,7 @@ var ( { RoundId: 0xf5b, LatestAnswer: bigIntFromString("-900000000"), - Transmitter: caigotypes.StrToFelt("634447934223750826572902672583054702307815157196919304685470566142330202833"), + Transmitter: starknettypes.StrToFelt("634447934223750826572902672583054702307815157196919304685470566142330202833"), LatestTimestamp: time.Date(2022, time.September, 27, 18, 51, 0, 0, time.Local), Observers: []uint8{0x1, 0x2, 0x3, 0x4}, ObservationsLen: 0x4, diff --git a/monitoring/pkg/monitoring/source_proxy.go b/monitoring/pkg/monitoring/source_proxy.go index 15d0bce6e..a54a03543 100644 --- a/monitoring/pkg/monitoring/source_proxy.go +++ b/monitoring/pkg/monitoring/source_proxy.go @@ -5,9 +5,18 @@ import ( "fmt" "math/big" +<<<<<<< HEAD caigotypes "github.com/smartcontractkit/caigo/types" relayMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring" +||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) + caigotypes "github.com/smartcontractkit/caigo/types" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +======= + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +>>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" ) @@ -32,8 +41,12 @@ func (s *proxySourceFactory) NewSource( _ relayMonitoring.ChainConfig, feedConfig relayMonitoring.FeedConfig, ) (relayMonitoring.Source, error) { + contractAddress, err := starknetutils.HexToFelt(feedConfig.GetContractAddress()) + if err != nil { + return nil, err + } return &proxySource{ - caigotypes.HexToHash(feedConfig.GetContractAddress()), + contractAddress, s.ocr2Reader, }, nil } @@ -43,7 +56,7 @@ func (s *proxySourceFactory) GetType() string { } type proxySource struct { - contractAddress caigotypes.Hash + contractAddress *felt.Felt ocr2Reader ocr2.OCR2Reader } diff --git a/monitoring/pkg/monitoring/source_txresults.go b/monitoring/pkg/monitoring/source_txresults.go index 352c30b60..d22732ab6 100644 --- a/monitoring/pkg/monitoring/source_txresults.go +++ b/monitoring/pkg/monitoring/source_txresults.go @@ -5,9 +5,18 @@ import ( "fmt" "sync" +<<<<<<< HEAD caigotypes "github.com/smartcontractkit/caigo/types" relayMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring" +||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) + caigotypes "github.com/smartcontractkit/caigo/types" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +======= + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" + relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" +>>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" ) @@ -28,8 +37,12 @@ func (s *txResultsSourceFactory) NewSource( _ relayMonitoring.ChainConfig, feedConfig relayMonitoring.FeedConfig, ) (relayMonitoring.Source, error) { + contractAddress, err := starknetutils.HexToFelt(feedConfig.GetContractAddress()) + if err != nil { + return nil, err + } return &txResultsSource{ - caigotypes.HexToHash(feedConfig.GetContractAddress()), + contractAddress, s.ocr2Reader, 0, sync.Mutex{}, @@ -41,7 +54,7 @@ func (s *txResultsSourceFactory) GetType() string { } type txResultsSource struct { - contractAddress caigotypes.Hash + contractAddress *felt.Felt ocr2Reader ocr2.OCR2Reader prevRoundID uint32 diff --git a/ops/devnet/devnet.go b/ops/devnet/devnet.go index 8b886b54f..13f40540d 100644 --- a/ops/devnet/devnet.go +++ b/ops/devnet/devnet.go @@ -6,7 +6,7 @@ import ( "strings" "time" - caigotypes "github.com/smartcontractkit/caigo/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" "github.com/go-resty/resty/v2" @@ -74,6 +74,7 @@ func (devnet *StarknetDevnetClient) AutoDumpState() { // AutoLoadState auto loads last saved devnet state on contract not found func (devnet *StarknetDevnetClient) AutoLoadState(client *ocr2.Client, ocrAddress string) { + addr, _ := starknetutils.HexToFelt(ocrAddress) t := time.NewTicker(15 * time.Second) go func() { for { @@ -83,7 +84,8 @@ func (devnet *StarknetDevnetClient) AutoLoadState(client *ocr2.Client, ocrAddres return case <-t.C: log.Debug().Msg("Checking for devnet OCR contract errors") - _, err := client.LatestTransmissionDetails(devnet.ctx, caigotypes.StrToFelt(ocrAddress)) + + _, err := client.LatestTransmissionDetails(devnet.ctx, addr) if err != nil && strings.Contains(err.Error(), "is not deployed") { _, err = devnet.client.R().SetBody(map[string]any{ "path": devnet.dumpPath, diff --git a/ops/go.mod b/ops/go.mod index aec90363e..9f4aedd2d 100644 --- a/ops/go.mod +++ b/ops/go.mod @@ -5,9 +5,9 @@ go 1.21 toolchain go1.21.1 require ( + github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 github.com/go-resty/resty/v2 v2.7.0 github.com/rs/zerolog v1.30.0 - github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-env v0.3.29 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.0-20230530233948-90c8af98011e github.com/smartcontractkit/chainlink-testing-framework v1.19.1 @@ -20,11 +20,13 @@ require ( github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/NethermindEth/juno v0.3.1 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/avast/retry-go v3.0.0+incompatible // indirect github.com/aws/constructs-go/constructs/v10 v10.1.255 // indirect github.com/aws/jsii-runtime-go v1.75.0 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2 v2.7.5 // indirect diff --git a/ops/go.sum b/ops/go.sum index 5bd5e7d49..6edbd6525 100644 --- a/ops/go.sum +++ b/ops/go.sum @@ -50,10 +50,6 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= -github.com/Microsoft/hcsshim v0.10.0-rc.8/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY= github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= @@ -105,13 +101,7 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/containerd/containerd v1.7.3 h1:cKwYKkP1eTj54bP3wCdXXBymmKRQMrWjkLSWZZJDa8o= -github.com/containerd/containerd v1.7.3/go.mod h1:32FOM4/O0RkNg7AjQj3hDzN9cUGtu+HMvaKUNiqCZB8= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= @@ -170,8 +160,6 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM45eo= github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= -github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= -github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.19.0 h1:BcCH3CN5tXt5aML+gwmbFwVptLLQA+eT866fCO9wVOM= @@ -348,7 +336,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -452,12 +439,6 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= -github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumvbfM1u/etVq42Afwq/jtNSBSOA8n5jntnNPo= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= github.com/smartcontractkit/chainlink-env v0.3.29 h1:hcIw/BeuB0wKiiE3umAUNBZzWkHO24XF3OW9xSrlMbI= github.com/smartcontractkit/chainlink-env v0.3.29/go.mod h1:9c0Czq4a6wZKY20BcoAlK29DnejQIiLo/MwKYtSFnHk= github.com/smartcontractkit/chainlink-testing-framework v1.19.1 h1:MdGM5jIrBi858Cv7qzfl1Qon93YW8InohAlDQqFoIb4= @@ -491,16 +472,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= -github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= -github.com/testcontainers/testcontainers-go v0.23.0 h1:ERYTSikX01QczBLPZpqsETTBO7lInqEP349phDOVJVs= -github.com/testcontainers/testcontainers-go v0.23.0/go.mod h1:3gzuZfb7T9qfcH2pHpV4RLlWrPjeWNQah6XlYQ32c4I= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/relayer/go.mod b/relayer/go.mod index 6c90b15a2..15166b753 100644 --- a/relayer/go.mod +++ b/relayer/go.mod @@ -5,11 +5,12 @@ go 1.21 toolchain go1.21.1 require ( + github.com/NethermindEth/juno v0.3.1 + github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 github.com/ethereum/go-ethereum v1.11.5 github.com/hashicorp/go-plugin v1.5.2 github.com/pelletier/go-toml/v2 v2.1.0 github.com/pkg/errors v0.9.1 - github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 github.com/stretchr/testify v1.8.4 @@ -21,10 +22,12 @@ require ( require ( cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/consensys/gnark-crypto v0.11.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect @@ -62,6 +65,7 @@ require ( github.com/prometheus/procfs v0.11.1 // indirect github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/stretchr/objx v0.5.0 // indirect + github.com/test-go/testify v1.1.4 // indirect github.com/tklauser/go-sysconf v0.3.10 // indirect github.com/tklauser/numcpus v0.5.0 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/relayer/go.sum b/relayer/go.sum index 4203f417b..a33e2c444 100644 --- a/relayer/go.sum +++ b/relayer/go.sum @@ -39,11 +39,12 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= -github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 h1:SDlJ7bAm4ewvrmZtR0DaiYbQGdKPeaaIm7bM+qRhFeU= @@ -68,11 +69,7 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= -github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= -github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -98,8 +95,6 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= -github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= @@ -226,7 +221,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -274,16 +268,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 h1:T3lFWumvbfM1u/etVq42Afwq/jtNSBSOA8n5jntnNPo= -github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704/go.mod h1:2QuJdEouTWjh5BDy5o/vgGXQtR4Gz8yH1IYB5eT7u4M= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= -github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= -github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= -github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= -github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= -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/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -299,14 +283,12 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A= github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/relayer/pkg/chainlink/ocr2/client.go b/relayer/pkg/chainlink/ocr2/client.go index 6a385c3cf..bc7e7d9c2 100644 --- a/relayer/pkg/chainlink/ocr2/client.go +++ b/relayer/pkg/chainlink/ocr2/client.go @@ -8,8 +8,9 @@ import ( "github.com/pkg/errors" - caigorpc "github.com/smartcontractkit/caigo/rpcv02" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" + starknetrpc "github.com/NethermindEth/starknet.go/rpc" + starknettypes "github.com/NethermindEth/starknet.go/types" "github.com/smartcontractkit/libocr/offchainreporting2/types" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" @@ -20,13 +21,13 @@ import ( //go:generate mockery --name OCR2Reader --output ./mocks/ type OCR2Reader interface { - LatestConfigDetails(context.Context, caigotypes.Felt) (ContractConfigDetails, error) - LatestTransmissionDetails(context.Context, caigotypes.Felt) (TransmissionDetails, error) - LatestRoundData(context.Context, caigotypes.Felt) (RoundData, error) - LinkAvailableForPayment(context.Context, caigotypes.Felt) (*big.Int, error) - ConfigFromEventAt(context.Context, caigotypes.Felt, uint64) (ContractConfig, error) - NewTransmissionsFromEventsAt(context.Context, caigotypes.Felt, uint64) ([]NewTransmissionEvent, error) - BillingDetails(context.Context, caigotypes.Felt) (BillingDetails, error) + LatestConfigDetails(context.Context, *felt.Felt) (ContractConfigDetails, error) + LatestTransmissionDetails(context.Context, *felt.Felt) (TransmissionDetails, error) + LatestRoundData(context.Context, *felt.Felt) (RoundData, error) + LinkAvailableForPayment(context.Context, *felt.Felt) (*big.Int, error) + ConfigFromEventAt(context.Context, *felt.Felt, uint64) (ContractConfig, error) + NewTransmissionsFromEventsAt(context.Context, *felt.Felt, uint64) ([]NewTransmissionEvent, error) + BillingDetails(context.Context, *felt.Felt) (BillingDetails, error) BaseReader() starknet.Reader } @@ -49,10 +50,10 @@ func (c *Client) BaseReader() starknet.Reader { return c.r } -func (c *Client) BillingDetails(ctx context.Context, address caigotypes.Felt) (bd BillingDetails, err error) { +func (c *Client) BillingDetails(ctx context.Context, address *felt.Felt) (bd BillingDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: "billing", + Selector: starknettypes.GetSelectorFromNameFelt("billing"), } res, err := c.r.CallContract(ctx, ops) @@ -65,8 +66,8 @@ func (c *Client) BillingDetails(ctx context.Context, address caigotypes.Felt) (b return bd, errors.New("unexpected result length") } - observationPayment := caigotypes.StrToFelt(res[0]).Big() - transmissionPayment := caigotypes.StrToFelt(res[1]).Big() + observationPayment := res[0].BigInt(big.NewInt(0)) + transmissionPayment := res[1].BigInt(big.NewInt(0)) bd, err = NewBillingDetails(observationPayment, transmissionPayment) if err != nil { @@ -76,10 +77,10 @@ func (c *Client) BillingDetails(ctx context.Context, address caigotypes.Felt) (b return } -func (c *Client) LatestConfigDetails(ctx context.Context, address caigotypes.Felt) (ccd ContractConfigDetails, err error) { +func (c *Client) LatestConfigDetails(ctx context.Context, address *felt.Felt) (ccd ContractConfigDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: "latest_config_details", + Selector: starknettypes.GetSelectorFromNameFelt("latest_config_details"), } res, err := c.r.CallContract(ctx, ops) @@ -92,10 +93,10 @@ func (c *Client) LatestConfigDetails(ctx context.Context, address caigotypes.Fel return ccd, errors.New("unexpected result length") } - blockNum := caigotypes.StrToFelt(res[1]) - configDigest := caigotypes.StrToFelt(res[2]) + blockNum := res[1] + configDigest := res[2] - ccd, err = NewContractConfigDetails(blockNum.Big(), configDigest.Bytes()) + ccd, err = NewContractConfigDetails(blockNum.BigInt(big.NewInt((0))), configDigest.Bytes()) if err != nil { return ccd, errors.Wrap(err, "couldn't initialize config details") } @@ -103,10 +104,10 @@ func (c *Client) LatestConfigDetails(ctx context.Context, address caigotypes.Fel return } -func (c *Client) LatestTransmissionDetails(ctx context.Context, address caigotypes.Felt) (td TransmissionDetails, err error) { +func (c *Client) LatestTransmissionDetails(ctx context.Context, address *felt.Felt) (td TransmissionDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: "latest_transmission_details", + Selector: starknettypes.GetSelectorFromNameFelt("latest_transmission_details"), } res, err := c.r.CallContract(ctx, ops) @@ -119,20 +120,20 @@ func (c *Client) LatestTransmissionDetails(ctx context.Context, address caigotyp return td, errors.New("unexpected result length") } - digest := caigotypes.StrToFelt(res[0]) + digest := res[0] configDigest := types.ConfigDigest{} - digest.Big().FillBytes(configDigest[:]) + digest.BigInt(big.NewInt(0)).FillBytes(configDigest[:]) - epoch, round := parseEpochAndRound(caigotypes.StrToFelt(res[1]).Big()) + epoch, round := parseEpochAndRound(res[1].BigInt(big.NewInt(0))) - latestAnswer, err := starknet.HexToUnsignedBig(res[2]) + latestAnswer := res[2].BigInt(big.NewInt(0)) if err != nil { return td, errors.Wrap(err, "latestAnswer invalid") } - timestampFelt := caigotypes.StrToFelt(res[3]) + timestampFelt := res[3] // TODO: Int64() can return invalid data if int is too big - unixTime := timestampFelt.Big().Int64() + unixTime := timestampFelt.BigInt(big.NewInt(0)).Int64() latestTimestamp := time.Unix(unixTime, 0) td = TransmissionDetails{ @@ -146,20 +147,16 @@ func (c *Client) LatestTransmissionDetails(ctx context.Context, address caigotyp return td, nil } -func (c *Client) LatestRoundData(ctx context.Context, address caigotypes.Felt) (round RoundData, err error) { +func (c *Client) LatestRoundData(ctx context.Context, address *felt.Felt) (round RoundData, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: "latest_round_data", + Selector: starknettypes.GetSelectorFromNameFelt("latest_round_data"), } - results, err := c.r.CallContract(ctx, ops) + felts, err := c.r.CallContract(ctx, ops) if err != nil { return round, errors.Wrap(err, "couldn't call the contract with selector latest_round_data") } - felts := []caigotypes.Felt{} - for _, result := range results { - felts = append(felts, caigotypes.StrToFelt(result)) - } round, err = NewRoundData(felts) if err != nil { @@ -168,10 +165,10 @@ func (c *Client) LatestRoundData(ctx context.Context, address caigotypes.Felt) ( return round, nil } -func (c *Client) LinkAvailableForPayment(ctx context.Context, address caigotypes.Felt) (*big.Int, error) { +func (c *Client) LinkAvailableForPayment(ctx context.Context, address *felt.Felt) (*big.Int, error) { results, err := c.r.CallContract(ctx, starknet.CallOps{ ContractAddress: address, - Selector: "link_available_for_payment", + Selector: starknettypes.GetSelectorFromNameFelt("link_available_for_payment"), }) if err != nil { return nil, errors.Wrap(err, "failed to call the contract with selector 'link_available_for_payment'") @@ -179,24 +176,24 @@ func (c *Client) LinkAvailableForPayment(ctx context.Context, address caigotypes if len(results) != 1 { return nil, errors.Wrap(err, "insufficient data from selector 'link_available_for_payment'") } - return caigotypes.HexToBN(results[0]), nil + return results[0].BigInt(big.NewInt(0)), nil } -func (c *Client) fetchEventsFromBlock(ctx context.Context, address caigotypes.Felt, eventType string, blockNum uint64) (eventsAsFeltArrs [][]caigotypes.Felt, err error) { - block := caigorpc.WithBlockNumber(blockNum) +func (c *Client) fetchEventsFromBlock(ctx context.Context, address *felt.Felt, eventType string, blockNum uint64) (eventsAsFeltArrs [][]*felt.Felt, err error) { + block := starknetrpc.WithBlockNumber(blockNum) - eventKey := caigotypes.BigToHex(caigotypes.GetSelectorFromName(eventType)) + eventKey := starknettypes.GetSelectorFromNameFelt(eventType) - input := caigorpc.EventsInput{ - EventFilter: caigorpc.EventFilter{ + input := starknetrpc.EventsInput{ + EventFilter: starknetrpc.EventFilter{ FromBlock: block, ToBlock: block, Address: address, - Keys: [][]string{{eventKey}}, // skip other event types + Keys: [][]*felt.Felt{{eventKey}}, // skip other event types // PageSize: 0, // PageNumber: 0, }, - ResultPageRequest: caigorpc.ResultPageRequest{ + ResultPageRequest: starknetrpc.ResultPageRequest{ // ContinuationToken: , ChunkSize: 10, }, @@ -210,12 +207,7 @@ func (c *Client) fetchEventsFromBlock(ctx context.Context, address caigotypes.Fe } for _, event := range events.Events { - // convert to felts - felts := []caigotypes.Felt{} - for _, felt := range event.Data { - felts = append(felts, caigotypes.StrToFelt(felt)) - } - eventsAsFeltArrs = append(eventsAsFeltArrs, felts) + eventsAsFeltArrs = append(eventsAsFeltArrs, event.Data) } if len(eventsAsFeltArrs) == 0 { return nil, errors.New("events not found in the block") @@ -223,7 +215,7 @@ func (c *Client) fetchEventsFromBlock(ctx context.Context, address caigotypes.Fe return eventsAsFeltArrs, nil } -func (c *Client) ConfigFromEventAt(ctx context.Context, address caigotypes.Felt, blockNum uint64) (cc ContractConfig, err error) { +func (c *Client) ConfigFromEventAt(ctx context.Context, address *felt.Felt, blockNum uint64) (cc ContractConfig, err error) { eventsAsFeltArrs, err := c.fetchEventsFromBlock(ctx, address, "ConfigSet", blockNum) if err != nil { return cc, errors.Wrap(err, "failed to fetch config_set events") @@ -243,7 +235,7 @@ func (c *Client) ConfigFromEventAt(ctx context.Context, address caigotypes.Felt, } // NewTransmissionsFromEventsAt finds events of type new_transmission emitted by the contract address in a given block number. -func (c *Client) NewTransmissionsFromEventsAt(ctx context.Context, address caigotypes.Felt, blockNum uint64) (events []NewTransmissionEvent, err error) { +func (c *Client) NewTransmissionsFromEventsAt(ctx context.Context, address *felt.Felt, blockNum uint64) (events []NewTransmissionEvent, err error) { eventsAsFeltArrs, err := c.fetchEventsFromBlock(ctx, address, "NewTransmission", blockNum) if err != nil { return nil, errors.Wrap(err, "failed to fetch new_transmission events") diff --git a/relayer/pkg/chainlink/ocr2/client_test.go b/relayer/pkg/chainlink/ocr2/client_test.go index 9ee04384d..a4cb6e528 100644 --- a/relayer/pkg/chainlink/ocr2/client_test.go +++ b/relayer/pkg/chainlink/ocr2/client_test.go @@ -11,8 +11,9 @@ import ( "testing" "time" - "github.com/smartcontractkit/caigo/gateway" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/starknet.go/gateway" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -56,24 +57,25 @@ func TestOCR2Client(t *testing.T) { err := json.Unmarshal([]byte(raw), &reqdata) require.NoError(t, err) - switch { - case caigotypes.BigToHex(caigotypes.GetSelectorFromName("billing")) == reqdata.Selector: + fmt.Printf("%v %v\n", reqdata.Selector, starknettypes.GetSelectorFromNameFelt("latest_transmission_details").String()) + switch reqdata.Selector { + case starknettypes.GetSelectorFromNameFelt("billing").String(): // billing response out = []byte(`{"result":["0x0","0x0","0x0","0x0"]}`) - case caigotypes.BigToHex(caigotypes.GetSelectorFromName("latest_config_details")) == reqdata.Selector: + case starknettypes.GetSelectorFromNameFelt("latest_config_details").String(): // latest config details response out = []byte(`{"result":["0x1","0x2","0x4b791b801cf0d7b6a2f9e59daf15ec2dd7d9cdc3bc5e037bada9c86e4821c"]}`) - case caigotypes.BigToHex(caigotypes.GetSelectorFromName("latest_transmission_details")) == reqdata.Selector: + case starknettypes.GetSelectorFromNameFelt("latest_transmission_details").String(): // latest transmission details response out = []byte(`{"result":["0x4cfc96325fa7d72e4854420e2d7b0abda72de17d45e4c3c0d9f626016d669","0x0","0x0","0x0"]}`) - case caigotypes.BigToHex(caigotypes.GetSelectorFromName("latest_round_data")) == reqdata.Selector: + case starknettypes.GetSelectorFromNameFelt("latest_round_data").String(): // latest transmission details response out = []byte(`{"result":["0x0","0x0","0x0","0x0","0x0"]}`) - case caigotypes.BigToHex(caigotypes.GetSelectorFromName("link_available_for_payment")) == reqdata.Selector: + case starknettypes.GetSelectorFromNameFelt("link_available_for_payment").String(): // latest transmission details response out = []byte(`{"result":["0x0"]}`) default: - require.False(t, true, "unsupported contract method") + require.False(t, true, "unsupported contract method %s", reqdata.Selector) } case "starknet_getEvents": out = []byte(BLOCK_OUTPUT) @@ -98,7 +100,8 @@ func TestOCR2Client(t *testing.T) { client, err := NewClient(reader, lggr) assert.NoError(t, err) - contractAddress := caigotypes.StrToFelt(ocr2ContractAddress) + contractAddress, err := starknetutils.HexToFelt(ocr2ContractAddress) + require.NoError(t, err) t.Run("get billing details", func(t *testing.T) { billing, err := client.BillingDetails(context.Background(), contractAddress) diff --git a/relayer/pkg/chainlink/ocr2/config_digester.go b/relayer/pkg/chainlink/ocr2/config_digester.go index f61f22c93..a7f96324a 100644 --- a/relayer/pkg/chainlink/ocr2/config_digester.go +++ b/relayer/pkg/chainlink/ocr2/config_digester.go @@ -6,7 +6,7 @@ import ( "math/big" "strings" - "github.com/smartcontractkit/caigo" + "github.com/NethermindEth/starknet.go" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -90,7 +90,7 @@ func (d offchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co ) msg = append(msg, offchainConfig...) // offchain_config - digest, err := caigo.Curve.ComputeHashOnElements(msg) + digest, err := starknetgo.Curve.ComputeHashOnElements(msg) if err != nil { return configDigest, err } diff --git a/relayer/pkg/chainlink/ocr2/contract_reader.go b/relayer/pkg/chainlink/ocr2/contract_reader.go index 7f53a8411..31e4a29ea 100644 --- a/relayer/pkg/chainlink/ocr2/contract_reader.go +++ b/relayer/pkg/chainlink/ocr2/contract_reader.go @@ -5,8 +5,9 @@ import ( "math/big" "time" + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" "github.com/pkg/errors" - caigotypes "github.com/smartcontractkit/caigo/types" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -22,14 +23,19 @@ type Reader interface { var _ Reader = (*contractReader)(nil) type contractReader struct { - address caigotypes.Felt + address *felt.Felt reader OCR2Reader lggr logger.Logger } func NewContractReader(address string, reader OCR2Reader, lggr logger.Logger) Reader { + felt, err := starknetutils.HexToFelt(address) + if err != nil { + panic("invalid felt value") + } + return &contractReader{ - address: caigotypes.StrToFelt(address), // TODO: propagate type everywhere + address: felt, // TODO: propagate type everywhere reader: reader, lggr: lggr, } diff --git a/relayer/pkg/chainlink/ocr2/contract_transmitter.go b/relayer/pkg/chainlink/ocr2/contract_transmitter.go index 88c50d96a..aa0a323c6 100644 --- a/relayer/pkg/chainlink/ocr2/contract_transmitter.go +++ b/relayer/pkg/chainlink/ocr2/contract_transmitter.go @@ -7,7 +7,9 @@ import ( "github.com/pkg/errors" - caigotypes "github.com/smartcontractkit/caigo/types" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2/medianreport" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm" @@ -20,9 +22,9 @@ var _ types.ContractTransmitter = (*contractTransmitter)(nil) type contractTransmitter struct { reader *transmissionsCache - contractAddress caigotypes.Felt - senderAddress caigotypes.Felt - accountAddress caigotypes.Felt + contractAddress *felt.Felt + senderAddress *felt.Felt + accountAddress *felt.Felt txm txm.TxManager } @@ -34,11 +36,15 @@ func NewContractTransmitter( accountAddress string, txm txm.TxManager, ) *contractTransmitter { + contractAddr, _ := starknetutils.HexToFelt(contractAddress) + senderAddr, _ := starknetutils.HexToFelt(senderAddress) + accountAddr, _ := starknetutils.HexToFelt(accountAddress) + return &contractTransmitter{ reader: reader, - contractAddress: caigotypes.StrToFelt(contractAddress), - senderAddress: caigotypes.StrToFelt(senderAddress), - accountAddress: caigotypes.StrToFelt(accountAddress), + contractAddress: contractAddr, + senderAddress: senderAddr, + accountAddress: accountAddr, txm: txm, } } @@ -84,10 +90,16 @@ func (c *contractTransmitter) Transmit( transmitPayload = append(transmitPayload, "0x"+hex.EncodeToString(signature[:32])) // public key } - err = c.txm.Enqueue(c.senderAddress, c.accountAddress, caigotypes.FunctionCall{ + // TODO: build felts directly rather than afterwards + calldata, err := starknetutils.HexArrToFelt(transmitPayload) + if err != nil { + return err + } + + err = c.txm.Enqueue(c.senderAddress, c.accountAddress, starknettypes.FunctionCall{ ContractAddress: c.contractAddress, - EntryPointSelector: "transmit", - Calldata: transmitPayload, + EntryPointSelector: starknettypes.GetSelectorFromNameFelt("transmit"), + Calldata: calldata, }) return err diff --git a/relayer/pkg/chainlink/ocr2/events.go b/relayer/pkg/chainlink/ocr2/events.go index 1be0c6660..01bf67c84 100644 --- a/relayer/pkg/chainlink/ocr2/events.go +++ b/relayer/pkg/chainlink/ocr2/events.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -26,7 +26,7 @@ var ( type NewTransmissionEvent struct { RoundId uint32 LatestAnswer *big.Int - Transmitter caigotypes.Felt + Transmitter *felt.Felt LatestTimestamp time.Time Observers []uint8 ObservationsLen uint32 @@ -40,7 +40,7 @@ type NewTransmissionEvent struct { } // ParseNewTransmissionEvent is decoding binary felt data as the NewTransmissionEvent type -func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEvent, error) { +func ParseNewTransmissionEvent(eventData []*felt.Felt) (NewTransmissionEvent, error) { { const observationsLenIndex = 5 const constNumOfElements = 11 @@ -49,7 +49,7 @@ func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEven return NewTransmissionEvent{}, errors.New("invalid: event data") } - observationsLen := eventData[observationsLenIndex].Big().Uint64() + observationsLen := eventData[observationsLenIndex].BigInt(big.NewInt(0)).Uint64() if len(eventData) != constNumOfElements+int(observationsLen) { return NewTransmissionEvent{}, errors.New("invalid: event data") } @@ -57,14 +57,11 @@ func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEven // round_id index := 0 - roundId := uint32(eventData[index].Big().Uint64()) + roundId := uint32(eventData[index].BigInt(big.NewInt(0)).Uint64()) // answer index++ - latestAnswer, err := starknet.HexToUnsignedBig(eventData[index].String()) - if err != nil { - return NewTransmissionEvent{}, errors.Wrap(err, "latestAnswer invalid") - } + latestAnswer := eventData[index].BigInt(big.NewInt(0)) // transmitter index++ @@ -72,16 +69,16 @@ func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEven // observation_timestamp index++ - unixTime := eventData[index].Big().Int64() + unixTime := eventData[index].BigInt(big.NewInt(0)).Int64() latestTimestamp := time.Unix(unixTime, 0) // observers (raw) max 31 index++ - observersRaw := starknet.PadBytes(eventData[index].Big().Bytes(), MaxObservers) + observersRaw := starknet.PadBytes(eventData[index].BigInt(big.NewInt(0)).Bytes(), MaxObservers) // observation_len index++ - observationsLen := uint32(eventData[index].Big().Uint64()) + observationsLen := uint32(eventData[index].BigInt(big.NewInt(0)).Uint64()) // observers (based on observationsLen) var observers []uint8 @@ -92,31 +89,28 @@ func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEven // observations (based on observationsLen) var observations []*big.Int for i := 0; i < int(observationsLen); i++ { - observations = append(observations, eventData[index+i+1].Big()) + observations = append(observations, eventData[index+i+1].BigInt(big.NewInt(0))) } // juels_per_fee_coin index += int(observationsLen) + 1 - juelsPerFeeCoin := eventData[index].Big() + juelsPerFeeCoin := eventData[index].BigInt(big.NewInt(0)) // juels_per_fee_coin index++ - gasPrice := eventData[index].Big() + gasPrice := eventData[index].BigInt(big.NewInt(0)) // config digest index++ - digest, err := types.BytesToConfigDigest(starknet.PadBytes(eventData[index].Bytes(), len(types.ConfigDigest{}))) - if err != nil { - return NewTransmissionEvent{}, errors.Wrap(err, "couldn't convert bytes to ConfigDigest") - } + digest := eventData[index].Bytes() // epoch_and_round index++ - epoch, round := parseEpochAndRound(eventData[index].Big()) + epoch, round := parseEpochAndRound(eventData[index].BigInt(big.NewInt(0))) // reimbursement index++ - reimbursement := eventData[index].Big() + reimbursement := eventData[index].BigInt(big.NewInt(0)) return NewTransmissionEvent{ RoundId: roundId, @@ -136,28 +130,28 @@ func ParseNewTransmissionEvent(eventData []caigotypes.Felt) (NewTransmissionEven } // ParseConfigSetEvent is decoding binary felt data as the libocr ContractConfig type -func ParseConfigSetEvent(eventData []caigotypes.Felt) (types.ContractConfig, error) { +func ParseConfigSetEvent(eventData []*felt.Felt) (types.ContractConfig, error) { { const oraclesLenIdx = 3 if len(eventData) < oraclesLenIdx { return types.ContractConfig{}, errors.New("invalid: event data") } - oraclesLen := eventData[oraclesLenIdx].Big().Uint64() + oraclesLen := eventData[oraclesLenIdx].BigInt(big.NewInt(0)).Uint64() onchainConfigLenIdx := oraclesLenIdx + 2*oraclesLen + 2 if uint64(len(eventData)) < onchainConfigLenIdx { return types.ContractConfig{}, errors.New("invalid: event data") } - onchainConfigLen := eventData[onchainConfigLenIdx].Big().Uint64() + onchainConfigLen := eventData[onchainConfigLenIdx].BigInt(big.NewInt(0)).Uint64() offchainConfigLenIdx := onchainConfigLenIdx + onchainConfigLen + 2 if uint64(len(eventData)) < offchainConfigLenIdx { return types.ContractConfig{}, errors.New("invalid: event data") } - offchainConfigLen := eventData[offchainConfigLenIdx].Big().Uint64() + offchainConfigLen := eventData[offchainConfigLenIdx].BigInt(big.NewInt(0)).Uint64() if uint64(len(eventData)) != offchainConfigLenIdx+offchainConfigLen+1 { return types.ContractConfig{}, errors.New("invalid: event data") } @@ -168,18 +162,15 @@ func ParseConfigSetEvent(eventData []caigotypes.Felt) (types.ContractConfig, err // latest_config_digest index++ - digest, err := types.BytesToConfigDigest(starknet.PadBytes(eventData[index].Bytes(), len(types.ConfigDigest{}))) - if err != nil { - return types.ContractConfig{}, errors.Wrap(err, "couldn't convert bytes to ConfigDigest") - } + digest := eventData[index].Bytes() // config_count index++ - configCount := eventData[index].Big().Uint64() + configCount := eventData[index].BigInt(big.NewInt(0)).Uint64() // oracles_len index++ - oraclesLen := eventData[index].Big().Uint64() + oraclesLen := eventData[index].BigInt(big.NewInt(0)).Uint64() // oracles index++ @@ -188,7 +179,8 @@ func ParseConfigSetEvent(eventData []caigotypes.Felt) (types.ContractConfig, err var transmitters []types.Account for i, member := range oracleMembers { if i%2 == 0 { - signers = append(signers, starknet.PadBytes(member.Bytes(), 32)) // pad to 32 bytes + b := member.Bytes() + signers = append(signers, b[:]) // pad to 32 bytes } else { transmitters = append(transmitters, types.Account(member.String())) } @@ -196,19 +188,19 @@ func ParseConfigSetEvent(eventData []caigotypes.Felt) (types.ContractConfig, err // f index = index + int(oraclesLen)*2 - f := eventData[index].Big().Uint64() + f := eventData[index].BigInt(big.NewInt(0)).Uint64() // onchain_config length index++ - onchainConfigLen := eventData[index].Big().Uint64() + onchainConfigLen := eventData[index].BigInt(big.NewInt(0)).Uint64() // onchain_config (version=1, min, max) index++ onchainConfigFelts := eventData[index:(index + int(onchainConfigLen))] onchainConfig, err := medianreport.OnchainConfigCodec{}.EncodeFromFelt( - onchainConfigFelts[0].Big(), - onchainConfigFelts[1].Big(), - onchainConfigFelts[2].Big(), + onchainConfigFelts[0].BigInt(big.NewInt(0)), + onchainConfigFelts[1].BigInt(big.NewInt(0)), + onchainConfigFelts[2].BigInt(big.NewInt(0)), ) if err != nil { return types.ContractConfig{}, errors.Wrap(err, "err in encoding onchain config from felts") @@ -216,11 +208,11 @@ func ParseConfigSetEvent(eventData []caigotypes.Felt) (types.ContractConfig, err // offchain_config_version index += int(onchainConfigLen) - offchainConfigVersion := eventData[index].Big().Uint64() + offchainConfigVersion := eventData[index].BigInt(big.NewInt(0)).Uint64() // offchain_config_len index++ - offchainConfigLen := eventData[index].Big().Uint64() + offchainConfigLen := eventData[index].BigInt(big.NewInt(0)).Uint64() // offchain_config index++ diff --git a/relayer/pkg/chainlink/ocr2/events_test.go b/relayer/pkg/chainlink/ocr2/events_test.go index 52f53590f..5ea442a22 100644 --- a/relayer/pkg/chainlink/ocr2/events_test.go +++ b/relayer/pkg/chainlink/ocr2/events_test.go @@ -9,7 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - caigotypes "github.com/smartcontractkit/caigo/types" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -61,7 +62,7 @@ var ( ) func TestNewTransmissionEvent_Parse(t *testing.T) { - eventData, err := starknet.StringsToFelt(newTransmissionEventRaw) + eventData, err := starknetutils.HexArrToFelt(newTransmissionEventRaw) assert.NoError(t, err) require.Equal(t, len(newTransmissionEventRaw), len(eventData)) @@ -81,7 +82,8 @@ func TestNewTransmissionEvent_Parse(t *testing.T) { transmitterHex := "0x2c0dd77ce74b1667dc6fa782bbafaef5becbe2d04b052726ab236daeb52ac5d" require.Equal(t, len(transmitterHex), int(2+31.5*2)) // len('0x') + len(max_felt_len) - expectedTransmitter := caigotypes.StrToFelt(transmitterHex) + expectedTransmitter, err := starknetutils.HexToFelt(transmitterHex) + require.NoError(t, err) require.Equal(t, e.Transmitter, expectedTransmitter) require.Equal(t, e.Observers, []uint8{0, 1, 2, 3}) @@ -94,7 +96,7 @@ func TestNewTransmissionEvent_Parse(t *testing.T) { } func TestConfigSetEvent_Parse(t *testing.T) { - eventData, err := starknet.StringsToFelt(configSetEventRaw) + eventData, err := starknetutils.HexArrToFelt(configSetEventRaw) assert.NoError(t, err) require.Equal(t, len(configSetEventRaw), len(eventData)) @@ -144,7 +146,7 @@ func TestNewTransmissionEventSelector(t *testing.T) { require.NoError(t, err) eventKey := new(big.Int) eventKey.SetBytes(bytes) - assert.Equal(t, caigotypes.GetSelectorFromName("NewTransmission").Cmp(eventKey), 0) + assert.Equal(t, starknettypes.GetSelectorFromName("NewTransmission").Cmp(eventKey), 0) } func TestConfigSetEventSelector(t *testing.T) { @@ -152,5 +154,5 @@ func TestConfigSetEventSelector(t *testing.T) { require.NoError(t, err) eventKey := new(big.Int) eventKey.SetBytes(bytes) - assert.Equal(t, caigotypes.GetSelectorFromName("ConfigSet").Cmp(eventKey), 0) + assert.Equal(t, starknettypes.GetSelectorFromName("ConfigSet").Cmp(eventKey), 0) } diff --git a/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go b/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go index 4ea4a9f67..1f86e0555 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go @@ -4,10 +4,6 @@ import ( "fmt" "math/big" - "github.com/pkg/errors" - "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" - - caigotypes "github.com/smartcontractkit/caigo/types" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" ) @@ -52,17 +48,8 @@ func (codec OnchainConfigCodec) Decode(b []byte) (median.OnchainConfig, error) { return median.OnchainConfig{}, err } - // convert felts to big.Ints - - min, err := starknet.FeltToUnsignedBig(caigotypes.BigToFelt(felts[1])) - if err != nil { - return median.OnchainConfig{}, errors.Wrap(err, "min invalid") - } - - max, err := starknet.FeltToUnsignedBig(caigotypes.BigToFelt(felts[2])) - if err != nil { - return median.OnchainConfig{}, errors.Wrap(err, "max invalid") - } + min := felts[1] + max := felts[2] if !(min.Cmp(max) <= 0) { return median.OnchainConfig{}, fmt.Errorf("OnchainConfig min (%v) should not be greater than max(%v)", min, max) diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report.go b/relayer/pkg/chainlink/ocr2/medianreport/report.go index 7049d8a6a..4edd36b0c 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report.go @@ -8,8 +8,9 @@ import ( "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" "github.com/pkg/errors" - caigotypes "github.com/smartcontractkit/caigo/types" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -43,25 +44,37 @@ func (c ReportCodec) BuildReport(oo []median.ParsedAttributedObservation) (types // preserve original array oo = append([]median.ParsedAttributedObservation{}, oo...) - numFelt := caigotypes.BigToFelt(big.NewInt(int64(num))) + numFelt, err := starknetutils.BigIntToFelt(big.NewInt(int64(num))) + if err != nil { + return nil, fmt.Errorf("invalid felt: %v", err) + } // median timestamp sort.Slice(oo, func(i, j int) bool { return oo[i].Timestamp < oo[j].Timestamp }) timestamp := oo[num/2].Timestamp - timestampFelt := caigotypes.BigToFelt(big.NewInt(int64(timestamp))) + timestampFelt, err := starknetutils.BigIntToFelt(big.NewInt(int64(timestamp))) + if err != nil { + return nil, fmt.Errorf("invalid felt: %v", err) + } // median juelsPerFeeCoin sort.Slice(oo, func(i, j int) bool { return oo[i].JuelsPerFeeCoin.Cmp(oo[j].JuelsPerFeeCoin) < 0 }) juelsPerFeeCoin := oo[num/2].JuelsPerFeeCoin - juelsPerFeeCoinFelt := caigotypes.BigToFelt(juelsPerFeeCoin) + juelsPerFeeCoinFelt, err := starknetutils.BigIntToFelt(juelsPerFeeCoin) + if err != nil { + return nil, fmt.Errorf("invalid felt: %v", err) + } // TODO: source from observations gasPrice := big.NewInt(1) // := oo[num/2].GasPrice - gasPriceFelt := caigotypes.BigToFelt(gasPrice) + gasPriceFelt, err := starknetutils.BigIntToFelt(gasPrice) + if err != nil { + return nil, fmt.Errorf("invalid felt: %v", err) + } // sort by values sort.Slice(oo, func(i, j int) bool { @@ -69,21 +82,32 @@ func (c ReportCodec) BuildReport(oo []median.ParsedAttributedObservation) (types }) var observers = make([]byte, starknet.FeltLength) - var observations []caigotypes.Felt + var observations []*felt.Felt for i, o := range oo { observers[i] = byte(o.Observer) - observations = append(observations, caigotypes.BigToFelt(o.Value)) + + f, err := starknetutils.BigIntToFelt(o.Value) + if err != nil { + return nil, fmt.Errorf("invalid felt: %v", err) + } + observations = append(observations, f) } var report []byte - report = append(report, timestampFelt.Bytes()...) + + buf := timestampFelt.Bytes() + report = append(report, buf[:]...) report = append(report, observers...) - report = append(report, numFelt.Bytes()...) + buf = numFelt.Bytes() + report = append(report, buf[:]...) for _, o := range observations { - report = append(report, o.Bytes()...) + buf = o.Bytes() + report = append(report, buf[:]...) } - report = append(report, juelsPerFeeCoinFelt.Bytes()...) - report = append(report, gasPriceFelt.Bytes()...) + buf = juelsPerFeeCoinFelt.Bytes() + report = append(report, buf[:]...) + buf = gasPriceFelt.Bytes() + report = append(report, buf[:]...) return report, nil } @@ -95,7 +119,7 @@ func (c ReportCodec) MedianFromReport(report types.Report) (*big.Int, error) { } // Decode the number of observations - numBig := caigotypes.BytesToFelt(report[(timestampSizeBytes + observersSizeBytes):prefixSizeBytes]).Big() + numBig := new(felt.Felt).SetBytes(report[(timestampSizeBytes + observersSizeBytes):prefixSizeBytes]).BigInt(big.NewInt(0)) if !numBig.IsUint64() { return nil, errors.New("length of observations is invalid") } @@ -119,11 +143,8 @@ func (c ReportCodec) MedianFromReport(report types.Report) (*big.Int, error) { for i := 0; i < n; i++ { start := prefixSizeBytes + observationSizeBytes*i end := start + observationSizeBytes - obv := caigotypes.BytesToFelt(report[start:end]) - o, err := starknet.FeltToUnsignedBig(obv) - if err != nil { - return nil, errors.Wrap(err, "observation invalid") - } + obv := new(felt.Felt).SetBytes(report[start:end]) + o := obv.BigInt(big.NewInt(0)) oo = append(oo, o) } diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go index c74355dd3..f86492926 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - caigotypes "github.com/smartcontractkit/caigo/types" "github.com/smartcontractkit/libocr/commontypes" "github.com/smartcontractkit/libocr/offchainreporting2/reportingplugin/median" ) @@ -71,7 +70,7 @@ func TestBuildReport(t *testing.T) { assert.Equal(t, totalLen, len(report), "validate length") // validate timestamp - timestamp := caigotypes.BytesToFelt(report[0:timestampSizeBytes]).Big() + timestamp := new(big.Int).SetBytes(report[0:timestampSizeBytes]) assert.Equal(t, uint64(oo[0].Timestamp), timestamp.Uint64(), "validate timestamp") // validate observers @@ -80,7 +79,7 @@ func TestBuildReport(t *testing.T) { // validate observer count index += observersSizeBytes - count := caigotypes.BytesToFelt(report[index : index+observationsLenBytes]).Big() + count := new(big.Int).SetBytes(report[index : index+observationsLenBytes]) assert.Equal(t, uint8(n), uint8(count.Uint64()), "validate observer count") // validate observations diff --git a/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go b/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go index 3da7aa9ce..ea85761de 100644 --- a/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go +++ b/relayer/pkg/chainlink/ocr2/mocks/OCR2Reader.go @@ -6,13 +6,13 @@ import ( context "context" big "math/big" + felt "github.com/NethermindEth/juno/core/felt" + mock "github.com/stretchr/testify/mock" ocr2 "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" starknet "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" - - types "github.com/smartcontractkit/caigo/types" ) // OCR2Reader is an autogenerated mock type for the OCR2Reader type @@ -37,21 +37,21 @@ func (_m *OCR2Reader) BaseReader() starknet.Reader { } // BillingDetails provides a mock function with given fields: _a0, _a1 -func (_m *OCR2Reader) BillingDetails(_a0 context.Context, _a1 types.Felt) (ocr2.BillingDetails, error) { +func (_m *OCR2Reader) BillingDetails(_a0 context.Context, _a1 *felt.Felt) (ocr2.BillingDetails, error) { ret := _m.Called(_a0, _a1) var r0 ocr2.BillingDetails var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (ocr2.BillingDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (ocr2.BillingDetails, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) ocr2.BillingDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) ocr2.BillingDetails); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(ocr2.BillingDetails) } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -61,21 +61,21 @@ func (_m *OCR2Reader) BillingDetails(_a0 context.Context, _a1 types.Felt) (ocr2. } // ConfigFromEventAt provides a mock function with given fields: _a0, _a1, _a2 -func (_m *OCR2Reader) ConfigFromEventAt(_a0 context.Context, _a1 types.Felt, _a2 uint64) (ocr2.ContractConfig, error) { +func (_m *OCR2Reader) ConfigFromEventAt(_a0 context.Context, _a1 *felt.Felt, _a2 uint64) (ocr2.ContractConfig, error) { ret := _m.Called(_a0, _a1, _a2) var r0 ocr2.ContractConfig var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt, uint64) (ocr2.ContractConfig, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt, uint64) (ocr2.ContractConfig, error)); ok { return rf(_a0, _a1, _a2) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt, uint64) ocr2.ContractConfig); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt, uint64) ocr2.ContractConfig); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Get(0).(ocr2.ContractConfig) } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt, uint64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt, uint64) error); ok { r1 = rf(_a0, _a1, _a2) } else { r1 = ret.Error(1) @@ -85,21 +85,21 @@ func (_m *OCR2Reader) ConfigFromEventAt(_a0 context.Context, _a1 types.Felt, _a2 } // LatestConfigDetails provides a mock function with given fields: _a0, _a1 -func (_m *OCR2Reader) LatestConfigDetails(_a0 context.Context, _a1 types.Felt) (ocr2.ContractConfigDetails, error) { +func (_m *OCR2Reader) LatestConfigDetails(_a0 context.Context, _a1 *felt.Felt) (ocr2.ContractConfigDetails, error) { ret := _m.Called(_a0, _a1) var r0 ocr2.ContractConfigDetails var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (ocr2.ContractConfigDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (ocr2.ContractConfigDetails, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) ocr2.ContractConfigDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) ocr2.ContractConfigDetails); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(ocr2.ContractConfigDetails) } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -109,21 +109,21 @@ func (_m *OCR2Reader) LatestConfigDetails(_a0 context.Context, _a1 types.Felt) ( } // LatestRoundData provides a mock function with given fields: _a0, _a1 -func (_m *OCR2Reader) LatestRoundData(_a0 context.Context, _a1 types.Felt) (ocr2.RoundData, error) { +func (_m *OCR2Reader) LatestRoundData(_a0 context.Context, _a1 *felt.Felt) (ocr2.RoundData, error) { ret := _m.Called(_a0, _a1) var r0 ocr2.RoundData var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (ocr2.RoundData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (ocr2.RoundData, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) ocr2.RoundData); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) ocr2.RoundData); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(ocr2.RoundData) } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -133,21 +133,21 @@ func (_m *OCR2Reader) LatestRoundData(_a0 context.Context, _a1 types.Felt) (ocr2 } // LatestTransmissionDetails provides a mock function with given fields: _a0, _a1 -func (_m *OCR2Reader) LatestTransmissionDetails(_a0 context.Context, _a1 types.Felt) (ocr2.TransmissionDetails, error) { +func (_m *OCR2Reader) LatestTransmissionDetails(_a0 context.Context, _a1 *felt.Felt) (ocr2.TransmissionDetails, error) { ret := _m.Called(_a0, _a1) var r0 ocr2.TransmissionDetails var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (ocr2.TransmissionDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (ocr2.TransmissionDetails, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) ocr2.TransmissionDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) ocr2.TransmissionDetails); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(ocr2.TransmissionDetails) } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -157,15 +157,15 @@ func (_m *OCR2Reader) LatestTransmissionDetails(_a0 context.Context, _a1 types.F } // LinkAvailableForPayment provides a mock function with given fields: _a0, _a1 -func (_m *OCR2Reader) LinkAvailableForPayment(_a0 context.Context, _a1 types.Felt) (*big.Int, error) { +func (_m *OCR2Reader) LinkAvailableForPayment(_a0 context.Context, _a1 *felt.Felt) (*big.Int, error) { ret := _m.Called(_a0, _a1) var r0 *big.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*big.Int, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) *big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *big.Int); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { @@ -173,7 +173,7 @@ func (_m *OCR2Reader) LinkAvailableForPayment(_a0 context.Context, _a1 types.Fel } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -183,15 +183,15 @@ func (_m *OCR2Reader) LinkAvailableForPayment(_a0 context.Context, _a1 types.Fel } // NewTransmissionsFromEventsAt provides a mock function with given fields: _a0, _a1, _a2 -func (_m *OCR2Reader) NewTransmissionsFromEventsAt(_a0 context.Context, _a1 types.Felt, _a2 uint64) ([]ocr2.NewTransmissionEvent, error) { +func (_m *OCR2Reader) NewTransmissionsFromEventsAt(_a0 context.Context, _a1 *felt.Felt, _a2 uint64) ([]ocr2.NewTransmissionEvent, error) { ret := _m.Called(_a0, _a1, _a2) var r0 []ocr2.NewTransmissionEvent var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt, uint64) ([]ocr2.NewTransmissionEvent, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt, uint64) ([]ocr2.NewTransmissionEvent, error)); ok { return rf(_a0, _a1, _a2) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt, uint64) []ocr2.NewTransmissionEvent); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt, uint64) []ocr2.NewTransmissionEvent); ok { r0 = rf(_a0, _a1, _a2) } else { if ret.Get(0) != nil { @@ -199,7 +199,7 @@ func (_m *OCR2Reader) NewTransmissionsFromEventsAt(_a0 context.Context, _a1 type } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt, uint64) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt, uint64) error); ok { r1 = rf(_a0, _a1, _a2) } else { r1 = ret.Error(1) diff --git a/relayer/pkg/chainlink/ocr2/types.go b/relayer/pkg/chainlink/ocr2/types.go index d81cf4f40..81b9b06e4 100644 --- a/relayer/pkg/chainlink/ocr2/types.go +++ b/relayer/pkg/chainlink/ocr2/types.go @@ -6,9 +6,7 @@ import ( "math/big" "time" - "github.com/pkg/errors" - - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/libocr/offchainreporting2/types" ) @@ -17,12 +15,7 @@ type ContractConfigDetails struct { Digest types.ConfigDigest } -func NewContractConfigDetails(blockNum *big.Int, digestBytes []byte) (ccd ContractConfigDetails, err error) { - digest, err := types.BytesToConfigDigest(digestBytes) - if err != nil { - return ccd, errors.Wrap(err, "couldn't decode config digest") - } - +func NewContractConfigDetails(blockNum *big.Int, digest [32]byte) (ccd ContractConfigDetails, err error) { return ContractConfigDetails{ Block: blockNum.Uint64(), Digest: digest, @@ -62,26 +55,27 @@ type RoundData struct { UpdatedAt time.Time } -func NewRoundData(felts []caigotypes.Felt) (data RoundData, err error) { +func NewRoundData(felts []*felt.Felt) (data RoundData, err error) { if len(felts) != 5 { return data, fmt.Errorf("expected number of felts to be 5 but got %d", len(felts)) } - if !felts[0].Big().IsUint64() && felts[0].Big().Uint64() > math.MaxUint32 { - return data, fmt.Errorf("aggregator round id does not fit in a uint32 '%s'", felts[0].Big()) + roundId := felts[0].BigInt(big.NewInt(0)) + if !roundId.IsUint64() && roundId.Uint64() > math.MaxUint32 { + return data, fmt.Errorf("aggregator round id does not fit in a uint32 '%s'", felts[0].String()) } - data.RoundID = uint32(felts[0].Big().Uint64()) - data.Answer = felts[1].Big() - blockNumber := felts[2].Big() + data.RoundID = uint32(roundId.Uint64()) + data.Answer = felts[1].BigInt(big.NewInt(0)) + blockNumber := felts[2].BigInt(big.NewInt(0)) if !blockNumber.IsUint64() { return data, fmt.Errorf("block number '%s' does not fit into uint64", blockNumber.String()) } data.BlockNumber = blockNumber.Uint64() - startedAt := felts[3].Big() + startedAt := felts[3].BigInt(big.NewInt(0)) if !startedAt.IsInt64() { return data, fmt.Errorf("startedAt '%s' does not fit into int64", startedAt.String()) } data.StartedAt = time.Unix(startedAt.Int64(), 0) - updatedAt := felts[4].Big() + updatedAt := felts[4].BigInt(big.NewInt(0)) if !updatedAt.IsInt64() { return data, fmt.Errorf("updatedAt '%s' does not fit into int64", startedAt.String()) } diff --git a/relayer/pkg/chainlink/ocr2/types_test.go b/relayer/pkg/chainlink/ocr2/types_test.go index 8d339f56c..3c30b9d1d 100644 --- a/relayer/pkg/chainlink/ocr2/types_test.go +++ b/relayer/pkg/chainlink/ocr2/types_test.go @@ -5,18 +5,10 @@ import ( "testing" "time" - caigotypes "github.com/smartcontractkit/caigo/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/require" ) -func StringsToCaigoFelts(in []string) []caigotypes.Felt { - out := make([]caigotypes.Felt, len(in)) - for i := 0; i < len(in); i++ { - out[i] = caigotypes.StrToFelt(in[i]) - } - return out -} - func TestNewRoundData(t *testing.T) { raw := []string{ "0x121e", @@ -26,7 +18,8 @@ func TestNewRoundData(t *testing.T) { "0x633344a5", } - felts := StringsToCaigoFelts(raw) + felts, err := starknetutils.HexArrToFelt(raw) + require.NoError(t, err) actualRound, err := NewRoundData(felts) require.NoError(t, err) expectedRound := RoundData{ diff --git a/relayer/pkg/chainlink/txm/keystore.go b/relayer/pkg/chainlink/txm/keystore.go index 9f854cd6f..628f5c49a 100644 --- a/relayer/pkg/chainlink/txm/keystore.go +++ b/relayer/pkg/chainlink/txm/keystore.go @@ -6,7 +6,7 @@ import ( "fmt" "math/big" - "github.com/smartcontractkit/caigo" + "github.com/NethermindEth/starknet.go" "github.com/smartcontractkit/chainlink-common/pkg/loop" adapters "github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/starknet" @@ -15,7 +15,7 @@ import ( // KeystoreAdapter is a starknet-specific adaption layer to translate between the generic Loop Keystore (bytes) and // the type specific caigo Keystore (big.Int) type KeystoreAdapter interface { - caigo.Keystore + starknetgo.Keystore Loopp() loop.Keystore } diff --git a/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go b/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go index 8e49300a0..076ee279e 100644 --- a/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go +++ b/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go @@ -6,9 +6,9 @@ import ( context "context" big "math/big" - mock "github.com/stretchr/testify/mock" + felt "github.com/NethermindEth/juno/core/felt" - types "github.com/smartcontractkit/caigo/types" + mock "github.com/stretchr/testify/mock" ) // NonceManagerClient is an autogenerated mock type for the NonceManagerClient type @@ -17,15 +17,15 @@ type NonceManagerClient struct { } // AccountNonce provides a mock function with given fields: _a0, _a1 -func (_m *NonceManagerClient) AccountNonce(_a0 context.Context, _a1 types.Felt) (*big.Int, error) { +func (_m *NonceManagerClient) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*big.Int, error) { ret := _m.Called(_a0, _a1) var r0 *big.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*big.Int, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) *big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *big.Int); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { @@ -33,7 +33,7 @@ func (_m *NonceManagerClient) AccountNonce(_a0 context.Context, _a1 types.Felt) } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) diff --git a/relayer/pkg/chainlink/txm/nonce.go b/relayer/pkg/chainlink/txm/nonce.go index 4401af81f..1982f6ff9 100644 --- a/relayer/pkg/chainlink/txm/nonce.go +++ b/relayer/pkg/chainlink/txm/nonce.go @@ -6,7 +6,7 @@ import ( "math/big" "sync" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/services" @@ -16,16 +16,16 @@ import ( //go:generate mockery --name NonceManagerClient --output ./mocks/ --case=underscore --filename nonce_manager_client.go type NonceManagerClient interface { - AccountNonce(context.Context, caigotypes.Felt) (*big.Int, error) + AccountNonce(context.Context, *felt.Felt) (*big.Int, error) } type NonceManager interface { services.Service - Register(ctx context.Context, address caigotypes.Felt, chainId string, client NonceManagerClient) error + Register(ctx context.Context, address *felt.Felt, chainId string, client NonceManagerClient) error - NextSequence(address caigotypes.Felt, chainID string) (*big.Int, error) - IncrementNextSequence(address caigotypes.Felt, chainID string, currentNonce *big.Int) error + NextSequence(address *felt.Felt, chainID string) (*big.Int, error) + IncrementNextSequence(address *felt.Felt, chainID string, currentNonce *big.Int) error } var _ NonceManager = (*nonceManager)(nil) @@ -66,7 +66,7 @@ func (nm *nonceManager) HealthReport() map[string]error { } // Register is used because we cannot pre-fetch nonces. the pubkey is known before hand, but the account address is not known until a job is started and sends a tx -func (nm *nonceManager) Register(ctx context.Context, addr caigotypes.Felt, chainId string, client NonceManagerClient) error { +func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, chainId string, client NonceManagerClient) error { nm.lock.Lock() defer nm.lock.Unlock() addressNonces, exists := nm.n[addr.String()] @@ -85,7 +85,7 @@ func (nm *nonceManager) Register(ctx context.Context, addr caigotypes.Felt, chai return nil } -func (nm *nonceManager) NextSequence(addr caigotypes.Felt, chainId string) (*big.Int, error) { +func (nm *nonceManager) NextSequence(addr *felt.Felt, chainId string) (*big.Int, error) { if err := nm.validate(addr, chainId); err != nil { return nil, err } @@ -95,7 +95,7 @@ func (nm *nonceManager) NextSequence(addr caigotypes.Felt, chainId string) (*big return nm.n[addr.String()][chainId], nil } -func (nm *nonceManager) IncrementNextSequence(addr caigotypes.Felt, chainId string, currentNonce *big.Int) error { +func (nm *nonceManager) IncrementNextSequence(addr *felt.Felt, chainId string, currentNonce *big.Int) error { if err := nm.validate(addr, chainId); err != nil { return err } @@ -110,7 +110,7 @@ func (nm *nonceManager) IncrementNextSequence(addr caigotypes.Felt, chainId stri return nil } -func (nm *nonceManager) validate(addr caigotypes.Felt, id string) error { +func (nm *nonceManager) validate(addr *felt.Felt, id string) error { nm.lock.RLock() defer nm.lock.RUnlock() if _, exists := nm.n[addr.String()]; !exists { diff --git a/relayer/pkg/chainlink/txm/nonce_test.go b/relayer/pkg/chainlink/txm/nonce_test.go index 1f9dea0a4..0ad4a01b8 100644 --- a/relayer/pkg/chainlink/txm/nonce_test.go +++ b/relayer/pkg/chainlink/txm/nonce_test.go @@ -5,7 +5,8 @@ import ( "math/big" "testing" - caigotypes "github.com/smartcontractkit/caigo/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" @@ -18,14 +19,15 @@ import ( "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm/mocks" ) -func newTestNonceManager(t *testing.T, chainID string, initNonce *big.Int) (txm.NonceManager, caigotypes.Felt, func()) { +func newTestNonceManager(t *testing.T, chainID string, initNonce *big.Int) (txm.NonceManager, *felt.Felt, func()) { // setup c := mocks.NewNonceManagerClient(t) lggr := logger.Test(t) nm := txm.NewNonceManager(lggr) // mock returns - keyHash := caigotypes.StrToFelt("test-key-id") + keyHash, err := starknetutils.HexToFelt("0x0") + require.NoError(t, err) c.On("AccountNonce", mock.Anything, mock.Anything).Return(initNonce, nil).Once() require.NoError(t, nm.Start(tests.Context(t))) @@ -53,7 +55,8 @@ func TestNonceManager_NextSequence(t *testing.T) { assert.Contains(t, err.Error(), fmt.Sprintf("nonce does not exist for key: %s and chain: %s", k.String(), "invalid_chainId")) // should fail with invalid address - randAddr1 := caigotypes.BigToFelt(big.NewInt(1)) + randAddr1, err := starknetutils.BigIntToFelt(big.NewInt(1)) + require.NoError(t, err) _, err = nm.NextSequence(randAddr1, chainId) require.Error(t, err) assert.Contains(t, err.Error(), fmt.Sprintf("nonce tracking does not exist for key: %s", randAddr1.String())) @@ -88,7 +91,8 @@ func TestNonceManager_IncrementNextSequence(t *testing.T) { assert.Contains(t, err.Error(), fmt.Sprintf("nonce does not exist for key: %s and chain: %s", k.String(), "invalid_chainId")) // should fail with invalid address - randAddr1 := caigotypes.BigToFelt(big.NewInt(1)) + randAddr1, err := starknetutils.BigIntToFelt(big.NewInt(1)) + require.NoError(t, err) err = nm.IncrementNextSequence(randAddr1, chainId, initPlusOne) require.Error(t, err) assert.Contains(t, err.Error(), fmt.Sprintf("nonce tracking does not exist for key: %s", randAddr1.String())) diff --git a/relayer/pkg/chainlink/txm/test_helpers.go b/relayer/pkg/chainlink/txm/test_helpers.go index f3fda3048..9b5e10e7e 100644 --- a/relayer/pkg/chainlink/txm/test_helpers.go +++ b/relayer/pkg/chainlink/txm/test_helpers.go @@ -7,7 +7,7 @@ import ( "testing" "time" - caigotypes "github.com/smartcontractkit/caigo/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -76,9 +76,9 @@ func TestKeys(t *testing.T, count int) (rawkeys [][]byte) { if i >= count { break } - - keyBytes := caigotypes.StrToFelt(k).Bytes() - rawkeys = append(rawkeys, keyBytes) + f, _ := starknetutils.HexToFelt(k) + keyBytes := f.Bytes() + rawkeys = append(rawkeys, keyBytes[:]) } return rawkeys } diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index f59d41468..4372bc88c 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -9,9 +9,11 @@ import ( "sync" "time" - "github.com/smartcontractkit/caigo" - caigorpc "github.com/smartcontractkit/caigo/rpcv02" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" + "github.com/NethermindEth/starknet.go" + starknetrpc "github.com/NethermindEth/starknet.go/rpc" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "golang.org/x/exp/maps" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -27,14 +29,14 @@ const ( ) type TxManager interface { - Enqueue(senderAddress caigotypes.Felt, accountAddress caigotypes.Felt, txFn caigotypes.FunctionCall) error + Enqueue(senderAddress *felt.Felt, accountAddress *felt.Felt, txFn starknettypes.FunctionCall) error InflightCount() (int, int) } type Tx struct { - senderAddress caigotypes.Felt - accountAddress caigotypes.Felt - call caigotypes.FunctionCall + senderAddress *felt.Felt + accountAddress *felt.Felt + call starknettypes.FunctionCall } type StarkTXM interface { @@ -126,15 +128,15 @@ func (txm *starktxm) broadcastLoop() { const FEE_MARGIN uint64 = 115 -func (txm *starktxm) broadcast(ctx context.Context, senderAddress caigotypes.Felt, accountAddress caigotypes.Felt, tx caigotypes.FunctionCall) (txhash string, err error) { - txs := []caigotypes.FunctionCall{tx} +func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, accountAddress *felt.Felt, tx starknettypes.FunctionCall) (txhash string, err error) { + txs := []starknettypes.FunctionCall{tx} client, err := txm.client.Get() if err != nil { txm.client.Reset() return txhash, fmt.Errorf("broadcast: failed to fetch client: %+w", err) } // create new account - account, err := caigo.NewRPCAccount(senderAddress, accountAddress, txm.ks, client.Provider, caigo.AccountVersion1) + account, err := starknetgo.NewRPCAccount(senderAddress, accountAddress, txm.ks, client.Provider, starknetgo.AccountVersion1) if err != nil { return txhash, fmt.Errorf("failed to create new account: %+w", err) } @@ -152,7 +154,7 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress caigotypes.Fel // get fee for txm // optional - pass nonce to fee estimate (if nonce gets ahead, estimate may fail) // can we estimate fee without calling estimate - tbd with 1.0 - feeEstimate, err := account.EstimateFee(ctx, txs, caigotypes.ExecuteDetails{}) + feeEstimate, err := account.EstimateFee(ctx, txs, starknettypes.ExecuteDetails{}) if err != nil { return txhash, fmt.Errorf("failed to estimate fee: %+w", err) } @@ -160,7 +162,7 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress caigotypes.Fel fee, _ := big.NewInt(0).SetString(string(feeEstimate.OverallFee), 0) expandedFee := big.NewInt(0).Mul(fee, big.NewInt(int64(FEE_MARGIN))) max := big.NewInt(0).Div(expandedFee, big.NewInt(100)) - details := caigotypes.ExecuteDetails{ + details := starknettypes.ExecuteDetails{ MaxFee: max, Nonce: nonce, } @@ -180,11 +182,12 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress caigotypes.Fel } // update nonce if transaction is successful + hash := res.TransactionHash.String() err = errors.Join( txm.nonce.IncrementNextSequence(accountAddress, chainID, nonce), - txm.txStore.Save(accountAddress, nonce, res.TransactionHash), + txm.txStore.Save(accountAddress, nonce, hash), ) - return res.TransactionHash, err + return hash, err } func (txm *starktxm) confirmLoop() { @@ -211,12 +214,17 @@ func (txm *starktxm) confirmLoop() { for addr := range hashes { for i := range hashes[addr] { hash := hashes[addr][i] - response, err := client.Provider.TransactionReceipt(ctx, caigotypes.StrToFelt(hashes[addr][i])) + f, err := starknetutils.HexToFelt(hash) + if err != nil { + txm.lggr.Errorw("invalid felt value", "hash", hash) + continue + } + response, err := client.Provider.TransactionReceipt(ctx, f) if err != nil { txm.lggr.Errorw("failed to fetch transaction status", "hash", hash, "error", err) continue } - receipt, ok := response.(caigorpc.InvokeTransactionReceipt) + receipt, ok := response.(starknetrpc.InvokeTransactionReceipt) if !ok { txm.lggr.Errorw("wrong receipt type", "type", reflect.TypeOf(response)) continue @@ -224,7 +232,7 @@ func (txm *starktxm) confirmLoop() { status := receipt.Status - if status == caigotypes.TransactionAcceptedOnL1 || status == caigotypes.TransactionAcceptedOnL2 || status == caigotypes.TransactionRejected { + if status == starknetrpc.TransactionAcceptedOnL1 || status == starknetrpc.TransactionAcceptedOnL2 || status == starknetrpc.TransactionRejected { txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status) if err := txm.txStore.Confirm(addr, hash); err != nil { txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err) @@ -261,7 +269,7 @@ func (txm *starktxm) HealthReport() map[string]error { return map[string]error{txm.Name(): txm.Healthy()} } -func (txm *starktxm) Enqueue(senderAddress, accountAddress caigotypes.Felt, tx caigotypes.FunctionCall) error { +func (txm *starktxm) Enqueue(senderAddress, accountAddress *felt.Felt, tx starknettypes.FunctionCall) error { // validate key exists for sender // use the embedded Loopp Keystore to do this; the spec and design // encourage passing nil data to the loop.Keystore.Sign as way to test diff --git a/relayer/pkg/chainlink/txm/txm_test.go b/relayer/pkg/chainlink/txm/txm_test.go index fbea54a1a..a6dbc39ca 100644 --- a/relayer/pkg/chainlink/txm/txm_test.go +++ b/relayer/pkg/chainlink/txm/txm_test.go @@ -9,10 +9,11 @@ import ( "testing" "time" - "github.com/smartcontractkit/caigo" - caigogw "github.com/smartcontractkit/caigo/gateway" - "github.com/smartcontractkit/caigo/test" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/starknet.go" + starknetgw "github.com/NethermindEth/starknet.go/gateway" + "github.com/NethermindEth/starknet.go/test" + starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" @@ -35,25 +36,26 @@ func TestIntegration_Txm(t *testing.T) { localKeys := map[string]*big.Int{} localAccounts := map[string]string{} for i := range accounts { - privKey, err := caigotypes.HexToBytes(accounts[i].PrivateKey) + privKey, err := starknettypes.HexToBytes(accounts[i].PrivateKey) require.NoError(t, err) - senderAddress := caigotypes.StrToFelt(accounts[i].PublicKey).String() - localKeys[senderAddress] = caigotypes.BytesToBig(privKey) - localAccounts[senderAddress] = accounts[i].Address + senderAddress, err := starknetutils.HexToFelt(accounts[i].PublicKey) + require.NoError(t, err) + localKeys[senderAddress.String()] = starknettypes.BytesToBig(privKey) + localAccounts[senderAddress.String()] = accounts[i].Address } // mock keystore looppKs := NewLooppKeystore(func(id string) (*big.Int, error) { - _, ok := localKeys[id] + key, ok := localKeys[id] if !ok { return nil, fmt.Errorf("key does not exist id=%s", id) } - return localKeys[id], nil + return key, nil }) ksAdapter := NewKeystoreAdapter(looppKs) lggr, observer := logger.TestObserved(t, zapcore.DebugLevel) timeout := 10 * time.Second - client, err := starknet.NewClient(caigogw.GOERLI_ID, url+"/rpc", lggr, &timeout) + client, err := starknet.NewClient(starknetgw.GOERLI_ID, url+"/rpc", lggr, &timeout) require.NoError(t, err) getClient := func() (*starknet.Client, error) { @@ -76,11 +78,21 @@ func TestIntegration_Txm(t *testing.T) { require.NoError(t, txm.Ready()) for senderAddressStr := range localKeys { - senderAddress := caigotypes.StrToFelt(senderAddressStr) + senderAddress, err := starknetutils.HexToFelt(senderAddressStr) + require.NoError(t, err) + + account, err := starknetutils.HexToFelt(localAccounts[senderAddressStr]) + require.NoError(t, err) + + contractAddress, err := starknetutils.HexToFelt("0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7") + require.NoError(t, err) + + selector := starknettypes.GetSelectorFromNameFelt("totalSupply") + for i := 0; i < n; i++ { - require.NoError(t, txm.Enqueue(senderAddress, caigotypes.StrToFelt(localAccounts[senderAddressStr]), caigotypes.FunctionCall{ - ContractAddress: caigotypes.StrToFelt("0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7"), // send to ETH token contract - EntryPointSelector: "totalSupply", + require.NoError(t, txm.Enqueue(senderAddress, account, starknettypes.FunctionCall{ + ContractAddress: contractAddress, // send to ETH token contract + EntryPointSelector: selector, })) } } @@ -135,7 +147,7 @@ func (lk *LooppKeystore) Sign(ctx context.Context, id string, hash []byte) ([]by } starkHash := new(big.Int).SetBytes(hash) - x, y, err := caigo.Curve.Sign(starkHash, k) + x, y, err := starknetgo.Curve.Sign(starkHash, k) if err != nil { return nil, fmt.Errorf("error signing data with curve: %w", err) } diff --git a/relayer/pkg/chainlink/txm/txstore.go b/relayer/pkg/chainlink/txm/txstore.go index 4c2c2b5f6..ce47b9de9 100644 --- a/relayer/pkg/chainlink/txm/txstore.go +++ b/relayer/pkg/chainlink/txm/txstore.go @@ -5,7 +5,7 @@ import ( "math/big" "sync" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" "golang.org/x/exp/maps" ) @@ -77,17 +77,17 @@ func (s *TxStore) InflightCount() int { } type ChainTxStore struct { - store map[caigotypes.Felt]*TxStore + store map[*felt.Felt]*TxStore lock sync.RWMutex } func NewChainTxStore() *ChainTxStore { return &ChainTxStore{ - store: map[caigotypes.Felt]*TxStore{}, + store: map[*felt.Felt]*TxStore{}, } } -func (c *ChainTxStore) Save(from caigotypes.Felt, nonce *big.Int, hash string) error { +func (c *ChainTxStore) Save(from *felt.Felt, nonce *big.Int, hash string) error { // use write lock for methods that modify underlying data c.lock.Lock() defer c.lock.Unlock() @@ -98,7 +98,7 @@ func (c *ChainTxStore) Save(from caigotypes.Felt, nonce *big.Int, hash string) e return c.store[from].Save(nonce, hash) } -func (c *ChainTxStore) Confirm(from caigotypes.Felt, hash string) error { +func (c *ChainTxStore) Confirm(from *felt.Felt, hash string) error { // use write lock for methods that modify underlying data c.lock.Lock() defer c.lock.Unlock() @@ -109,12 +109,12 @@ func (c *ChainTxStore) Confirm(from caigotypes.Felt, hash string) error { return c.store[from].Confirm(hash) } -func (c *ChainTxStore) GetAllInflightCount() map[caigotypes.Felt]int { +func (c *ChainTxStore) GetAllInflightCount() map[*felt.Felt]int { // use read lock for methods that read underlying data c.lock.RLock() defer c.lock.RUnlock() - list := map[caigotypes.Felt]int{} + list := map[*felt.Felt]int{} for i := range c.store { list[i] = c.store[i].InflightCount() @@ -123,12 +123,12 @@ func (c *ChainTxStore) GetAllInflightCount() map[caigotypes.Felt]int { return list } -func (c *ChainTxStore) GetAllUnconfirmed() map[caigotypes.Felt][]string { +func (c *ChainTxStore) GetAllUnconfirmed() map[*felt.Felt][]string { // use read lock for methods that read underlying data c.lock.RLock() defer c.lock.RUnlock() - list := map[caigotypes.Felt][]string{} + list := map[*felt.Felt][]string{} for i := range c.store { list[i] = c.store[i].GetUnconfirmed() @@ -136,7 +136,7 @@ func (c *ChainTxStore) GetAllUnconfirmed() map[caigotypes.Felt][]string { return list } -func (c *ChainTxStore) validate(from caigotypes.Felt) error { +func (c *ChainTxStore) validate(from *felt.Felt) error { if _, exists := c.store[from]; !exists { return fmt.Errorf("from address does not exist: %s", from) } diff --git a/relayer/pkg/chainlink/txm/txstore_test.go b/relayer/pkg/chainlink/txm/txstore_test.go index dd415952f..b87eb8243 100644 --- a/relayer/pkg/chainlink/txm/txstore_test.go +++ b/relayer/pkg/chainlink/txm/txstore_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - caigotypes "github.com/smartcontractkit/caigo/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -131,36 +131,41 @@ func TestChainTxStore(t *testing.T) { c := NewChainTxStore() + felt, err := starknetutils.BigIntToFelt(big.NewInt(0)) + require.NoError(t, err) + felt1, err := starknetutils.BigIntToFelt(big.NewInt(1)) + require.NoError(t, err) + // automatically save the from address - require.NoError(t, c.Save(caigotypes.Felt{}, big.NewInt(0), "0x0")) + require.NoError(t, c.Save(felt, big.NewInt(0), "0x0")) // reject saving for existing address and reused hash & nonce // error messages are tested within TestTxStore - assert.Error(t, c.Save(caigotypes.Felt{}, big.NewInt(0), "0x1")) - assert.Error(t, c.Save(caigotypes.Felt{}, big.NewInt(1), "0x0")) + assert.Error(t, c.Save(felt, big.NewInt(0), "0x1")) + assert.Error(t, c.Save(felt, big.NewInt(1), "0x0")) // inflight count - count, exists := c.GetAllInflightCount()[caigotypes.Felt{}] + count, exists := c.GetAllInflightCount()[felt] require.True(t, exists) assert.Equal(t, 1, count) - _, exists = c.GetAllInflightCount()[caigotypes.BigToFelt(big.NewInt(1))] + _, exists = c.GetAllInflightCount()[felt1] require.False(t, exists) // get unconfirmed list := c.GetAllUnconfirmed() assert.Equal(t, 1, len(list)) - hashes, ok := list[caigotypes.Felt{}] + hashes, ok := list[felt] assert.True(t, ok) assert.Equal(t, []string{"0x0"}, hashes) // confirm - assert.NoError(t, c.Confirm(caigotypes.Felt{}, "0x0")) - assert.ErrorContains(t, c.Confirm(caigotypes.BigToFelt(big.NewInt(1)), "0x0"), "from address does not exist") - assert.Error(t, c.Confirm(caigotypes.Felt{}, "0x1")) + assert.NoError(t, c.Confirm(felt, "0x0")) + assert.ErrorContains(t, c.Confirm(felt1, "0x0"), "from address does not exist") + assert.Error(t, c.Confirm(felt, "0x1")) list = c.GetAllUnconfirmed() assert.Equal(t, 1, len(list)) - assert.Equal(t, 0, len(list[caigotypes.Felt{}])) - count, exists = c.GetAllInflightCount()[caigotypes.Felt{}] + assert.Equal(t, 0, len(list[felt])) + count, exists = c.GetAllInflightCount()[felt] assert.True(t, exists) assert.Equal(t, 0, count) } diff --git a/relayer/pkg/starknet/client.go b/relayer/pkg/starknet/client.go index aa50ef473..7260fd3f5 100644 --- a/relayer/pkg/starknet/client.go +++ b/relayer/pkg/starknet/client.go @@ -7,10 +7,11 @@ import ( "github.com/pkg/errors" + "github.com/NethermindEth/juno/core/felt" + caigo "github.com/NethermindEth/starknet.go" + starknetrpc "github.com/NethermindEth/starknet.go/rpc" + starknetutils "github.com/NethermindEth/starknet.go/utils" ethrpc "github.com/ethereum/go-ethereum/rpc" - "github.com/smartcontractkit/caigo" - caigorpc "github.com/smartcontractkit/caigo/rpcv02" - caigotypes "github.com/smartcontractkit/caigo/types" "github.com/smartcontractkit/chainlink-common/pkg/logger" ) @@ -18,16 +19,16 @@ import ( //go:generate mockery --name Reader --output ./mocks/ type Reader interface { - CallContract(context.Context, CallOps) ([]string, error) + CallContract(context.Context, CallOps) ([]*felt.Felt, error) LatestBlockHeight(context.Context) (uint64, error) // provider interface - BlockWithTxHashes(ctx context.Context, blockID caigorpc.BlockID) (*caigorpc.Block, error) - Call(context.Context, caigotypes.FunctionCall, caigorpc.BlockID) ([]string, error) - Events(ctx context.Context, input caigorpc.EventsInput) (*caigorpc.EventsOutput, error) - TransactionByHash(context.Context, caigotypes.Felt) (caigorpc.Transaction, error) - TransactionReceipt(context.Context, caigotypes.Felt) (caigorpc.TransactionReceipt, error) - AccountNonce(context.Context, caigotypes.Felt) (*big.Int, error) + BlockWithTxHashes(ctx context.Context, blockID starknetrpc.BlockID) (*starknetrpc.Block, error) + Call(context.Context, starknetrpc.FunctionCall, starknetrpc.BlockID) ([]*felt.Felt, error) + Events(ctx context.Context, input starknetrpc.EventsInput) (*starknetrpc.EventChunk, error) + TransactionByHash(context.Context, *felt.Felt) (starknetrpc.Transaction, error) + TransactionReceipt(context.Context, *felt.Felt) (starknetrpc.TransactionReceipt, error) + AccountNonce(context.Context, *felt.Felt) (*big.Int, error) } type Writer interface { @@ -40,10 +41,10 @@ type ReaderWriter interface { var _ ReaderWriter = (*Client)(nil) -// var _ caigotypes.Provider = (*Client)(nil) +// var _ starknettypes.Provider = (*Client)(nil) type Client struct { - Provider *caigorpc.Provider + Provider *starknetrpc.Provider lggr logger.Logger defaultTimeout time.Duration } @@ -57,7 +58,7 @@ func NewClient(_chainID string, baseURL string, lggr logger.Logger, timeout *tim } client := &Client{ - Provider: caigorpc.NewProvider(c), + Provider: starknetrpc.NewProvider(c), lggr: lggr, } @@ -74,19 +75,19 @@ func NewClient(_chainID string, baseURL string, lggr logger.Logger, timeout *tim // -- Custom Wrapped Func -- -func (c *Client) CallContract(ctx context.Context, ops CallOps) (res []string, err error) { - tx := caigotypes.FunctionCall{ +func (c *Client) CallContract(ctx context.Context, ops CallOps) (data []*felt.Felt, err error) { + tx := starknetrpc.FunctionCall{ ContractAddress: ops.ContractAddress, EntryPointSelector: ops.Selector, Calldata: ops.Calldata, } - res, err = c.Call(ctx, tx, caigorpc.WithBlockTag("pending")) + res, err := c.Call(ctx, tx, starknetrpc.WithBlockTag("pending")) if err != nil { - return res, errors.Wrap(err, "error in client.CallContract") + return nil, errors.Wrap(err, "error in client.CallContract") } - return + return res, nil } func (c *Client) LatestBlockHeight(ctx context.Context) (height uint64, err error) { @@ -106,7 +107,7 @@ func (c *Client) LatestBlockHeight(ctx context.Context) (height uint64, err erro // -- caigo.Provider interface -- -func (c *Client) BlockWithTxHashes(ctx context.Context, blockID caigorpc.BlockID) (*caigorpc.Block, error) { +func (c *Client) BlockWithTxHashes(ctx context.Context, blockID starknetrpc.BlockID) (*starknetrpc.Block, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) @@ -115,12 +116,12 @@ func (c *Client) BlockWithTxHashes(ctx context.Context, blockID caigorpc.BlockID out, err := c.Provider.BlockWithTxHashes(ctx, blockID) if err != nil { - return out.(*caigorpc.Block), errors.Wrap(err, "error in client.BlockWithTxHashes") + return out.(*starknetrpc.Block), errors.Wrap(err, "error in client.BlockWithTxHashes") } - return out.(*caigorpc.Block), nil + return out.(*starknetrpc.Block), nil } -func (c *Client) Call(ctx context.Context, calls caigotypes.FunctionCall, blockHashOrTag caigorpc.BlockID) ([]string, error) { +func (c *Client) Call(ctx context.Context, calls starknetrpc.FunctionCall, blockHashOrTag starknetrpc.BlockID) ([]*felt.Felt, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) @@ -138,7 +139,7 @@ func (c *Client) Call(ctx context.Context, calls caigotypes.FunctionCall, blockH } -func (c *Client) TransactionByHash(ctx context.Context, hash caigotypes.Felt) (caigorpc.Transaction, error) { +func (c *Client) TransactionByHash(ctx context.Context, hash *felt.Felt) (starknetrpc.Transaction, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) @@ -156,7 +157,7 @@ func (c *Client) TransactionByHash(ctx context.Context, hash caigotypes.Felt) (c } -func (c *Client) TransactionReceipt(ctx context.Context, hash caigotypes.Felt) (caigorpc.TransactionReceipt, error) { +func (c *Client) TransactionReceipt(ctx context.Context, hash *felt.Felt) (starknetrpc.TransactionReceipt, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) @@ -174,7 +175,7 @@ func (c *Client) TransactionReceipt(ctx context.Context, hash caigotypes.Felt) ( } -func (c *Client) Events(ctx context.Context, input caigorpc.EventsInput) (*caigorpc.EventsOutput, error) { +func (c *Client) Events(ctx context.Context, input starknetrpc.EventsInput) (*starknetrpc.EventChunk, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) @@ -191,14 +192,17 @@ func (c *Client) Events(ctx context.Context, input caigorpc.EventsInput) (*caigo return out, nil } -func (c *Client) AccountNonce(ctx context.Context, accountAddress caigotypes.Felt) (*big.Int, error) { +func (c *Client) AccountNonce(ctx context.Context, accountAddress *felt.Felt) (*big.Int, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) defer cancel() } - sender := caigotypes.BigToFelt(big.NewInt((0))) // not actually used in account.Nonce() + sender, err := starknetutils.BigIntToFelt(big.NewInt((0))) // not actually used in account.Nonce() + if err != nil { + return nil, errors.Wrap(err, "error in client.AccountNonce") + } account, err := caigo.NewRPCAccount(sender, accountAddress, nil, c.Provider, caigo.AccountVersion1) if err != nil { return nil, errors.Wrap(err, "error in client.AccountNonce") diff --git a/relayer/pkg/starknet/client_test.go b/relayer/pkg/starknet/client_test.go index 45af3f54b..9d58e69db 100644 --- a/relayer/pkg/starknet/client_test.go +++ b/relayer/pkg/starknet/client_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/smartcontractkit/caigo/gateway" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/starknet.go/gateway" + starknettypes "github.com/NethermindEth/starknet.go/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -40,12 +40,12 @@ func TestRPCClient(t *testing.T) { switch call.Method { case "starknet_chainId": - id := caigotypes.BigToHex(caigotypes.UTF8StrToBig(chainID)) + id := starknettypes.BigToHex(starknettypes.UTF8StrToBig(chainID)) out = []byte(fmt.Sprintf(`{"result": "%s"}`, id)) case "starknet_blockNumber": out = []byte(`{"result": 1}`) default: - require.False(t, true, "unsupported RPC method") + require.False(t, true, "unsupported RPC method %s", call.Method) } _, err := w.Write(out) require.NoError(t, err) diff --git a/relayer/pkg/starknet/mocks/Reader.go b/relayer/pkg/starknet/mocks/Reader.go index 5d0bcfeb1..f5229e04a 100644 --- a/relayer/pkg/starknet/mocks/Reader.go +++ b/relayer/pkg/starknet/mocks/Reader.go @@ -6,13 +6,13 @@ import ( context "context" big "math/big" + felt "github.com/NethermindEth/juno/core/felt" + mock "github.com/stretchr/testify/mock" - rpcv02 "github.com/smartcontractkit/caigo/rpcv02" + rpc "github.com/NethermindEth/starknet.go/rpc" starknet "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" - - types "github.com/smartcontractkit/caigo/types" ) // Reader is an autogenerated mock type for the Reader type @@ -21,15 +21,15 @@ type Reader struct { } // AccountNonce provides a mock function with given fields: _a0, _a1 -func (_m *Reader) AccountNonce(_a0 context.Context, _a1 types.Felt) (*big.Int, error) { +func (_m *Reader) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*big.Int, error) { ret := _m.Called(_a0, _a1) var r0 *big.Int var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*big.Int, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) *big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *big.Int); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { @@ -37,7 +37,7 @@ func (_m *Reader) AccountNonce(_a0 context.Context, _a1 types.Felt) (*big.Int, e } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -47,23 +47,23 @@ func (_m *Reader) AccountNonce(_a0 context.Context, _a1 types.Felt) (*big.Int, e } // BlockWithTxHashes provides a mock function with given fields: ctx, blockID -func (_m *Reader) BlockWithTxHashes(ctx context.Context, blockID rpcv02.BlockID) (*rpcv02.Block, error) { +func (_m *Reader) BlockWithTxHashes(ctx context.Context, blockID rpc.BlockID) (*rpc.Block, error) { ret := _m.Called(ctx, blockID) - var r0 *rpcv02.Block + var r0 *rpc.Block var r1 error - if rf, ok := ret.Get(0).(func(context.Context, rpcv02.BlockID) (*rpcv02.Block, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.BlockID) (*rpc.Block, error)); ok { return rf(ctx, blockID) } - if rf, ok := ret.Get(0).(func(context.Context, rpcv02.BlockID) *rpcv02.Block); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.BlockID) *rpc.Block); ok { r0 = rf(ctx, blockID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*rpcv02.Block) + r0 = ret.Get(0).(*rpc.Block) } } - if rf, ok := ret.Get(1).(func(context.Context, rpcv02.BlockID) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, rpc.BlockID) error); ok { r1 = rf(ctx, blockID) } else { r1 = ret.Error(1) @@ -73,23 +73,23 @@ func (_m *Reader) BlockWithTxHashes(ctx context.Context, blockID rpcv02.BlockID) } // Call provides a mock function with given fields: _a0, _a1, _a2 -func (_m *Reader) Call(_a0 context.Context, _a1 types.FunctionCall, _a2 rpcv02.BlockID) ([]string, error) { +func (_m *Reader) Call(_a0 context.Context, _a1 rpc.FunctionCall, _a2 rpc.BlockID) ([]*felt.Felt, error) { ret := _m.Called(_a0, _a1, _a2) - var r0 []string + var r0 []*felt.Felt var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.FunctionCall, rpcv02.BlockID) ([]string, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.FunctionCall, rpc.BlockID) ([]*felt.Felt, error)); ok { return rf(_a0, _a1, _a2) } - if rf, ok := ret.Get(0).(func(context.Context, types.FunctionCall, rpcv02.BlockID) []string); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.FunctionCall, rpc.BlockID) []*felt.Felt); ok { r0 = rf(_a0, _a1, _a2) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) + r0 = ret.Get(0).([]*felt.Felt) } } - if rf, ok := ret.Get(1).(func(context.Context, types.FunctionCall, rpcv02.BlockID) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, rpc.FunctionCall, rpc.BlockID) error); ok { r1 = rf(_a0, _a1, _a2) } else { r1 = ret.Error(1) @@ -99,19 +99,19 @@ func (_m *Reader) Call(_a0 context.Context, _a1 types.FunctionCall, _a2 rpcv02.B } // CallContract provides a mock function with given fields: _a0, _a1 -func (_m *Reader) CallContract(_a0 context.Context, _a1 starknet.CallOps) ([]string, error) { +func (_m *Reader) CallContract(_a0 context.Context, _a1 starknet.CallOps) ([]*felt.Felt, error) { ret := _m.Called(_a0, _a1) - var r0 []string + var r0 []*felt.Felt var r1 error - if rf, ok := ret.Get(0).(func(context.Context, starknet.CallOps) ([]string, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, starknet.CallOps) ([]*felt.Felt, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, starknet.CallOps) []string); ok { + if rf, ok := ret.Get(0).(func(context.Context, starknet.CallOps) []*felt.Felt); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) + r0 = ret.Get(0).([]*felt.Felt) } } @@ -125,23 +125,23 @@ func (_m *Reader) CallContract(_a0 context.Context, _a1 starknet.CallOps) ([]str } // Events provides a mock function with given fields: ctx, input -func (_m *Reader) Events(ctx context.Context, input rpcv02.EventsInput) (*rpcv02.EventsOutput, error) { +func (_m *Reader) Events(ctx context.Context, input rpc.EventsInput) (*rpc.EventChunk, error) { ret := _m.Called(ctx, input) - var r0 *rpcv02.EventsOutput + var r0 *rpc.EventChunk var r1 error - if rf, ok := ret.Get(0).(func(context.Context, rpcv02.EventsInput) (*rpcv02.EventsOutput, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.EventsInput) (*rpc.EventChunk, error)); ok { return rf(ctx, input) } - if rf, ok := ret.Get(0).(func(context.Context, rpcv02.EventsInput) *rpcv02.EventsOutput); ok { + if rf, ok := ret.Get(0).(func(context.Context, rpc.EventsInput) *rpc.EventChunk); ok { r0 = rf(ctx, input) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*rpcv02.EventsOutput) + r0 = ret.Get(0).(*rpc.EventChunk) } } - if rf, ok := ret.Get(1).(func(context.Context, rpcv02.EventsInput) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, rpc.EventsInput) error); ok { r1 = rf(ctx, input) } else { r1 = ret.Error(1) @@ -175,23 +175,23 @@ func (_m *Reader) LatestBlockHeight(_a0 context.Context) (uint64, error) { } // TransactionByHash provides a mock function with given fields: _a0, _a1 -func (_m *Reader) TransactionByHash(_a0 context.Context, _a1 types.Felt) (rpcv02.Transaction, error) { +func (_m *Reader) TransactionByHash(_a0 context.Context, _a1 *felt.Felt) (rpc.Transaction, error) { ret := _m.Called(_a0, _a1) - var r0 rpcv02.Transaction + var r0 rpc.Transaction var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (rpcv02.Transaction, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (rpc.Transaction, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) rpcv02.Transaction); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) rpc.Transaction); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(rpcv02.Transaction) + r0 = ret.Get(0).(rpc.Transaction) } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -201,23 +201,23 @@ func (_m *Reader) TransactionByHash(_a0 context.Context, _a1 types.Felt) (rpcv02 } // TransactionReceipt provides a mock function with given fields: _a0, _a1 -func (_m *Reader) TransactionReceipt(_a0 context.Context, _a1 types.Felt) (rpcv02.TransactionReceipt, error) { +func (_m *Reader) TransactionReceipt(_a0 context.Context, _a1 *felt.Felt) (rpc.TransactionReceipt, error) { ret := _m.Called(_a0, _a1) - var r0 rpcv02.TransactionReceipt + var r0 rpc.TransactionReceipt var r1 error - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) (rpcv02.TransactionReceipt, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (rpc.TransactionReceipt, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, types.Felt) rpcv02.TransactionReceipt); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) rpc.TransactionReceipt); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(rpcv02.TransactionReceipt) + r0 = ret.Get(0).(rpc.TransactionReceipt) } } - if rf, ok := ret.Get(1).(func(context.Context, types.Felt) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *felt.Felt) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) diff --git a/relayer/pkg/starknet/types.go b/relayer/pkg/starknet/types.go index 8c949c307..d79603af6 100644 --- a/relayer/pkg/starknet/types.go +++ b/relayer/pkg/starknet/types.go @@ -1,11 +1,11 @@ package starknet import ( - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" ) type CallOps struct { - ContractAddress caigotypes.Felt - Selector string - Calldata []string + ContractAddress *felt.Felt + Selector *felt.Felt + Calldata []*felt.Felt } diff --git a/relayer/pkg/starknet/utils.go b/relayer/pkg/starknet/utils.go index 8cc1c2ecc..0a45ad6b3 100644 --- a/relayer/pkg/starknet/utils.go +++ b/relayer/pkg/starknet/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "math/big" - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" "github.com/pkg/errors" "golang.org/x/exp/constraints" @@ -88,41 +88,14 @@ func DecodeFelts(felts []*big.Int) ([]byte, error) { return data, nil } -func FeltToUnsignedBig(felt caigotypes.Felt) (num *big.Int, err error) { - num = felt.Big() - if caigotypes.MaxFelt.Big().Cmp(num) == -1 { - return nil, fmt.Errorf("felt value is too large: %s", num) - } - // will always return a non-negative value because it uses Bytes() behind the scenes - return num, nil -} - -func HexToUnsignedBig(str string) (num *big.Int, err error) { - felt := caigotypes.StrToFelt(str) - return FeltToUnsignedBig(felt) -} - -func FeltsToBig(in []caigotypes.Felt) (out []*big.Int) { +func FeltsToBig(in []*felt.Felt) (out []*big.Int) { for _, f := range in { - out = append(out, f.Big()) + out = append(out, f.BigInt(big.NewInt(0))) } return out } -// StringsToFelt maps felts from 'string' (hex) representation to 'caigo.Felt' representation -func StringsToFelt(in []string) (out []caigotypes.Felt, _ error) { - if in == nil { - return nil, errors.New("invalid: input value") - } - - for _, f := range in { - out = append(out, caigotypes.StrToFelt(f)) - } - - return out, nil -} - /* Testing utils - do not use (XXX) outside testing context */ func XXXMustHexDecodeString(data string) []byte { diff --git a/relayer/pkg/starknet/utils_test.go b/relayer/pkg/starknet/utils_test.go index 15d11ff8f..69ff2ce86 100644 --- a/relayer/pkg/starknet/utils_test.go +++ b/relayer/pkg/starknet/utils_test.go @@ -7,8 +7,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - caigotypes "github.com/smartcontractkit/caigo/types" ) var ( @@ -40,28 +38,6 @@ func TestPadBytes(t *testing.T) { } } -func TestFeltToUnsignedBig(t *testing.T) { - - negativeBig := caigotypes.BigToFelt(big.NewInt(-100)) - // negative felts are not supported - num, err := FeltToUnsignedBig(negativeBig) - assert.NoError(t, err) - assert.Equal(t, num, big.NewInt(100)) - - positiveBig := caigotypes.BigToFelt(big.NewInt(100)) - num, err = FeltToUnsignedBig(positiveBig) - assert.NoError(t, err) - assert.Equal(t, num, big.NewInt(100)) - -} - -func TestHexToUnSignedBig(t *testing.T) { - // Positive value (99) - answer, err := HexToUnsignedBig("0x63") - assert.NoError(t, err) - assert.Equal(t, big.NewInt(99), answer) -} - func TestDecodeFeltFails(t *testing.T) { val, _ := new(big.Int).SetString("1231927389172389172983712738127391273891", 10) From 0f1917e6f1b763be2b57868ebb71b5f2a4141d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 9 Jan 2024 10:50:04 +0900 Subject: [PATCH 02/11] nix: Update flake dependencies --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 99fbfe931..d21fabcde 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "type": "github" }, "original": { @@ -38,11 +38,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697456312, - "narHash": "sha256-roiSnrqb5r+ehnKCauPLugoU8S36KgmWraHgRqVYndo=", + "lastModified": 1704538339, + "narHash": "sha256-1734d3mQuux9ySvwf6axRWZRBhtcZA9Q8eftD6EZg6U=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ca012a02bf8327be9e488546faecae5e05d7d749", + "rev": "46ae0210ce163b3cba6c7da08840c1d63de9c701", "type": "github" }, "original": { @@ -81,11 +81,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1692238117, - "narHash": "sha256-gOoxig/GBuGOYWqE3+7OMrgPVduxjjsbo4qikRb1h3s=", + "lastModified": 1704680242, + "narHash": "sha256-5bD6iSPDgVTLly2gy2oJVwzuyuFZOz2p4qt8c8UoYIE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "3e0e4ec062706ebba759795ad18ad72ad69d41f3", + "rev": "2037779e018ebc2d381001a891e2a793fce7a74f", "type": "github" }, "original": { From 640e9bf50630b94e73296dadd6c953eb3ea34886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 10 Jan 2024 16:34:57 +0900 Subject: [PATCH 03/11] Update for sdk 0.6.1 (git revision) --- integration-tests/common/common.go | 4 +- integration-tests/common/test_common.go | 13 ++- integration-tests/go.mod | 10 ++- integration-tests/go.sum | 26 +++++- monitoring/go.mod | 9 ++- monitoring/go.sum | 59 +++++++++++++- monitoring/pkg/monitoring/source_envelope.go | 15 +--- .../pkg/monitoring/source_envelope_test.go | 17 +--- monitoring/pkg/monitoring/source_proxy.go | 12 +-- monitoring/pkg/monitoring/source_txresults.go | 12 +-- ops/go.mod | 8 +- ops/go.sum | 51 +++++++++++- relayer/go.mod | 6 +- relayer/go.sum | 43 +++++++++- relayer/pkg/chainlink/ocr2/client.go | 14 ++-- relayer/pkg/chainlink/ocr2/client_test.go | 16 ++-- relayer/pkg/chainlink/ocr2/config_digester.go | 4 +- .../chainlink/ocr2/contract_transmitter.go | 6 +- relayer/pkg/chainlink/ocr2/events_test.go | 5 +- .../pkg/chainlink/ocr2/medianreport/report.go | 25 ++---- relayer/pkg/chainlink/txm/keystore.go | 4 +- .../txm/mocks/nonce_manager_client.go | 12 ++- relayer/pkg/chainlink/txm/nonce.go | 20 ++--- relayer/pkg/chainlink/txm/nonce_test.go | 17 ++-- relayer/pkg/chainlink/txm/txm.go | 79 ++++++++++++------- relayer/pkg/chainlink/txm/txm_test.go | 21 +++-- relayer/pkg/chainlink/txm/txstore.go | 29 ++++--- relayer/pkg/chainlink/txm/txstore_test.go | 65 ++++++++------- relayer/pkg/starknet/client.go | 18 ++--- relayer/pkg/starknet/client_test.go | 7 +- relayer/pkg/starknet/mocks/Reader.go | 12 ++- 31 files changed, 379 insertions(+), 260 deletions(-) diff --git a/integration-tests/common/common.go b/integration-tests/common/common.go index b4e00cf32..477574ece 100644 --- a/integration-tests/common/common.go +++ b/integration-tests/common/common.go @@ -13,8 +13,6 @@ import ( "github.com/rs/zerolog/log" "gopkg.in/guregu/null.v4" - "github.com/NethermindEth/starknet.go/gateway" - "github.com/smartcontractkit/chainlink-starknet/ops/devnet" "github.com/smartcontractkit/chainlink-testing-framework/k8s/environment" "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/alias" @@ -30,7 +28,7 @@ var ( serviceKeyL2 = "starknet-dev" serviceKeyChainlink = "chainlink" chainName = "starknet" - chainId = gateway.GOERLI_ID + chainId = "SN_GOERLI" ) type Common struct { diff --git a/integration-tests/common/test_common.go b/integration-tests/common/test_common.go index a0d5175b7..59534111d 100644 --- a/integration-tests/common/test_common.go +++ b/integration-tests/common/test_common.go @@ -11,8 +11,7 @@ import ( "time" "github.com/NethermindEth/juno/core/felt" - caigo "github.com/NethermindEth/starknet.go" - starknettypes "github.com/NethermindEth/starknet.go/types" + curve "github.com/NethermindEth/starknet.go/curve" starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -53,7 +52,7 @@ func init() { } func pubKeyToDevnetAccount(pubkey starkkey.PublicKey) ([]byte, error) { - xHash, err := caigo.Curve.ComputeHashOnElements([]*big.Int{pubkey.X}) + xHash, err := curve.Curve.ComputeHashOnElements([]*big.Int{pubkey.X}) if err != nil { return nil, err } @@ -64,7 +63,7 @@ func pubKeyToDevnetAccount(pubkey starkkey.PublicKey) ([]byte, error) { ops.DevnetClassHash, xHash, } - hash, err := caigo.Curve.ComputeHashOnElements(elements) + hash, err := curve.Curve.ComputeHashOnElements(elements) if err != nil { return nil, err } @@ -278,13 +277,13 @@ func (testState *Test) ValidateRounds(rounds int, isSoak bool) error { } resLINK, errLINK := testState.Starknet.CallContract(ctx, starknet.CallOps{ ContractAddress: linkContractAddress, - Selector: starknettypes.GetSelectorFromNameFelt("balance_of"), + Selector: starknetutils.GetSelectorFromNameFelt("balance_of"), Calldata: []*felt.Felt{contractAddress}, }) require.NoError(testState.T, errLINK, "Reader balance from LINK contract should not fail", "err", errLINK) resAgg, errAgg := testState.Starknet.CallContract(ctx, starknet.CallOps{ ContractAddress: contractAddress, - Selector: starknettypes.GetSelectorFromNameFelt("link_available_for_payment"), + Selector: starknetutils.GetSelectorFromNameFelt("link_available_for_payment"), }) require.NoError(testState.T, errAgg, "link_available_for_payment should not fail", "err", errAgg) balLINK := resLINK[0].BigInt(big.NewInt(0)) @@ -378,7 +377,7 @@ func (testState *Test) ValidateRounds(rounds int, isSoak bool) error { } roundDataRaw, err := testState.Starknet.CallContract(ctx, starknet.CallOps{ ContractAddress: proxyAddress, - Selector: starknettypes.GetSelectorFromNameFelt("latest_round_data"), + Selector: starknetutils.GetSelectorFromNameFelt("latest_round_data"), }) if !isSoak { require.NoError(testState.T, err, "Reading round data from proxy should not fail") diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 5ec709e49..79136df08 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -3,12 +3,11 @@ module github.com/smartcontractkit/chainlink-starknet/integration-tests go 1.21.4 require ( + github.com/NethermindEth/juno v0.3.1 + github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 github.com/google/uuid v1.4.0 github.com/lib/pq v1.10.9 - github.com/NethermindEth/juno v0.3.1 - github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 github.com/rs/zerolog v1.30.0 - github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 github.com/smartcontractkit/chainlink-starknet/ops v0.0.0-20231117204155-b253a2f56664 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.1-beta-test.0.20231215215547-68a402815b84 @@ -23,7 +22,6 @@ require ( require ( github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/consensys/gnark-crypto v0.11.0 // indirect - github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect github.com/test-go/testify v1.1.4 // indirect ) @@ -88,6 +86,7 @@ require ( github.com/cometbft/cometbft v0.37.2 // indirect github.com/cometbft/cometbft-db v0.8.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect + github.com/consensys/bavard v0.1.13 // indirect github.com/containerd/containerd v1.7.7 // indirect github.com/containerd/continuity v0.4.3 // indirect github.com/containerd/log v0.1.0 // indirect @@ -271,6 +270,7 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/spdystream v0.2.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect @@ -329,6 +329,7 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/slack-go/slack v0.12.2 // indirect + github.com/smartcontractkit/caigo v0.0.0-20230621050857-b29a4ca8c704 // indirect github.com/smartcontractkit/chainlink-automation v1.0.1 // indirect github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20231215215216-51cb121f7f33 // indirect github.com/smartcontractkit/chainlink-data-streams v0.0.0-20231204152908-a6e3fe8ff2a1 // indirect @@ -437,6 +438,7 @@ require ( k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect nhooyr.io/websocket v1.8.7 // indirect pgregory.net/rapid v0.5.5 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/controller-runtime v0.13.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kustomize/api v0.12.1 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 10f17e971..332500cb5 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -129,8 +129,8 @@ github.com/Microsoft/hcsshim v0.11.1 h1:hJ3s7GbWlGK4YVV92sO88BQSyF4ZLVy7/awqOlPx github.com/Microsoft/hcsshim v0.11.1/go.mod h1:nFJmaO4Zr5Y7eADdFOpYswDDlNVbvcIJJNJLECr5JQg= github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA= github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q= -github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 h1:SAE7oDXo82lT+arBtg6sozPMt9bNSkXY1A2TxlCGRw4= -github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3/go.mod h1:4fchLnLzJuwl1bnNUR+iBjKYN11afzJCdBcGZKIuFeU= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 h1:9SBvy3eZut1X+wEyAFqfb7ADGj8IQw7ZnlkMwz0YOTY= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -271,12 +271,28 @@ github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+ github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06 h1:T+Np/xtzIjYM/P5NAw0e2Rf1FGvzDau1h54MKvx8G7w= +github.com/cockroachdb/pebble v0.0.0-20230906160148-46873a6a7a06/go.mod h1:bynZ3gvVyhlvjLI7PT6dmZ7g76xzJ7HpxfjgkzCGz6s= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= +github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.8.0 h1:vUMDaH3ApkX8m0KZvOFFy9b5DZHBAjsnEuo9AKVZpjo= github.com/cometbft/cometbft-db v0.8.0/go.mod h1:6ASCP4pfhmrCBpfk01/9E1SI29nD3HfVHrY4PG8x5c0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e/mYVRak= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks= +github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= +github.com/containerd/containerd v1.7.7 h1:QOC2K4A42RQpcrZyptP6z9EJZnlHfHJUfZrAAHe15q4= +github.com/containerd/containerd v1.7.7/go.mod h1:3c4XZv6VeT9qgf9GMTxNTMFxGJrGpI2vz1yk4ye+YY8= +github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= +github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= @@ -709,6 +725,7 @@ github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -1093,6 +1110,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= @@ -2179,6 +2199,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/controller-runtime v0.13.0 h1:iqa5RNciy7ADWnIc8QxCbOX5FEKVR3uxVxKHRMc2WIQ= sigs.k8s.io/controller-runtime v0.13.0/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/monitoring/go.mod b/monitoring/go.mod index df3e77955..6baec3c2e 100644 --- a/monitoring/go.mod +++ b/monitoring/go.mod @@ -5,9 +5,9 @@ go 1.21 toolchain go1.21.1 require ( - github.com/prometheus/client_golang v1.17.0 github.com/NethermindEth/juno v0.3.1 - github.com/NethermindEth/starknet.go v0.4.2-0.20230804102546-d30334cf21f3 + github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 + github.com/prometheus/client_golang v1.17.0 github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 github.com/smartcontractkit/chainlink-starknet/relayer v0.0.0-20230508053614-9f2fd5fd4ff1 github.com/smartcontractkit/libocr v0.0.0-20230925165524-ffa38fe11ef8 @@ -24,6 +24,7 @@ require ( github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/confluentinc/confluent-kafka-go/v2 v2.3.0 // indirect + github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.11.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect @@ -33,14 +34,12 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.5.0 // indirect github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 // indirect - github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // 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/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.3.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0 // indirect @@ -56,6 +55,7 @@ require ( github.com/mattn/go-isatty v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9 // indirect github.com/oklog/run v1.0.0 // indirect @@ -94,6 +94,7 @@ require ( 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 + rsc.io/tmplfunc v0.0.3 // indirect ) replace ( diff --git a/monitoring/go.sum b/monitoring/go.sum index 18e5c61f2..6225ec13d 100644 --- a/monitoring/go.sum +++ b/monitoring/go.sum @@ -41,10 +41,21 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg6 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/hcsshim v0.9.4 h1:mnUj0ivWy6UzbB1uLFqKR6F+ZyiDc7j4iGgHTpO+5+I= +github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= +github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA= +github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 h1:9SBvy3eZut1X+wEyAFqfb7ADGj8IQw7ZnlkMwz0YOTY= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 h1:SDlJ7bAm4ewvrmZtR0DaiYbQGdKPeaaIm7bM+qRhFeU= @@ -69,7 +80,21 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14 h1:4spJmU4jzTXRbaQV9yrGHBDL/nTgaebjbW4Qidtkz0w= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= +github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/confluentinc/confluent-kafka-go/v2 v2.3.0 h1:icCHutJouWlQREayFwCc7lxDAhws08td+W3/gdqgZts= +github.com/confluentinc/confluent-kafka-go/v2 v2.3.0/go.mod h1:/VTy8iEpe6mD9pkCH5BhijlUl8ulUXymKv1Qig5Rgb8= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks= +github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= +github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA= +github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO4JTrUzo6IA= +github.com/containerd/containerd v1.6.8 h1:h4dOFDwzHmqFEP754PgfgTeVXFnLiRc6kiqC7tplDJs= +github.com/containerd/containerd v1.6.8/go.mod h1:By6p5KqPK0/7/CgO/A6t/Gz+CUYUu2zf1hUaaymVXB0= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -103,6 +128,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= +github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= @@ -138,6 +165,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -168,12 +197,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -184,6 +210,7 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -231,6 +258,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a h1:dHCfT5W7gghzPtfsW488uPmEOm85wewI+ypUwibyTdU= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/linkedin/goavro/v2 v2.9.7/go.mod h1:UgQUb2N/pmueQYH9bfqFioWxzYCZXSfF8Jw03O5sjqA= github.com/linkedin/goavro/v2 v2.12.0 h1:rIQQSj8jdAUlKQh6DttK8wCRv4t4QO09g1C4aBWXslg= github.com/linkedin/goavro/v2 v2.12.0/go.mod h1:KXx+erlq+RPlGSPmLF7xGo6SAbh8sCQ53x064+ioxhk= @@ -252,6 +282,9 @@ github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/moby/sys/mount v0.3.3 h1:fX1SVkXFJ47XWDoeFW4Sq7PdQJnV2QIDZAqjNqgEjUs= github.com/moby/sys/mount v0.3.3/go.mod h1:PBaEorSNTLG5t/+4EgukEQVlAvVEc6ZjTySwKdqp5K0= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= @@ -300,6 +333,18 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 h1:WCcC4vZDS1tYNxjWlwRJZQy28r8CM github.com/santhosh-tekuri/jsonschema/v5 v5.2.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= +github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= +github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= +github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= +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= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -317,12 +362,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= +github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= +github.com/testcontainers/testcontainers-go v0.14.0 h1:h0D5GaYG9mhOWr2qHdEKDXpkce/VlvaYOCzTRi6UBi8= +github.com/testcontainers/testcontainers-go v0.14.0/go.mod h1:hSRGJ1G8Q5Bw2gXgPulJOLlEBaYJHeBSOkQM5JLG+JQ= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A= github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -667,3 +718,5 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/monitoring/pkg/monitoring/source_envelope.go b/monitoring/pkg/monitoring/source_envelope.go index d8fca6f2a..323bdf788 100644 --- a/monitoring/pkg/monitoring/source_envelope.go +++ b/monitoring/pkg/monitoring/source_envelope.go @@ -6,19 +6,8 @@ import ( "math/big" "sync" -<<<<<<< HEAD - caigotypes "github.com/smartcontractkit/caigo/types" -||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) - caigotypes "github.com/smartcontractkit/caigo/types" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" - relayUtils "github.com/smartcontractkit/chainlink-relay/pkg/utils" -======= - starknettypes "github.com/NethermindEth/starknet.go/types" - starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/NethermindEth/juno/core/felt" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" - relayUtils "github.com/smartcontractkit/chainlink-relay/pkg/utils" ->>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/libocr/offchainreporting2/types" "go.uber.org/multierr" @@ -179,7 +168,7 @@ var zeroBigInt = big.NewInt(0) func (s *envelopeSource) fetchLinkBalance(ctx context.Context, linkTokenAddress, contractAddress *felt.Felt) (*big.Int, error) { results, err := s.ocr2Reader.BaseReader().CallContract(ctx, starknet.CallOps{ ContractAddress: linkTokenAddress, - Selector: starknettypes.GetSelectorFromNameFelt("balanceOf"), + Selector: starknetutils.GetSelectorFromNameFelt("balanceOf"), Calldata: []*felt.Felt{contractAddress}, }) if err != nil { diff --git a/monitoring/pkg/monitoring/source_envelope_test.go b/monitoring/pkg/monitoring/source_envelope_test.go index 188551025..0833f37c5 100644 --- a/monitoring/pkg/monitoring/source_envelope_test.go +++ b/monitoring/pkg/monitoring/source_envelope_test.go @@ -6,18 +6,7 @@ import ( "testing" "time" -<<<<<<< HEAD - "github.com/smartcontractkit/caigo" - caigotypes "github.com/smartcontractkit/caigo/types" -||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) - "github.com/smartcontractkit/caigo" - caigotypes "github.com/smartcontractkit/caigo/types" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" -======= - "github.com/NethermindEth/starknet.go" - starknettypes "github.com/NethermindEth/starknet.go/types" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" ->>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/libocr/offchainreporting2/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -76,7 +65,7 @@ func TestEnvelopeSource(t *testing.T) { ContractAddress: chainConfig.GetLinkTokenAddress(), Selector: "balanceOf", Calldata: []string{ - starknetgo.HexToBN(feedConfig.ContractAddress).String(), + starknetutils.HexToBN(feedConfig.ContractAddress).String(), }, }, ).Return(starknetReaderCallContractBalanceOfResponse, nil) @@ -104,7 +93,7 @@ var ( { RoundId: 0xf5b, LatestAnswer: bigIntFromString("-900000000"), - Transmitter: starknettypes.StrToFelt("634447934223750826572902672583054702307815157196919304685470566142330202833"), + Transmitter: starknetutils.StrToFelt("634447934223750826572902672583054702307815157196919304685470566142330202833"), LatestTimestamp: time.Date(2022, time.September, 27, 18, 51, 0, 0, time.Local), Observers: []uint8{0x1, 0x2, 0x3, 0x4}, ObservationsLen: 0x4, diff --git a/monitoring/pkg/monitoring/source_proxy.go b/monitoring/pkg/monitoring/source_proxy.go index a54a03543..9b3d15657 100644 --- a/monitoring/pkg/monitoring/source_proxy.go +++ b/monitoring/pkg/monitoring/source_proxy.go @@ -5,18 +5,10 @@ import ( "fmt" "math/big" -<<<<<<< HEAD - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" + starknetutils "github.com/NethermindEth/starknet.go/utils" relayMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring" -||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) - caigotypes "github.com/smartcontractkit/caigo/types" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" -======= - starknetutils "github.com/NethermindEth/starknet.go/utils" - "github.com/NethermindEth/juno/core/felt" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" ->>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" ) diff --git a/monitoring/pkg/monitoring/source_txresults.go b/monitoring/pkg/monitoring/source_txresults.go index d22732ab6..19ca6a885 100644 --- a/monitoring/pkg/monitoring/source_txresults.go +++ b/monitoring/pkg/monitoring/source_txresults.go @@ -5,18 +5,10 @@ import ( "fmt" "sync" -<<<<<<< HEAD - caigotypes "github.com/smartcontractkit/caigo/types" + "github.com/NethermindEth/juno/core/felt" + starknetutils "github.com/NethermindEth/starknet.go/utils" relayMonitoring "github.com/smartcontractkit/chainlink-common/pkg/monitoring" -||||||| parent of 5c692ac2 (Use latest upstream sdk: starknet.go) - caigotypes "github.com/smartcontractkit/caigo/types" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" -======= - starknetutils "github.com/NethermindEth/starknet.go/utils" - "github.com/NethermindEth/juno/core/felt" - relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring" ->>>>>>> 5c692ac2 (Use latest upstream sdk: starknet.go) "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2" ) diff --git a/ops/go.mod b/ops/go.mod index 9f4aedd2d..68ef86922 100644 --- a/ops/go.mod +++ b/ops/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.21.1 require ( - github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 + github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 github.com/go-resty/resty/v2 v2.7.0 github.com/rs/zerolog v1.30.0 github.com/smartcontractkit/chainlink-env v0.3.29 @@ -34,6 +34,8 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect github.com/chaos-mesh/chaos-mesh/api/v1alpha1 v0.0.0-20220226050744-799408773657 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.11.0 // indirect github.com/containerd/containerd v1.7.3 // indirect github.com/cpuguy83/dockercfg v0.3.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -68,7 +70,6 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.3.1 // indirect @@ -95,6 +96,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/moby/patternmatcher v0.5.0 // indirect github.com/moby/spdystream v0.2.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect @@ -127,6 +129,7 @@ require ( github.com/spf13/cobra v1.6.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.8.4 // indirect + github.com/test-go/testify v1.1.4 // indirect github.com/testcontainers/testcontainers-go v0.23.0 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -177,6 +180,7 @@ require ( k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect k8s.io/kubectl v0.25.11 // indirect k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/controller-runtime v0.13.0 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/kustomize/api v0.12.1 // indirect diff --git a/ops/go.sum b/ops/go.sum index 6edbd6525..c7d907519 100644 --- a/ops/go.sum +++ b/ops/go.sum @@ -50,6 +50,14 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/Microsoft/hcsshim v0.10.0-rc.8 h1:YSZVvlIIDD1UxQpJp0h+dnpLUw+TrY0cx8obKsp3bek= +github.com/Microsoft/hcsshim v0.10.0-rc.8/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM= +github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA= +github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 h1:9SBvy3eZut1X+wEyAFqfb7ADGj8IQw7ZnlkMwz0YOTY= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY= github.com/VictoriaMetrics/fastcache v1.10.0/go.mod h1:tjiYeEfYXCqacuvYw/7UoDIeJaNxq6132xHICNP77w8= @@ -66,6 +74,8 @@ github.com/aws/jsii-runtime-go v1.75.0 h1:NhpUfyiL7/wsRuUekFsz8FFBCYLfPD/l61kKg9 github.com/aws/jsii-runtime-go v1.75.0/go.mod h1:TKCyrtM0pygEPo4rDZzbMSDNCDNTSYSN6/mGyHI6O3I= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= +github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 h1:SDlJ7bAm4ewvrmZtR0DaiYbQGdKPeaaIm7bM+qRhFeU= @@ -101,7 +111,17 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14 h1:4spJmU4jzTXRbaQV9yrGHBDL/nTgaebjbW4Qidtkz0w= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= +github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks= +github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= +github.com/containerd/containerd v1.7.3 h1:cKwYKkP1eTj54bP3wCdXXBymmKRQMrWjkLSWZZJDa8o= +github.com/containerd/containerd v1.7.3/go.mod h1:32FOM4/O0RkNg7AjQj3hDzN9cUGtu+HMvaKUNiqCZB8= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= @@ -160,6 +180,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM45eo= github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= +github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= +github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.19.0 h1:BcCH3CN5tXt5aML+gwmbFwVptLLQA+eT866fCO9wVOM= @@ -214,6 +236,8 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -248,13 +272,10 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 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/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -272,6 +293,7 @@ github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8/go.mod h1:Jh3hGz2jkYa github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -336,6 +358,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a h1:dHCfT5W7gghzPtfsW488uPmEOm85wewI+ypUwibyTdU= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -361,6 +386,9 @@ github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/moby/patternmatcher v0.5.0 h1:YCZgJOeULcxLw1Q+sVR636pmS7sPEn1Qo2iAN6M7DBo= github.com/moby/patternmatcher v0.5.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= @@ -439,6 +467,10 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= github.com/smartcontractkit/chainlink-env v0.3.29 h1:hcIw/BeuB0wKiiE3umAUNBZzWkHO24XF3OW9xSrlMbI= github.com/smartcontractkit/chainlink-env v0.3.29/go.mod h1:9c0Czq4a6wZKY20BcoAlK29DnejQIiLo/MwKYtSFnHk= github.com/smartcontractkit/chainlink-testing-framework v1.19.1 h1:MdGM5jIrBi858Cv7qzfl1Qon93YW8InohAlDQqFoIb4= @@ -472,7 +504,18 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d h1:vfofYNRScrDdvS342BElfbETmL1Aiz3i2t0zfRj16Hs= +github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= +github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= +github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= +github.com/testcontainers/testcontainers-go v0.23.0 h1:ERYTSikX01QczBLPZpqsETTBO7lInqEP349phDOVJVs= +github.com/testcontainers/testcontainers-go v0.23.0/go.mod h1:3gzuZfb7T9qfcH2pHpV4RLlWrPjeWNQah6XlYQ32c4I= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -886,6 +929,8 @@ k8s.io/utils v0.0.0-20230711102312-30195339c3c7/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/controller-runtime v0.13.0 h1:iqa5RNciy7ADWnIc8QxCbOX5FEKVR3uxVxKHRMc2WIQ= sigs.k8s.io/controller-runtime v0.13.0/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl+PgtYNI6WNTI= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/relayer/go.mod b/relayer/go.mod index 15166b753..20c429503 100644 --- a/relayer/go.mod +++ b/relayer/go.mod @@ -6,7 +6,7 @@ toolchain go1.21.1 require ( github.com/NethermindEth/juno v0.3.1 - github.com/NethermindEth/starknet.go v0.4.2-0.20230830055456-308b763a11d3 + github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 github.com/ethereum/go-ethereum v1.11.5 github.com/hashicorp/go-plugin v1.5.2 github.com/pelletier/go-toml/v2 v2.1.0 @@ -27,6 +27,7 @@ require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.11.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect @@ -41,7 +42,6 @@ require ( github.com/go-stack/stack v1.8.1 // indirect github.com/gogo/protobuf v1.3.3 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-querystring v1.1.0 // indirect github.com/google/uuid v1.3.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0 // indirect @@ -55,6 +55,7 @@ require ( github.com/mattn/go-isatty v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9 // indirect github.com/oklog/run v1.0.0 // indirect @@ -88,6 +89,7 @@ require ( 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 + rsc.io/tmplfunc v0.0.3 // indirect ) replace ( diff --git a/relayer/go.sum b/relayer/go.sum index a33e2c444..088f38132 100644 --- a/relayer/go.sum +++ b/relayer/go.sum @@ -39,6 +39,13 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/NethermindEth/juno v0.3.1 h1:AW72LiAm9gqUeCVJWvepnZcTnpU4Vkl0KzPMxS+42FA= +github.com/NethermindEth/juno v0.3.1/go.mod h1:SGbTpgGaCsxhFsKOid7Ylnz//WZ8swtILk+NbHGsk/Q= +github.com/NethermindEth/starknet.go v0.6.0 h1:nEEgn9wmLS3jj8W31RAnfyzHkZtS3nSypkqo/f4bhOM= +github.com/NethermindEth/starknet.go v0.6.0/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1 h1:9SBvy3eZut1X+wEyAFqfb7ADGj8IQw7ZnlkMwz0YOTY= +github.com/NethermindEth/starknet.go v0.6.1-0.20231218140327-915109ab5bc1/go.mod h1:V6qrbi1+fTDCftETIT1grBXIf+TvWP/4Aois1a9EF1E= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -69,7 +76,15 @@ github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14 h1:4spJmU4jzTXRbaQV9yrGHBDL/nTgaebjbW4Qidtkz0w= +github.com/cockroachdb/pebble v0.0.0-20230209222158-0568b5fd3d14/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= +github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.11.0 h1:QqzHQlwEqlQr5jfWblGDkwlKHpT+4QodYqqExkAtyks= +github.com/consensys/gnark-crypto v0.11.0/go.mod h1:Iq/P3HHl0ElSjsg2E1gsMwhAyxnxoKK5nVyZKd+/KhU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -95,6 +110,8 @@ github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= +github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays= github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= @@ -157,12 +174,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -173,6 +187,7 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -221,6 +236,9 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a h1:dHCfT5W7gghzPtfsW488uPmEOm85wewI+ypUwibyTdU= +github.com/leanovate/gopter v0.2.10-0.20210127095200-9abe2343507a/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -237,6 +255,9 @@ github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJ github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249 h1:NHrXEjTNQY7P0Zfx1aMrNhpgxHmow66XQtm0aQLY0AE= @@ -268,6 +289,16 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327 h1:7P+djpKBMQ2Cpv1ieUQdkZvDLt6owPvniHfMHSPFYjQ= +github.com/smartcontractkit/chainlink-common v0.1.7-0.20231218150613-43bf581ae327/go.mod h1:IdlfCN9rUs8Q/hrOYe8McNBIwEOHEsi0jilb3Cw77xs= +github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306 h1:ko88+ZznniNJZbZPWAvHQU8SwKAdHngdDZ+pvVgB5ss= +github.com/smartcontractkit/go-plugin v0.0.0-20231003134350-e49dad63b306/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU= +github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f/go.mod h1:MvMXoufZAtqExNexqi4cjrNYE9MefKddKylxjS+//n0= +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= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -283,12 +314,16 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= +github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A= github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -634,3 +669,5 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/relayer/pkg/chainlink/ocr2/client.go b/relayer/pkg/chainlink/ocr2/client.go index bc7e7d9c2..abcc6c112 100644 --- a/relayer/pkg/chainlink/ocr2/client.go +++ b/relayer/pkg/chainlink/ocr2/client.go @@ -10,7 +10,7 @@ import ( "github.com/NethermindEth/juno/core/felt" starknetrpc "github.com/NethermindEth/starknet.go/rpc" - starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/libocr/offchainreporting2/types" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet" @@ -53,7 +53,7 @@ func (c *Client) BaseReader() starknet.Reader { func (c *Client) BillingDetails(ctx context.Context, address *felt.Felt) (bd BillingDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: starknettypes.GetSelectorFromNameFelt("billing"), + Selector: starknetutils.GetSelectorFromNameFelt("billing"), } res, err := c.r.CallContract(ctx, ops) @@ -80,7 +80,7 @@ func (c *Client) BillingDetails(ctx context.Context, address *felt.Felt) (bd Bil func (c *Client) LatestConfigDetails(ctx context.Context, address *felt.Felt) (ccd ContractConfigDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: starknettypes.GetSelectorFromNameFelt("latest_config_details"), + Selector: starknetutils.GetSelectorFromNameFelt("latest_config_details"), } res, err := c.r.CallContract(ctx, ops) @@ -107,7 +107,7 @@ func (c *Client) LatestConfigDetails(ctx context.Context, address *felt.Felt) (c func (c *Client) LatestTransmissionDetails(ctx context.Context, address *felt.Felt) (td TransmissionDetails, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: starknettypes.GetSelectorFromNameFelt("latest_transmission_details"), + Selector: starknetutils.GetSelectorFromNameFelt("latest_transmission_details"), } res, err := c.r.CallContract(ctx, ops) @@ -150,7 +150,7 @@ func (c *Client) LatestTransmissionDetails(ctx context.Context, address *felt.Fe func (c *Client) LatestRoundData(ctx context.Context, address *felt.Felt) (round RoundData, err error) { ops := starknet.CallOps{ ContractAddress: address, - Selector: starknettypes.GetSelectorFromNameFelt("latest_round_data"), + Selector: starknetutils.GetSelectorFromNameFelt("latest_round_data"), } felts, err := c.r.CallContract(ctx, ops) @@ -168,7 +168,7 @@ func (c *Client) LatestRoundData(ctx context.Context, address *felt.Felt) (round func (c *Client) LinkAvailableForPayment(ctx context.Context, address *felt.Felt) (*big.Int, error) { results, err := c.r.CallContract(ctx, starknet.CallOps{ ContractAddress: address, - Selector: starknettypes.GetSelectorFromNameFelt("link_available_for_payment"), + Selector: starknetutils.GetSelectorFromNameFelt("link_available_for_payment"), }) if err != nil { return nil, errors.Wrap(err, "failed to call the contract with selector 'link_available_for_payment'") @@ -182,7 +182,7 @@ func (c *Client) LinkAvailableForPayment(ctx context.Context, address *felt.Felt func (c *Client) fetchEventsFromBlock(ctx context.Context, address *felt.Felt, eventType string, blockNum uint64) (eventsAsFeltArrs [][]*felt.Felt, err error) { block := starknetrpc.WithBlockNumber(blockNum) - eventKey := starknettypes.GetSelectorFromNameFelt(eventType) + eventKey := starknetutils.GetSelectorFromNameFelt(eventType) input := starknetrpc.EventsInput{ EventFilter: starknetrpc.EventFilter{ diff --git a/relayer/pkg/chainlink/ocr2/client_test.go b/relayer/pkg/chainlink/ocr2/client_test.go index a4cb6e528..436fd8bc3 100644 --- a/relayer/pkg/chainlink/ocr2/client_test.go +++ b/relayer/pkg/chainlink/ocr2/client_test.go @@ -11,8 +11,6 @@ import ( "testing" "time" - "github.com/NethermindEth/starknet.go/gateway" - starknettypes "github.com/NethermindEth/starknet.go/types" starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -26,7 +24,7 @@ const BLOCK_OUTPUT = `{"result": {"events": [ {"from_address": "0xd43963a4e875a3 const ocr2ContractAddress = "0xd43963a4e875a361f5d164b2e70953598eb4f45fde86924082d51b4d78e489" // matches BLOCK_OUTPUT event func TestOCR2Client(t *testing.T) { - chainID := gateway.GOERLI_ID + chainID := "SN_GOERLI" lggr := logger.Test(t) mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -57,21 +55,21 @@ func TestOCR2Client(t *testing.T) { err := json.Unmarshal([]byte(raw), &reqdata) require.NoError(t, err) - fmt.Printf("%v %v\n", reqdata.Selector, starknettypes.GetSelectorFromNameFelt("latest_transmission_details").String()) + fmt.Printf("%v %v\n", reqdata.Selector, starknetutils.GetSelectorFromNameFelt("latest_transmission_details").String()) switch reqdata.Selector { - case starknettypes.GetSelectorFromNameFelt("billing").String(): + case starknetutils.GetSelectorFromNameFelt("billing").String(): // billing response out = []byte(`{"result":["0x0","0x0","0x0","0x0"]}`) - case starknettypes.GetSelectorFromNameFelt("latest_config_details").String(): + case starknetutils.GetSelectorFromNameFelt("latest_config_details").String(): // latest config details response out = []byte(`{"result":["0x1","0x2","0x4b791b801cf0d7b6a2f9e59daf15ec2dd7d9cdc3bc5e037bada9c86e4821c"]}`) - case starknettypes.GetSelectorFromNameFelt("latest_transmission_details").String(): + case starknetutils.GetSelectorFromNameFelt("latest_transmission_details").String(): // latest transmission details response out = []byte(`{"result":["0x4cfc96325fa7d72e4854420e2d7b0abda72de17d45e4c3c0d9f626016d669","0x0","0x0","0x0"]}`) - case starknettypes.GetSelectorFromNameFelt("latest_round_data").String(): + case starknetutils.GetSelectorFromNameFelt("latest_round_data").String(): // latest transmission details response out = []byte(`{"result":["0x0","0x0","0x0","0x0","0x0"]}`) - case starknettypes.GetSelectorFromNameFelt("link_available_for_payment").String(): + case starknetutils.GetSelectorFromNameFelt("link_available_for_payment").String(): // latest transmission details response out = []byte(`{"result":["0x0"]}`) default: diff --git a/relayer/pkg/chainlink/ocr2/config_digester.go b/relayer/pkg/chainlink/ocr2/config_digester.go index a7f96324a..113a1e84e 100644 --- a/relayer/pkg/chainlink/ocr2/config_digester.go +++ b/relayer/pkg/chainlink/ocr2/config_digester.go @@ -6,7 +6,7 @@ import ( "math/big" "strings" - "github.com/NethermindEth/starknet.go" + "github.com/NethermindEth/starknet.go/curve" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -90,7 +90,7 @@ func (d offchainConfigDigester) ConfigDigest(cfg types.ContractConfig) (types.Co ) msg = append(msg, offchainConfig...) // offchain_config - digest, err := starknetgo.Curve.ComputeHashOnElements(msg) + digest, err := curve.Curve.ComputeHashOnElements(msg) if err != nil { return configDigest, err } diff --git a/relayer/pkg/chainlink/ocr2/contract_transmitter.go b/relayer/pkg/chainlink/ocr2/contract_transmitter.go index aa0a323c6..32b7c98a9 100644 --- a/relayer/pkg/chainlink/ocr2/contract_transmitter.go +++ b/relayer/pkg/chainlink/ocr2/contract_transmitter.go @@ -7,7 +7,7 @@ import ( "github.com/pkg/errors" - starknettypes "github.com/NethermindEth/starknet.go/types" + starknetrpc "github.com/NethermindEth/starknet.go/rpc" starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/NethermindEth/juno/core/felt" @@ -96,9 +96,9 @@ func (c *contractTransmitter) Transmit( return err } - err = c.txm.Enqueue(c.senderAddress, c.accountAddress, starknettypes.FunctionCall{ + err = c.txm.Enqueue(c.senderAddress, c.accountAddress, starknetrpc.FunctionCall{ ContractAddress: c.contractAddress, - EntryPointSelector: starknettypes.GetSelectorFromNameFelt("transmit"), + EntryPointSelector: starknetutils.GetSelectorFromNameFelt("transmit"), Calldata: calldata, }) diff --git a/relayer/pkg/chainlink/ocr2/events_test.go b/relayer/pkg/chainlink/ocr2/events_test.go index 5ea442a22..e0f74fe90 100644 --- a/relayer/pkg/chainlink/ocr2/events_test.go +++ b/relayer/pkg/chainlink/ocr2/events_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - starknettypes "github.com/NethermindEth/starknet.go/types" starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/libocr/offchainreporting2/types" @@ -146,7 +145,7 @@ func TestNewTransmissionEventSelector(t *testing.T) { require.NoError(t, err) eventKey := new(big.Int) eventKey.SetBytes(bytes) - assert.Equal(t, starknettypes.GetSelectorFromName("NewTransmission").Cmp(eventKey), 0) + assert.Equal(t, starknetutils.GetSelectorFromName("NewTransmission").Cmp(eventKey), 0) } func TestConfigSetEventSelector(t *testing.T) { @@ -154,5 +153,5 @@ func TestConfigSetEventSelector(t *testing.T) { require.NoError(t, err) eventKey := new(big.Int) eventKey.SetBytes(bytes) - assert.Equal(t, starknettypes.GetSelectorFromName("ConfigSet").Cmp(eventKey), 0) + assert.Equal(t, starknetutils.GetSelectorFromName("ConfigSet").Cmp(eventKey), 0) } diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report.go b/relayer/pkg/chainlink/ocr2/medianreport/report.go index 4edd36b0c..63686d3b4 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report.go @@ -44,37 +44,25 @@ func (c ReportCodec) BuildReport(oo []median.ParsedAttributedObservation) (types // preserve original array oo = append([]median.ParsedAttributedObservation{}, oo...) - numFelt, err := starknetutils.BigIntToFelt(big.NewInt(int64(num))) - if err != nil { - return nil, fmt.Errorf("invalid felt: %v", err) - } + numFelt := starknetutils.BigIntToFelt(big.NewInt(int64(num))) // median timestamp sort.Slice(oo, func(i, j int) bool { return oo[i].Timestamp < oo[j].Timestamp }) timestamp := oo[num/2].Timestamp - timestampFelt, err := starknetutils.BigIntToFelt(big.NewInt(int64(timestamp))) - if err != nil { - return nil, fmt.Errorf("invalid felt: %v", err) - } + timestampFelt := starknetutils.BigIntToFelt(big.NewInt(int64(timestamp))) // median juelsPerFeeCoin sort.Slice(oo, func(i, j int) bool { return oo[i].JuelsPerFeeCoin.Cmp(oo[j].JuelsPerFeeCoin) < 0 }) juelsPerFeeCoin := oo[num/2].JuelsPerFeeCoin - juelsPerFeeCoinFelt, err := starknetutils.BigIntToFelt(juelsPerFeeCoin) - if err != nil { - return nil, fmt.Errorf("invalid felt: %v", err) - } + juelsPerFeeCoinFelt := starknetutils.BigIntToFelt(juelsPerFeeCoin) // TODO: source from observations gasPrice := big.NewInt(1) // := oo[num/2].GasPrice - gasPriceFelt, err := starknetutils.BigIntToFelt(gasPrice) - if err != nil { - return nil, fmt.Errorf("invalid felt: %v", err) - } + gasPriceFelt := starknetutils.BigIntToFelt(gasPrice) // sort by values sort.Slice(oo, func(i, j int) bool { @@ -86,10 +74,7 @@ func (c ReportCodec) BuildReport(oo []median.ParsedAttributedObservation) (types for i, o := range oo { observers[i] = byte(o.Observer) - f, err := starknetutils.BigIntToFelt(o.Value) - if err != nil { - return nil, fmt.Errorf("invalid felt: %v", err) - } + f := starknetutils.BigIntToFelt(o.Value) observations = append(observations, f) } diff --git a/relayer/pkg/chainlink/txm/keystore.go b/relayer/pkg/chainlink/txm/keystore.go index 628f5c49a..4d4741155 100644 --- a/relayer/pkg/chainlink/txm/keystore.go +++ b/relayer/pkg/chainlink/txm/keystore.go @@ -6,7 +6,7 @@ import ( "fmt" "math/big" - "github.com/NethermindEth/starknet.go" + starknetaccount "github.com/NethermindEth/starknet.go/account" "github.com/smartcontractkit/chainlink-common/pkg/loop" adapters "github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/starknet" @@ -15,7 +15,7 @@ import ( // KeystoreAdapter is a starknet-specific adaption layer to translate between the generic Loop Keystore (bytes) and // the type specific caigo Keystore (big.Int) type KeystoreAdapter interface { - starknetgo.Keystore + starknetaccount.Keystore Loopp() loop.Keystore } diff --git a/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go b/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go index 076ee279e..e8358121c 100644 --- a/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go +++ b/relayer/pkg/chainlink/txm/mocks/nonce_manager_client.go @@ -4,10 +4,8 @@ package mocks import ( context "context" - big "math/big" felt "github.com/NethermindEth/juno/core/felt" - mock "github.com/stretchr/testify/mock" ) @@ -17,19 +15,19 @@ type NonceManagerClient struct { } // AccountNonce provides a mock function with given fields: _a0, _a1 -func (_m *NonceManagerClient) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*big.Int, error) { +func (_m *NonceManagerClient) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*felt.Felt, error) { ret := _m.Called(_a0, _a1) - var r0 *big.Int + var r0 *felt.Felt var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*felt.Felt, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *felt.Felt); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*big.Int) + r0 = ret.Get(0).(*felt.Felt) } } diff --git a/relayer/pkg/chainlink/txm/nonce.go b/relayer/pkg/chainlink/txm/nonce.go index 1982f6ff9..7d9587548 100644 --- a/relayer/pkg/chainlink/txm/nonce.go +++ b/relayer/pkg/chainlink/txm/nonce.go @@ -3,7 +3,6 @@ package txm import ( "context" "fmt" - "math/big" "sync" "github.com/NethermindEth/juno/core/felt" @@ -16,7 +15,7 @@ import ( //go:generate mockery --name NonceManagerClient --output ./mocks/ --case=underscore --filename nonce_manager_client.go type NonceManagerClient interface { - AccountNonce(context.Context, *felt.Felt) (*big.Int, error) + AccountNonce(context.Context, *felt.Felt) (*felt.Felt, error) } type NonceManager interface { @@ -24,8 +23,8 @@ type NonceManager interface { Register(ctx context.Context, address *felt.Felt, chainId string, client NonceManagerClient) error - NextSequence(address *felt.Felt, chainID string) (*big.Int, error) - IncrementNextSequence(address *felt.Felt, chainID string, currentNonce *big.Int) error + NextSequence(address *felt.Felt, chainID string) (*felt.Felt, error) + IncrementNextSequence(address *felt.Felt, chainID string, currentNonce *felt.Felt) error } var _ NonceManager = (*nonceManager)(nil) @@ -34,14 +33,14 @@ type nonceManager struct { starter utils.StartStopOnce lggr logger.Logger - n map[string]map[string]*big.Int // map address + chain ID to nonce + n map[string]map[string]*felt.Felt // map address + chain ID to nonce lock sync.RWMutex } func NewNonceManager(lggr logger.Logger) *nonceManager { return &nonceManager{ lggr: logger.Named(lggr, "NonceManager"), - n: map[string]map[string]*big.Int{}, + n: map[string]map[string]*felt.Felt{}, } } @@ -71,7 +70,7 @@ func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, chainId s defer nm.lock.Unlock() addressNonces, exists := nm.n[addr.String()] if !exists { - nm.n[addr.String()] = map[string]*big.Int{} + nm.n[addr.String()] = map[string]*felt.Felt{} } _, exists = addressNonces[chainId] if !exists { @@ -85,7 +84,7 @@ func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, chainId s return nil } -func (nm *nonceManager) NextSequence(addr *felt.Felt, chainId string) (*big.Int, error) { +func (nm *nonceManager) NextSequence(addr *felt.Felt, chainId string) (*felt.Felt, error) { if err := nm.validate(addr, chainId); err != nil { return nil, err } @@ -95,7 +94,7 @@ func (nm *nonceManager) NextSequence(addr *felt.Felt, chainId string) (*big.Int, return nm.n[addr.String()][chainId], nil } -func (nm *nonceManager) IncrementNextSequence(addr *felt.Felt, chainId string, currentNonce *big.Int) error { +func (nm *nonceManager) IncrementNextSequence(addr *felt.Felt, chainId string, currentNonce *felt.Felt) error { if err := nm.validate(addr, chainId); err != nil { return err } @@ -106,7 +105,8 @@ func (nm *nonceManager) IncrementNextSequence(addr *felt.Felt, chainId string, c if n.Cmp(currentNonce) != 0 { return fmt.Errorf("mismatched nonce for %s: %s (expected) != %s (got)", addr, n, currentNonce) } - nm.n[addr.String()][chainId] = big.NewInt(n.Int64() + 1) + one := new(felt.Felt).SetUint64(1) + nm.n[addr.String()][chainId] = new(felt.Felt).Add(n, one) return nil } diff --git a/relayer/pkg/chainlink/txm/nonce_test.go b/relayer/pkg/chainlink/txm/nonce_test.go index 0ad4a01b8..19e321ba5 100644 --- a/relayer/pkg/chainlink/txm/nonce_test.go +++ b/relayer/pkg/chainlink/txm/nonce_test.go @@ -5,8 +5,8 @@ import ( "math/big" "testing" - starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/NethermindEth/juno/core/felt" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/smartcontractkit/chainlink-common/pkg/logger" "github.com/smartcontractkit/chainlink-common/pkg/utils/tests" @@ -19,7 +19,7 @@ import ( "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm/mocks" ) -func newTestNonceManager(t *testing.T, chainID string, initNonce *big.Int) (txm.NonceManager, *felt.Felt, func()) { +func newTestNonceManager(t *testing.T, chainID string, initNonce *felt.Felt) (txm.NonceManager, *felt.Felt, func()) { // setup c := mocks.NewNonceManagerClient(t) lggr := logger.Test(t) @@ -40,7 +40,7 @@ func TestNonceManager_NextSequence(t *testing.T) { t.Parallel() chainId := "test_nextSequence" - initNonce := big.NewInt(10) + initNonce := new(felt.Felt).SetUint64(10) nm, k, stop := newTestNonceManager(t, chainId, initNonce) defer stop() @@ -55,7 +55,7 @@ func TestNonceManager_NextSequence(t *testing.T) { assert.Contains(t, err.Error(), fmt.Sprintf("nonce does not exist for key: %s and chain: %s", k.String(), "invalid_chainId")) // should fail with invalid address - randAddr1, err := starknetutils.BigIntToFelt(big.NewInt(1)) + randAddr1 := starknetutils.BigIntToFelt(big.NewInt(1)) require.NoError(t, err) _, err = nm.NextSequence(randAddr1, chainId) require.Error(t, err) @@ -66,12 +66,13 @@ func TestNonceManager_IncrementNextSequence(t *testing.T) { t.Parallel() chainId := "test_nextSequence" - initNonce := big.NewInt(10) + initNonce := new(felt.Felt).SetUint64(10) nm, k, stop := newTestNonceManager(t, chainId, initNonce) defer stop() - initMinusOne := big.NewInt(initNonce.Int64() - 1) - initPlusOne := big.NewInt(initNonce.Int64() + 1) + one := new(felt.Felt).SetUint64(1) + initMinusOne := new(felt.Felt).Sub(initNonce, one) + initPlusOne := new(felt.Felt).Add(initNonce, one) // should fail if nonce is lower then expected err := nm.IncrementNextSequence(k, chainId, initMinusOne) @@ -91,7 +92,7 @@ func TestNonceManager_IncrementNextSequence(t *testing.T) { assert.Contains(t, err.Error(), fmt.Sprintf("nonce does not exist for key: %s and chain: %s", k.String(), "invalid_chainId")) // should fail with invalid address - randAddr1, err := starknetutils.BigIntToFelt(big.NewInt(1)) + randAddr1 := starknetutils.BigIntToFelt(big.NewInt(1)) require.NoError(t, err) err = nm.IncrementNextSequence(randAddr1, chainId, initPlusOne) require.Error(t, err) diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index 4372bc88c..152d5d9d2 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -4,15 +4,13 @@ import ( "context" "errors" "fmt" - "math/big" "reflect" "sync" "time" "github.com/NethermindEth/juno/core/felt" - "github.com/NethermindEth/starknet.go" + starknetaccount "github.com/NethermindEth/starknet.go/account" starknetrpc "github.com/NethermindEth/starknet.go/rpc" - starknettypes "github.com/NethermindEth/starknet.go/types" starknetutils "github.com/NethermindEth/starknet.go/utils" "golang.org/x/exp/maps" @@ -29,14 +27,14 @@ const ( ) type TxManager interface { - Enqueue(senderAddress *felt.Felt, accountAddress *felt.Felt, txFn starknettypes.FunctionCall) error + Enqueue(senderAddress *felt.Felt, accountAddress *felt.Felt, txFn starknetrpc.FunctionCall) error InflightCount() (int, int) } type Tx struct { senderAddress *felt.Felt accountAddress *felt.Felt - call starknettypes.FunctionCall + call starknetrpc.FunctionCall } type StarkTXM interface { @@ -128,15 +126,15 @@ func (txm *starktxm) broadcastLoop() { const FEE_MARGIN uint64 = 115 -func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, accountAddress *felt.Felt, tx starknettypes.FunctionCall) (txhash string, err error) { - txs := []starknettypes.FunctionCall{tx} +func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, accountAddress *felt.Felt, call starknetrpc.FunctionCall) (txhash string, err error) { client, err := txm.client.Get() if err != nil { txm.client.Reset() return txhash, fmt.Errorf("broadcast: failed to fetch client: %+w", err) } // create new account - account, err := starknetgo.NewRPCAccount(senderAddress, accountAddress, txm.ks, client.Provider, starknetgo.AccountVersion1) + accountVersion := 0 + account, err := starknetaccount.NewAccount(client.Provider, senderAddress, accountAddress.String(), txm.ks, accountVersion) if err != nil { return txhash, fmt.Errorf("failed to create new account: %+w", err) } @@ -151,31 +149,55 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, ac return txhash, fmt.Errorf("failed to get nonce: %+w", err) } - // get fee for txm + // TODO: update to v3 + + maxfee, err := starknetutils.HexToFelt("0x95e566845d000") + if err != nil { + return txhash, err + } + + // Building the tx struct + tx := starknetrpc.InvokeTxnV1{ + MaxFee: maxfee, + Version: starknetrpc.TransactionV1, + Nonce: nonce, + Type: starknetrpc.TransactionType_Invoke, + SenderAddress: account.AccountAddress, + } + + // Building the Calldata with the help of FmtCalldata where we pass in the FnCall struct along with the Cairo version + tx.Calldata, err = account.FmtCalldata([]starknetrpc.FunctionCall{call}) + if err != nil { + return txhash, err + } + + // Signing of the transaction that is done by the account + err = account.SignInvokeTransaction(context.Background(), &tx) + if err != nil { + return txhash, err + } + + // get fee for tx // optional - pass nonce to fee estimate (if nonce gets ahead, estimate may fail) // can we estimate fee without calling estimate - tbd with 1.0 - feeEstimate, err := account.EstimateFee(ctx, txs, starknettypes.ExecuteDetails{}) + simFlags := []starknetrpc.SimulationFlag{} + feeEstimate, err := account.EstimateFee(ctx, []starknetrpc.BroadcastTxn{tx}, simFlags, starknetrpc.BlockID{Tag: "latest"}) if err != nil { return txhash, fmt.Errorf("failed to estimate fee: %+w", err) } + // expandedFee := new(felt.Felt).Mul(feeEstimate[0].OverallFee, FEE_MARGIN) + // maxfee = new(felt.Felt).Div(expandedFee, new(felt.Felt).SetUint64(100)) + tx.MaxFee = feeEstimate[0].OverallFee // TODO: mul times margin - fee, _ := big.NewInt(0).SetString(string(feeEstimate.OverallFee), 0) - expandedFee := big.NewInt(0).Mul(fee, big.NewInt(int64(FEE_MARGIN))) - max := big.NewInt(0).Div(expandedFee, big.NewInt(100)) - details := starknettypes.ExecuteDetails{ - MaxFee: max, - Nonce: nonce, - } - - // transmit txs execCtx, execCancel := context.WithTimeout(ctx, txm.cfg.TxTimeout()) defer execCancel() - res, err := account.Execute(execCtx, txs, details) + + // finally, transmit the invoke + res, err := account.AddInvokeTransaction(execCtx, tx) if err != nil { // TODO: handle initial broadcast errors - what kind of errors occur? return txhash, fmt.Errorf("failed to invoke tx: %+w", err) } - // handle nil pointer if res == nil { return txhash, errors.New("execute response and error are nil") @@ -224,20 +246,21 @@ func (txm *starktxm) confirmLoop() { txm.lggr.Errorw("failed to fetch transaction status", "hash", hash, "error", err) continue } + // TODO: there's no more pending status so a txn status is always accepted or rejected receipt, ok := response.(starknetrpc.InvokeTransactionReceipt) if !ok { txm.lggr.Errorw("wrong receipt type", "type", reflect.TypeOf(response)) continue } - status := receipt.Status + status := receipt.GetExecutionStatus() - if status == starknetrpc.TransactionAcceptedOnL1 || status == starknetrpc.TransactionAcceptedOnL2 || status == starknetrpc.TransactionRejected { - txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status) - if err := txm.txStore.Confirm(addr, hash); err != nil { - txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err) - } + // if status == starknetrpc.TxnStatus_Accepted_On_L1 || status == starknetrpc.TxnStatus_Accepted_On_L2 || status == starknetrpc.TxnStatus_Rejected { + txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status) + if err := txm.txStore.Confirm(addr, hash); err != nil { + txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err) } + // } } } case <-txm.stop: @@ -269,7 +292,7 @@ func (txm *starktxm) HealthReport() map[string]error { return map[string]error{txm.Name(): txm.Healthy()} } -func (txm *starktxm) Enqueue(senderAddress, accountAddress *felt.Felt, tx starknettypes.FunctionCall) error { +func (txm *starktxm) Enqueue(senderAddress, accountAddress *felt.Felt, tx starknetrpc.FunctionCall) error { // validate key exists for sender // use the embedded Loopp Keystore to do this; the spec and design // encourage passing nil data to the loop.Keystore.Sign as way to test diff --git a/relayer/pkg/chainlink/txm/txm_test.go b/relayer/pkg/chainlink/txm/txm_test.go index a6dbc39ca..b365193fd 100644 --- a/relayer/pkg/chainlink/txm/txm_test.go +++ b/relayer/pkg/chainlink/txm/txm_test.go @@ -9,10 +9,9 @@ import ( "testing" "time" - "github.com/NethermindEth/starknet.go" - starknetgw "github.com/NethermindEth/starknet.go/gateway" - "github.com/NethermindEth/starknet.go/test" - starknettypes "github.com/NethermindEth/starknet.go/types" + "github.com/NethermindEth/starknet.go/curve" + "github.com/NethermindEth/starknet.go/devnet" + starknetrpc "github.com/NethermindEth/starknet.go/rpc" starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -28,7 +27,7 @@ import ( func TestIntegration_Txm(t *testing.T) { n := 2 // number of txs per key url := SetupLocalStarknetNode(t) - devnet := test.NewDevNet(url) + devnet := devnet.NewDevNet(url) accounts, err := devnet.Accounts() require.NoError(t, err) @@ -36,11 +35,11 @@ func TestIntegration_Txm(t *testing.T) { localKeys := map[string]*big.Int{} localAccounts := map[string]string{} for i := range accounts { - privKey, err := starknettypes.HexToBytes(accounts[i].PrivateKey) + privKey, err := utils.HexToBytes(accounts[i].PrivateKey) require.NoError(t, err) senderAddress, err := starknetutils.HexToFelt(accounts[i].PublicKey) require.NoError(t, err) - localKeys[senderAddress.String()] = starknettypes.BytesToBig(privKey) + localKeys[senderAddress.String()] = utils.BytesToBig(privKey) localAccounts[senderAddress.String()] = accounts[i].Address } @@ -55,7 +54,7 @@ func TestIntegration_Txm(t *testing.T) { ksAdapter := NewKeystoreAdapter(looppKs) lggr, observer := logger.TestObserved(t, zapcore.DebugLevel) timeout := 10 * time.Second - client, err := starknet.NewClient(starknetgw.GOERLI_ID, url+"/rpc", lggr, &timeout) + client, err := starknet.NewClient("SN_GOERLI", url+"/rpc", lggr, &timeout) require.NoError(t, err) getClient := func() (*starknet.Client, error) { @@ -87,10 +86,10 @@ func TestIntegration_Txm(t *testing.T) { contractAddress, err := starknetutils.HexToFelt("0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7") require.NoError(t, err) - selector := starknettypes.GetSelectorFromNameFelt("totalSupply") + selector := utils.GetSelectorFromNameFelt("totalSupply") for i := 0; i < n; i++ { - require.NoError(t, txm.Enqueue(senderAddress, account, starknettypes.FunctionCall{ + require.NoError(t, txm.Enqueue(senderAddress, account, starknetrpc.FunctionCall{ ContractAddress: contractAddress, // send to ETH token contract EntryPointSelector: selector, })) @@ -147,7 +146,7 @@ func (lk *LooppKeystore) Sign(ctx context.Context, id string, hash []byte) ([]by } starkHash := new(big.Int).SetBytes(hash) - x, y, err := starknetgo.Curve.Sign(starkHash, k) + x, y, err := curve.Curve.Sign(starkHash, k) if err != nil { return nil, fmt.Errorf("error signing data with curve: %w", err) } diff --git a/relayer/pkg/chainlink/txm/txstore.go b/relayer/pkg/chainlink/txm/txstore.go index ce47b9de9..ceb20935b 100644 --- a/relayer/pkg/chainlink/txm/txstore.go +++ b/relayer/pkg/chainlink/txm/txstore.go @@ -2,7 +2,6 @@ package txm import ( "fmt" - "math/big" "sync" "github.com/NethermindEth/juno/core/felt" @@ -12,27 +11,27 @@ import ( // TxStore tracks broadcast & unconfirmed txs type TxStore struct { lock sync.RWMutex - nonceToHash map[int64]string // map nonce to txhash - hashToNonce map[string]int64 // map hash to nonce - currentNonce *big.Int // minimum nonce + nonceToHash map[*felt.Felt]string // map nonce to txhash + hashToNonce map[string]*felt.Felt // map hash to nonce + currentNonce *felt.Felt // minimum nonce } -func NewTxStore(current *big.Int) *TxStore { +func NewTxStore(current *felt.Felt) *TxStore { return &TxStore{ - nonceToHash: map[int64]string{}, - hashToNonce: map[string]int64{}, + nonceToHash: map[*felt.Felt]string{}, + hashToNonce: map[string]*felt.Felt{}, currentNonce: current, } } -func (s *TxStore) Save(nonce *big.Int, hash string) error { +func (s *TxStore) Save(nonce *felt.Felt, hash string) error { s.lock.Lock() defer s.lock.Unlock() if s.currentNonce.Cmp(nonce) == 1 { return fmt.Errorf("nonce too low: %s < %s (lowest)", nonce, s.currentNonce) } - if h, exists := s.nonceToHash[nonce.Int64()]; exists { + if h, exists := s.nonceToHash[nonce]; exists { return fmt.Errorf("nonce used: tried to use nonce (%s) for tx (%s), already used by (%s)", nonce, hash, h) } if n, exists := s.hashToNonce[hash]; exists { @@ -40,14 +39,14 @@ func (s *TxStore) Save(nonce *big.Int, hash string) error { } // store hash - s.nonceToHash[nonce.Int64()] = hash - s.hashToNonce[hash] = nonce.Int64() + s.nonceToHash[nonce] = hash + s.hashToNonce[hash] = nonce // find next unused nonce - _, exists := s.nonceToHash[s.currentNonce.Int64()] + _, exists := s.nonceToHash[s.currentNonce] for exists { - s.currentNonce.Add(s.currentNonce, big.NewInt(1)) - _, exists = s.nonceToHash[s.currentNonce.Int64()] + s.currentNonce.Add(s.currentNonce, new(felt.Felt).SetUint64(1)) + _, exists = s.nonceToHash[s.currentNonce] } return nil } @@ -87,7 +86,7 @@ func NewChainTxStore() *ChainTxStore { } } -func (c *ChainTxStore) Save(from *felt.Felt, nonce *big.Int, hash string) error { +func (c *ChainTxStore) Save(from *felt.Felt, nonce *felt.Felt, hash string) error { // use write lock for methods that modify underlying data c.lock.Lock() defer c.lock.Unlock() diff --git a/relayer/pkg/chainlink/txm/txstore_test.go b/relayer/pkg/chainlink/txm/txstore_test.go index b87eb8243..648996173 100644 --- a/relayer/pkg/chainlink/txm/txstore_test.go +++ b/relayer/pkg/chainlink/txm/txstore_test.go @@ -3,11 +3,10 @@ package txm import ( "errors" "fmt" - "math/big" "sync" "testing" - starknetutils "github.com/NethermindEth/starknet.go/utils" + "github.com/NethermindEth/juno/core/felt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -18,9 +17,9 @@ func TestTxStore(t *testing.T) { t.Run("happypath", func(t *testing.T) { t.Parallel() - s := NewTxStore(big.NewInt(0)) + s := NewTxStore(&felt.Zero) assert.Equal(t, 0, s.InflightCount()) - require.NoError(t, s.Save(big.NewInt(0), "0x0")) + require.NoError(t, s.Save(&felt.Zero, "0x0")) assert.Equal(t, 1, s.InflightCount()) assert.Equal(t, []string{"0x0"}, s.GetUnconfirmed()) require.NoError(t, s.Confirm("0x0")) @@ -32,38 +31,38 @@ func TestTxStore(t *testing.T) { t.Parallel() // create - s := NewTxStore(big.NewInt(0)) + s := NewTxStore(&felt.Zero) // accepts tx in order - require.NoError(t, s.Save(big.NewInt(0), "0x0")) + require.NoError(t, s.Save(&felt.Zero, "0x0")) assert.Equal(t, 1, s.InflightCount()) - assert.Equal(t, int64(1), s.currentNonce.Int64()) + assert.Equal(t, new(felt.Felt).SetUint64(1), s.currentNonce) // accepts tx that skips a nonce - require.NoError(t, s.Save(big.NewInt(2), "0x2")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(2), "0x2")) assert.Equal(t, 2, s.InflightCount()) - assert.Equal(t, int64(1), s.currentNonce.Int64()) + assert.Equal(t, new(felt.Felt).SetUint64(1), s.currentNonce) // accepts tx that fills in the missing nonce + fast forwards currentNonce - require.NoError(t, s.Save(big.NewInt(1), "0x1")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(1), "0x1")) assert.Equal(t, 3, s.InflightCount()) - assert.Equal(t, int64(3), s.currentNonce.Int64()) + assert.Equal(t, new(felt.Felt).SetUint64(3), s.currentNonce) // skip a nonce for later tests - require.NoError(t, s.Save(big.NewInt(4), "0x4")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(4), "0x4")) assert.Equal(t, 4, s.InflightCount()) - assert.Equal(t, int64(3), s.currentNonce.Int64()) + assert.Equal(t, new(felt.Felt).SetUint64(3), s.currentNonce) // rejects old nonce - require.ErrorContains(t, s.Save(big.NewInt(0), "0xold"), "nonce too low: 0 < 3 (lowest)") + require.ErrorContains(t, s.Save(&felt.Zero, "0xold"), "nonce too low: 0 < 3 (lowest)") assert.Equal(t, 4, s.InflightCount()) // reject already in use nonce - require.ErrorContains(t, s.Save(big.NewInt(4), "0xskip"), "nonce used: tried to use nonce (4) for tx (0xskip), already used by (0x4)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(4), "0xskip"), "nonce used: tried to use nonce (4) for tx (0xskip), already used by (0x4)") assert.Equal(t, 4, s.InflightCount()) // reject already in use tx hash - require.ErrorContains(t, s.Save(big.NewInt(5), "0x0"), "hash used: tried to use tx (0x0) for nonce (5), already used nonce (0)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(5), "0x0"), "hash used: tried to use tx (0x0) for nonce (5), already used nonce (0)") assert.Equal(t, 4, s.InflightCount()) // race save @@ -72,11 +71,11 @@ func TestTxStore(t *testing.T) { var wg sync.WaitGroup wg.Add(2) go func() { - err0 = s.Save(big.NewInt(10), "0x10") + err0 = s.Save(new(felt.Felt).SetUint64(10), "0x10") wg.Done() }() go func() { - err1 = s.Save(big.NewInt(10), "0x10") + err1 = s.Save(new(felt.Felt).SetUint64(10), "0x10") wg.Done() }() wg.Wait() @@ -87,9 +86,9 @@ func TestTxStore(t *testing.T) { t.Parallel() // init store - s := NewTxStore(big.NewInt(0)) + s := NewTxStore(&felt.Zero) for i := 0; i < 5; i++ { - require.NoError(t, s.Save(big.NewInt(int64(i)), "0x"+fmt.Sprintf("%d", i))) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(uint64(i)), "0x"+fmt.Sprintf("%d", i))) } // confirm in order @@ -108,7 +107,7 @@ func TestTxStore(t *testing.T) { require.ErrorContains(t, s.Confirm("0xNULL"), "tx hash does not exist - it may already be confirmed") // race confirm - require.NoError(t, s.Save(big.NewInt(10), "0x10")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(10), "0x10")) var err0 error var err1 error var wg sync.WaitGroup @@ -131,21 +130,19 @@ func TestChainTxStore(t *testing.T) { c := NewChainTxStore() - felt, err := starknetutils.BigIntToFelt(big.NewInt(0)) - require.NoError(t, err) - felt1, err := starknetutils.BigIntToFelt(big.NewInt(1)) - require.NoError(t, err) + felt0 := new(felt.Felt).SetUint64(0) + felt1 := new(felt.Felt).SetUint64(1) // automatically save the from address - require.NoError(t, c.Save(felt, big.NewInt(0), "0x0")) + require.NoError(t, c.Save(felt0, new(felt.Felt).SetUint64(0), "0x0")) // reject saving for existing address and reused hash & nonce // error messages are tested within TestTxStore - assert.Error(t, c.Save(felt, big.NewInt(0), "0x1")) - assert.Error(t, c.Save(felt, big.NewInt(1), "0x0")) + assert.Error(t, c.Save(felt0, new(felt.Felt).SetUint64(0), "0x1")) + assert.Error(t, c.Save(felt0, new(felt.Felt).SetUint64(1), "0x0")) // inflight count - count, exists := c.GetAllInflightCount()[felt] + count, exists := c.GetAllInflightCount()[felt0] require.True(t, exists) assert.Equal(t, 1, count) _, exists = c.GetAllInflightCount()[felt1] @@ -154,18 +151,18 @@ func TestChainTxStore(t *testing.T) { // get unconfirmed list := c.GetAllUnconfirmed() assert.Equal(t, 1, len(list)) - hashes, ok := list[felt] + hashes, ok := list[felt0] assert.True(t, ok) assert.Equal(t, []string{"0x0"}, hashes) // confirm - assert.NoError(t, c.Confirm(felt, "0x0")) + assert.NoError(t, c.Confirm(felt0, "0x0")) assert.ErrorContains(t, c.Confirm(felt1, "0x0"), "from address does not exist") - assert.Error(t, c.Confirm(felt, "0x1")) + assert.Error(t, c.Confirm(felt0, "0x1")) list = c.GetAllUnconfirmed() assert.Equal(t, 1, len(list)) - assert.Equal(t, 0, len(list[felt])) - count, exists = c.GetAllInflightCount()[felt] + assert.Equal(t, 0, len(list[felt0])) + count, exists = c.GetAllInflightCount()[felt0] assert.True(t, exists) assert.Equal(t, 0, count) } diff --git a/relayer/pkg/starknet/client.go b/relayer/pkg/starknet/client.go index 7260fd3f5..e27896a4e 100644 --- a/relayer/pkg/starknet/client.go +++ b/relayer/pkg/starknet/client.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "github.com/NethermindEth/juno/core/felt" - caigo "github.com/NethermindEth/starknet.go" + starknetaccount "github.com/NethermindEth/starknet.go/account" starknetrpc "github.com/NethermindEth/starknet.go/rpc" starknetutils "github.com/NethermindEth/starknet.go/utils" ethrpc "github.com/ethereum/go-ethereum/rpc" @@ -28,7 +28,7 @@ type Reader interface { Events(ctx context.Context, input starknetrpc.EventsInput) (*starknetrpc.EventChunk, error) TransactionByHash(context.Context, *felt.Felt) (starknetrpc.Transaction, error) TransactionReceipt(context.Context, *felt.Felt) (starknetrpc.TransactionReceipt, error) - AccountNonce(context.Context, *felt.Felt) (*big.Int, error) + AccountNonce(context.Context, *felt.Felt) (*felt.Felt, error) } type Writer interface { @@ -44,7 +44,7 @@ var _ ReaderWriter = (*Client)(nil) // var _ starknettypes.Provider = (*Client)(nil) type Client struct { - Provider *starknetrpc.Provider + Provider starknetrpc.RpcProvider lggr logger.Logger defaultTimeout time.Duration } @@ -192,20 +192,18 @@ func (c *Client) Events(ctx context.Context, input starknetrpc.EventsInput) (*st return out, nil } -func (c *Client) AccountNonce(ctx context.Context, accountAddress *felt.Felt) (*big.Int, error) { +func (c *Client) AccountNonce(ctx context.Context, accountAddress *felt.Felt) (*felt.Felt, error) { if c.defaultTimeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, c.defaultTimeout) defer cancel() } - sender, err := starknetutils.BigIntToFelt(big.NewInt((0))) // not actually used in account.Nonce() + sender := starknetutils.BigIntToFelt(big.NewInt((0))) // not actually used in account.Nonce() + accountVersion := 0 + account, err := starknetaccount.NewAccount(c.Provider, sender, accountAddress.String(), nil, accountVersion) if err != nil { return nil, errors.Wrap(err, "error in client.AccountNonce") } - account, err := caigo.NewRPCAccount(sender, accountAddress, nil, c.Provider, caigo.AccountVersion1) - if err != nil { - return nil, errors.Wrap(err, "error in client.AccountNonce") - } - return account.Nonce(ctx) + return account.Nonce(ctx, starknetrpc.BlockID{Tag: "latest"}, account.AccountAddress) } diff --git a/relayer/pkg/starknet/client_test.go b/relayer/pkg/starknet/client_test.go index 9d58e69db..e3d88b24a 100644 --- a/relayer/pkg/starknet/client_test.go +++ b/relayer/pkg/starknet/client_test.go @@ -10,8 +10,7 @@ import ( "testing" "time" - "github.com/NethermindEth/starknet.go/gateway" - starknettypes "github.com/NethermindEth/starknet.go/types" + starknetutils "github.com/NethermindEth/starknet.go/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -19,7 +18,7 @@ import ( ) var ( - chainID = gateway.GOERLI_ID + chainID = "SN_GOERLI" timeout = 10 * time.Second ) @@ -40,7 +39,7 @@ func TestRPCClient(t *testing.T) { switch call.Method { case "starknet_chainId": - id := starknettypes.BigToHex(starknettypes.UTF8StrToBig(chainID)) + id := starknetutils.BigToHex(starknetutils.UTF8StrToBig(chainID)) out = []byte(fmt.Sprintf(`{"result": "%s"}`, id)) case "starknet_blockNumber": out = []byte(`{"result": 1}`) diff --git a/relayer/pkg/starknet/mocks/Reader.go b/relayer/pkg/starknet/mocks/Reader.go index f5229e04a..cb88175c1 100644 --- a/relayer/pkg/starknet/mocks/Reader.go +++ b/relayer/pkg/starknet/mocks/Reader.go @@ -4,10 +4,8 @@ package mocks import ( context "context" - big "math/big" felt "github.com/NethermindEth/juno/core/felt" - mock "github.com/stretchr/testify/mock" rpc "github.com/NethermindEth/starknet.go/rpc" @@ -21,19 +19,19 @@ type Reader struct { } // AccountNonce provides a mock function with given fields: _a0, _a1 -func (_m *Reader) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*big.Int, error) { +func (_m *Reader) AccountNonce(_a0 context.Context, _a1 *felt.Felt) (*felt.Felt, error) { ret := _m.Called(_a0, _a1) - var r0 *big.Int + var r0 *felt.Felt var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*big.Int, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) (*felt.Felt, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *big.Int); ok { + if rf, ok := ret.Get(0).(func(context.Context, *felt.Felt) *felt.Felt); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*big.Int) + r0 = ret.Get(0).(*felt.Felt) } } From a5851d1e0e2f07cd9d772ddb5d263accfadfb7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 10 Jan 2024 16:40:53 +0900 Subject: [PATCH 04/11] Remove venv Was only used for devnet in some cases, we want to switch to new devnet everywhere now. --- .github/workflows/contracts.yml | 3 --- .github/workflows/integration_contracts.yml | 3 --- .github/workflows/integration_gauntlet.yml | 3 --- .github/workflows/relayer.yml | 3 --- contracts/constraints.txt | 0 contracts/requirements.txt | 5 ----- shell.nix | 8 -------- 7 files changed, 25 deletions(-) delete mode 100644 contracts/constraints.txt delete mode 100644 contracts/requirements.txt diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 3800499bf..3cc470e0f 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -23,9 +23,6 @@ jobs: - name: Install Cairo uses: ./.github/actions/install-cairo - - name: Install starknet-devnet (via venv+pip) - run: nix develop -c pip install -r contracts/requirements.txt -c contracts/constraints.txt - - name: Test run: nix develop -c make test-ts-contracts diff --git a/.github/workflows/integration_contracts.yml b/.github/workflows/integration_contracts.yml index 835082dd8..fa421a134 100644 --- a/.github/workflows/integration_contracts.yml +++ b/.github/workflows/integration_contracts.yml @@ -23,8 +23,5 @@ jobs: - name: Install Cairo uses: ./.github/actions/install-cairo - - name: Install starknet-devnet (via venv+pip) - run: nix develop -c pip install -r contracts/requirements.txt -c contracts/constraints.txt - - name: Test run: nix develop -c make test-integration-contracts diff --git a/.github/workflows/integration_gauntlet.yml b/.github/workflows/integration_gauntlet.yml index 5dc4bfe40..892c42002 100644 --- a/.github/workflows/integration_gauntlet.yml +++ b/.github/workflows/integration_gauntlet.yml @@ -49,9 +49,6 @@ jobs: - name: Install Cairo uses: ./.github/actions/install-cairo - - name: Install starknet-devnet (via venv+pip) - run: nix develop -c pip install -r contracts/requirements.txt -c contracts/constraints.txt - - name: Test run: nix develop -c make test-integration-gauntlet diff --git a/.github/workflows/relayer.yml b/.github/workflows/relayer.yml index 3227a9110..2bbbe0a63 100644 --- a/.github/workflows/relayer.yml +++ b/.github/workflows/relayer.yml @@ -35,8 +35,5 @@ jobs: ./relayer/coverage.txt ./relayer/race_coverage.txt - - name: Install starknet-devnet (via venv+pip) - run: nix develop -c pip install -r contracts/requirements.txt -c contracts/constraints.txt - - name: Integration Test run: nix develop -c make test-integration-go diff --git a/contracts/constraints.txt b/contracts/constraints.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/contracts/requirements.txt b/contracts/requirements.txt deleted file mode 100644 index a50aff25e..000000000 --- a/contracts/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -ecdsa -fastecdsa -sympy -cairo-lang>=0.12.1 -starknet-devnet>=0.6.0 diff --git a/shell.nix b/shell.nix index 4fb605bef..0743e2678 100644 --- a/shell.nix +++ b/shell.nix @@ -5,12 +5,6 @@ buildInputs = with pkgs; [ stdenv.cc.cc.lib (rust-bin.stable.latest.default.override { extensions = ["rust-src"]; }) - python39 - python39Packages.pip - python39Packages.venvShellHook - python39Packages.fastecdsa # so libgmp is correctly sourced - zlib # for numpy - gmp nodejs-18_x (yarn.override { nodejs = nodejs-18_x; }) nodePackages.typescript @@ -36,6 +30,4 @@ LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.zlib stdenv.cc.cc.lib]; # lib64 HELM_REPOSITORY_CONFIG = "./.helm-repositories.yaml"; - - venvDir = "./.venv"; } From 87f505ab29adcd70b8c9d6aad7d7b99ccda30739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 10 Jan 2024 16:55:02 +0900 Subject: [PATCH 05/11] Switch to new starknet-devnet --- ops/charts/devnet/templates/deployment.yaml | 6 ++-- ops/devnet/environment.go | 4 +-- ops/scripts/devnet-hardhat.sh | 34 +++++---------------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/ops/charts/devnet/templates/deployment.yaml b/ops/charts/devnet/templates/deployment.yaml index 3e920911d..50e22e7a3 100644 --- a/ops/charts/devnet/templates/deployment.yaml +++ b/ops/charts/devnet/templates/deployment.yaml @@ -31,7 +31,7 @@ spec: - "-c" - | mkdir -p cairo-build - curl -L --output release.tgz https://github.com/starkware-libs/cairo/releases/download/v2.0.2/release-x86_64-unknown-linux-musl.tar.gz + curl -L --output release.tgz https://github.com/starkware-libs/cairo/releases/download/v2.4.3/release-x86_64-unknown-linux-musl.tar.gz tar xzf release.tgz mv cairo/* cairo-build/ volumeMounts: @@ -47,8 +47,8 @@ spec: {{- else }} - name: cairo-build mountPath: /cairo-build - image: "{{ .Values.repository | default "shardlabs/starknet-devnet"}}:{{ .Values.tag | default "0.6.0"}}" - args: ["--sierra-compiler-path", "/cairo-build/bin/starknet-sierra-compile", "--lite-mode", "--port", {{ .Values.service.internalPort | quote}}, "--seed", {{ .Values.seed | quote}}] + image: "{{ .Values.repository | default "shardlabs/starknet-devnet-rs"}}:{{ .Values.tag | default "latest"}}" + args: ["--port", {{ .Values.service.internalPort | quote}}, "--seed", {{ .Values.seed | quote}}] {{- end }} imagePullPolicy: IfNotPresent {{- if eq .Values.real_node true }} diff --git a/ops/devnet/environment.go b/ops/devnet/environment.go index 082754a49..24389ac5d 100644 --- a/ops/devnet/environment.go +++ b/ops/devnet/environment.go @@ -72,8 +72,8 @@ func defaultProps() map[string]any { "replicas": "1", "starknet-dev": map[string]any{ "image": map[string]any{ - "image": "shardlabs/starknet-devnet", - "version": "v0.6.0", + "image": "shardlabs/starknet-devnet-rs", + "version": "5d2536a99852b1a61bbbfdcaa6755cb4275bffddm", }, "resources": map[string]any{ "requests": map[string]any{ diff --git a/ops/scripts/devnet-hardhat.sh b/ops/scripts/devnet-hardhat.sh index 39ae970ba..24163644a 100755 --- a/ops/scripts/devnet-hardhat.sh +++ b/ops/scripts/devnet-hardhat.sh @@ -3,26 +3,9 @@ set -euo pipefail -cpu_struct=`arch`; -echo $cpu_struct; - -git_root="$(git rev-parse --show-toplevel)" -cairo_build_path="${git_root}/cairo-build" -cairo_sierra_compile_path="${cairo_build_path}/bin/starknet-sierra-compile" - -cairo_checkout_path="${git_root}/vendor/cairo" -cairo_compiler_manifest="${cairo_checkout_path}/Cargo.toml" - -if [ -f "${cairo_sierra_compile_path}" ]; then - docker_volume="${cairo_build_path}:/cairo-build" - startup_args="starknet-devnet --lite-mode --host 0.0.0.0 --sierra-compiler-path /cairo-build/bin/starknet-sierra-compile" -elif [ -f "${cairo_compiler_manifest}" ]; then - docker_volume="${cairo_checkout_path}:/cairo" - startup_args="(wget https://sh.rustup.rs -O - | sh -s -- -y) && apk add gmp-dev g++ gcc libffi-dev && PATH=\"/root/.cargo/bin:\${PATH}\" starknet-devnet --lite-mode --host 0.0.0.0 --cairo-compiler-manifest /cairo/Cargo.toml" -else - echo "No Cargo.toml; did you checkout the cairo git submodule?" - exit 1 -fi +# cpu_struct=`arch`; +# echo $cpu_struct; +cpu_struct="linux"; # Clean up first bash "$(dirname -- "$0";)/devnet-hardhat-down.sh" @@ -31,13 +14,13 @@ echo "Checking CPU structure..." if [[ $cpu_struct == *"arm"* ]] then echo "Starting arm devnet container..." - container_version="0.6.0-arm" + container_version="5d2536a99852b1a61bbbfdcaa6755cb4275bffdd-arm" else echo "Starting i386 devnet container..." - container_version="0.6.0" + container_version="5d2536a99852b1a61bbbfdcaa6755cb4275bffdd" fi -echo "Starting starknet-devnet: ${startup_args}" +echo "Starting starknet-devnet" # we need to replace the entrypoint because starknet-devnet's docker builds at 0.5.1 don't include cargo or gcc. docker run \ @@ -45,10 +28,7 @@ docker run \ -p 127.0.0.1:8545:8545 \ -d \ --name chainlink-starknet.starknet-devnet \ - --volume "${docker_volume}" \ - --entrypoint sh \ - "shardlabs/starknet-devnet:${container_version}" \ - -c "${startup_args}" + "shardlabs/starknet-devnet-rs:${container_version}" echo "Starting hardhat..." docker run --net container:chainlink-starknet.starknet-devnet -d --name chainlink-starknet.hardhat ethereumoptimism/hardhat-node:nightly From 7746ac28ada84f75946e235686d208260ecb4f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 10 Jan 2024 17:29:50 +0900 Subject: [PATCH 06/11] fix a couple go tests --- relayer/pkg/chainlink/txm/nonce_test.go | 2 -- relayer/pkg/chainlink/txm/txstore.go | 3 ++- relayer/pkg/chainlink/txm/txstore_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/relayer/pkg/chainlink/txm/nonce_test.go b/relayer/pkg/chainlink/txm/nonce_test.go index 19e321ba5..37600adf4 100644 --- a/relayer/pkg/chainlink/txm/nonce_test.go +++ b/relayer/pkg/chainlink/txm/nonce_test.go @@ -56,7 +56,6 @@ func TestNonceManager_NextSequence(t *testing.T) { // should fail with invalid address randAddr1 := starknetutils.BigIntToFelt(big.NewInt(1)) - require.NoError(t, err) _, err = nm.NextSequence(randAddr1, chainId) require.Error(t, err) assert.Contains(t, err.Error(), fmt.Sprintf("nonce tracking does not exist for key: %s", randAddr1.String())) @@ -93,7 +92,6 @@ func TestNonceManager_IncrementNextSequence(t *testing.T) { // should fail with invalid address randAddr1 := starknetutils.BigIntToFelt(big.NewInt(1)) - require.NoError(t, err) err = nm.IncrementNextSequence(randAddr1, chainId, initPlusOne) require.Error(t, err) assert.Contains(t, err.Error(), fmt.Sprintf("nonce tracking does not exist for key: %s", randAddr1.String())) diff --git a/relayer/pkg/chainlink/txm/txstore.go b/relayer/pkg/chainlink/txm/txstore.go index ceb20935b..7d20ac880 100644 --- a/relayer/pkg/chainlink/txm/txstore.go +++ b/relayer/pkg/chainlink/txm/txstore.go @@ -24,6 +24,7 @@ func NewTxStore(current *felt.Felt) *TxStore { } } +// TODO: Save should make a copy otherwise wee're modiffying the same memory and could loop func (s *TxStore) Save(nonce *felt.Felt, hash string) error { s.lock.Lock() defer s.lock.Unlock() @@ -45,7 +46,7 @@ func (s *TxStore) Save(nonce *felt.Felt, hash string) error { // find next unused nonce _, exists := s.nonceToHash[s.currentNonce] for exists { - s.currentNonce.Add(s.currentNonce, new(felt.Felt).SetUint64(1)) + s.currentNonce = new(felt.Felt).Add(s.currentNonce, new(felt.Felt).SetUint64(1)) _, exists = s.nonceToHash[s.currentNonce] } return nil diff --git a/relayer/pkg/chainlink/txm/txstore_test.go b/relayer/pkg/chainlink/txm/txstore_test.go index 648996173..cbba2c81f 100644 --- a/relayer/pkg/chainlink/txm/txstore_test.go +++ b/relayer/pkg/chainlink/txm/txstore_test.go @@ -19,7 +19,7 @@ func TestTxStore(t *testing.T) { s := NewTxStore(&felt.Zero) assert.Equal(t, 0, s.InflightCount()) - require.NoError(t, s.Save(&felt.Zero, "0x0")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(0), "0x0")) assert.Equal(t, 1, s.InflightCount()) assert.Equal(t, []string{"0x0"}, s.GetUnconfirmed()) require.NoError(t, s.Confirm("0x0")) @@ -31,10 +31,10 @@ func TestTxStore(t *testing.T) { t.Parallel() // create - s := NewTxStore(&felt.Zero) + s := NewTxStore(new(felt.Felt).SetUint64(0)) // accepts tx in order - require.NoError(t, s.Save(&felt.Zero, "0x0")) + require.NoError(t, s.Save(new(felt.Felt).SetUint64(0), "0x0")) assert.Equal(t, 1, s.InflightCount()) assert.Equal(t, new(felt.Felt).SetUint64(1), s.currentNonce) @@ -54,7 +54,7 @@ func TestTxStore(t *testing.T) { assert.Equal(t, new(felt.Felt).SetUint64(3), s.currentNonce) // rejects old nonce - require.ErrorContains(t, s.Save(&felt.Zero, "0xold"), "nonce too low: 0 < 3 (lowest)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(0), "0xold"), "nonce too low: 0 < 3 (lowest)") assert.Equal(t, 4, s.InflightCount()) // reject already in use nonce @@ -86,7 +86,7 @@ func TestTxStore(t *testing.T) { t.Parallel() // init store - s := NewTxStore(&felt.Zero) + s := NewTxStore(new(felt.Felt).SetUint64(0)) for i := 0; i < 5; i++ { require.NoError(t, s.Save(new(felt.Felt).SetUint64(uint64(i)), "0x"+fmt.Sprintf("%d", i))) } From 5a11cd9360889d5b2a14263f48dead851edc753d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 11 Jan 2024 13:40:26 +0900 Subject: [PATCH 07/11] Fix nonce manager so it passes tests --- relayer/pkg/chainlink/txm/txstore.go | 24 +++++++++++------------ relayer/pkg/chainlink/txm/txstore_test.go | 14 ++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/relayer/pkg/chainlink/txm/txstore.go b/relayer/pkg/chainlink/txm/txstore.go index 7d20ac880..d56a2bafb 100644 --- a/relayer/pkg/chainlink/txm/txstore.go +++ b/relayer/pkg/chainlink/txm/txstore.go @@ -11,16 +11,16 @@ import ( // TxStore tracks broadcast & unconfirmed txs type TxStore struct { lock sync.RWMutex - nonceToHash map[*felt.Felt]string // map nonce to txhash - hashToNonce map[string]*felt.Felt // map hash to nonce - currentNonce *felt.Felt // minimum nonce + nonceToHash map[felt.Felt]string // map nonce to txhash + hashToNonce map[string]felt.Felt // map hash to nonce + currentNonce felt.Felt // minimum nonce } func NewTxStore(current *felt.Felt) *TxStore { return &TxStore{ - nonceToHash: map[*felt.Felt]string{}, - hashToNonce: map[string]*felt.Felt{}, - currentNonce: current, + nonceToHash: map[felt.Felt]string{}, + hashToNonce: map[string]felt.Felt{}, + currentNonce: *current, } } @@ -30,23 +30,23 @@ func (s *TxStore) Save(nonce *felt.Felt, hash string) error { defer s.lock.Unlock() if s.currentNonce.Cmp(nonce) == 1 { - return fmt.Errorf("nonce too low: %s < %s (lowest)", nonce, s.currentNonce) + return fmt.Errorf("nonce too low: %s < %s (lowest)", nonce, &s.currentNonce) } - if h, exists := s.nonceToHash[nonce]; exists { + if h, exists := s.nonceToHash[*nonce]; exists { return fmt.Errorf("nonce used: tried to use nonce (%s) for tx (%s), already used by (%s)", nonce, hash, h) } if n, exists := s.hashToNonce[hash]; exists { - return fmt.Errorf("hash used: tried to use tx (%s) for nonce (%s), already used nonce (%d)", hash, nonce, n) + return fmt.Errorf("hash used: tried to use tx (%s) for nonce (%s), already used nonce (%s)", hash, nonce, &n) } // store hash - s.nonceToHash[nonce] = hash - s.hashToNonce[hash] = nonce + s.nonceToHash[*nonce] = hash + s.hashToNonce[hash] = *nonce // find next unused nonce _, exists := s.nonceToHash[s.currentNonce] for exists { - s.currentNonce = new(felt.Felt).Add(s.currentNonce, new(felt.Felt).SetUint64(1)) + s.currentNonce = *new(felt.Felt).Add(&s.currentNonce, new(felt.Felt).SetUint64(1)) _, exists = s.nonceToHash[s.currentNonce] } return nil diff --git a/relayer/pkg/chainlink/txm/txstore_test.go b/relayer/pkg/chainlink/txm/txstore_test.go index cbba2c81f..3c7f500d5 100644 --- a/relayer/pkg/chainlink/txm/txstore_test.go +++ b/relayer/pkg/chainlink/txm/txstore_test.go @@ -36,33 +36,33 @@ func TestTxStore(t *testing.T) { // accepts tx in order require.NoError(t, s.Save(new(felt.Felt).SetUint64(0), "0x0")) assert.Equal(t, 1, s.InflightCount()) - assert.Equal(t, new(felt.Felt).SetUint64(1), s.currentNonce) + assert.Equal(t, new(felt.Felt).SetUint64(1), &s.currentNonce) // accepts tx that skips a nonce require.NoError(t, s.Save(new(felt.Felt).SetUint64(2), "0x2")) assert.Equal(t, 2, s.InflightCount()) - assert.Equal(t, new(felt.Felt).SetUint64(1), s.currentNonce) + assert.Equal(t, new(felt.Felt).SetUint64(1), &s.currentNonce) // accepts tx that fills in the missing nonce + fast forwards currentNonce require.NoError(t, s.Save(new(felt.Felt).SetUint64(1), "0x1")) assert.Equal(t, 3, s.InflightCount()) - assert.Equal(t, new(felt.Felt).SetUint64(3), s.currentNonce) + assert.Equal(t, new(felt.Felt).SetUint64(3), &s.currentNonce) // skip a nonce for later tests require.NoError(t, s.Save(new(felt.Felt).SetUint64(4), "0x4")) assert.Equal(t, 4, s.InflightCount()) - assert.Equal(t, new(felt.Felt).SetUint64(3), s.currentNonce) + assert.Equal(t, new(felt.Felt).SetUint64(3), &s.currentNonce) // rejects old nonce - require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(0), "0xold"), "nonce too low: 0 < 3 (lowest)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(0), "0xold"), "nonce too low: 0x0 < 0x3 (lowest)") assert.Equal(t, 4, s.InflightCount()) // reject already in use nonce - require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(4), "0xskip"), "nonce used: tried to use nonce (4) for tx (0xskip), already used by (0x4)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(4), "0xskip"), "nonce used: tried to use nonce (0x4) for tx (0xskip), already used by (0x4)") assert.Equal(t, 4, s.InflightCount()) // reject already in use tx hash - require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(5), "0x0"), "hash used: tried to use tx (0x0) for nonce (5), already used nonce (0)") + require.ErrorContains(t, s.Save(new(felt.Felt).SetUint64(5), "0x0"), "hash used: tried to use tx (0x0) for nonce (0x5), already used nonce (0x0)") assert.Equal(t, 4, s.InflightCount()) // race save From 704d4d1c004d0df47e22abc6d1c4664898675546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Fri, 12 Jan 2024 13:13:48 +0900 Subject: [PATCH 08/11] txm: Test now runs but signing is invalid --- ops/charts/devnet/templates/deployment.yaml | 2 +- ops/scripts/devnet-hardhat-down.sh | 16 +++--- ops/scripts/devnet-hardhat.sh | 5 +- .../chainlink/ocr2/contract_transmitter.go | 6 +- relayer/pkg/chainlink/txm/nonce.go | 10 ++-- relayer/pkg/chainlink/txm/nonce_test.go | 2 +- relayer/pkg/chainlink/txm/test_helpers.go | 1 - relayer/pkg/chainlink/txm/txm.go | 28 +++++----- relayer/pkg/chainlink/txm/txm_test.go | 56 ++++++++++++------- relayer/pkg/starknet/client.go | 8 +-- 10 files changed, 76 insertions(+), 58 deletions(-) diff --git a/ops/charts/devnet/templates/deployment.yaml b/ops/charts/devnet/templates/deployment.yaml index 50e22e7a3..df4bc41e7 100644 --- a/ops/charts/devnet/templates/deployment.yaml +++ b/ops/charts/devnet/templates/deployment.yaml @@ -48,7 +48,7 @@ spec: - name: cairo-build mountPath: /cairo-build image: "{{ .Values.repository | default "shardlabs/starknet-devnet-rs"}}:{{ .Values.tag | default "latest"}}" - args: ["--port", {{ .Values.service.internalPort | quote}}, "--seed", {{ .Values.seed | quote}}] + args: ["--port", {{ .Values.service.internalPort | quote}}, "--seed", {{ .Values.seed | quote}}, "--account-class", "cairo1"] {{- end }} imagePullPolicy: IfNotPresent {{- if eq .Values.real_node true }} diff --git a/ops/scripts/devnet-hardhat-down.sh b/ops/scripts/devnet-hardhat-down.sh index 193628820..4b9b02111 100755 --- a/ops/scripts/devnet-hardhat-down.sh +++ b/ops/scripts/devnet-hardhat-down.sh @@ -1,25 +1,25 @@ #!/usr/bin/env bash # TODO: this script needs to be replaced with a predefined K8s enviroment -echo "Cleaning up Starknet Devnet container..." +echo "Cleaning up Hardhat container..." -dpid=`docker ps | grep chainlink-starknet.starknet-devnet | awk '{print $1}'`; -echo "Checking for existing 'chainlink-starknet.starknet-devnet' docker container..." +dpid=`docker ps | grep chainlink-starknet.hardhat | awk '{print $1}'`; +echo "Checking for existing 'chainlink-starknet.hardhat' docker container..." if [ -z "$dpid" ] then - echo "No docker Starknet Devnet container running."; + echo "No docker Hardhat container running."; else docker kill $dpid; docker rm $dpid; fi -echo "Cleaning up Hardhat container..." +echo "Cleaning up Starknet Devnet container..." -dpid=`docker ps | grep chainlink-starknet.hardhat | awk '{print $1}'`; -echo "Checking for existing 'chainlink-starknet.hardhat' docker container..." +dpid=`docker ps | grep chainlink-starknet.starknet-devnet | awk '{print $1}'`; +echo "Checking for existing 'chainlink-starknet.starknet-devnet' docker container..." if [ -z "$dpid" ] then - echo "No docker Hardhat container running."; + echo "No docker Starknet Devnet container running."; else docker kill $dpid; docker rm $dpid; diff --git a/ops/scripts/devnet-hardhat.sh b/ops/scripts/devnet-hardhat.sh index 24163644a..e4b202d8f 100755 --- a/ops/scripts/devnet-hardhat.sh +++ b/ops/scripts/devnet-hardhat.sh @@ -27,8 +27,11 @@ docker run \ -p 127.0.0.1:5050:5050 \ -p 127.0.0.1:8545:8545 \ -d \ + -e RUST_LOG=debug \ --name chainlink-starknet.starknet-devnet \ - "shardlabs/starknet-devnet-rs:${container_version}" + "shardlabs/starknet-devnet-rs:${container_version}" \ + --seed 0 \ + --account-class cairo1 echo "Starting hardhat..." docker run --net container:chainlink-starknet.starknet-devnet -d --name chainlink-starknet.hardhat ethereumoptimism/hardhat-node:nightly diff --git a/relayer/pkg/chainlink/ocr2/contract_transmitter.go b/relayer/pkg/chainlink/ocr2/contract_transmitter.go index 32b7c98a9..d05da007b 100644 --- a/relayer/pkg/chainlink/ocr2/contract_transmitter.go +++ b/relayer/pkg/chainlink/ocr2/contract_transmitter.go @@ -7,9 +7,9 @@ import ( "github.com/pkg/errors" + "github.com/NethermindEth/juno/core/felt" starknetrpc "github.com/NethermindEth/starknet.go/rpc" starknetutils "github.com/NethermindEth/starknet.go/utils" - "github.com/NethermindEth/juno/core/felt" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/ocr2/medianreport" "github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm" @@ -23,7 +23,7 @@ type contractTransmitter struct { reader *transmissionsCache contractAddress *felt.Felt - senderAddress *felt.Felt + senderAddress *felt.Felt // account.publicKey accountAddress *felt.Felt txm txm.TxManager @@ -96,7 +96,7 @@ func (c *contractTransmitter) Transmit( return err } - err = c.txm.Enqueue(c.senderAddress, c.accountAddress, starknetrpc.FunctionCall{ + err = c.txm.Enqueue(c.accountAddress, c.senderAddress, starknetrpc.FunctionCall{ ContractAddress: c.contractAddress, EntryPointSelector: starknetutils.GetSelectorFromNameFelt("transmit"), Calldata: calldata, diff --git a/relayer/pkg/chainlink/txm/nonce.go b/relayer/pkg/chainlink/txm/nonce.go index 7d9587548..85436b3ae 100644 --- a/relayer/pkg/chainlink/txm/nonce.go +++ b/relayer/pkg/chainlink/txm/nonce.go @@ -21,7 +21,7 @@ type NonceManagerClient interface { type NonceManager interface { services.Service - Register(ctx context.Context, address *felt.Felt, chainId string, client NonceManagerClient) error + Register(ctx context.Context, address *felt.Felt, publicKey *felt.Felt, chainId string, client NonceManagerClient) error NextSequence(address *felt.Felt, chainID string) (*felt.Felt, error) IncrementNextSequence(address *felt.Felt, chainID string, currentNonce *felt.Felt) error @@ -65,12 +65,12 @@ func (nm *nonceManager) HealthReport() map[string]error { } // Register is used because we cannot pre-fetch nonces. the pubkey is known before hand, but the account address is not known until a job is started and sends a tx -func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, chainId string, client NonceManagerClient) error { +func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, publicKey *felt.Felt, chainId string, client NonceManagerClient) error { nm.lock.Lock() defer nm.lock.Unlock() - addressNonces, exists := nm.n[addr.String()] + addressNonces, exists := nm.n[publicKey.String()] if !exists { - nm.n[addr.String()] = map[string]*felt.Felt{} + nm.n[publicKey.String()] = map[string]*felt.Felt{} } _, exists = addressNonces[chainId] if !exists { @@ -78,7 +78,7 @@ func (nm *nonceManager) Register(ctx context.Context, addr *felt.Felt, chainId s if err != nil { return err } - nm.n[addr.String()][chainId] = n + nm.n[publicKey.String()][chainId] = n } return nil diff --git a/relayer/pkg/chainlink/txm/nonce_test.go b/relayer/pkg/chainlink/txm/nonce_test.go index 37600adf4..3ccfab00e 100644 --- a/relayer/pkg/chainlink/txm/nonce_test.go +++ b/relayer/pkg/chainlink/txm/nonce_test.go @@ -31,7 +31,7 @@ func newTestNonceManager(t *testing.T, chainID string, initNonce *felt.Felt) (tx c.On("AccountNonce", mock.Anything, mock.Anything).Return(initNonce, nil).Once() require.NoError(t, nm.Start(tests.Context(t))) - require.NoError(t, nm.Register(tests.Context(t), keyHash, chainID, c)) + require.NoError(t, nm.Register(tests.Context(t), keyHash, keyHash, chainID, c)) return nm, keyHash, func() { require.NoError(t, nm.Close()) } } diff --git a/relayer/pkg/chainlink/txm/test_helpers.go b/relayer/pkg/chainlink/txm/test_helpers.go index 9b5e10e7e..8cadf9307 100644 --- a/relayer/pkg/chainlink/txm/test_helpers.go +++ b/relayer/pkg/chainlink/txm/test_helpers.go @@ -37,7 +37,6 @@ func SetupLocalStarknetNode(t *testing.T) string { cmd := exec.Command("starknet-devnet", "--seed", "0", // use same seed for testing "--port", port, - "--lite-mode", ) var stdErr bytes.Buffer cmd.Stderr = &stdErr diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index 152d5d9d2..a3036c5f7 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -27,12 +27,12 @@ const ( ) type TxManager interface { - Enqueue(senderAddress *felt.Felt, accountAddress *felt.Felt, txFn starknetrpc.FunctionCall) error + Enqueue(accountAddress *felt.Felt, publicKey *felt.Felt, txFn starknetrpc.FunctionCall) error InflightCount() (int, int) } type Tx struct { - senderAddress *felt.Felt + publicKey *felt.Felt accountAddress *felt.Felt call starknetrpc.FunctionCall } @@ -114,7 +114,7 @@ func (txm *starktxm) broadcastLoop() { tx := <-txm.queue // broadcast tx serially - wait until accepted by mempool before processing next - hash, err := txm.broadcast(ctx, tx.senderAddress, tx.accountAddress, tx.call) + hash, err := txm.broadcast(ctx, tx.publicKey, tx.accountAddress, tx.call) if err != nil { txm.lggr.Errorw("transaction failed to broadcast", "error", err, "tx", tx.call) } else { @@ -126,15 +126,15 @@ func (txm *starktxm) broadcastLoop() { const FEE_MARGIN uint64 = 115 -func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, accountAddress *felt.Felt, call starknetrpc.FunctionCall) (txhash string, err error) { +func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accountAddress *felt.Felt, call starknetrpc.FunctionCall) (txhash string, err error) { client, err := txm.client.Get() if err != nil { txm.client.Reset() return txhash, fmt.Errorf("broadcast: failed to fetch client: %+w", err) } // create new account - accountVersion := 0 - account, err := starknetaccount.NewAccount(client.Provider, senderAddress, accountAddress.String(), txm.ks, accountVersion) + cairoVersion := 2 + account, err := starknetaccount.NewAccount(client.Provider, accountAddress, publicKey.String(), txm.ks, cairoVersion) if err != nil { return txhash, fmt.Errorf("failed to create new account: %+w", err) } @@ -144,7 +144,7 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, ac return txhash, fmt.Errorf("failed to get chainID: %+w", err) } - nonce, err := txm.nonce.NextSequence(accountAddress, chainID) + nonce, err := txm.nonce.NextSequence(publicKey, chainID) if err != nil { return txhash, fmt.Errorf("failed to get nonce: %+w", err) } @@ -174,7 +174,7 @@ func (txm *starktxm) broadcast(ctx context.Context, senderAddress *felt.Felt, ac // Signing of the transaction that is done by the account err = account.SignInvokeTransaction(context.Background(), &tx) if err != nil { - return txhash, err + return txhash, fmt.Errorf("failed to sign tx: %+w", err) } // get fee for tx @@ -292,13 +292,13 @@ func (txm *starktxm) HealthReport() map[string]error { return map[string]error{txm.Name(): txm.Healthy()} } -func (txm *starktxm) Enqueue(senderAddress, accountAddress *felt.Felt, tx starknetrpc.FunctionCall) error { +func (txm *starktxm) Enqueue(accountAddress, publicKey *felt.Felt, tx starknetrpc.FunctionCall) error { // validate key exists for sender // use the embedded Loopp Keystore to do this; the spec and design // encourage passing nil data to the loop.Keystore.Sign as way to test // existence of a key - if _, err := txm.ks.Loopp().Sign(context.Background(), senderAddress.String(), nil); err != nil { - return err + if _, err := txm.ks.Loopp().Sign(context.Background(), publicKey.String(), nil); err != nil { + return fmt.Errorf("enqueue: failed to sign: %+w", err) } client, err := txm.client.Get() @@ -313,12 +313,12 @@ func (txm *starktxm) Enqueue(senderAddress, accountAddress *felt.Felt, tx starkn } // register account for nonce manager - if err := txm.nonce.Register(context.TODO(), accountAddress, chainID, client); err != nil { - return err + if err := txm.nonce.Register(context.TODO(), accountAddress, publicKey, chainID, client); err != nil { + return fmt.Errorf("failed to register nonce: %+w", err) } select { - case txm.queue <- Tx{senderAddress: senderAddress, accountAddress: accountAddress, call: tx}: + case txm.queue <- Tx{publicKey: publicKey, accountAddress: accountAddress, call: tx}: // TODO fix naming here default: return fmt.Errorf("failed to enqueue transaction: %+v", tx) } diff --git a/relayer/pkg/chainlink/txm/txm_test.go b/relayer/pkg/chainlink/txm/txm_test.go index b365193fd..809ab9396 100644 --- a/relayer/pkg/chainlink/txm/txm_test.go +++ b/relayer/pkg/chainlink/txm/txm_test.go @@ -26,32 +26,49 @@ import ( func TestIntegration_Txm(t *testing.T) { n := 2 // number of txs per key - url := SetupLocalStarknetNode(t) + // url := SetupLocalStarknetNode(t) + url := "http://127.0.0.1:5050" devnet := devnet.NewDevNet(url) accounts, err := devnet.Accounts() require.NoError(t, err) + fmt.Println("qqq") // parse keys into expected format - localKeys := map[string]*big.Int{} - localAccounts := map[string]string{} + type Key struct { + PrivateKey *big.Int + Account string + } + localKeys := map[string]Key{} for i := range accounts { - privKey, err := utils.HexToBytes(accounts[i].PrivateKey) - require.NoError(t, err) - senderAddress, err := starknetutils.HexToFelt(accounts[i].PublicKey) - require.NoError(t, err) - localKeys[senderAddress.String()] = utils.BytesToBig(privKey) - localAccounts[senderAddress.String()] = accounts[i].Address + publicKey := accounts[i].PublicKey + fmt.Printf("account %v pubkey %v\n", accounts[i].Address, publicKey) + localKeys[publicKey] = Key{ + PrivateKey: starknetutils.HexToBN(accounts[i].PrivateKey), + Account: accounts[i].Address, + } } + // TODO: try using official keystore & signing instead + // Initializing the account memkeyStore + // ks := account.NewMemKeystore() + // fakePrivKeyBI, ok := new(big.Int).SetString(privateKey, 0) + // if !ok { + // panic(err.Error()) + // } + // ks.Put(public_key, fakePrivKeyBI) + + // error computing loopp signature key does not exist + // mock keystore - looppKs := NewLooppKeystore(func(id string) (*big.Int, error) { - key, ok := localKeys[id] + looppKs := NewLooppKeystore(func(publicKey string) (*big.Int, error) { + key, ok := localKeys[publicKey] if !ok { - return nil, fmt.Errorf("key does not exist id=%s", id) + return nil, fmt.Errorf("key does not exist id=%s", publicKey) } - return key, nil + return key.PrivateKey, nil }) ksAdapter := NewKeystoreAdapter(looppKs) + lggr, observer := logger.TestObserved(t, zapcore.DebugLevel) timeout := 10 * time.Second client, err := starknet.NewClient("SN_GOERLI", url+"/rpc", lggr, &timeout) @@ -75,28 +92,29 @@ func TestIntegration_Txm(t *testing.T) { // start txm + checks require.NoError(t, txm.Start(context.Background())) require.NoError(t, txm.Ready()) + fmt.Println("sss") - for senderAddressStr := range localKeys { - senderAddress, err := starknetutils.HexToFelt(senderAddressStr) + for publicKeyStr := range localKeys { + publicKey, err := starknetutils.HexToFelt(publicKeyStr) require.NoError(t, err) - account, err := starknetutils.HexToFelt(localAccounts[senderAddressStr]) + accountAddress, err := starknetutils.HexToFelt(localKeys[publicKeyStr].Account) require.NoError(t, err) contractAddress, err := starknetutils.HexToFelt("0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7") require.NoError(t, err) - selector := utils.GetSelectorFromNameFelt("totalSupply") + selector := starknetutils.GetSelectorFromNameFelt("totalSupply") for i := 0; i < n; i++ { - require.NoError(t, txm.Enqueue(senderAddress, account, starknetrpc.FunctionCall{ + require.NoError(t, txm.Enqueue(accountAddress, publicKey, starknetrpc.FunctionCall{ ContractAddress: contractAddress, // send to ETH token contract EntryPointSelector: selector, })) } } var empty bool - for i := 0; i < 60; i++ { + for i := 0; i < 30; i++ { time.Sleep(500 * time.Millisecond) queued, unconfirmed := txm.InflightCount() accepted := len(observer.FilterMessageSnippet("ACCEPTED_ON_L2").All()) diff --git a/relayer/pkg/starknet/client.go b/relayer/pkg/starknet/client.go index e27896a4e..02de45433 100644 --- a/relayer/pkg/starknet/client.go +++ b/relayer/pkg/starknet/client.go @@ -2,7 +2,6 @@ package starknet import ( "context" - "math/big" "time" "github.com/pkg/errors" @@ -10,7 +9,6 @@ import ( "github.com/NethermindEth/juno/core/felt" starknetaccount "github.com/NethermindEth/starknet.go/account" starknetrpc "github.com/NethermindEth/starknet.go/rpc" - starknetutils "github.com/NethermindEth/starknet.go/utils" ethrpc "github.com/ethereum/go-ethereum/rpc" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -199,9 +197,9 @@ func (c *Client) AccountNonce(ctx context.Context, accountAddress *felt.Felt) (* defer cancel() } - sender := starknetutils.BigIntToFelt(big.NewInt((0))) // not actually used in account.Nonce() - accountVersion := 0 - account, err := starknetaccount.NewAccount(c.Provider, sender, accountAddress.String(), nil, accountVersion) + sender := &felt.Zero // not actually used in account.Nonce() + cairoVersion := 2 + account, err := starknetaccount.NewAccount(c.Provider, accountAddress, sender.String(), nil, cairoVersion) if err != nil { return nil, errors.Wrap(err, "error in client.AccountNonce") } From 8ffd8d4cc2aeb31273dbf0e162aa968793ddd190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 16 Jan 2024 10:04:37 +0900 Subject: [PATCH 09/11] Fix devnet startup wait --- ops/scripts/devnet-hardhat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ops/scripts/devnet-hardhat.sh b/ops/scripts/devnet-hardhat.sh index e4b202d8f..af0cca3b4 100755 --- a/ops/scripts/devnet-hardhat.sh +++ b/ops/scripts/devnet-hardhat.sh @@ -48,7 +48,7 @@ do prev_output="${output}" fi - if [[ $output == *"Listening"* ]]; then + if [[ $output == *"listening"* ]]; then echo "" echo "starknet-devnet is ready." exit 0 From 042fb1b50f2887ed23f0bf72e42de3fa245b2973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 16 Jan 2024 10:04:56 +0900 Subject: [PATCH 10/11] fix txm implementation --- relayer/pkg/chainlink/txm/txm.go | 50 +++++++++++++-------------- relayer/pkg/chainlink/txm/txm_test.go | 11 ------ 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index a3036c5f7..a9086b296 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "reflect" "sync" "time" @@ -160,6 +159,7 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun tx := starknetrpc.InvokeTxnV1{ MaxFee: maxfee, Version: starknetrpc.TransactionV1, + Signature: []*felt.Felt{}, Nonce: nonce, Type: starknetrpc.TransactionType_Invoke, SenderAddress: account.AccountAddress, @@ -171,23 +171,26 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun return txhash, err } - // Signing of the transaction that is done by the account - err = account.SignInvokeTransaction(context.Background(), &tx) - if err != nil { - return txhash, fmt.Errorf("failed to sign tx: %+w", err) - } + // TODO: if we estimate with sig then the hash changes and we have to re-sign + // if we don't then the signature is invalid?? // get fee for tx // optional - pass nonce to fee estimate (if nonce gets ahead, estimate may fail) // can we estimate fee without calling estimate - tbd with 1.0 - simFlags := []starknetrpc.SimulationFlag{} - feeEstimate, err := account.EstimateFee(ctx, []starknetrpc.BroadcastTxn{tx}, simFlags, starknetrpc.BlockID{Tag: "latest"}) - if err != nil { - return txhash, fmt.Errorf("failed to estimate fee: %+w", err) - } + // simFlags := []starknetrpc.SimulationFlag{} + // feeEstimate, err := account.EstimateFee(ctx, []starknetrpc.BroadcastTxn{tx}, simFlags, starknetrpc.BlockID{Tag: "latest"}) + // if err != nil { + // return txhash, fmt.Errorf("failed to estimate fee: %+w", err) + // } // expandedFee := new(felt.Felt).Mul(feeEstimate[0].OverallFee, FEE_MARGIN) // maxfee = new(felt.Felt).Div(expandedFee, new(felt.Felt).SetUint64(100)) - tx.MaxFee = feeEstimate[0].OverallFee // TODO: mul times margin + // tx.MaxFee = feeEstimate[0].OverallFee // TODO: mul times margin + + // Signing of the transaction that is done by the account + err = account.SignInvokeTransaction(context.Background(), &tx) + if err != nil { + return txhash, fmt.Errorf("failed to sign tx: %+w", err) + } execCtx, execCancel := context.WithTimeout(ctx, txm.cfg.TxTimeout()) defer execCancel() @@ -206,7 +209,7 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun // update nonce if transaction is successful hash := res.TransactionHash.String() err = errors.Join( - txm.nonce.IncrementNextSequence(accountAddress, chainID, nonce), + txm.nonce.IncrementNextSequence(publicKey, chainID, nonce), txm.txStore.Save(accountAddress, nonce, hash), ) return hash, err @@ -241,26 +244,21 @@ func (txm *starktxm) confirmLoop() { txm.lggr.Errorw("invalid felt value", "hash", hash) continue } - response, err := client.Provider.TransactionReceipt(ctx, f) + response, err := client.Provider.GetTransactionStatus(ctx, f) if err != nil { txm.lggr.Errorw("failed to fetch transaction status", "hash", hash, "error", err) continue } - // TODO: there's no more pending status so a txn status is always accepted or rejected - receipt, ok := response.(starknetrpc.InvokeTransactionReceipt) - if !ok { - txm.lggr.Errorw("wrong receipt type", "type", reflect.TypeOf(response)) - continue - } - status := receipt.GetExecutionStatus() + status := response.FinalityStatus - // if status == starknetrpc.TxnStatus_Accepted_On_L1 || status == starknetrpc.TxnStatus_Accepted_On_L2 || status == starknetrpc.TxnStatus_Rejected { - txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status) - if err := txm.txStore.Confirm(addr, hash); err != nil { - txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err) + // any status other than received + if status == starknetrpc.TxnStatus_Accepted_On_L1 || status == starknetrpc.TxnStatus_Accepted_On_L2 || status == starknetrpc.TxnStatus_Rejected { + txm.lggr.Debugw(fmt.Sprintf("tx confirmed: %s", status), "hash", hash, "status", status) + if err := txm.txStore.Confirm(addr, hash); err != nil { + txm.lggr.Errorw("failed to confirm tx in TxStore", "hash", hash, "sender", addr, "error", err) + } } - // } } } case <-txm.stop: diff --git a/relayer/pkg/chainlink/txm/txm_test.go b/relayer/pkg/chainlink/txm/txm_test.go index 809ab9396..08146c56b 100644 --- a/relayer/pkg/chainlink/txm/txm_test.go +++ b/relayer/pkg/chainlink/txm/txm_test.go @@ -48,17 +48,6 @@ func TestIntegration_Txm(t *testing.T) { } } - // TODO: try using official keystore & signing instead - // Initializing the account memkeyStore - // ks := account.NewMemKeystore() - // fakePrivKeyBI, ok := new(big.Int).SetString(privateKey, 0) - // if !ok { - // panic(err.Error()) - // } - // ks.Put(public_key, fakePrivKeyBI) - - // error computing loopp signature key does not exist - // mock keystore looppKs := NewLooppKeystore(func(publicKey string) (*big.Int, error) { key, ok := localKeys[publicKey] From 90c49ea576c5e009397ff986ffd4ca3f5fc2bd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 16 Jan 2024 15:51:17 +0900 Subject: [PATCH 11/11] Switch to v3 transactions for future compat --- relayer/pkg/chainlink/txm/txm.go | 53 +++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/relayer/pkg/chainlink/txm/txm.go b/relayer/pkg/chainlink/txm/txm.go index a9086b296..627fd9a3b 100644 --- a/relayer/pkg/chainlink/txm/txm.go +++ b/relayer/pkg/chainlink/txm/txm.go @@ -9,6 +9,7 @@ import ( "github.com/NethermindEth/juno/core/felt" starknetaccount "github.com/NethermindEth/starknet.go/account" + "github.com/NethermindEth/starknet.go/rpc" starknetrpc "github.com/NethermindEth/starknet.go/rpc" starknetutils "github.com/NethermindEth/starknet.go/utils" "golang.org/x/exp/maps" @@ -150,19 +151,33 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun // TODO: update to v3 - maxfee, err := starknetutils.HexToFelt("0x95e566845d000") - if err != nil { - return txhash, err - } + // maxfee, err := starknetutils.HexToFelt("0x95e566845d000") + // if err != nil { + // return txhash, err + // } // Building the tx struct - tx := starknetrpc.InvokeTxnV1{ - MaxFee: maxfee, - Version: starknetrpc.TransactionV1, - Signature: []*felt.Felt{}, - Nonce: nonce, + tx := starknetrpc.InvokeTxnV3{ Type: starknetrpc.TransactionType_Invoke, SenderAddress: account.AccountAddress, + Version: starknetrpc.TransactionV3, + Signature: []*felt.Felt{}, + Nonce: nonce, + ResourceBounds: starknetrpc.ResourceBoundsMapping{ // TODO: use proper values + L1Gas: starknetrpc.ResourceBounds{ + MaxAmount: "0x186a0", + MaxPricePerUnit: "0x5af3107a4000", + }, + L2Gas: starknetrpc.ResourceBounds{ + MaxAmount: "0x0", + MaxPricePerUnit: "0x0", + }, + }, + Tip: "0x0", + PayMasterData: []*felt.Felt{}, + AccountDeploymentData: []*felt.Felt{}, + NonceDataMode: rpc.DAModeL1, // TODO: confirm + FeeMode: rpc.DAModeL1, // TODO: confirm } // Building the Calldata with the help of FmtCalldata where we pass in the FnCall struct along with the Cairo version @@ -187,10 +202,20 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun // tx.MaxFee = feeEstimate[0].OverallFee // TODO: mul times margin // Signing of the transaction that is done by the account - err = account.SignInvokeTransaction(context.Background(), &tx) + // TODO: SignInvokeTransaction for V3 is missing so we do it by hand + // err = account.SignInvokeTransaction(context.Background(), &tx) + // if err != nil { + // return txhash, fmt.Errorf("failed to sign tx: %+w", err) + // } + hash, err := account.TransactionHashInvoke(tx) if err != nil { - return txhash, fmt.Errorf("failed to sign tx: %+w", err) + return txhash, err + } + signature, err := account.Sign(ctx, hash) + if err != nil { + return txhash, err } + tx.Signature = signature execCtx, execCancel := context.WithTimeout(ctx, txm.cfg.TxTimeout()) defer execCancel() @@ -207,12 +232,12 @@ func (txm *starktxm) broadcast(ctx context.Context, publicKey *felt.Felt, accoun } // update nonce if transaction is successful - hash := res.TransactionHash.String() + txhash = res.TransactionHash.String() err = errors.Join( txm.nonce.IncrementNextSequence(publicKey, chainID, nonce), - txm.txStore.Save(accountAddress, nonce, hash), + txm.txStore.Save(accountAddress, nonce, txhash), ) - return hash, err + return txhash, err } func (txm *starktxm) confirmLoop() {