Skip to content

Commit

Permalink
Merge branch 'develop' into verify-single-payment-token
Browse files Browse the repository at this point in the history
  • Loading branch information
austinborn authored Sep 14, 2023
2 parents b67c646 + d407306 commit 34f3cd0
Show file tree
Hide file tree
Showing 57 changed files with 514 additions and 377 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build-publish-develop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: 'Push develop to private ECR'
name: "Push develop to private ECR"

on:
push:
branches:
- develop
workflow_dispatch:
inputs:
git_ref:
description: "Git ref (commit SHA, branch name, tag name, etc.) to checkout"
required: true
env:
GIT_REF: ${{ github.event.inputs.git_ref || github.ref }}

jobs:
push-chainlink-develop:
Expand All @@ -25,7 +32,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

with:
ref: ${{ env.GIT_REF }}
- name: Build, sign and publish chainlink image
uses: ./.github/actions/build-sign-publish-chainlink
with:
Expand Down
6 changes: 3 additions & 3 deletions core/services/gateway/api/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const (
NoError ErrorCode = iota
UserMessageParseError
UnsupportedDONIdError
InternalHandlerError
HandlerError
RequestTimeoutError
NodeReponseEncodingError
FatalError
Expand All @@ -18,7 +18,7 @@ func ToJsonRPCErrorCode(errorCode ErrorCode) int {
NoError: 0,
UserMessageParseError: -32700, // Parse Error
UnsupportedDONIdError: -32602, // Invalid Params
InternalHandlerError: -32000, // Server Error
HandlerError: -32600, // Invalid Request
RequestTimeoutError: -32000, // Server Error
NodeReponseEncodingError: -32603, // Internal Error
FatalError: -32000, // Server Error
Expand All @@ -37,7 +37,7 @@ func ToHttpErrorCode(errorCode ErrorCode) int {
NoError: 200, // OK
UserMessageParseError: 400, // Bad Request
UnsupportedDONIdError: 400, // Bad Request
InternalHandlerError: 500, // Internal Server Error
HandlerError: 400, // Bad Request
RequestTimeoutError: 504, // Gateway Timeout
NodeReponseEncodingError: 500, // Internal Server Error
FatalError: 500, // Internal Server Error
Expand Down
2 changes: 1 addition & 1 deletion core/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (g *gateway) ProcessRequest(ctx context.Context, rawRequest []byte) (rawRes
responseCh := make(chan handlers.UserCallbackPayload, 1)
err = handler.HandleUserMessage(ctx, msg, responseCh)
if err != nil {
return newError(g.codec, msg.Body.MessageId, api.InternalHandlerError, err.Error())
return newError(g.codec, msg.Body.MessageId, api.HandlerError, err.Error())
}
// await response
var response handlers.UserCallbackPayload
Expand Down
4 changes: 2 additions & 2 deletions core/services/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ func TestGateway_ProcessRequest_HandlerError(t *testing.T) {

req := newSignedRequest(t, "abcd", "request", "testDON", []byte{})
response, statusCode := gw.ProcessRequest(testutils.Context(t), req)
requireJsonRPCError(t, response, "abcd", -32000, "failure")
require.Equal(t, 500, statusCode)
requireJsonRPCError(t, response, "abcd", -32600, "failure")
require.Equal(t, 400, statusCode)
}
5 changes: 3 additions & 2 deletions integration-tests/actions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/smartcontractkit/chainlink-env/environment"
"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
ctfClient "github.com/smartcontractkit/chainlink-testing-framework/client"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink-testing-framework/testreporters"
"github.com/smartcontractkit/chainlink-testing-framework/utils"

Expand Down Expand Up @@ -251,7 +252,7 @@ func TeardownSuite(
failingLogLevel zapcore.Level, // Examines logs after the test, and fails the test if any Chainlink logs are found at or above provided level
clients ...blockchain.EVMClient,
) error {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
if err := testreporters.WriteTeardownLogs(t, env, optionalTestReporter, failingLogLevel); err != nil {
return errors.Wrap(err, "Error dumping environment logs, leaving environment running for manual retrieval")
}
Expand Down Expand Up @@ -295,7 +296,7 @@ func TeardownRemoteSuite(
optionalTestReporter testreporters.TestReporter, // Optionally pass in a test reporter to log further metrics
client blockchain.EVMClient,
) error {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
var err error
if err = testreporters.SendReport(t, namespace, "./", optionalTestReporter); err != nil {
l.Warn().Err(err).Msg("Error writing test report")
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/lib/pq"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/utils"
"github.com/smartcontractkit/chainlink-testing-framework/logging"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
Expand Down Expand Up @@ -48,7 +48,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndex(
deltaStage time.Duration,
keyIndex int,
) (contracts.OCRv2Config, error) {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndex(chainlinkNodes, keyIndex)
if err != nil {
return contracts.OCRv2Config{}, err
Expand Down Expand Up @@ -172,7 +172,7 @@ func CreateOCRKeeperJobs(
keyIndex int,
registryVersion ethereum.KeeperRegistryVersion,
) {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
bootstrapNode := chainlinkNodes[0]
bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys()
require.NoError(t, err, "Shouldn't fail reading P2P keys from bootstrap node")
Expand Down
33 changes: 17 additions & 16 deletions integration-tests/actions/automation_ocr_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ package actions
import (
"encoding/json"
"fmt"
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
"github.com/rs/zerolog"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink-testing-framework/utils"
"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
"github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
Expand All @@ -30,24 +27,23 @@ import (
)

func BuildAutoOCR2ConfigVarsLocal(
t *testing.T,
l zerolog.Logger,
chainlinkNodes []*client.ChainlinkClient,
registryConfig contracts.KeeperRegistrySettings,
registrar string,
deltaStage time.Duration,
) (contracts.OCRv2Config, error) {
return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(t, chainlinkNodes, registryConfig, registrar, deltaStage, 0)
return BuildAutoOCR2ConfigVarsWithKeyIndexLocal(l, chainlinkNodes, registryConfig, registrar, deltaStage, 0)
}

func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(
t *testing.T,
l zerolog.Logger,
chainlinkNodes []*client.ChainlinkClient,
registryConfig contracts.KeeperRegistrySettings,
registrar string,
deltaStage time.Duration,
keyIndex int,
) (contracts.OCRv2Config, error) {
l := utils.GetTestLogger(t)
S, oracleIdentities, err := GetOracleIdentitiesWithKeyIndexLocal(chainlinkNodes, keyIndex)
if err != nil {
return contracts.OCRv2Config{}, err
Expand Down Expand Up @@ -136,13 +132,17 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(

var signers []common.Address
for _, signer := range signerOnchainPublicKeys {
require.Equal(t, 20, len(signer), "OnChainPublicKey '%v' has wrong length for address", signer)
if len(signer) != 20 {
return contracts.OCRv2Config{}, fmt.Errorf("OnChainPublicKey '%v' has wrong length for address", signer)
}
signers = append(signers, common.BytesToAddress(signer))
}

var transmitters []common.Address
for _, transmitter := range transmitterAccounts {
require.True(t, common.IsHexAddress(string(transmitter)), "TransmitAccount '%s' is not a valid Ethereum address", string(transmitter))
if !common.IsHexAddress(string(transmitter)) {
return contracts.OCRv2Config{}, fmt.Errorf("TransmitAccount '%s' is not a valid Ethereum address", string(transmitter))
}
transmitters = append(transmitters, common.HexToAddress(string(transmitter)))
}

Expand All @@ -164,6 +164,7 @@ func BuildAutoOCR2ConfigVarsWithKeyIndexLocal(

// CreateOCRKeeperJobs bootstraps the first node and to the other nodes sends ocr jobs
func CreateOCRKeeperJobsLocal(
l zerolog.Logger,
chainlinkNodes []*client.ChainlinkClient,
registryAddr string,
chainID int64,
Expand All @@ -173,7 +174,7 @@ func CreateOCRKeeperJobsLocal(
bootstrapNode := chainlinkNodes[0]
bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys()
if err != nil {
log.Error().Err(err).Msg("Shouldn't fail reading P2P keys from bootstrap node")
l.Error().Err(err).Msg("Shouldn't fail reading P2P keys from bootstrap node")
return err
}
bootstrapP2PId := bootstrapP2PIds.Data[0].Attributes.PeerID
Expand Down Expand Up @@ -201,20 +202,20 @@ func CreateOCRKeeperJobsLocal(
}
_, err = bootstrapNode.MustCreateJob(bootstrapSpec)
if err != nil {
log.Error().Err(err).Msg("Shouldn't fail creating bootstrap job on bootstrap node")
l.Error().Err(err).Msg("Shouldn't fail creating bootstrap job on bootstrap node")
return err
}

P2Pv2Bootstrapper := fmt.Sprintf("%s@%s:%d", bootstrapP2PId, bootstrapNode.InternalIP(), 6690)
for nodeIndex := 1; nodeIndex < len(chainlinkNodes); nodeIndex++ {
nodeTransmitterAddress, err := chainlinkNodes[nodeIndex].EthAddresses()
if err != nil {
log.Error().Err(err).Msgf("Shouldn't fail getting primary ETH address from OCR node %d", nodeIndex+1)
l.Error().Err(err).Msgf("Shouldn't fail getting primary ETH address from OCR node %d", nodeIndex+1)
return err
}
nodeOCRKeys, err := chainlinkNodes[nodeIndex].MustReadOCR2Keys()
if err != nil {
log.Error().Err(err).Msgf("Shouldn't fail getting OCR keys from OCR node %d", nodeIndex+1)
l.Error().Err(err).Msgf("Shouldn't fail getting OCR keys from OCR node %d", nodeIndex+1)
return err
}
var nodeOCRKeyId []string
Expand Down Expand Up @@ -248,11 +249,11 @@ func CreateOCRKeeperJobsLocal(

_, err = chainlinkNodes[nodeIndex].MustCreateJob(&autoOCR2JobSpec)
if err != nil {
log.Error().Err(err).Msgf("Shouldn't fail creating OCR Task job on OCR node %d err: %+v", nodeIndex+1, err)
l.Error().Err(err).Msgf("Shouldn't fail creating OCR Task job on OCR node %d err: %+v", nodeIndex+1, err)
return err
}

}
log.Info().Msg("Done creating OCR automation jobs")
l.Info().Msg("Done creating OCR automation jobs")
return nil
}
14 changes: 7 additions & 7 deletions integration-tests/actions/keeper_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/utils"
"github.com/smartcontractkit/chainlink-testing-framework/logging"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
Expand Down Expand Up @@ -339,7 +339,7 @@ func RegisterUpkeepContracts(t *testing.T, linkToken contracts.LinkToken, linkFu
}

func RegisterUpkeepContractsWithCheckData(t *testing.T, linkToken contracts.LinkToken, linkFunds *big.Int, client blockchain.EVMClient, upkeepGasLimit uint32, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, numberOfContracts int, upkeepAddresses []string, checkData [][]byte, isLogTrigger bool) []*big.Int {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
registrationTxHashes := make([]common.Hash, 0)
upkeepIds := make([]*big.Int, 0)
for contractCount, upkeepAddress := range upkeepAddresses {
Expand Down Expand Up @@ -398,7 +398,7 @@ func RegisterUpkeepContractsWithCheckData(t *testing.T, linkToken contracts.Link
}

func DeployKeeperConsumers(t *testing.T, contractDeployer contracts.ContractDeployer, client blockchain.EVMClient, numberOfContracts int, isLogTrigger bool) []contracts.KeeperConsumer {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
keeperConsumerContracts := make([]contracts.KeeperConsumer, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand Down Expand Up @@ -441,7 +441,7 @@ func DeployKeeperConsumersPerformance(
checkGasToBurn, // How much gas should be burned on checkUpkeep() calls
performGasToBurn int64, // How much gas should be burned on performUpkeep() calls
) []contracts.KeeperConsumerPerformance {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
upkeeps := make([]contracts.KeeperConsumerPerformance, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand Down Expand Up @@ -478,7 +478,7 @@ func DeployPerformDataChecker(
numberOfContracts int,
expectedData []byte,
) []contracts.KeeperPerformDataChecker {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
upkeeps := make([]contracts.KeeperPerformDataChecker, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand Down Expand Up @@ -510,7 +510,7 @@ func DeployUpkeepCounters(
testRange *big.Int,
interval *big.Int,
) []contracts.UpkeepCounter {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
upkeepCounters := make([]contracts.UpkeepCounter, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand Down Expand Up @@ -543,7 +543,7 @@ func DeployUpkeepPerformCounterRestrictive(
testRange *big.Int,
averageEligibilityCadence *big.Int,
) []contracts.UpkeepPerformCounterRestrictive {
l := utils.GetTestLogger(t)
l := logging.GetTestLogger(t)
upkeepCounters := make([]contracts.UpkeepPerformCounterRestrictive, 0)

for contractCount := 0; contractCount < numberOfContracts; contractCount++ {
Expand Down
13 changes: 7 additions & 6 deletions integration-tests/actions/keeper_helpers_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package actions
import (
"fmt"

"github.com/rs/zerolog/log"
"github.com/rs/zerolog"

"github.com/smartcontractkit/chainlink/integration-tests/client"
"github.com/smartcontractkit/chainlink/integration-tests/contracts"
)

func CreateKeeperJobsLocal(
l zerolog.Logger,
chainlinkNodes []*client.ChainlinkClient,
keeperRegistry contracts.KeeperRegistry,
ocrConfig contracts.OCRv2Config,
Expand All @@ -19,12 +20,12 @@ func CreateKeeperJobsLocal(
primaryNode := chainlinkNodes[0]
primaryNodeAddress, err := primaryNode.PrimaryEthAddress()
if err != nil {
log.Error().Err(err).Msg("Reading ETH Keys from Chainlink Client shouldn't fail")
l.Error().Err(err).Msg("Reading ETH Keys from Chainlink Client shouldn't fail")
return nil, err
}
nodeAddresses, err := ChainlinkNodeAddressesLocal(chainlinkNodes)
if err != nil {
log.Error().Err(err).Msg("Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail")
l.Error().Err(err).Msg("Retrieving on-chain wallet addresses for chainlink nodes shouldn't fail")
return nil, err
}
nodeAddressesStr, payees := make([]string, 0), make([]string, 0)
Expand All @@ -34,14 +35,14 @@ func CreateKeeperJobsLocal(
}
err = keeperRegistry.SetKeepers(nodeAddressesStr, payees, ocrConfig)
if err != nil {
log.Error().Err(err).Msg("Setting keepers in the registry shouldn't fail")
l.Error().Err(err).Msg("Setting keepers in the registry shouldn't fail")
return nil, err
}
jobs := []*client.Job{}
for _, chainlinkNode := range chainlinkNodes {
chainlinkNodeAddress, err := chainlinkNode.PrimaryEthAddress()
if err != nil {
log.Error().Err(err).Msg("Error retrieving chainlink node address")
l.Error().Err(err).Msg("Error retrieving chainlink node address")
return nil, err
}
job, err := chainlinkNode.MustCreateJob(&client.KeeperJobSpec{
Expand All @@ -52,7 +53,7 @@ func CreateKeeperJobsLocal(
MinIncomingConfirmations: 1,
})
if err != nil {
log.Error().Err(err).Msg("Creating KeeperV2 Job shouldn't fail")
l.Error().Err(err).Msg("Creating KeeperV2 Job shouldn't fail")
return nil, err
}
jobs = append(jobs, job)
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/actions/ocr2_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"
Expand Down Expand Up @@ -360,13 +361,14 @@ func StartNewOCR2Round(
ocrInstances []contracts.OffchainAggregatorV2,
client blockchain.EVMClient,
timeout time.Duration,
logger zerolog.Logger,
) error {
for i := 0; i < len(ocrInstances); i++ {
err := ocrInstances[i].RequestNewRound()
if err != nil {
return fmt.Errorf("requesting new OCR round %d have failed: %w", i+1, err)
}
ocrRound := contracts.NewOffchainAggregatorV2RoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), timeout)
ocrRound := contracts.NewOffchainAggregatorV2RoundConfirmer(ocrInstances[i], big.NewInt(roundNumber), timeout, logger)
client.AddHeaderEventSubscription(ocrInstances[i].Address(), ocrRound)
err = client.WaitForEvents()
if err != nil {
Expand Down
Loading

0 comments on commit 34f3cd0

Please sign in to comment.