Skip to content

Commit

Permalink
Merge branch 'develop' into fix/batch-call-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-momin committed Feb 22, 2024
2 parents d95e188 + 63c286d commit 3c8125a
Show file tree
Hide file tree
Showing 89 changed files with 4,342 additions and 264 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/automation-nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,30 @@ jobs:
env:
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
CHAINLINK_ENV_USER: ${{ github.actor }}
TEST_LOG_LEVEL: debug
TEST_LOG_LEVEL: info
SELECTED_NETWORKS: "SIMULATED"
strategy:
fail-fast: false
matrix:
tests:
- name: Upgrade
- name: Upgrade 2.0
suite: smoke
nodes: 6
nodes: 1
os: ubuntu20.04-8cores-32GB
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade$ ./smoke
command: -run ^TestAutomationNodeUpgrade/registry_2_0 ./smoke
- name: Upgrade 2.1
suite: smoke
nodes: 5
os: ubuntu20.04-8cores-32GB
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_1 ./smoke
- name: Upgrade 2.2
suite: smoke
nodes: 5
os: ubuntu20.04-8cores-32GB
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_2 ./smoke
runs-on: ${{ matrix.tests.os }}
name: Automation ${{ matrix.tests.name }} Test
steps:
Expand Down Expand Up @@ -184,7 +196,7 @@ jobs:
strategy:
fail-fast: false
matrix:
name: [ Upgrade ]
name: [ Upgrade 2.0, Upgrade 2.1, Upgrade 2.2 ]
steps:
- name: Get Results
id: test-results
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/automation-ondemand-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,32 +121,46 @@ jobs:
env:
CHAINLINK_COMMIT_SHA: ${{ github.sha }}
CHAINLINK_ENV_USER: ${{ github.actor }}
TEST_LOG_LEVEL: debug
TEST_LOG_LEVEL: info
strategy:
fail-fast: false
matrix:
tests:
- name: chaos
suite: chaos
nodes: 5
nodes: 15
os: ubuntu-latest
pyroscope_env: ci-automation-on-demand-chaos
network: SIMULATED
command: -run ^TestAutomationChaos$ ./chaos
- name: reorg
suite: reorg
nodes: 1
nodes: 5
os: ubuntu-latest
pyroscope_env: ci-automation-on-demand-reorg
network: SIMULATED_NONDEV
command: -run ^TestAutomationReorg$ ./reorg
- name: upgrade
- name: upgrade 2.0
suite: smoke
nodes: 1
os: ubuntu20.04-8cores-32GB
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_0 ./smoke
- name: upgrade 2.1
suite: smoke
nodes: 6
nodes: 1
os: ubuntu20.04-8cores-32GB
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade/registry_2_1 ./smoke
- name: upgrade 2.2
suite: smoke
nodes: 1
os: ubuntu20.04-8cores-32GB
pyroscope_env: ci-automation-on-demand-upgrade
network: SIMULATED
command: -run ^TestAutomationNodeUpgrade$ ./smoke
command: -run ^TestAutomationNodeUpgrade/registry_2_2 ./smoke
runs-on: ${{ matrix.tests.os }}
name: Automation On Demand ${{ matrix.tests.name }} Test
steps:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,7 @@ tools/flakeytests/coverage.txt
**/testdata/fuzz/*

# Runtime test configuration that might contain secrets
overrides.toml
overrides.toml

# Pythin venv
.venv/
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ gomodtidy: ## Run go mod tidy on all modules.
go mod tidy
cd ./core/scripts && go mod tidy
cd ./integration-tests && go mod tidy
cd ./integration-tests/load && go mod tidy

.PHONY: godoc
godoc: ## Install and run godoc
Expand Down
1 change: 1 addition & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
let config = {
abiExporter: {
path: './abi',
runOnCompile: true,
},
paths: {
artifacts: './artifacts',
Expand Down
2 changes: 1 addition & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"files": [
"src/v0.8",
"abi/src/v0.8"
"abi/v0.8"
],
"pnpm": {
"_comment": "See https://github.com/ethers-io/ethers.js/discussions/2849#discussioncomment-2696454",
Expand Down
16 changes: 10 additions & 6 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
evmtypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/keystone/generated/forwarder"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
)

var forwardABI = evmtypes.MustGetABI(forwarder.KeystoneForwarderMetaData.ABI)

func InitializeWrite(registry commontypes.CapabilitiesRegistry, legacyEVMChains legacyevm.LegacyChainContainer) error {
func InitializeWrite(registry commontypes.CapabilitiesRegistry, legacyEVMChains legacyevm.LegacyChainContainer, lggr logger.Logger) error {
for _, chain := range legacyEVMChains.Slice() {
capability := NewEvmWrite(chain)
capability := NewEvmWrite(chain, lggr)
if err := registry.Add(context.TODO(), capability); err != nil {
return err
}
Expand All @@ -41,12 +42,15 @@ var (
_ capabilities.ActionCapability = &EvmWrite{}
)

const defaultGasLimit = 200000

type EvmWrite struct {
chain legacyevm.Chain
capabilities.CapabilityInfo
lggr logger.Logger
}

func NewEvmWrite(chain legacyevm.Chain) *EvmWrite {
func NewEvmWrite(chain legacyevm.Chain, lggr logger.Logger) *EvmWrite {
// generate ID based on chain selector
name := fmt.Sprintf("write_%v", chain.ID())
chainName, err := chainselectors.NameFromChainId(chain.ID().Uint64())
Expand All @@ -64,6 +68,7 @@ func NewEvmWrite(chain legacyevm.Chain) *EvmWrite {
return &EvmWrite{
chain,
info,
lggr.Named("EvmWrite"),
}
}

Expand Down Expand Up @@ -153,6 +158,7 @@ func encodePayload(args []any, rawSelector string) ([]byte, error) {
}

func (cap *EvmWrite) Execute(ctx context.Context, callback chan<- capabilities.CapabilityResponse, request capabilities.CapabilityRequest) error {
cap.lggr.Debugw("Execute", "request", request)
// TODO: idempotency

// TODO: extract into ChainWriter?
Expand Down Expand Up @@ -184,8 +190,6 @@ func (cap *EvmWrite) Execute(ctx context.Context, callback chan<- capabilities.C

// TODO: validate encoded report is prefixed with workflowID and executionID that match the request meta

// unlimited gas in the MVP demo
gasLimit := 0
// No signature validation in the MVP demo
signatures := [][]byte{}

Expand All @@ -208,7 +212,7 @@ func (cap *EvmWrite) Execute(ctx context.Context, callback chan<- capabilities.C
FromAddress: config.FromAddress().Address(),
ToAddress: config.ForwarderAddress().Address(),
EncodedPayload: calldata,
FeeLimit: uint32(gasLimit),
FeeLimit: uint32(defaultGasLimit),
Meta: txMeta,
Strategy: strategy,
Checker: checker,
Expand Down
3 changes: 2 additions & 1 deletion core/capabilities/targets/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/configtest"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/evmtest"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey"

Expand Down Expand Up @@ -45,7 +46,7 @@ func TestEvmWrite(t *testing.T) {
evmcfg := evmtest.NewChainScopedConfig(t, cfg)
chain.On("Config").Return(evmcfg)

capability := targets.NewEvmWrite(chain)
capability := targets.NewEvmWrite(chain, logger.TestLogger(t))
ctx := testutils.Context(t)

config, err := values.NewMap(map[string]any{
Expand Down
13 changes: 9 additions & 4 deletions core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,15 @@ func NewLogPoller(orm ORM, ec Client, lggr logger.Logger, pollPeriod time.Durati
}

type Filter struct {
Name string // see FilterName(id, args) below
EventSigs evmtypes.HashArray
Addresses evmtypes.AddressArray
Retention time.Duration
Name string // see FilterName(id, args) below
Addresses evmtypes.AddressArray
EventSigs evmtypes.HashArray // list of possible values for eventsig (aka topic1)
Topic2 evmtypes.HashArray // list of possible values for topic2
Topic3 evmtypes.HashArray // list of possible values for topic3
Topic4 evmtypes.HashArray // list of possible values for topic4
Retention time.Duration // maximum amount of time to retain logs
MaxLogsKept uint64 // maximum number of logs to retain ( 0 = unlimited )
LogsPerBlock uint64 // rate limit ( maximum # of logs per block, 0 = unlimited )
}

// FilterName is a suggested convenience function for clients to construct unique filter names
Expand Down
10 changes: 5 additions & 5 deletions core/chains/evm/logpoller/log_poller_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,31 @@ func TestLogPoller_RegisterFilter(t *testing.T) {
require.Equal(t, 1, len(f.Addresses))
assert.Equal(t, common.HexToAddress("0x0000000000000000000000000000000000000000"), f.Addresses[0])

err := lp.RegisterFilter(Filter{"Emitter Log 1", []common.Hash{EmitterABI.Events["Log1"].ID}, []common.Address{a1}, 0})
err := lp.RegisterFilter(Filter{Name: "Emitter Log 1", EventSigs: []common.Hash{EmitterABI.Events["Log1"].ID}, Addresses: []common.Address{a1}})
require.NoError(t, err)
assert.Equal(t, []common.Address{a1}, lp.Filter(nil, nil, nil).Addresses)
assert.Equal(t, [][]common.Hash{{EmitterABI.Events["Log1"].ID}}, lp.Filter(nil, nil, nil).Topics)
validateFiltersTable(t, lp, orm)

// Should de-dupe EventSigs
err = lp.RegisterFilter(Filter{"Emitter Log 1 + 2", []common.Hash{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}, []common.Address{a2}, 0})
err = lp.RegisterFilter(Filter{Name: "Emitter Log 1 + 2", EventSigs: []common.Hash{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}, Addresses: []common.Address{a2}})
require.NoError(t, err)
assert.Equal(t, []common.Address{a1, a2}, lp.Filter(nil, nil, nil).Addresses)
assert.Equal(t, [][]common.Hash{{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}}, lp.Filter(nil, nil, nil).Topics)
validateFiltersTable(t, lp, orm)

// Should de-dupe Addresses
err = lp.RegisterFilter(Filter{"Emitter Log 1 + 2 dupe", []common.Hash{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}, []common.Address{a2}, 0})
err = lp.RegisterFilter(Filter{Name: "Emitter Log 1 + 2 dupe", EventSigs: []common.Hash{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}, Addresses: []common.Address{a2}})
require.NoError(t, err)
assert.Equal(t, []common.Address{a1, a2}, lp.Filter(nil, nil, nil).Addresses)
assert.Equal(t, [][]common.Hash{{EmitterABI.Events["Log1"].ID, EmitterABI.Events["Log2"].ID}}, lp.Filter(nil, nil, nil).Topics)
validateFiltersTable(t, lp, orm)

// Address required.
err = lp.RegisterFilter(Filter{"no address", []common.Hash{EmitterABI.Events["Log1"].ID}, []common.Address{}, 0})
err = lp.RegisterFilter(Filter{Name: "no address", EventSigs: []common.Hash{EmitterABI.Events["Log1"].ID}})
require.Error(t, err)
// Event required
err = lp.RegisterFilter(Filter{"No event", []common.Hash{}, []common.Address{a1}, 0})
err = lp.RegisterFilter(Filter{Name: "No event", Addresses: []common.Address{a1}})
require.Error(t, err)
validateFiltersTable(t, lp, orm)

Expand Down
Loading

0 comments on commit 3c8125a

Please sign in to comment.