Skip to content

Commit

Permalink
Merge branch 'develop' into re-2167/fix-network-policies-helm
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov committed Jan 18, 2024
2 parents 90987fe + 958e2c6 commit 3b20ba1
Show file tree
Hide file tree
Showing 98 changed files with 899 additions and 714 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
analyze:
name: Analyze ${{ matrix.language }}
runs-on: ubuntu20.04-4cores-16GB
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/solidity-hardhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
fail-fast: false
matrix:
split: ${{ fromJson(needs.split-tests.outputs.splits) }}
runs-on: ubuntu20.04-4cores-16GB
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
fail-fast: false
matrix:
split: ${{ fromJson(needs.split-tests.outputs.splits) }}
runs-on: ubuntu20.04-4cores-16GB
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
5 changes: 3 additions & 2 deletions common/config/chaintype.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ const (
ChainWeMix ChainType = "wemix"
ChainKroma ChainType = "kroma"
ChainZkSync ChainType = "zksync"
ChainScroll ChainType = "scroll"
)

var ErrInvalidChainType = fmt.Errorf("must be one of %s or omitted", strings.Join([]string{
string(ChainArbitrum), string(ChainMetis), string(ChainXDai), string(ChainOptimismBedrock), string(ChainCelo),
string(ChainKroma), string(ChainWeMix), string(ChainZkSync)}, ", "))
string(ChainKroma), string(ChainWeMix), string(ChainZkSync), string(ChainScroll)}, ", "))

// IsValid returns true if the ChainType value is known or empty.
func (c ChainType) IsValid() bool {
switch c {
case "", ChainArbitrum, ChainMetis, ChainOptimismBedrock, ChainXDai, ChainCelo, ChainKroma, ChainWeMix, ChainZkSync:
case "", ChainArbitrum, ChainMetis, ChainOptimismBedrock, ChainXDai, ChainCelo, ChainKroma, ChainWeMix, ChainZkSync, ChainScroll:
return true
}
return false
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults/Scroll_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ChainID = '534352'
FinalityDepth = 1
ChainType = 'scroll'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
# Scroll only emits blocks when a new tx is received, so this method of liveness detection is not useful
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults/Scroll_Sepolia.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ChainID = '534351'
FinalityDepth = 1
ChainType = 'scroll'
LogPollInterval = '3s'
MinIncomingConfirmations = 1
# Scroll only emits blocks when a new tx is received, so this method of liveness detection is not useful
Expand Down
12 changes: 11 additions & 1 deletion core/chains/evm/gas/rollups/l1_gas_price_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ const (
// `function l1BaseFee() external view returns (uint256);`
KromaGasOracle_l1BaseFee = "519b4bd3"

// GasOracleAddress is the address of the precompiled contract that exists on scroll chain.
// This is the case for Scroll.
ScrollGasOracleAddress = "0x5300000000000000000000000000000000000002"
// GasOracle_l1BaseFee is the a hex encoded call to:
// `function l1BaseFee() external view returns (uint256);`
ScrollGasOracle_l1BaseFee = "519b4bd3"

// Interval at which to poll for L1BaseFee. A good starting point is the L1 block time.
PollPeriod = 12 * time.Second
)

var supportedChainTypes = []config.ChainType{config.ChainArbitrum, config.ChainOptimismBedrock, config.ChainKroma}
var supportedChainTypes = []config.ChainType{config.ChainArbitrum, config.ChainOptimismBedrock, config.ChainKroma, config.ChainScroll}

func IsRollupWithL1Support(chainType config.ChainType) bool {
return slices.Contains(supportedChainTypes, chainType)
Expand All @@ -87,6 +94,9 @@ func NewL1GasPriceOracle(lggr logger.Logger, ethClient ethClient, chainType conf
case config.ChainKroma:
address = KromaGasOracleAddress
callArgs = KromaGasOracle_l1BaseFee
case config.ChainScroll:
address = ScrollGasOracleAddress
callArgs = ScrollGasOracle_l1BaseFee
default:
panic(fmt.Sprintf("Received unspported chaintype %s", chainType))
}
Expand Down
22 changes: 22 additions & 0 deletions core/chains/evm/gas/rollups/l1_gas_price_oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,26 @@ func TestL1GasPriceOracle(t *testing.T) {

assert.Equal(t, assets.NewWei(l1BaseFee), gasPrice)
})

t.Run("Calling GasPrice on started Scroll L1Oracle returns Scroll l1GasPrice", func(t *testing.T) {
l1BaseFee := big.NewInt(200)

ethClient := mocks.NewETHClient(t)
ethClient.On("CallContract", mock.Anything, mock.IsType(ethereum.CallMsg{}), mock.IsType(&big.Int{})).Run(func(args mock.Arguments) {
callMsg := args.Get(1).(ethereum.CallMsg)
blockNumber := args.Get(2).(*big.Int)
assert.Equal(t, ScrollGasOracleAddress, callMsg.To.String())
assert.Equal(t, ScrollGasOracle_l1BaseFee, fmt.Sprintf("%x", callMsg.Data))
assert.Nil(t, blockNumber)
}).Return(common.BigToHash(l1BaseFee).Bytes(), nil)

oracle := NewL1GasPriceOracle(logger.Test(t), ethClient, config.ChainScroll)
require.NoError(t, oracle.Start(testutils.Context(t)))
t.Cleanup(func() { assert.NoError(t, oracle.Close()) })

gasPrice, err := oracle.GasPrice(testutils.Context(t))
require.NoError(t, err)

assert.Equal(t, assets.NewWei(l1BaseFee), gasPrice)
})
}
4 changes: 2 additions & 2 deletions core/chains/evm/logpoller/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func populateDatabase(t testing.TB, o *logpoller.DbORM, chainID *big.Int) (commo
EventSig: event1,
Topics: [][]byte{event1[:], logpoller.EvmWord(uint64(i + 1000*j)).Bytes()},
Address: addr,
TxHash: utils.RandomAddress().Hash(),
TxHash: utils.RandomHash(),
Data: logpoller.EvmWord(uint64(i + 1000*j)).Bytes(),
CreatedAt: blockTimestamp,
})

}
require.NoError(t, o.InsertLogs(logs))
require.NoError(t, o.InsertBlock(utils.RandomAddress().Hash(), int64((j+1)*1000-1), startDate.Add(time.Duration(j*1000)*time.Hour), 0))
require.NoError(t, o.InsertBlock(utils.RandomHash(), int64((j+1)*1000-1), startDate.Add(time.Duration(j*1000)*time.Hour), 0))
}

return event1, address1, address2
Expand Down
14 changes: 7 additions & 7 deletions core/chains/evm/logpoller/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ func TestSelectLatestBlockNumberEventSigsAddrsWithConfs(t *testing.T) {
GenLog(th.ChainID, 2, 2, utils.RandomAddress().String(), event2[:], address2),
GenLog(th.ChainID, 2, 3, utils.RandomAddress().String(), event2[:], address2),
}))
require.NoError(t, th.ORM.InsertBlock(utils.RandomAddress().Hash(), 3, time.Now(), 1))
require.NoError(t, th.ORM.InsertBlock(utils.RandomHash(), 3, time.Now(), 1))

tests := []struct {
name string
Expand Down Expand Up @@ -1205,9 +1205,9 @@ func TestSelectLogsCreatedAfter(t *testing.T) {
GenLogWithTimestamp(th.ChainID, 2, 2, utils.RandomAddress().String(), event[:], address, block2ts),
GenLogWithTimestamp(th.ChainID, 1, 3, utils.RandomAddress().String(), event[:], address, block3ts),
}))
require.NoError(t, th.ORM.InsertBlock(utils.RandomAddress().Hash(), 1, block1ts, 0))
require.NoError(t, th.ORM.InsertBlock(utils.RandomAddress().Hash(), 2, block2ts, 1))
require.NoError(t, th.ORM.InsertBlock(utils.RandomAddress().Hash(), 3, block3ts, 2))
require.NoError(t, th.ORM.InsertBlock(utils.RandomHash(), 1, block1ts, 0))
require.NoError(t, th.ORM.InsertBlock(utils.RandomHash(), 2, block2ts, 1))
require.NoError(t, th.ORM.InsertBlock(utils.RandomHash(), 3, block3ts, 2))

type expectedLog struct {
block int64
Expand Down Expand Up @@ -1309,7 +1309,7 @@ func TestNestedLogPollerBlocksQuery(t *testing.T) {
require.Len(t, logs, 0)

// Persist block
require.NoError(t, th.ORM.InsertBlock(utils.RandomAddress().Hash(), 10, time.Now(), 0))
require.NoError(t, th.ORM.InsertBlock(utils.RandomHash(), 10, time.Now(), 0))

// Check if query actually works well with provided dataset
logs, err = th.ORM.SelectIndexedLogs(address, event, 1, []common.Hash{event}, logpoller.Unconfirmed)
Expand Down Expand Up @@ -1542,12 +1542,12 @@ func Benchmark_LogsDataWordBetween(b *testing.B) {
EventSig: commitReportAccepted,
Topics: [][]byte{},
Address: commitStoreAddress,
TxHash: utils.RandomAddress().Hash(),
TxHash: utils.RandomHash(),
Data: data,
CreatedAt: time.Now(),
})
}
require.NoError(b, o.InsertBlock(utils.RandomAddress().Hash(), int64(numberOfReports*numberOfMessagesPerReport), time.Now(), int64(numberOfReports*numberOfMessagesPerReport)))
require.NoError(b, o.InsertBlock(utils.RandomHash(), int64(numberOfReports*numberOfMessagesPerReport), time.Now(), int64(numberOfReports*numberOfMessagesPerReport)))
require.NoError(b, o.InsertLogs(dbLogs))

b.ResetTimer()
Expand Down
6 changes: 6 additions & 0 deletions core/chains/evm/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func RandomAddress() common.Address {
return common.BytesToAddress(b)
}

func RandomHash() common.Hash {
b := make([]byte, 32)
_, _ = rand.Read(b) // Assignment for errcheck. Only used in tests so we can ignore.
return common.BytesToHash(b)
}

// IsEmptyAddress checks that the address is empty, synonymous with the zero
// account/address. No logs can come from this address, as there is no contract
// present there.
Expand Down
7 changes: 7 additions & 0 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -56,6 +57,12 @@ import (
"github.com/smartcontractkit/chainlink/v2/plugins"
)

func init() {
// hack to undo geth's disruption of the std default logger
// remove with geth v1.13.10
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, nil)))
}

var (
initGlobalsOnce sync.Once
prometheus *ginprom.Prometheus
Expand Down
2 changes: 1 addition & 1 deletion core/config/docs/chains-evm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BlockBackfillDepth = 10 # Default
# BlockBackfillSkip enables skipping of very long backfills.
BlockBackfillSkip = false # Default
# ChainType is automatically detected from chain ID. Set this to force a certain chain type regardless of chain ID.
# Available types: arbitrum, metis, optimismBedrock, xdai, celo, kroma, wemix, zksync
# Available types: arbitrum, metis, optimismBedrock, xdai, celo, kroma, wemix, zksync, scroll
ChainType = 'arbitrum' # Example
# FinalityDepth is the number of blocks after which an ethereum transaction is considered "final". Note that the default is automatically set based on chain ID so it should not be necessary to change this under normal operation.
# BlocksConsideredFinal determines how deeply we look back to ensure that transactions are confirmed onto the longest chain
Expand Down
4 changes: 2 additions & 2 deletions core/config/mercury_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"time"

ocr2models "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/models"
"github.com/smartcontractkit/chainlink-common/pkg/types"
)

type MercuryCache interface {
Expand All @@ -17,7 +17,7 @@ type MercuryTLS interface {
}

type Mercury interface {
Credentials(credName string) *ocr2models.MercuryCredentials
Credentials(credName string) *types.MercuryCredentials
Cache() MercuryCache
TLS() MercuryTLS
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.12.2
GETH_VERSION: 1.13.8
functions: ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.abi ../../../contracts/solc/v0.8.19/functions/v1_X/FunctionsRequest.bin 3c972870b0afeb6d73a29ebb182f24956a2cebb127b21c4f867d1ecf19a762db
functions_allow_list: ../../../contracts/solc/v0.8.19/functions/v1_X/TermsOfServiceAllowList.abi ../../../contracts/solc/v0.8.19/functions/v1_X/TermsOfServiceAllowList.bin 6beec092fbb3b619dfe69f1ad23392b0bbaf00327b335e4080f921c7122a57e4
functions_billing_registry_events_mock: ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryEventsMock.abi ../../../contracts/solc/v0.8.6/functions/v0_0_0/FunctionsBillingRegistryEventsMock.bin 50deeb883bd9c3729702be335c0388f9d8553bab4be5e26ecacac496a89e2b77
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.12.2
GETH_VERSION: 1.13.8
aggregator_v2v3_interface: ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV2V3Interface.bin 95e8814b408bb05bf21742ef580d98698b7db6a9bac6a35c3de12b23aec4ee28
aggregator_v3_interface: ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV3Interface.abi ../../contracts/solc/v0.8.6/AggregatorV2V3Interface/AggregatorV3Interface.bin 351b55d3b0f04af67db6dfb5c92f1c64479400ca1fec77afc20bc0ce65cb49ab
authorized_forwarder: ../../contracts/solc/v0.8.19/AuthorizedForwarder/AuthorizedForwarder.abi ../../contracts/solc/v0.8.19/AuthorizedForwarder/AuthorizedForwarder.bin 8ea76c883d460f8353a45a493f2aebeb5a2d9a7b4619d1bc4fff5fb590bb3e10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.12.2
GETH_VERSION: 1.13.8
errored_verifier: ../../../contracts/solc/v0.8.16/ErroredVerifier/ErroredVerifier.abi ../../../contracts/solc/v0.8.16/ErroredVerifier/ErroredVerifier.bin 510d18a58bfda646be35e46491baf73041eb333a349615465b20e2b5b41c5f73
exposed_verifier: ../../../contracts/solc/v0.8.16/ExposedVerifier/ExposedVerifier.abi ../../../contracts/solc/v0.8.16/ExposedVerifier/ExposedVerifier.bin 6932cea8f2738e874d3ec9e1a4231d2421704030c071d9e15dd2f7f08482c246
fee_manager: ../../../contracts/solc/v0.8.16/FeeManager/FeeManager.abi ../../../contracts/solc/v0.8.16/FeeManager/FeeManager.bin 1b852df75bfabcc2b57539e84309cd57f9e693a2bb6b25a50e4a6101ccf32c49
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.12.2
GETH_VERSION: 1.13.8
burn_mint_erc677: ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.abi ../../../contracts/solc/v0.8.19/BurnMintERC677/BurnMintERC677.bin 405c9016171e614b17e10588653ef8d33dcea21dd569c3fddc596a46fcff68a3
erc20: ../../../contracts/solc/v0.8.19/ERC20/ERC20.abi ../../../contracts/solc/v0.8.19/ERC20/ERC20.bin 5b1a93d9b24f250e49a730c96335a8113c3f7010365cba578f313b483001d4fc
link_token: ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.abi ../../../contracts/solc/v0.8.19/LinkToken/LinkToken.bin c0ef9b507103aae541ebc31d87d051c2764ba9d843076b30ec505d37cdfffaba
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GETH_VERSION: 1.12.2
GETH_VERSION: 1.13.8
entry_point: ../../../contracts/solc/v0.8.15/EntryPoint/EntryPoint.abi ../../../contracts/solc/v0.8.15/EntryPoint/EntryPoint.bin 2cb4bb2ba3efa8df3dfb0a57eb3727d17b68fe202682024fa7cfb4faf026833e
greeter: ../../../contracts/solc/v0.8.15/Greeter.abi ../../../contracts/solc/v0.8.15/Greeter.bin 653dcba5c33a46292073939ce1e639372cf521c0ec2814d4c9f20c72f796f18c
greeter_wrapper: ../../../contracts/solc/v0.8.15/Greeter/Greeter.abi ../../../contracts/solc/v0.8.15/Greeter/Greeter.bin 653dcba5c33a46292073939ce1e639372cf521c0ec2814d4c9f20c72f796f18c
Expand Down
95 changes: 95 additions & 0 deletions core/scripts/chaincli/DEBUGGING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## Automation Debugging Script

### Context

The debugging script is a tool within ChainCLI designed to facilitate the debugging of upkeeps in Automation v21, covering both conditional and log-based scenarios.

### Setup

Before starting, you will need:
1. Git clone this chainlink [repo](https://github.com/smartcontractkit/chainlink)
2. A working [Go](https://go.dev/doc/install) installation
2. Change directory to `core/scripts/chaincli` and create a `.env` file based on the example `.env.debugging.example`

### Configuration in `.env` File

#### Mandatory Fields

Ensure the following fields are provided in your `.env` file:

- `NODE_URL`: Archival node URL
- `KEEPER_REGISTRY_ADDRESS`: Address of the Keeper Registry contract. Refer to the [Supported Networks](https://docs.chain.link/chainlink-automation/overview/supported-networks#configurations) doc for addresses.

#### Optional Fields (Streams Lookup)

If your targeted upkeep involves streams lookup, include the following information:

- `DATA_STREAMS_ID`
- `DATA_STREAMS_KEY`
- `DATA_STREAMS_LEGACY_URL`
- `DATA_STREAMS_URL`

#### Optional Fields (Tenderly Integration)

For detailed transaction simulation logs, set up Tenderly credentials. Refer to the [Tenderly Documentation](https://docs.tenderly.co/other/platform-access/how-to-generate-api-access-tokens) for creating an API key, account name, and project name.

- `TENDERLY_KEY`
- `TENDERLY_ACCOUNT_NAME`
- `TENDERLY_PROJECT_NAME`

### Usage

Execute the following command based on your upkeep type:

- For conditional upkeep:

```bash
go run main.go keeper debug UPKEEP_ID
```

- For log trigger upkeep:

```bash
go run main.go keeper debug UPKEEP_ID TX_HASH LOG_INDEX
```

### Checks Performed by the Debugging Script

1. **Fetch and Sanity Check Upkeep:**
- Verify upkeep status: active, paused, or canceled
- Check upkeep balance

2. **For Conditional Upkeep:**
- Check conditional upkeep
- Simulate `performUpkeep`

3. **For Log Trigger Upkeep:**
- Check if the upkeep has already run for log-trigger-based upkeep
- Verify if log matches trigger configuration
- Check upkeep
- If check result indicates a streams lookup is required (TargetCheckReverted):
- Verify if the upkeep is allowed to use Mercury
- Execute Mercury request
- Execute check callback

- Simulate `performUpkeep`

### Examples
- Eligible and log trigger based and using mercury lookup v0.3:

```bash
go run main.go keeper debug 5591498142036749453487419299781783197030971023186134955311257372668222176389 0xdc6d0e547a5aa85fefa5b0f3a37e3493eafb5aeba8b5f3071ce53c9e9a539e9c 0
```

- Ineligible and conditional upkeep:

```bash
go run main.go keeper debug 52635131310730056105456985154251306793887717546629785340977553840883117540096
```

- Ineligible and Log does not match trigger config:

```bash
go run main.go keeper debug 5591498142036749453487419299781783197030971023186134955311257372668222176389 0xc0686ae85d2a7a976ef46df6c613517b9fd46f23340ac583be4e44f5c8b7a186 1
```
---
Loading

0 comments on commit 3b20ba1

Please sign in to comment.