Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions deployment/common/changeset/deploy_link_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import (
"context"
"fmt"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
ethTypes "github.com/ethereum/go-ethereum/core/types"
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/chainlink-common/pkg/logger"

"github.com/gagliardetto/solana-go"

chainsel "github.com/smartcontractkit/chain-selectors"

solCommomUtil "github.com/smartcontractkit/chainlink-ccip/chains/solana/utils/common"
Expand Down Expand Up @@ -110,7 +115,14 @@ func deployLinkTokenContractEVM(
) (*deployment.ContractDeploy[*link_token.LinkToken], error) {
linkToken, err := deployment.DeployContract[*link_token.LinkToken](lggr, chain, ab,
func(chain deployment.Chain) deployment.ContractDeploy[*link_token.LinkToken] {
linkTokenAddr, tx, linkToken, err2 := link_token.DeployLinkToken(
deployLinkToken := link_token.DeployLinkToken
if chain.IsZk {
deployLinkToken = func(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *ethTypes.Transaction, *link_token.LinkToken, error) {
address, _, contract, err := link_token.DeployLinkTokenZk(nil, chain.ClientZk, chain.DeployerKeyZk, chain.Client)
return address, nil, contract, err
}
}
linkTokenAddr, tx, linkToken, err2 := deployLinkToken(
chain.DeployerKey,
chain.Client,
)
Expand Down
5 changes: 5 additions & 0 deletions deployment/common/changeset/deploy_link_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ func TestDeployLinkToken(t *testing.T) {
t.Parallel()
changeset.DeployLinkTokenTest(t, 0)
}

func TestDeployLinkTokenZk(t *testing.T) {
t.Parallel()
changeset.DeployLinkTokenTestZk(t)
}
12 changes: 12 additions & 0 deletions deployment/common/changeset/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ func DeployLinkTokenTest(t *testing.T, solChains int) {
Chains: 1,
SolChains: solChains,
})
deployLinkTokenTestWithEnv(t, e, solChains)
}

func DeployLinkTokenTestZk(t *testing.T) {
lggr := logger.Test(t)
e := memory.NewMemoryEnvironment(t, lggr, zapcore.InfoLevel, memory.MemoryEnvironmentConfig{
ZkChains: 1,
})
deployLinkTokenTestWithEnv(t, e, 0)
}

func deployLinkTokenTestWithEnv(t *testing.T, e deployment.Environment, solChains int) {
chain1 := e.AllChainSelectors()[0]
config := []uint64{chain1}
var solChain1 uint64
Expand Down
20 changes: 19 additions & 1 deletion deployment/common/view/v1_0/link_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"go.uber.org/zap/zapcore"

"github.com/smartcontractkit/chainlink-evm/gethwrappers/shared/generated/link_token"
"github.com/smartcontractkit/chainlink/deployment"
"github.com/smartcontractkit/chainlink/deployment/environment/memory"
"github.com/smartcontractkit/chainlink/v2/core/logger"
)
Expand All @@ -22,6 +23,22 @@ func TestLinkTokenView(t *testing.T) {
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)

testLinkTokenViewWithEnv(t, chain, lt)
}

func TestLinkTokenViewZKSync(t *testing.T) {
e := memory.NewMemoryEnvironment(t, logger.TestLogger(t), zapcore.InfoLevel, memory.MemoryEnvironmentConfig{
ZkChains: 1,
})
chain := e.Chains[e.AllChainSelectors()[0]]
_, _, lt, err := link_token.DeployLinkTokenZk(nil, chain.ClientZk, chain.DeployerKeyZk, chain.Client)
require.NoError(t, err)

testLinkTokenViewWithEnv(t, chain, lt)
}

func testLinkTokenViewWithEnv(t *testing.T, chain deployment.Chain, lt *link_token.LinkToken) {
v, err := GenerateLinkTokenView(lt)
require.NoError(t, err)

Expand All @@ -34,11 +51,12 @@ func TestLinkTokenView(t *testing.T) {
require.Empty(t, v.Burners)

// Add some minters
tx, err = lt.GrantMintAndBurnRoles(chain.DeployerKey, chain.DeployerKey.From)
tx, err := lt.GrantMintAndBurnRoles(chain.DeployerKey, chain.DeployerKey.From)
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)
tx, err = lt.Mint(chain.DeployerKey, chain.DeployerKey.From, big.NewInt(100))
require.NoError(t, err)
_, err = chain.Confirm(tx)
require.NoError(t, err)

Expand Down
9 changes: 8 additions & 1 deletion deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
"github.com/zksync-sdk/zksync2-go/accounts"
"github.com/zksync-sdk/zksync2-go/clients"
"google.golang.org/grpc"

chain_selectors "github.com/smartcontractkit/chain-selectors"
types2 "github.com/smartcontractkit/libocr/offchainreporting2/types"
types3 "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"google.golang.org/grpc"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
csav1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/csa"
Expand Down Expand Up @@ -63,6 +66,10 @@ type Chain struct {
// Users are a set of keys that can be used to interact with the chain.
// These are distinct from the deployer key.
Users []*bind.TransactOpts
// ZK Sync deployment specifics
IsZk bool
ClientZk *clients.Client
DeployerKeyZk *accounts.Wallet
}

func (c Chain) String() string {
Expand Down
5 changes: 5 additions & 0 deletions deployment/environment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func GetProgramsPath() string {
type MemoryEnvironmentConfig struct {
Chains int
SolChains int
ZkChains int
NumOfUsersPerChain int
Nodes int
Bootstraps int
Expand Down Expand Up @@ -218,6 +219,10 @@ func NewMemoryEnvironmentFromChainsNodes(
func NewMemoryEnvironment(t *testing.T, lggr logger.Logger, logLevel zapcore.Level, config MemoryEnvironmentConfig) deployment.Environment {
chains, _ := NewMemoryChains(t, config.Chains, config.NumOfUsersPerChain)
solChains := NewMemoryChainsSol(t, config.SolChains)
zkChains := NewZKChains(t, config.ZkChains)
for chainSel, chain := range zkChains {
chains[chainSel] = chain
}
nodes := NewNodes(t, logLevel, chains, solChains, config.Nodes, config.Bootstraps, config.RegistryConfig)
var nodeIDs []string
for id := range nodes {
Expand Down
88 changes: 88 additions & 0 deletions deployment/environment/memory/zksync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package memory

import (
"context"
"strconv"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/hashicorp/consul/sdk/freeport"
"github.com/stretchr/testify/require"

chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"

"github.com/smartcontractkit/chainlink/deployment"

"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/testcontainers/testcontainers-go"
"github.com/zksync-sdk/zksync2-go/accounts"
"github.com/zksync-sdk/zksync2-go/clients"
)

func NewZKChains(t *testing.T, numChains int) map[uint64]deployment.Chain {
chains := make(map[uint64]deployment.Chain)

for i := 0; i < numChains; i++ {
chainID := chainsel.TEST_90000051.EvmChainID + uint64(i) //nolint:gosec // it shouldn't overflow

output, err := blockchain.NewBlockchainNetwork(&blockchain.Input{
Type: "anvil-zksync",
ChainID: strconv.FormatUint(chainID, 10),
Port: strconv.FormatInt(int64(freeport.GetN(t, 1)[0]), 10),
})
require.NoError(t, err)

testcontainers.CleanupContainer(t, output.Container)

sel, err := chainsel.SelectorFromChainId(chainID)
require.NoError(t, err)

client, err := ethclient.Dial(output.Nodes[0].ExternalHTTPUrl)
require.NoError(t, err)

gasPrice, err := client.SuggestGasPrice(context.Background())
require.NoError(t, err)

keyedTransactors := make([]*bind.TransactOpts, 0)
for _, pk := range blockchain.AnvilZKSyncRichAccountPks {
privateKey, err := crypto.HexToECDSA(pk)
require.NoError(t, err)
transactor, err := bind.NewKeyedTransactorWithChainID(privateKey, new(big.Int).SetUint64(chainID))
transactor.GasPrice = gasPrice
require.NoError(t, err)
keyedTransactors = append(keyedTransactors, transactor)
}

clientZk := clients.NewClient(client.Client())
deployerZk, err := accounts.NewWallet(common.Hex2Bytes(blockchain.AnvilZKSyncRichAccountPks[0]), clientZk, nil)
require.NoError(t, err)

chain := deployment.Chain{
Selector: sel,
Client: client,
DeployerKey: keyedTransactors[0], // to use to interact with contracts
Users: keyedTransactors[1:],
Confirm: func(tx *types.Transaction) (uint64, error) {
receipt, err := bind.WaitMined(context.Background(), client, tx)
if err != nil {
return 0, err
}
return receipt.Status, nil
},
IsZk: true,
ClientZk: clientZk,
DeployerKeyZk: deployerZk,
}

chains[sel] = chain
}

return chains
}
8 changes: 8 additions & 0 deletions deployment/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
github.com/smartcontractkit/chainlink-ccip v0.0.0-20250408103656-875e982e6437
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250408172557-9bce44d32d44
github.com/smartcontractkit/chainlink-common v0.6.1-0.20250407100046-dfdf9600557b
github.com/smartcontractkit/chainlink-evm v0.0.0-20250408161604-b6539361da24

Check failure on line 39 in deployment/go.mod

View workflow job for this annotation

GitHub Actions / Validate go.mod dependencies

[./deployment/go.mod] dependency github.com/smartcontractkit/[email protected] not on default branch (develop). Version(commit): 8063a6546b1a Tree: https://github.com/smartcontractkit/chainlink-evm/tree/8063a6546b1a Commit: https://github.com/smartcontractkit/chainlink-evm/commit/8063a6546b1a
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250402142713-6529d36f91f3
github.com/smartcontractkit/chainlink-protos/job-distributor v0.9.0
github.com/smartcontractkit/chainlink-protos/orchestrator v0.5.0
Expand All @@ -48,6 +48,7 @@
github.com/spf13/cast v1.7.1
github.com/stretchr/testify v1.10.0
github.com/testcontainers/testcontainers-go v0.35.0
github.com/zksync-sdk/zksync2-go v1.0.0
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
Expand Down Expand Up @@ -116,7 +117,10 @@
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/block-vision/sui-go-sdk v1.0.6 // indirect
github.com/btcsuite/btcd v0.24.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.6 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/buger/goterm v0.0.0-20200322175922-2f3e71b85129 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/bytecodealliance/wasmtime-go/v28 v28.0.0 // indirect
Expand Down Expand Up @@ -371,6 +375,7 @@
github.com/smartcontractkit/wsrpc v0.8.5-0.20250318131857-4568a0f8d12d // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stephenlacy/go-ethereum-hdwallet v0.0.0-20230913225845-a4fa94429863 // indirect
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.14 // indirect
Expand All @@ -383,6 +388,7 @@
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/vektah/gqlparser/v2 v2.5.14 // indirect
Expand Down Expand Up @@ -468,3 +474,5 @@
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/testcontainers/testcontainers-go => github.com/testcontainers/testcontainers-go v0.34.0
)

replace github.com/smartcontractkit/chainlink-evm => github.com/smartcontractkit/chainlink-evm v0.0.0-20250409012750-8063a6546b1a
Loading
Loading