diff --git a/contracts/hardhat.ccip.zksync.config.ts b/contracts/hardhat.ccip.zksync.config.ts index b8f2e1d154..58bff2ce03 100644 --- a/contracts/hardhat.ccip.zksync.config.ts +++ b/contracts/hardhat.ccip.zksync.config.ts @@ -89,9 +89,8 @@ let config = { ], }, zksolc: { + version: '1.5.3', settings: { - compilerPath: 'zksolc', - version: 'v1.5.3', optimizer: { enabled: true, mode: '3', diff --git a/contracts/scripts/zksyncverify/README.md b/contracts/scripts/zksyncverify/README.md index 97158f660b..95f1737d18 100644 --- a/contracts/scripts/zksyncverify/README.md +++ b/contracts/scripts/zksyncverify/README.md @@ -1,5 +1,9 @@ # Verify ZkSync Contracts For CCIP +G++ <-> CCIP repo artifacts mapping +- The current version of zkSync artifacts in G++ was generated with `v2.14.0-ccip1.5.0` version of zkSync contracts. +- For MCMS contracts change the zkSolc version to v1.5.0 + Pre-requisites: - `pnpm install` at contracts directory - `pnpm run zksync:compile `>> for compiling the contracts, you can uncomment `contractsToCompile` in [hardhat.ccip.zksync.config.ts](../../hardhat.ccip.zksync.config.ts) to compile only the contracts you need diff --git a/contracts/scripts/zksyncverify/main.go b/contracts/scripts/zksyncverify/main.go index 99a7ef4a9e..a49821ba2a 100644 --- a/contracts/scripts/zksyncverify/main.go +++ b/contracts/scripts/zksyncverify/main.go @@ -1,7 +1,6 @@ package main import ( - "context" "encoding/hex" "encoding/json" "flag" @@ -13,10 +12,39 @@ import ( "github.com/AlekSi/pointer" "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum/go-ethereum/rpc" ) +// CustomTx represents a custom transaction structure with selected fields +type CustomTx struct { + Hash string `json:"hash"` + Data string `json:"data"` +} + +func getTransaction(rpcClient *rpc.Client, txHash string) (*CustomTx, error) { + var result map[string]interface{} + if err := rpcClient.Call(&result, "eth_getTransactionByHash", txHash); err != nil { + return nil, fmt.Errorf("failed to fetch transaction: %w", err) + } + + data, ok := result["input"].(string) + if !ok { + return nil, fmt.Errorf("missing or invalid 'input' field in transaction result") + } + + hash, ok := result["hash"].(string) + if !ok { + return nil, fmt.Errorf("missing or invalid 'hash' field in transaction result") + } + + tx := &CustomTx{ + Hash: hash, + Data: data, + } + return tx, nil +} + // This script decodes the constructor arguments of a contract from a hex string func main() { abiFilePath := flag.String("abiPath", "", "Absolute Path to the compiled contract ABI JSON file") @@ -38,11 +66,13 @@ func main() { if err != nil { log.Fatalf("Failed to connect to the rpc client: %v", err) } - tx, _, err := client.TransactionByHash(context.Background(), common.HexToHash(pointer.GetString(deploymentTx))) + + rpcClient := client.Client() + tx, err := getTransaction(rpcClient, pointer.GetString(deploymentTx)) if err != nil { log.Fatalf("Failed to get transaction receipt: %v", err) } - params = string(tx.Data()) + params = tx.Data[2:] } else { params = pointer.GetString(encodedConstructorArgs) } @@ -61,6 +91,7 @@ func main() { log.Fatalf("Failed to unmarshal ABI file content: %v", err) } + fmt.Println("Bytecode Size:", calculateBytecodeSize(compiledFile.DeployedBytecode)) // Parse the ABI parsedABI, err := abi.JSON(strings.NewReader(string(compiledFile.ABI))) if err != nil { @@ -84,6 +115,7 @@ func main() { // Create a map to hold the named constructor arguments constructorArgsMap := make(map[string]interface{}) + fmt.Println("Constructor Arguments order for reference:") for i, arg := range parsedABI.Constructor.Inputs { fmt.Println(arg.Name) constructorArgsMap[arg.Name] = decodedArgs[i] @@ -98,3 +130,8 @@ func main() { fmt.Println("Decoded Constructor Arguments in JSON Format:") fmt.Println(string(decodedArgsJSON)) } + +func calculateBytecodeSize(bytecode string) int { + bytecode = strings.TrimPrefix(bytecode, "0x") + return len(bytecode) / 2 +}