Skip to content

Commit

Permalink
Merge branch 'develop' into update-automation-ondemand-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcl committed Aug 23, 2024
2 parents ab2f152 + e4f346a commit 3cfb8be
Show file tree
Hide file tree
Showing 88 changed files with 9,634 additions and 394 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-eels-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Improve TXM performance by optimizing Confirmer and Finalizer queries to stop pulling EVM receipt. #internal
5 changes: 5 additions & 0 deletions .changeset/eight-bees-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#bugfix head reporter non-zero reporting period
5 changes: 5 additions & 0 deletions .changeset/loud-windows-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Added gas limit estimation feature to EVM gas estimators #added
5 changes: 5 additions & 0 deletions .changeset/two-mugs-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

Edited the Optimism Stack L1 Oracle to add support for Mantle #added
10 changes: 7 additions & 3 deletions .github/actions/goreleaser-build-sign-publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ Following inputs can be used as `step.with` keys

| Name | Type | Default | Description |
| ---------------------------- | ------ | ------------------ | ----------------------------------------------------------------------- |
| `goreleaser-version` | String | `1.13.1` | `goreleaser` version |
| `zig-version` | String | `0.10.0` | `zig` version |
| `cosign-version` | String | `v1.13.1` | `cosign` version |
| `goreleaser-version` | String | `~> v2` | `goreleaser` version |
| `zig-version` | String | `0.10.1` | `zig` version |
| `cosign-version` | String | `v2.2.2` | `cosign` version |
| `macos-sdk-dir` | String | `MacOSX12.3.sdk` | MacOSX sdk directory |
| `enable-docker-publish` | Bool | `true` | Enable publishing of Docker images / manifests |
| `docker-registry` | String | `localhost:5001` | Docker registry |
| `docker-image-name` | String | `chainlink` | Docker image name |
| `docker-image-tag` | String | `develop` | Docker image tag |
| `enable-goreleaser-snapshot` | Bool | `false` | Enable goreleaser build / release snapshot |
| `enable-goreleaser-split` | Bool | `false` | Enable goreleaser build using split and merge |
| `goreleaser-split-arch` | String | `""` | The arch to build the image with - amd64, arm64 |
| `goreleaser-exec` | String | `goreleaser` | The goreleaser executable, can invoke wrapper script |
| `goreleaser-config` | String | `.goreleaser.yaml` | The goreleaser configuration yaml |
| `enable-cosign` | Bool | `false` | Enable signing of Docker images |
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/goreleaser-build-sign-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A composite action that allows building and publishing signed chain
inputs:
goreleaser-version:
description: The goreleaser version
default: 1.23.0
default: "~> v2"
required: false
goreleaser-key:
description: The goreleaser key
Expand Down Expand Up @@ -83,7 +83,7 @@ runs:
with:
go-version-file: "go.mod"
- name: Setup goreleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
distribution: goreleaser-pro
install-only: true
Expand Down
2 changes: 0 additions & 2 deletions .github/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,6 @@ runner-test-matrix:
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E CCIP Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPOffRampCapacityLimit$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
Expand All @@ -960,7 +959,6 @@ runner-test-matrix:
test_env_type: docker
runs_on: ubuntu-latest
workflows:
- PR E2E CCIP Tests
- Nightly E2E Tests
test_cmd: cd integration-tests/ccip-tests/smoke && go test ccip_test.go -test.run ^TestSmokeCCIPOffRampAggRateLimit$ -timeout 30m -count=1 -test.parallel=1 -json
test_env_vars:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/crib-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,20 @@ jobs:
echo $GITHUB_WORKSPACE
- name: Deploy and validate CRIB Environment for Core
uses: smartcontractkit/.github/actions/crib-deploy-environment@9a4954089045a765eca4bac68f396b2df5a5ea25 # crib-deploy-environment@0.7.1
uses: smartcontractkit/.github/actions/crib-deploy-environment@4dd21a9d6e3f1383ffe8b9650b55f6e6031d3d0a # crib-deploy-environment@1.0.0
id: deploy-crib
with:
github-token: ${{ steps.token.outputs.access-token }}
api-gateway-host: ${{ secrets.AWS_API_GW_HOST_K8S_STAGE }}
aws-region: ${{ secrets.AWS_REGION }}
aws-role-arn: ${{ secrets.AWS_OIDC_CRIB_ROLE_ARN_STAGE }}
ecr-private-registry-stage: ${{ secrets.AWS_ACCOUNT_ID_STAGE }}
ecr-private-registry: ${{ secrets.AWS_ACCOUNT_ID_PROD }}
ingress-base-domain: ${{ secrets.INGRESS_BASE_DOMAIN_STAGE }}
k8s-cluster-name: ${{ secrets.AWS_K8S_CLUSTER_NAME_STAGE }}
devspace-profiles: "local-dev-simulated-core-ocr1"
crib-alert-slack-webhook: ${{ secrets.CRIB_ALERT_SLACK_WEBHOOK }}
product-image: ${{ secrets.AWS_SDLC_ECR_HOSTNAME }}/chainlink
product-image-tag: develop
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
Expand Down
4 changes: 3 additions & 1 deletion .goreleaser.develop.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project_name: chainlink

version: 2

env:
- ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }}
- IMAGE_PREFIX={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }}
Expand Down Expand Up @@ -196,7 +198,7 @@ checksum:
name_template: "checksums.txt"

snapshot:
name_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}"
version_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}"

partial:
by: target
Expand Down
5 changes: 3 additions & 2 deletions .goreleaser.devspace.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## goreleaser <1.14.0
project_name: chainlink-devspace

version: 2

env:
- ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }}
- IMAGE_LABEL_DESCRIPTION="node of the decentralized oracle network, bridging on and off-chain computation"
Expand Down Expand Up @@ -75,7 +76,7 @@ checksum:
name_template: "checksums.txt"

snapshot:
name_template: '{{ .Env.CHAINLINK_VERSION }}-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }}'
version_template: '{{ .Env.CHAINLINK_VERSION }}-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }}'

changelog:
sort: asc
Expand Down
1 change: 1 addition & 0 deletions common/fee/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
ErrBumpFeeExceedsLimit = errors.New("fee bump exceeds limit")
ErrBump = errors.New("fee bump failed")
ErrConnectivity = errors.New("transaction propagation issue: transactions are not being mined")
ErrFeeLimitTooLow = errors.New("provided fee limit too low")
)

func IsBumpErr(err error) bool {
Expand Down
7 changes: 6 additions & 1 deletion common/txmgr/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/utils"

"github.com/smartcontractkit/chainlink/v2/common/client"
commonfee "github.com/smartcontractkit/chainlink/v2/common/fee"
feetypes "github.com/smartcontractkit/chainlink/v2/common/fee/types"
txmgrtypes "github.com/smartcontractkit/chainlink/v2/common/txmgr/types"
"github.com/smartcontractkit/chainlink/v2/common/types"
Expand Down Expand Up @@ -434,7 +435,11 @@ func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) hand
}

attempt, _, _, retryable, err := eb.NewTxAttempt(ctx, *etx, eb.lggr)
if err != nil {
// Mark transaction as fatal if provided gas limit is set too low
if errors.Is(err, commonfee.ErrFeeLimitTooLow) {
etx.Error = null.StringFrom(commonfee.ErrFeeLimitTooLow.Error())
return eb.saveFatallyErroredTransaction(eb.lggr, etx), false
} else if err != nil {
return fmt.Errorf("processUnstartedTxs failed on NewAttempt: %w", err), retryable
}

Expand Down
2 changes: 2 additions & 0 deletions common/txmgr/types/tx_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type TransactionStore[
// Search for Tx using the fromAddress and sequence
FindTxWithSequence(ctx context.Context, fromAddress ADDR, seq SEQ) (etx *Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
FindNextUnstartedTransactionFromAddress(ctx context.Context, fromAddress ADDR, chainID CHAIN_ID) (*Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], error)

// FindTransactionsConfirmedInBlockRange retrieves tx with attempts and partial receipt values for optimization purpose
FindTransactionsConfirmedInBlockRange(ctx context.Context, highBlockNumber, lowBlockNumber int64, chainID CHAIN_ID) (etxs []*Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
FindEarliestUnconfirmedBroadcastTime(ctx context.Context, chainID CHAIN_ID) (null.Time, error)
FindEarliestUnconfirmedTxAttemptBlock(ctx context.Context, chainID CHAIN_ID) (null.Int, error)
Expand Down
5 changes: 5 additions & 0 deletions contracts/.changeset/thirty-lamps-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/contracts': patch
---

implement an auto registry for zksync with no forwarder interface change
1 change: 0 additions & 1 deletion contracts/.solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
./src/v0.8/automation/libraries/internal/Cron.sol
./src/v0.8/automation/AutomationForwarder.sol
./src/v0.8/automation/AutomationForwarderLogic.sol
./src/v0.8/automation/ZKSyncAutomationForwarder.sol
./src/v0.8/automation/interfaces/v2_2/IAutomationRegistryMaster.sol
./src/v0.8/automation/interfaces/v2_3/IAutomationRegistryMaster2_3.sol

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @description this script generates a master interface for interacting with the automation registry
* @notice run this script with pnpm ts-node ./scripts/generate-zksync-automation-master-interface-v2_3.ts
*/
import { ZKSyncAutomationRegistry2_3__factory as Registry } from '../typechain/factories/ZKSyncAutomationRegistry2_3__factory'
import { ZKSyncAutomationRegistryLogicA2_3__factory as RegistryLogicA } from '../typechain/factories/ZKSyncAutomationRegistryLogicA2_3__factory'
import { ZKSyncAutomationRegistryLogicB2_3__factory as RegistryLogicB } from '../typechain/factories/ZKSyncAutomationRegistryLogicB2_3__factory'
import { ZKSyncAutomationRegistryLogicC2_3__factory as RegistryLogicC } from '../typechain/factories/ZKSyncAutomationRegistryLogicC2_3__factory'
import { utils } from 'ethers'
import fs from 'fs'
import { exec } from 'child_process'

const dest = 'src/v0.8/automation/interfaces/zksync'
const srcDest = `${dest}/IZKSyncAutomationRegistryMaster2_3.sol`
const tmpDest = `${dest}/tmp.txt`

const combinedABI = []
const abiSet = new Set()
const abis = [
Registry.abi,
RegistryLogicA.abi,
RegistryLogicB.abi,
RegistryLogicC.abi,
]

for (const abi of abis) {
for (const entry of abi) {
const id = utils.id(JSON.stringify(entry))
if (!abiSet.has(id)) {
abiSet.add(id)
if (
entry.type === 'function' &&
(entry.name === 'checkUpkeep' ||
entry.name === 'checkCallback' ||
entry.name === 'simulatePerformUpkeep')
) {
entry.stateMutability = 'view' // override stateMutability for check / callback / simulate functions
}
combinedABI.push(entry)
}
}
}

const checksum = utils.id(abis.join(''))

fs.writeFileSync(`${tmpDest}`, JSON.stringify(combinedABI))

const cmd = `
cat ${tmpDest} | pnpm abi-to-sol --solidity-version ^0.8.4 --license MIT > ${srcDest} IZKSyncAutomationRegistryMaster2_3;
echo "// solhint-disable \n// abi-checksum: ${checksum}" | cat - ${srcDest} > ${tmpDest} && mv ${tmpDest} ${srcDest};
pnpm prettier --write ${srcDest};
`

exec(cmd)

console.log(
'generated new master interface for zksync automation registry v2_3',
)
31 changes: 23 additions & 8 deletions contracts/src/v0.8/automation/ZKSyncAutomationForwarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
pragma solidity ^0.8.16;

import {IAutomationRegistryConsumer} from "./interfaces/IAutomationRegistryConsumer.sol";
import {GAS_BOUND_CALLER, IGasBoundCaller} from "./interfaces/zksync/IGasBoundCaller.sol";

uint256 constant PERFORM_GAS_CUSHION = 5_000;
uint256 constant PERFORM_GAS_CUSHION = 50_000;

/**
* @title AutomationForwarder is a relayer that sits between the registry and the customer's target contract
* @title ZKSyncAutomationForwarder is a relayer that sits between the registry and the customer's target contract
* @dev The purpose of the forwarder is to give customers a consistent address to authorize against,
* which stays consistent between migrations. The Forwarder also exposes the registry address, so that users who
* want to programmatically interact with the registry (ie top up funds) can do so.
*/
contract ZKSyncAutomationForwarder {
error InvalidCaller(address);

/// @notice the user's target contract address
address private immutable i_target;

Expand All @@ -31,11 +34,14 @@ contract ZKSyncAutomationForwarder {
* @param gasAmount is the amount of gas to use in the call
* @param data is the 4 bytes function selector + arbitrary function data
* @return success indicating whether the target call succeeded or failed
* @return gasUsed the total gas used from this forwarding call
*/
function forward(uint256 gasAmount, bytes memory data) external returns (bool success, uint256 gasUsed) {
if (msg.sender != address(s_registry)) revert();
if (msg.sender != address(s_registry)) revert InvalidCaller(msg.sender);

uint256 g1 = gasleft();
address target = i_target;
gasUsed = gasleft();

assembly {
let g := gas()
// Compute g -= PERFORM_GAS_CUSHION and check for underflow
Expand All @@ -52,18 +58,27 @@ contract ZKSyncAutomationForwarder {
if iszero(extcodesize(target)) {
revert(0, 0)
}
// call with exact gas
success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0)
}
gasUsed = gasUsed - gasleft();

bytes memory returnData;
// solhint-disable-next-line avoid-low-level-calls
(success, returnData) = GAS_BOUND_CALLER.delegatecall{gas: gasAmount}(
abi.encodeWithSelector(IGasBoundCaller.gasBoundCall.selector, target, gasAmount, data)
);
uint256 pubdataGasSpent;
if (success) {
(, pubdataGasSpent) = abi.decode(returnData, (bytes, uint256));
}
gasUsed = g1 - gasleft() + pubdataGasSpent;
return (success, gasUsed);
}

function getTarget() external view returns (address) {
return i_target;
}

fallback() external {
// solhint-disable-next-line no-complex-fallback
fallback() external payable {
// copy to memory for assembly access
address logic = i_logic;
// copied directly from OZ's Proxy contract
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

address constant GAS_BOUND_CALLER = address(0xc706EC7dfA5D4Dc87f29f859094165E8290530f5);

interface IGasBoundCaller {
function gasBoundCall(address _to, uint256 _maxTotalGas, bytes calldata _data) external payable;
}
10 changes: 10 additions & 0 deletions contracts/src/v0.8/automation/interfaces/zksync/ISystemContext.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.19;

ISystemContext constant SYSTEM_CONTEXT_CONTRACT = ISystemContext(address(0x800b));

interface ISystemContext {
function gasPrice() external view returns (uint256);
function gasPerPubdataByte() external view returns (uint256 gasPerPubdataByte);
function getCurrentPubdataSpent() external view returns (uint256 currentPubdataSpent);
}
Loading

0 comments on commit 3cfb8be

Please sign in to comment.