Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonce Error Handling #365

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions integration-tests/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ package common

import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"
"testing"
"time"

chainconfig "github.com/smartcontractkit/chainlink-starknet/integration-tests/config"
"github.com/smartcontractkit/chainlink-starknet/integration-tests/testconfig"
"github.com/smartcontractkit/chainlink-starknet/ops/devnet"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/config"
"github.com/smartcontractkit/chainlink-starknet/relayer/pkg/starknet"
ctfconfig "github.com/smartcontractkit/chainlink-testing-framework/config"
"github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/chainlink"
mock_adapter "github.com/smartcontractkit/chainlink-testing-framework/k8s/pkg/helm/mock-adapter"
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"os"
"os/exec"
"strconv"
"strings"
"testing"
"time"

"github.com/google/uuid"
"github.com/lib/pq"
Expand Down Expand Up @@ -49,13 +51,14 @@ type TestEnvDetails struct {
}

type RPCDetails struct {
RPCL1Internal string
RPCL2Internal string
RPCL1External string
RPCL2External string
MockServerUrl string
MockServerEndpoint string
P2PPort string
RPCL1Internal string
RPCL2Internal string
RPCL2InternalApiKey string
RPCL1External string
RPCL2External string
MockServerUrl string
MockServerEndpoint string
P2PPort string
}

func New(testConfig *testconfig.TestConfig) *Common {
Expand All @@ -70,6 +73,15 @@ func New(testConfig *testconfig.TestConfig) *Common {
if *testConfig.Common.Network == "testnet" {
chainDetails = chainconfig.SepoliaConfig()
chainDetails.L2RPCInternal = *testConfig.Common.L2RPCUrl
if testConfig.Common.L2RPCApiKey == nil {
chainDetails.L2RPCInternalApiKey = ""
} else {
chainDetails.L2RPCInternalApiKey = *testConfig.Common.L2RPCApiKey
}
} else {
// set up mocked local feedernet server because starknet-devnet does not provide one
localDevnetFeederSrv := starknet.NewTestServer()
chainDetails.FeederURL = localDevnetFeederSrv.URL
}

c = &Common{
Expand All @@ -79,8 +91,9 @@ func New(testConfig *testconfig.TestConfig) *Common {
TestDuration: duration,
},
RPCDetails: &RPCDetails{
P2PPort: "6690",
RPCL2Internal: chainDetails.L2RPCInternal,
P2PPort: "6690",
RPCL2Internal: chainDetails.L2RPCInternal,
RPCL2InternalApiKey: chainDetails.L2RPCInternalApiKey,
},
}

Expand Down Expand Up @@ -136,12 +149,14 @@ func (c *Common) Default(t *testing.T, namespacePrefix string) (*Common, error)

func (c *Common) DefaultNodeConfig() *cl.Config {
starkConfig := config.TOMLConfig{
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
Enabled: ptr.Ptr(true),
ChainID: ptr.Ptr(c.ChainDetails.ChainID),
FeederURL: common_cfg.MustParseURL(c.ChainDetails.FeederURL),
Nodes: []*config.Node{
{
Name: ptr.Ptr("primary"),
URL: common_cfg.MustParseURL(c.RPCDetails.RPCL2Internal),
Name: ptr.Ptr("primary"),
URL: common_cfg.MustParseURL(c.RPCDetails.RPCL2Internal),
APIKey: ptr.Ptr(c.RPCDetails.RPCL2InternalApiKey),
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/common/gauntlet_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/smartcontractkit/chainlink-starknet/integration-tests/utils"
"os"

"github.com/smartcontractkit/chainlink-starknet/integration-tests/utils"
)

func (m *OCRv2TestState) fundNodes() ([]string, error) {
Expand All @@ -26,7 +27,7 @@ func (m *OCRv2TestState) fundNodes() ([]string, error) {
for _, key := range nAccounts {
// We are not deploying in parallel here due to testnet limitations (429 too many requests)
l.Debug().Msg(fmt.Sprintf("Funding node with address: %s", key))
_, err := m.Clients.GauntletClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "100000000000000000") // Transferring 0.1 STRK to each node
_, err := m.Clients.GauntletClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "1000000000000000000") // Transferring 0.1 STRK to each node
if err != nil {
return nil, err
}
Expand Down
12 changes: 7 additions & 5 deletions integration-tests/common/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ package common
import (
"context"
"fmt"
"net/http"

starknetdevnet "github.com/NethermindEth/starknet.go/devnet"
"github.com/go-resty/resty/v2"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
test_env_ctf "github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"net/http"

"math/big"
"testing"
"time"

test_env_starknet "github.com/smartcontractkit/chainlink-starknet/integration-tests/docker/test_env"
"github.com/smartcontractkit/chainlink-starknet/integration-tests/testconfig"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"math/big"
"testing"
"time"

"github.com/NethermindEth/juno/core/felt"
starknetutils "github.com/NethermindEth/starknet.go/utils"
Expand Down Expand Up @@ -200,7 +202,7 @@ func (m *OCRv2TestState) DeployCluster() {
require.NoError(m.TestConfig.T, m.TestConfig.err)
}
lggr := logger.Nop()
m.Clients.StarknetClient, m.TestConfig.err = starknet.NewClient(m.Common.ChainDetails.ChainID, m.Common.RPCDetails.RPCL2External, lggr, &rpcRequestTimeout)
m.Clients.StarknetClient, m.TestConfig.err = starknet.NewClient(m.Common.ChainDetails.ChainID, m.Common.RPCDetails.RPCL2External, m.Common.RPCDetails.RPCL2InternalApiKey, lggr, &rpcRequestTimeout)
require.NoError(m.TestConfig.T, m.TestConfig.err, "Creating starknet client should not fail")
m.Clients.OCR2Client, m.TestConfig.err = ocr2.NewClient(m.Clients.StarknetClient, lggr)
require.NoError(m.TestConfig.T, m.TestConfig.err, "Creating ocr2 client should not fail")
Expand Down
13 changes: 8 additions & 5 deletions integration-tests/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ var (
)

type Config struct {
ChainName string
ChainID string
StarkTokenAddress string
L2RPCInternal string
TokenName string
ChainName string
ChainID string
StarkTokenAddress string
L2RPCInternal string
L2RPCInternalApiKey string
TokenName string
FeederURL string
}

func SepoliaConfig() *Config {
Expand All @@ -19,6 +21,7 @@ func SepoliaConfig() *Config {
StarkTokenAddress: starkTokenAddress,
// Will be overridden if set in toml
L2RPCInternal: "https://starknet-sepolia.public.blastapi.io/rpc/v0_6",
FeederURL: "https://alpha-sepolia.starknet.io/feeder_gateway",
}
}

Expand Down
8 changes: 5 additions & 3 deletions integration-tests/smoke/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package smoke_test
import (
"flag"
"fmt"
"maps"
"os"
"testing"

"github.com/smartcontractkit/chainlink-starknet/integration-tests/common"
tc "github.com/smartcontractkit/chainlink-starknet/integration-tests/testconfig"
"github.com/smartcontractkit/chainlink-starknet/ops/gauntlet"
Expand All @@ -12,9 +16,6 @@ import (
"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"
"maps"
"os"
"testing"
)

var (
Expand Down Expand Up @@ -49,6 +50,7 @@ func TestOCRBasic(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
logging.Init()
//
state, err := common.NewOCRv2State(t, "smoke-ocr2", &config)
require.NoError(t, err, "Could not setup the ocrv2 state")

Expand Down
11 changes: 7 additions & 4 deletions integration-tests/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"embed"
"encoding/base64"
"fmt"
"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"
"os"
"strings"

"github.com/smartcontractkit/chainlink-testing-framework/docker/test_env"

"github.com/barkimedes/go-deepcopy"
"github.com/google/uuid"
"github.com/pelletier/go-toml/v2"
Expand Down Expand Up @@ -109,9 +110,11 @@ func (c *TestConfig) AsBase64() (string, error) {
}

type Common struct {
Network *string `toml:"network"`
InsideK8s *bool `toml:"inside_k8"`
User *string `toml:"user"`
Network *string `toml:"network"`
InsideK8s *bool `toml:"inside_k8"`
User *string `toml:"user"`
// if rpc requires api key to be passed as an HTTP header
L2RPCApiKey *string `toml:"l2_rpc_url_api_key"`
L2RPCUrl *string `toml:"l2_rpc_url"`
PrivateKey *string `toml:"private_key"`
Account *string `toml:"account"`
Expand Down
1 change: 1 addition & 0 deletions monitoring/cmd/monitoring/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func main() {
starknetClient, err := starknet.NewClient(
starknetConfig.GetChainID(),
starknetConfig.GetRPCEndpoint(),
starknetConfig.GetRPCApiKey(),
logger.With(log, "component", "starknet-client"),
&readTimeout,
)
Expand Down
13 changes: 13 additions & 0 deletions monitoring/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ require (

require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.3 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // 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.12.1 // indirect
Expand All @@ -36,10 +42,12 @@ require (
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/getsentry/sentry-go v0.19.0 // indirect
github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.4.0 // indirect
Expand All @@ -52,6 +60,9 @@ require (
github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/linkedin/goavro/v2 v2.12.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -68,9 +79,11 @@ require (
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/riferrei/srclient v0.5.4 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/test-go/testify v1.1.4 // indirect
Expand Down
Loading
Loading