Skip to content

Commit

Permalink
contracts/scripts: reduce offramp optimizations (#1414)
Browse files Browse the repository at this point in the history
## Motivation

The offramp was failing to deploy due to too many optimizations causing
a max code size exceeded error.

## Solution

Reduce the number of optimizations by 1.

Also, add a test that deploys v1.6 contracts and ensures that they are
deployable on the simulated backend.
  • Loading branch information
makramkd authored Sep 5, 2024
1 parent d2c51be commit 53057b1
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/scripts/native_solc_compile_all_ccip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SOLC_VERSION="0.8.24"
OPTIMIZE_RUNS=26000
OPTIMIZE_RUNS_OFFRAMP=18000
OPTIMIZE_RUNS_ONRAMP=4100
OPTIMIZE_RUNS_MULTI_OFFRAMP=2000
OPTIMIZE_RUNS_MULTI_OFFRAMP=1999


SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
Expand Down
97 changes: 97 additions & 0 deletions core/gethwrappers/ccip/deployment_test/deployment_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package deploymenttest

import (
"math/big"
"testing"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/fee_quoter"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/nonce_manager"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/offramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/onramp"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/token_admin_registry"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
)

// This tests ensures that all of the compiled contracts can be
// deployed to an actual blockchain (i.e no "max code size exceeded" errors).
// It does not attempt to correctly set up the contracts, so bogus inputs are used.
func TestDeployAllV1_6(t *testing.T) {
owner := testutils.MustNewSimTransactor(t)
chain := backends.NewSimulatedBackend(core.GenesisAlloc{
owner.From: {Balance: assets.Ether(100).ToInt()},
}, 30e6)

// router
_, _, _, err := router.DeployRouter(owner, chain, common.HexToAddress("0x1"), common.HexToAddress("0x2"))
require.NoError(t, err)
chain.Commit()

// nonce manager
_, _, _, err = nonce_manager.DeployNonceManager(owner, chain, []common.Address{common.HexToAddress("0x1")})
require.NoError(t, err)
chain.Commit()

// offramp
_, _, _, err = offramp.DeployOffRamp(owner, chain, offramp.OffRampStaticConfig{
ChainSelector: 1,
Rmn: common.HexToAddress("0x1"),
TokenAdminRegistry: common.HexToAddress("0x2"),
NonceManager: common.HexToAddress("0x3"),
}, offramp.OffRampDynamicConfig{
FeeQuoter: common.HexToAddress("0x4"),
PermissionLessExecutionThresholdSeconds: uint32((8 * time.Hour).Seconds()),
MaxTokenTransferGas: 50_000,
MaxPoolReleaseOrMintGas: 50_000,
MessageValidator: common.HexToAddress("0x5"),
}, nil)
require.NoError(t, err)
chain.Commit()

// onramp
_, _, _, err = onramp.DeployOnRamp(owner, chain, onramp.OnRampStaticConfig{
ChainSelector: 1,
Rmn: common.HexToAddress("0x1"),
NonceManager: common.HexToAddress("0x2"),
TokenAdminRegistry: common.HexToAddress("0x3"),
}, onramp.OnRampDynamicConfig{
FeeQuoter: common.HexToAddress("0x4"),
MessageValidator: common.HexToAddress("0x5"),
FeeAggregator: common.HexToAddress("0x6"),
AllowListAdmin: common.HexToAddress("0x7"),
}, nil)
require.NoError(t, err)
chain.Commit()

// fee quoter
_, _, _, err = fee_quoter.DeployFeeQuoter(
owner,
chain,
fee_quoter.FeeQuoterStaticConfig{
MaxFeeJuelsPerMsg: big.NewInt(1e18),
LinkToken: common.HexToAddress("0x1"),
StalenessThreshold: 10,
},
[]common.Address{common.HexToAddress("0x1")},
[]common.Address{common.HexToAddress("0x2")},
[]fee_quoter.FeeQuoterTokenPriceFeedUpdate{},
[]fee_quoter.FeeQuoterTokenTransferFeeConfigArgs{},
[]fee_quoter.FeeQuoterPremiumMultiplierWeiPerEthArgs{},
[]fee_quoter.FeeQuoterDestChainConfigArgs{})
require.NoError(t, err)
chain.Commit()

// token admin registry
_, _, _, err = token_admin_registry.DeployTokenAdminRegistry(owner, chain)
require.NoError(t, err)
chain.Commit()

// TODO: add rmn home and rmn remote
}
Loading

0 comments on commit 53057b1

Please sign in to comment.