Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 583f07c

Browse files
authored
updated zkSync scripts & instructions (#1587)
## Motivation ## Solution
1 parent ecc1fb0 commit 583f07c

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

contracts/hardhat.ccip.zksync.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ let config = {
8989
],
9090
},
9191
zksolc: {
92+
version: '1.5.3',
9293
settings: {
93-
compilerPath: 'zksolc',
94-
version: 'v1.5.3',
9594
optimizer: {
9695
enabled: true,
9796
mode: '3',

contracts/scripts/zksyncverify/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Verify ZkSync Contracts For CCIP
22

3+
G++ <-> CCIP repo artifacts mapping
4+
- The current version of zkSync artifacts in G++ was generated with `v2.14.0-ccip1.5.0` version of zkSync contracts.
5+
- For MCMS contracts change the zkSolc version to v1.5.0
6+
37
Pre-requisites:
48
- `pnpm install` at contracts directory
59
- `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

contracts/scripts/zksyncverify/main.go

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"context"
54
"encoding/hex"
65
"encoding/json"
76
"flag"
@@ -13,10 +12,39 @@ import (
1312

1413
"github.com/AlekSi/pointer"
1514
"github.com/ethereum/go-ethereum/accounts/abi"
16-
"github.com/ethereum/go-ethereum/common"
1715
"github.com/ethereum/go-ethereum/ethclient"
16+
"github.com/ethereum/go-ethereum/rpc"
1817
)
1918

19+
// CustomTx represents a custom transaction structure with selected fields
20+
type CustomTx struct {
21+
Hash string `json:"hash"`
22+
Data string `json:"data"`
23+
}
24+
25+
func getTransaction(rpcClient *rpc.Client, txHash string) (*CustomTx, error) {
26+
var result map[string]interface{}
27+
if err := rpcClient.Call(&result, "eth_getTransactionByHash", txHash); err != nil {
28+
return nil, fmt.Errorf("failed to fetch transaction: %w", err)
29+
}
30+
31+
data, ok := result["input"].(string)
32+
if !ok {
33+
return nil, fmt.Errorf("missing or invalid 'input' field in transaction result")
34+
}
35+
36+
hash, ok := result["hash"].(string)
37+
if !ok {
38+
return nil, fmt.Errorf("missing or invalid 'hash' field in transaction result")
39+
}
40+
41+
tx := &CustomTx{
42+
Hash: hash,
43+
Data: data,
44+
}
45+
return tx, nil
46+
}
47+
2048
// This script decodes the constructor arguments of a contract from a hex string
2149
func main() {
2250
abiFilePath := flag.String("abiPath", "", "Absolute Path to the compiled contract ABI JSON file")
@@ -38,11 +66,13 @@ func main() {
3866
if err != nil {
3967
log.Fatalf("Failed to connect to the rpc client: %v", err)
4068
}
41-
tx, _, err := client.TransactionByHash(context.Background(), common.HexToHash(pointer.GetString(deploymentTx)))
69+
70+
rpcClient := client.Client()
71+
tx, err := getTransaction(rpcClient, pointer.GetString(deploymentTx))
4272
if err != nil {
4373
log.Fatalf("Failed to get transaction receipt: %v", err)
4474
}
45-
params = string(tx.Data())
75+
params = tx.Data[2:]
4676
} else {
4777
params = pointer.GetString(encodedConstructorArgs)
4878
}
@@ -61,6 +91,7 @@ func main() {
6191
log.Fatalf("Failed to unmarshal ABI file content: %v", err)
6292
}
6393

94+
fmt.Println("Bytecode Size:", calculateBytecodeSize(compiledFile.DeployedBytecode))
6495
// Parse the ABI
6596
parsedABI, err := abi.JSON(strings.NewReader(string(compiledFile.ABI)))
6697
if err != nil {
@@ -84,6 +115,7 @@ func main() {
84115

85116
// Create a map to hold the named constructor arguments
86117
constructorArgsMap := make(map[string]interface{})
118+
fmt.Println("Constructor Arguments order for reference:")
87119
for i, arg := range parsedABI.Constructor.Inputs {
88120
fmt.Println(arg.Name)
89121
constructorArgsMap[arg.Name] = decodedArgs[i]
@@ -98,3 +130,8 @@ func main() {
98130
fmt.Println("Decoded Constructor Arguments in JSON Format:")
99131
fmt.Println(string(decodedArgsJSON))
100132
}
133+
134+
func calculateBytecodeSize(bytecode string) int {
135+
bytecode = strings.TrimPrefix(bytecode, "0x")
136+
return len(bytecode) / 2
137+
}

0 commit comments

Comments
 (0)