Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into tt/solanaUpgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
tt-cll committed Feb 21, 2025
2 parents a8f2263 + 5e8f1f6 commit 589fb37
Show file tree
Hide file tree
Showing 99 changed files with 2,186 additions and 1,465 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-cameras-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#updated Move BoxOutput util function to the only place it is called.
2 changes: 1 addition & 1 deletion .github/integration-in-memory-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runner-test-matrix:
runs_on: ubuntu-latest
triggers:
- PR Integration CCIP Tests
test_cmd: cd integration-tests/smoke/ccip && go test ccip_fees_test.go -timeout 12m -test.parallel=2 -count=1 -json
test_cmd: cd integration-tests/smoke/ccip && go test ccip_fees_test.go -timeout 20m -test.parallel=2 -count=1 -json

- id: smoke/ccip/ccip_messaging_test.go:*
path: integration-tests/smoke/ccip/ccip_messaging_test.go
Expand Down
9 changes: 3 additions & 6 deletions core/capabilities/ccip/ccipevm/gas_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ const (
30_000*3 // supportsInterface of ERC165Checker library performs 3 static-calls of 30k gas each
PerTokenOverheadGas = TokenAdminRegistryPoolLookupGas +
SupportsInterfaceCheck +
200_000 + // releaseOrMint using callWithExactGas
50_000 // transfer using callWithExactGas
200_000 // releaseOrMint using callWithExactGas
RateLimiterOverheadGas = 2_100 + // COLD_SLOAD_COST for accessing token bucket
5_000 // SSTORE_RESET_GAS for updating & decreasing token bucket
ConstantMessagePartBytes = 10 * 32 // A message consists of 10 abi encoded fields 32B each (after encoding)
ExecutionStateProcessingOverheadGas = 2_100 + // COLD_SLOAD_COST for first reading the state
20_000 + // SSTORE_SET_GAS for writing from 0 (untouched) to non-zero (in-progress)
100 //# SLOAD_GAS = WARM_STORAGE_READ_COST for rewriting from non-zero (in-progress) to non-zero (success/failure)
// TODO: investigate the write overhead for v1.6
DestGasOverhead = 110_000 + 110_000 + 130_000 // 110K for commit, 110K for RMN, 130K for Exec
DestGasOverhead = 300_000 // Commit and Exec costs
)

func NewGasEstimateProvider() EstimateProvider {
Expand Down Expand Up @@ -106,8 +104,7 @@ func (gp EstimateProvider) CalculateMessageMaxGasWithError(msg cciptypes.Message
adminRegistryOverhead = TokenAdminRegistryWarmupCost
}

return DestGasOverhead +
messageGasLimit.Uint64() +
return messageGasLimit.Uint64() +
messageCallDataGas +
ExecutionStateProcessingOverheadGas +
SupportsInterfaceCheck +
Expand Down
18 changes: 9 additions & 9 deletions core/capabilities/ccip/ccipevm/gas_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ func Test_calculateMessageMaxGas(t *testing.T) {
{
name: "base",
args: args{dataLen: 5, numTokens: 2, extraArgs: makeExtraArgsV1(200_000), tokenGasOverhead: 10},
want: 1_372_284,
want: 922_284,
},
{
name: "large",
args: args{dataLen: 1000, numTokens: 1000, extraArgs: makeExtraArgsV1(200_000), tokenGasOverhead: 1},
want: 347_028_520,
want: 296_678_520,
},
{
name: "overheadGas test 1",
args: args{dataLen: 0, numTokens: 0, extraArgs: makeExtraArgsV1(200_000), tokenGasOverhead: 100},
want: 669_920,
want: 319_920,
},
{
name: "overheadGas test 2",
Expand All @@ -46,7 +46,7 @@ func Test_calculateMessageMaxGas(t *testing.T) {
extraArgs: makeExtraArgsV1(200_000),
tokenGasOverhead: 2,
},
want: 1_025_950,
want: 625_950,
},
{
name: "allowOOO set to true makes no difference to final gas estimate",
Expand All @@ -56,7 +56,7 @@ func Test_calculateMessageMaxGas(t *testing.T) {
extraArgs: makeExtraArgsV2(200_000, true),
tokenGasOverhead: 100,
},
want: 1_372_464,
want: 922_464,
},
{
name: "allowOOO set to false makes no difference to final gas estimate",
Expand All @@ -66,7 +66,7 @@ func Test_calculateMessageMaxGas(t *testing.T) {
extraArgs: makeExtraArgsV2(200_000, false),
tokenGasOverhead: 100,
},
want: 1_372_464,
want: 922_464,
},
}

Expand Down Expand Up @@ -104,7 +104,7 @@ func TestCalculateMaxGas(t *testing.T) {
numberOfTokens: 0,
extraArgs: makeExtraArgsV1(200_000),
tokenGasOverhead: 10,
want: 672_992,
want: 322_992,
},
{
name: "maxGasOverheadGas 2",
Expand All @@ -113,7 +113,7 @@ func TestCalculateMaxGas(t *testing.T) {
numberOfTokens: 1,
extraArgs: makeExtraArgsV1(200_000),
tokenGasOverhead: 10,
want: 1_028_518,
want: 628_518,
},
{
name: "v2 extra args",
Expand All @@ -122,7 +122,7 @@ func TestCalculateMaxGas(t *testing.T) {
numberOfTokens: 1,
extraArgs: makeExtraArgsV2(200_000, true),
tokenGasOverhead: 10,
want: 1_028_518,
want: 628_518,
},
}

Expand Down
6 changes: 2 additions & 4 deletions core/gethwrappers/go_generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
cutils "github.com/smartcontractkit/chainlink-common/pkg/utils"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/utils"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -39,7 +37,7 @@ func TestCheckContractHashesFromLastGoGenerate(t *testing.T) {
wd = "<directory containing this test>"
}
require.Equal(t, versions.GethVersion, GethVersion,
color.HiRedString(utils.BoxOutput("please re-run `go generate %s` and commit the"+
color.HiRedString(BoxOutput("please re-run `go generate %s` and commit the"+
"changes", wd)))

for _, contractVersionInfo := range versions.ContractVersions {
Expand Down Expand Up @@ -96,7 +94,7 @@ func compareCurrentCompilerArtifactAgainstRecordsAndSoliditySources(
require.NoError(t, err)
recompileCommand := fmt.Sprintf("(cd %s/contracts; make wrappers-all)", rootDir)
assert.Equal(t, versionInfo.Hash, hash,
utils.BoxOutput(`compiled %s and/or %s has changed; please rerun
BoxOutput(`compiled %s and/or %s has changed; please rerun
%s,
and commit the changes`, versionInfo.AbiPath, versionInfo.BinaryPath, recompileCommand))
}
Expand Down
29 changes: 29 additions & 0 deletions core/gethwrappers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
)

// VersionHash is the hash used to detect changes in the underlying contract
Expand Down Expand Up @@ -61,3 +62,31 @@ func TempDir(dirPrefix string) (string, func()) {
}
}
}

// BoxOutput formats its arguments as fmt.Printf, and encloses them in a box of
// arrows pointing at their content, in order to better highlight it. See
// ExampleBoxOutput
func BoxOutput(errorMsgTemplate string, errorMsgValues ...interface{}) string {
errorMsgTemplate = fmt.Sprintf(errorMsgTemplate, errorMsgValues...)
lines := strings.Split(errorMsgTemplate, "\n")
maxlen := 0
for _, line := range lines {
if len(line) > maxlen {
maxlen = len(line)
}
}
internalLength := maxlen + 4
output := "↘" + strings.Repeat("↓", internalLength) + "↙\n" // top line
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
readme := strings.Repeat("README ", maxlen/7)
output += "→ " + readme + strings.Repeat(" ", maxlen-len(readme)) + " ←\n"
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
for _, line := range lines {
output += "→ " + line + strings.Repeat(" ", maxlen-len(line)) + " ←\n"
}
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
output += "→ " + readme + strings.Repeat(" ", maxlen-len(readme)) + " ←\n"
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
return "\n" + output + "↗" + strings.Repeat("↑", internalLength) + "↖" + // bottom line
"\n\n"
}
27 changes: 27 additions & 0 deletions core/gethwrappers/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gethwrappers_test

import (
"testing"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers"

"github.com/stretchr/testify/assert"
)

func TestBoxOutput(t *testing.T) {
t.Parallel()

output := gethwrappers.BoxOutput("some error %d %s", 123, "foo")
const expected = "\n" +
"↘↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↙\n" +
"→ ←\n" +
"→ README README ←\n" +
"→ ←\n" +
"→ some error 123 foo ←\n" +
"→ ←\n" +
"→ README README ←\n" +
"→ ←\n" +
"↗↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↖\n" +
"\n"
assert.Equal(t, expected, output)
}
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect
github.com/smartcontractkit/chain-selectors v1.0.40 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250220215921-f69bcbaa0051 // indirect
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250221121938-dd0db587bff4 // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250214202341-4190f2db1c01 // indirect
github.com/smartcontractkit/chainlink-feeds v0.1.1 // indirect
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250207205350-420ccacab78a // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,8 @@ github.com/smartcontractkit/chain-selectors v1.0.40 h1:iLvvoZeehVq6/7F+zzolQLF0D
github.com/smartcontractkit/chain-selectors v1.0.40/go.mod h1:xsKM0aN3YGcQKTPRPDDtPx2l4mlTN1Djmg0VVXV40b8=
github.com/smartcontractkit/chainlink-automation v0.8.1 h1:sTc9LKpBvcKPc1JDYAmgBc2xpDKBco/Q4h4ydl6+UUU=
github.com/smartcontractkit/chainlink-automation v0.8.1/go.mod h1:Iij36PvWZ6blrdC5A/nrQUBuf3MH3JvsBB9sSyc9W08=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250220215921-f69bcbaa0051 h1:RhCgqArY5iaNK8YFYfAzV3FLOHVkXkML7abVRsW7ID8=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250220215921-f69bcbaa0051/go.mod h1:Hht/OJq/PxC+gnBCIPyzHt4Otsw6mYwUVsmtOqIvlxo=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250221121938-dd0db587bff4 h1:voKtyPNWsT4o/IilRbkEMsvYEWhYMpkl94mi3fDQz60=
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250221121938-dd0db587bff4/go.mod h1:Hht/OJq/PxC+gnBCIPyzHt4Otsw6mYwUVsmtOqIvlxo=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250214202341-4190f2db1c01 h1:R3OD6Phi0ULIQ2uvHiKVWYdgpi/O1Mt46CUK1UApcXU=
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250214202341-4190f2db1c01/go.mod h1:Bmwq4lNb5tE47sydN0TKetcLEGbgl+VxHEWp4S0LI60=
github.com/smartcontractkit/chainlink-common v0.4.2-0.20250214231858-f365e2bdecea h1:/1f/pWf7vSV9acTR9UPn2exPAwQG/LHGa4l9OywhS00=
Expand Down
28 changes: 0 additions & 28 deletions core/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,34 +513,6 @@ func (m *KeyedMutex) LockInt64(key int64) func() {
return mtx.Unlock
}

// BoxOutput formats its arguments as fmt.Printf, and encloses them in a box of
// arrows pointing at their content, in order to better highlight it. See
// ExampleBoxOutput
func BoxOutput(errorMsgTemplate string, errorMsgValues ...interface{}) string {
errorMsgTemplate = fmt.Sprintf(errorMsgTemplate, errorMsgValues...)
lines := strings.Split(errorMsgTemplate, "\n")
maxlen := 0
for _, line := range lines {
if len(line) > maxlen {
maxlen = len(line)
}
}
internalLength := maxlen + 4
output := "↘" + strings.Repeat("↓", internalLength) + "↙\n" // top line
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
readme := strings.Repeat("README ", maxlen/7)
output += "→ " + readme + strings.Repeat(" ", maxlen-len(readme)) + " ←\n"
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
for _, line := range lines {
output += "→ " + line + strings.Repeat(" ", maxlen-len(line)) + " ←\n"
}
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
output += "→ " + readme + strings.Repeat(" ", maxlen-len(readme)) + " ←\n"
output += "→ " + strings.Repeat(" ", maxlen) + " ←\n"
return "\n" + output + "↗" + strings.Repeat("↑", internalLength) + "↖" + // bottom line
"\n\n"
}

// ConcatBytes appends a bunch of byte arrays into a single byte array
func ConcatBytes(bufs ...[]byte) []byte {
return bytes.Join(bufs, []byte{})
Expand Down
18 changes: 0 additions & 18 deletions core/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,6 @@ func TestHashPassword(t *testing.T) {
assert.False(t, ok)
}

func TestBoxOutput(t *testing.T) {
t.Parallel()

output := utils.BoxOutput("some error %d %s", 123, "foo")
const expected = "\n" +
"↘↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↙\n" +
"→ ←\n" +
"→ README README ←\n" +
"→ ←\n" +
"→ some error 123 foo ←\n" +
"→ ←\n" +
"→ README README ←\n" +
"→ ←\n" +
"↗↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↖\n" +
"\n"
assert.Equal(t, expected, output)
}

func TestISO8601UTC(t *testing.T) {
t.Parallel()

Expand Down
10 changes: 5 additions & 5 deletions deployment/ccip/changeset/deployer_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ func TestDeployerGroupMultipleProposalsMCMS(t *testing.T) {

e, _ := testhelpers.NewMemoryEnvironment(t, testhelpers.WithNumOfChains(2))

state, err := changeset.LoadOnchainState(e.Env)
currentState, err := changeset.LoadOnchainState(e.Env)
require.NoError(t, err)

timelocksPerChain := changeset.BuildTimelockPerChain(e.Env, state)
timelocksPerChain := changeset.BuildTimelockPerChain(e.Env, currentState)

contractsByChain := make(map[uint64][]common.Address)
for _, chain := range e.Env.AllChainSelectors() {
contractsByChain[chain] = []common.Address{state.Chains[chain].LinkToken.Address()}
contractsByChain[chain] = []common.Address{currentState.Chains[chain].LinkToken.Address()}
}

_, err = commonchangeset.Apply(t, e.Env, timelocksPerChain,
Expand Down Expand Up @@ -397,10 +397,10 @@ func TestDeployerGroupMultipleProposalsMCMS(t *testing.T) {
)
require.NoError(t, err)

state, err = changeset.LoadOnchainState(e.Env)
currentState, err = changeset.LoadOnchainState(e.Env)
require.NoError(t, err)

token := state.Chains[e.HomeChainSel].LinkToken
token := currentState.Chains[e.HomeChainSel].LinkToken

amount, err := token.BalanceOf(nil, cfg.address)
require.NoError(t, err)
Expand Down
13 changes: 7 additions & 6 deletions deployment/ccip/changeset/solana/cs_chain_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
solState "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/state"

"github.com/smartcontractkit/chainlink/deployment"
cs "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"
)

var _ deployment.ChangeSet[cs.SetOCR3OffRampConfig] = SetOCR3ConfigSolana
var _ deployment.ChangeSet[v1_6.SetOCR3OffRampConfig] = SetOCR3ConfigSolana
var _ deployment.ChangeSet[AddRemoteChainToSolanaConfig] = AddRemoteChainToSolana
var _ deployment.ChangeSet[BillingTokenConfig] = AddBillingToken
var _ deployment.ChangeSet[BillingTokenForRemoteChainConfig] = AddBillingTokenForRemoteChain
Expand Down Expand Up @@ -44,7 +45,7 @@ func commonValidation(e deployment.Environment, selector uint64, tokenPubKey sol
if !ok {
return fmt.Errorf("chain selector %d not found in environment", selector)
}
state, err := cs.LoadOnchainState(e)
state, err := changeset.LoadOnchainState(e)
if err != nil {
return fmt.Errorf("failed to load onchain state: %w", err)
}
Expand All @@ -68,7 +69,7 @@ func commonValidation(e deployment.Environment, selector uint64, tokenPubKey sol
return nil
}

func validateRouterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateRouterConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.Router.IsZero() {
return fmt.Errorf("router not found in existing state, deploy the router first for chain %d", chain.Selector)
}
Expand All @@ -81,7 +82,7 @@ func validateRouterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainS
return nil
}

func validateFeeQuoterConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateFeeQuoterConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.FeeQuoter.IsZero() {
return fmt.Errorf("fee quoter not found in existing state, deploy the fee quoter first for chain %d", chain.Selector)
}
Expand All @@ -94,7 +95,7 @@ func validateFeeQuoterConfig(chain deployment.SolChain, chainState cs.SolCCIPCha
return nil
}

func validateOffRampConfig(chain deployment.SolChain, chainState cs.SolCCIPChainState) error {
func validateOffRampConfig(chain deployment.SolChain, chainState changeset.SolCCIPChainState) error {
if chainState.OffRamp.IsZero() {
return fmt.Errorf("offramp not found in existing state, deploy the offramp first for chain %d", chain.Selector)
}
Expand Down
8 changes: 5 additions & 3 deletions deployment/ccip/changeset/solana/cs_chain_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import (
solTokenUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/tokens"

"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"

ccipChangeset "github.com/smartcontractkit/chainlink/deployment/ccip/changeset"
changeset_solana "github.com/smartcontractkit/chainlink/deployment/ccip/changeset/solana"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/testhelpers"
"github.com/smartcontractkit/chainlink/deployment/ccip/changeset/v1_6"

"github.com/smartcontractkit/chainlink/deployment"
commonchangeset "github.com/smartcontractkit/chainlink/deployment/common/changeset"
Expand All @@ -38,9 +40,9 @@ func TestAddRemoteChain(t *testing.T) {

tenv.Env, err = commonchangeset.Apply(t, tenv.Env, nil,
commonchangeset.Configure(
deployment.CreateLegacyChangeSet(ccipChangeset.UpdateOnRampsDestsChangeset),
ccipChangeset.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]ccipChangeset.OnRampDestinationUpdate{
deployment.CreateLegacyChangeSet(v1_6.UpdateOnRampsDestsChangeset),
v1_6.UpdateOnRampDestsConfig{
UpdatesByChain: map[uint64]map[uint64]v1_6.OnRampDestinationUpdate{
evmChain: {
solChain: {
IsEnabled: true,
Expand Down
Loading

0 comments on commit 589fb37

Please sign in to comment.