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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-tips-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Optimize beholder validator in system tests (part 2)
5 changes: 5 additions & 0 deletions .changeset/slick-drinks-like.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Update PoR workflow to use chainlink BalanceReader bindings
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/ethereum/go-ethereum v1.16.2
github.com/smartcontractkit/chain-selectors v1.0.67
github.com/smartcontractkit/chainlink-common v0.9.6
github.com/smartcontractkit/chainlink-evm/gethwrappers v0.0.0-20251003122604-772b72191274
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20250918131840-564fe2776a35
github.com/smartcontractkit/cre-sdk-go v0.8.0
github.com/smartcontractkit/cre-sdk-go/capabilities/blockchain/evm v0.8.0
Expand All @@ -17,13 +18,26 @@ require (
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.20.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/consensys/gnark-crypto v0.18.0 // indirect
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
github.com/ethereum/c-kzg-4844/v2 v2.1.0 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
Expand All @@ -36,11 +50,16 @@ require (
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/smartcontractkit/libocr v0.0.0-20250707144819-babe0ec4e358 // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/supranational/blst v0.3.14 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
google.golang.org/protobuf v1.36.7 // indirect
)

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"log/slog"
"math/big"
"strings"
"time"

"gopkg.in/yaml.v3"
Expand All @@ -27,31 +26,10 @@ import (
"github.com/smartcontractkit/cre-sdk-go/cre/wasm"

"github.com/smartcontractkit/chainlink-common/pkg/workflows/sdk"
"github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/balance_reader"
types "github.com/smartcontractkit/chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based/types"
)

const balanceReaderABIJson = `[
{
"inputs":[
{
"internalType":"address[]",
"name":"addresses",
"type":"address[]"
}
],
"name":"getNativeBalances",
"outputs":[
{
"internalType":"uint256[]",
"name":"",
"type":"uint256[]"
}
],
"stateMutability":"view",
"type":"function"
}
]`

func RunProofOfReservesWorkflow(config types.WorkflowConfig, logger *slog.Logger, secretsProvider cre.SecretsProvider) (cre.Workflow[types.WorkflowConfig], error) {
return cre.Workflow[types.WorkflowConfig]{
cre.Handler(
Expand Down Expand Up @@ -90,7 +68,7 @@ func onTrigger(config types.WorkflowConfig, runtime cre.Runtime, payload *cron.P
runtime.Logger().With().Info(fmt.Sprintf("[logger] Got on-chain balance with BalanceAt() for address %s: %s", addressToRead1, balanceAtResult.String()))

// get balance with CallContract
readBalancesParsedABI, err := getReadBalancesContractABI(runtime, balanceReaderABIJson)
readBalancesParsedABI, err := getReadBalancesContractABI(runtime)
if err != nil {
runtime.Logger().Error(fmt.Sprintf("failed to get ReadBalances ABI: %v", err))
return "", fmt.Errorf("failed to get ReadBalances ABI: %w", err)
Expand Down Expand Up @@ -179,17 +157,18 @@ func onTrigger(config types.WorkflowConfig, runtime cre.Runtime, payload *cron.P
return message, nil
}

func getReadBalancesContractABI(runtime cre.Runtime, balanceReaderABI string) (abi.ABI, error) {
parsedABI, err := abi.JSON(strings.NewReader(balanceReaderABI))
if err != nil {
runtime.Logger().Error(fmt.Sprintf("failed to parse ABI: %v", err))
return abi.ABI{}, fmt.Errorf("failed to parse ABI: %w", err)
func getReadBalancesContractABI(runtime cre.Runtime) (*abi.ABI, error) {
runtime.Logger().Info("getting Balance Reader contract ABI")
readBalancesABI, abiErr := balance_reader.BalanceReaderMetaData.GetAbi()
if abiErr != nil {
runtime.Logger().Error("failed to get Balance Reader contract ABI", "error", abiErr)
return nil, fmt.Errorf("failed to get Balance Reader contract ABI: %w", abiErr)
}
runtime.Logger().With().Info(fmt.Sprintln("Parsed ABI successfully"))
return parsedABI, nil
runtime.Logger().Info("successfully got Balance Reader contract ABI")
return readBalancesABI, nil
}

func readBalancesFromContract(addresses []common.Address, readBalancesABI abi.ABI, evmClient evm.Client, runtime cre.Runtime, config types.WorkflowConfig) (*evm.CallContractReply, error) {
func readBalancesFromContract(addresses []common.Address, readBalancesABI *abi.ABI, evmClient evm.Client, runtime cre.Runtime, config types.WorkflowConfig) (*evm.CallContractReply, error) {
methodName := "getNativeBalances"
packedData, err := readBalancesABI.Pack(methodName, addresses)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ flowchart LR
chainlink/core/scripts/cre/environment/examples/workflows/v2/cron --> cre-sdk-go/capabilities/scheduler/cron
click chainlink/core/scripts/cre/environment/examples/workflows/v2/cron href "https://github.com/smartcontractkit/chainlink"
chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based --> chainlink-common
chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based --> chainlink-evm/gethwrappers
chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based --> cre-sdk-go/capabilities/blockchain/evm
chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based --> cre-sdk-go/capabilities/networking/http
chainlink/core/scripts/cre/environment/examples/workflows/v2/proof-of-reserve/cron-based --> cre-sdk-go/capabilities/scheduler/cron
Expand Down
2 changes: 1 addition & 1 deletion system-tests/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ replace github.com/smartcontractkit/chainlink/system-tests/tests/regression/cre/

require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/avast/retry-go/v4 v4.6.1
github.com/confluentinc/confluent-kafka-go v1.9.2
github.com/ethereum/go-ethereum v1.16.3
github.com/fbsobreira/gotron-sdk v0.0.0-20250403083053-2943ce8c759b
Expand Down Expand Up @@ -124,7 +125,6 @@ require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/atombender/go-jsonschema v0.16.1-0.20240916205339-a74cd4e2851c // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/avast/retry-go/v4 v4.6.1 // indirect
github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect
github.com/aws/aws-sdk-go v1.55.7 // indirect
github.com/aws/aws-sdk-go-v2 v1.38.1 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Inside `core/scripts/cre/environment` directory
2. Identify the appropriate topology that you want to test
3. Stop and clear any existing environment: `go run . env stop -a`
4. Run: `CTF_CONFIGS=<path-to-your-topology-config> go run . env start && ./bin/ctf obs up` to start env + observability
5. Optionally run blockscout `./bin/ctf bs up`
6. Execute the tests in `system-tests/tests/regression/cre`: `go test -timeout 15m -run "^Test_CRE_V2"`.
5. Optionally run the Blockscout (chain explorer) `./bin/ctf bs up`
6. Execute the tests in `system-tests/tests/regression/cre`: `go test -timeout 15m -run "^Test_CRE_V2"`
*/
func Test_CRE_V2_Consensus_Regression(t *testing.T) {
// a template for Consensus negative tests names to avoid duplication
Expand Down
4 changes: 2 additions & 2 deletions system-tests/tests/regression/cre/v2_evm_regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var evmNegativeTestsFilterLogsWithInvalidAddress = []evmNegativeTest{
}

var evmNegativeTestsFilterLogsWithInvalidFromBlock = []evmNegativeTest{
// FilterLogs - invalid TromBlock/ToBlock values
// FilterLogs - invalid FromBlock/ToBlock values
// Distance between blocks should not be more than 100
{"negative number", "-1", filterLogsInvalidFromBlock, "block number -1 is not supported"},
{"zero", "0", filterLogsInvalidFromBlock, "block number 0 is not supported"},
Expand Down Expand Up @@ -214,7 +214,7 @@ func EVMReadFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, evmNegative
t_helpers.CompileAndDeployWorkflow(t, testEnv, testLogger, workflowName, &workflowConfig, workflowFileLocation)

expectedError := evmNegativeTest.expectedError
timeout := 90 * time.Second
timeout := 2 * time.Minute
err := t_helpers.AssertBeholderMessage(listenerCtx, t, expectedError, testLogger, messageChan, kafkaErrChan, timeout)
require.NoError(t, err, "EVM Read Fail test failed")
testLogger.Info().Msg("EVM Read Fail test successfully completed")
Expand Down
Loading
Loading