From 416f85a44bbd08f5afa54d5548342b785eacf891 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 23 Dec 2024 14:38:38 -0500 Subject: [PATCH 01/98] feat: relayer binary --- Makefile | 21 +++++++++++++++++++-- relayer/main.go | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 relayer/main.go diff --git a/Makefile b/Makefile index 4326275..b399e3e 100644 --- a/Makefile +++ b/Makefile @@ -65,16 +65,33 @@ build-simapp: mod @go build $(BUILD_FLAGS) -o build/ ./simapp/simd/ .PHONY: build-simapp -## build: Build the simapp binary. -build: build-simapp +## build: Build all the binaries into the ./build directory. +build: build-simapp build-relayer .PHONY: build +## build-relayer: Build the relayer binary into the ./build directory. +build-relayer: mod + @cd ./relayer/ + @mkdir -p build/ + @go build $(BUILD_FLAGS) -o build/ ./relayer/ +.PHONY: build-relayer + ## install-simapp: Build and install the simapp binary into the $GOPATH/bin directory. install-simapp: @echo "--> Installing simd" @go install $(BUILD_FLAGS) ./simapp/simd/ .PHONY: install-simapp +## install-relayer: Build and install the relayer binary into the $GOPATH/bin directory. +install-relayer: + @echo "--> Installing relayer" + @go install $(BUILD_FLAGS) ./relayer +.PHONY: install-relayer + +## install: Install all binaries into the $GOPATH/bin directory. +install: install-simapp install-relayer +.PHONY: install + ## mod: Update all go.mod files. mod: @echo "--> Updating go.mod" diff --git a/relayer/main.go b/relayer/main.go new file mode 100644 index 0000000..24bb744 --- /dev/null +++ b/relayer/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Printf("Hello from relayer\n") +} From 87c8b2103d738d5c64e0f1b5c3d148504cd8e247 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 23 Dec 2024 14:42:33 -0500 Subject: [PATCH 02/98] todo --- relayer/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/relayer/main.go b/relayer/main.go index 24bb744..5062a01 100644 --- a/relayer/main.go +++ b/relayer/main.go @@ -4,4 +4,7 @@ import "fmt" func main() { fmt.Printf("Hello from relayer\n") + // Update the tendermint client on the reth rollup (querying the prover process for the groth16 proof proving the simapps state transition from a previous trusted height to a new one) + // Need to query SimApp's IBC module to learn if there are any new packets to relay. + // TODO: can we use an existing relayer for this functionality? } From b1eb7481f2be3da9f493c11906e2d24d485cd619 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 14:34:55 -0500 Subject: [PATCH 03/98] revert: separate relayer binary --- Makefile | 19 +++---------------- relayer/main.go | 10 ---------- testing/demo/pkg/transfer/main.go | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 relayer/main.go diff --git a/Makefile b/Makefile index c162514..9805f67 100644 --- a/Makefile +++ b/Makefile @@ -107,30 +107,17 @@ build-simapp: mod @go build $(BUILD_FLAGS) -o build/ ./simapp/simd/ .PHONY: build-simapp -## build: Build all the binaries into the ./build directory. -build: build-simapp build-relayer +## build: Build the simapp the binaries into the ./build directory. +build: build-simapp .PHONY: build -## build-relayer: Build the relayer binary into the ./build directory. -build-relayer: mod - @cd ./relayer/ - @mkdir -p build/ - @go build $(BUILD_FLAGS) -o build/ ./relayer/ -.PHONY: build-relayer - ## install-simapp: Build and install the simapp binary into the $GOPATH/bin directory. install-simapp: @echo "--> Installing simd" @go install $(BUILD_FLAGS) ./simapp/simd/ .PHONY: install-simapp -## install-relayer: Build and install the relayer binary into the $GOPATH/bin directory. -install-relayer: - @echo "--> Installing relayer" - @go install $(BUILD_FLAGS) ./relayer -.PHONY: install-relayer - -## install: Install all binaries into the $GOPATH/bin directory. +## install: Install the simapp binary into the $GOPATH/bin directory. install: install-simapp install-relayer .PHONY: install diff --git a/relayer/main.go b/relayer/main.go deleted file mode 100644 index 5062a01..0000000 --- a/relayer/main.go +++ /dev/null @@ -1,10 +0,0 @@ -package main - -import "fmt" - -func main() { - fmt.Printf("Hello from relayer\n") - // Update the tendermint client on the reth rollup (querying the prover process for the groth16 proof proving the simapps state transition from a previous trusted height to a new one) - // Need to query SimApp's IBC module to learn if there are any new packets to relay. - // TODO: can we use an existing relayer for this functionality? -} diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 14db844..31bf1a2 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -36,6 +36,17 @@ func main() { os.Exit(1) } + // 2a -> Listen for events that SimApp has emitted that there are pending packets ready to be sent to other chains. It queries the chain for the receipt based on a predetermined location. + err = QueryPendingPackets() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // 2b -> The relayer needs to prove to the EVM rollup that SimApp has actually successfully executed the first part of the transfer: locking up the tokens. Proving this requires two steps: First the relayer queries a state transition proof from the prover process. This will prove the latest state root from the last trusted state root stored in the state of the ICS07 Tendermint smart contract on the EVM. Now the EVM has an up to date record of SimApp's current state (which includes the receipt). Second, the relayer asks the prover for a proof that the receipt is a merkle leaf of the state root i.e. it's part of state + // 2c -> The prover has a zk circuit for generating both proofs. One takes tendermint headers and uses the SkippingVerification algorithm to assert the latest header. The other takes IAVL merkle proofs and proves some leaf key as part of the root. These are both STARK proofs which can be processed by the smart contracts on the EVM. + // 2d -> The last step of the relayer is to combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. + } func SubmitMsgTransfer() error { @@ -99,3 +110,9 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { Signer: relayer, }, nil } + +func QueryPendingPackets() error { + fmt.Println("Querying for pending packets...") + // TODO: implement + return nil +} From 163b7cc72dc8831944e2007c5039beee737c8e28 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 14:51:32 -0500 Subject: [PATCH 04/98] query events associated with the tx --- testing/demo/pkg/transfer/main.go | 66 +++++++++++++++++++------------ testing/demo/pkg/utils/utils.go | 8 ++++ 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 31bf1a2..6000440 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -16,28 +16,30 @@ import ( ) const ( - // relayer is an address registered in simapp - relayer = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" + // senderAddress is an address on SimApp that will send funds via the MsgTransfer. + senderAddress = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" - // ethereumUserAddress is an address registered in the ethereum chain - ethereumUserAddress = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" + // receiverAddress is an address on the EVM chain that will receive funds via the MsgTransfer. + receiverAddress = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" - // denom is the denomination of the token on simapp + // denom is the denomination of the token on SimApp. denom = "stake" - // amount is the amount of tokens to transfer + // amount is the amount of tokens to transfer. amount = 100 ) func main() { - err := SubmitMsgTransfer() + txHash, err := SubmitMsgTransfer() if err != nil { fmt.Println(err) os.Exit(1) } - // 2a -> Listen for events that SimApp has emitted that there are pending packets ready to be sent to other chains. It queries the chain for the receipt based on a predetermined location. - err = QueryPendingPackets() + // 2a -> Listen for events that SimApp has emitted that there are pending + // packets ready to be sent to other chains. It queries the chain for the + // receipt based on a predetermined location. + err = QueryPendingPackets(txHash) if err != nil { fmt.Println(err) os.Exit(1) @@ -49,38 +51,38 @@ func main() { } -func SubmitMsgTransfer() error { +func SubmitMsgTransfer() (txHash string, err error) { fmt.Printf("Setting up client context...\n") clientCtx, err := utils.SetupClientContext() if err != nil { - return fmt.Errorf("failed to setup client context: %v", err) + return "", fmt.Errorf("failed to setup client context: %v", err) } - err = submitMsgTransfer(clientCtx) + txHash, err = submitMsgTransfer(clientCtx) if err != nil { - return fmt.Errorf("failed to submit MsgTransfer: %v", err) + return "", fmt.Errorf("failed to submit MsgTransfer: %v", err) } - return nil + return txHash, nil } -func submitMsgTransfer(clientCtx client.Context) error { +func submitMsgTransfer(clientCtx client.Context) (txHash string, err error) { msgTransfer, err := createMsgTransfer() if err != nil { - return fmt.Errorf("failed to create MsgTransfer: %w", err) + return "", fmt.Errorf("failed to create MsgTransfer: %w", err) } fmt.Printf("Broadcasting MsgTransfer...\n") - response, err := utils.BroadcastMessages(clientCtx, relayer, 200_000, &msgTransfer) + response, err := utils.BroadcastMessages(clientCtx, senderAddress, 200_000, &msgTransfer) if err != nil { - return fmt.Errorf("failed to broadcast MsgTransfer %w", err) + return "", fmt.Errorf("failed to broadcast MsgTransfer %w", err) } if response.Code != 0 { - return fmt.Errorf("failed to execute MsgTransfer %v", response.RawLog) + return "", fmt.Errorf("failed to execute MsgTransfer %v", response.RawLog) } fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) - return nil + return response.TxHash, nil } func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { @@ -88,8 +90,8 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ Denom: coin.Denom, Amount: coin.Amount.BigInt(), - Sender: relayer, - Receiver: ethereumUserAddress, + Sender: senderAddress, + Receiver: receiverAddress, Memo: "test transfer", } transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) @@ -107,12 +109,24 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { SourceChannel: ibctesting.FirstChannelID, TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), Payloads: []channeltypesv2.Payload{payload}, - Signer: relayer, + Signer: senderAddress, }, nil } -func QueryPendingPackets() error { - fmt.Println("Querying for pending packets...") - // TODO: implement +func QueryPendingPackets(txHash string) error { + fmt.Printf("Querying for pending packets...\n") + + fmt.Printf("Setting up client context...\n") + clientCtx, err := utils.SetupClientContext() + if err != nil { + return err + } + + txResponse, err := utils.QueryTx(clientCtx, txHash) + if err != nil { + return fmt.Errorf("failed to query transaction: %v", err) + } + fmt.Printf("Transaction details: %v\n", txResponse) + fmt.Printf("Transaction events: %v\n", txResponse.Events) return nil } diff --git a/testing/demo/pkg/utils/utils.go b/testing/demo/pkg/utils/utils.go index a61548b..09e4bc3 100644 --- a/testing/demo/pkg/utils/utils.go +++ b/testing/demo/pkg/utils/utils.go @@ -227,3 +227,11 @@ func WaitForCondition(timeoutAfter, pollingInterval time.Duration, fn func() (bo } } } + +func QueryTx(clientContext client.Context, txHash string) (*sdk.TxResponse, error) { + txResponse, err := authtx.QueryTx(clientContext, txHash) + if err != nil { + return nil, fmt.Errorf("failed to query transaction: %v", err) + } + return txResponse, nil +} From f9349ff032c5c0553853c5db797c6b7cfb15b6d2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 15:00:37 -0500 Subject: [PATCH 05/98] debug: no pending packets after msg transfer ~ $ simd query ibc channelv2 unreceived-packets channel-0 height: revision_height: "475" revision_number: "0" sequences: [] ~ $ simd query ibc channelv2 unreceived-packets channel-1 height: revision_height: "475" revision_number: "0" sequences: [] --- testing/demo/pkg/transfer/main.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 6000440..2e94312 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -27,6 +27,9 @@ const ( // amount is the amount of tokens to transfer. amount = 100 + + // channelID is the channel ID on SimApp that was created by the `make setup` command. + channelID = "channel-0" ) func main() { @@ -114,19 +117,20 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { } func QueryPendingPackets(txHash string) error { + // Instead of doing this, the more correct way might be to query the IBC module on SimApp for the pending packets on a particular channel. To do that, we need to figure out which channel to query. fmt.Printf("Querying for pending packets...\n") - fmt.Printf("Setting up client context...\n") - clientCtx, err := utils.SetupClientContext() - if err != nil { - return err - } - - txResponse, err := utils.QueryTx(clientCtx, txHash) - if err != nil { - return fmt.Errorf("failed to query transaction: %v", err) - } - fmt.Printf("Transaction details: %v\n", txResponse) - fmt.Printf("Transaction events: %v\n", txResponse.Events) + // fmt.Printf("Setting up client context...\n") + // clientCtx, err := utils.SetupClientContext() + // if err != nil { + // return err + // } + + // txResponse, err := utils.QueryTx(clientCtx, txHash) + // if err != nil { + // return fmt.Errorf("failed to query transaction: %v", err) + // } + // fmt.Printf("Transaction details: %v\n", txResponse) + // fmt.Printf("Transaction events: %v\n", txResponse.Events) return nil } From 22286d5197cf9441de2cdd3380a99ef575afaacd Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 15:12:10 -0500 Subject: [PATCH 06/98] feat: query pending packet commitments --- testing/demo/pkg/transfer/main.go | 47 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 2e94312..0af38e2 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "fmt" "os" "time" @@ -42,7 +43,7 @@ func main() { // 2a -> Listen for events that SimApp has emitted that there are pending // packets ready to be sent to other chains. It queries the chain for the // receipt based on a predetermined location. - err = QueryPendingPackets(txHash) + err = QueryPendingPacketCommitments(txHash) if err != nil { fmt.Println(err) os.Exit(1) @@ -55,7 +56,6 @@ func main() { } func SubmitMsgTransfer() (txHash string, err error) { - fmt.Printf("Setting up client context...\n") clientCtx, err := utils.SetupClientContext() if err != nil { return "", fmt.Errorf("failed to setup client context: %v", err) @@ -116,21 +116,32 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { }, nil } -func QueryPendingPackets(txHash string) error { - // Instead of doing this, the more correct way might be to query the IBC module on SimApp for the pending packets on a particular channel. To do that, we need to figure out which channel to query. - fmt.Printf("Querying for pending packets...\n") - - // fmt.Printf("Setting up client context...\n") - // clientCtx, err := utils.SetupClientContext() - // if err != nil { - // return err - // } - - // txResponse, err := utils.QueryTx(clientCtx, txHash) - // if err != nil { - // return fmt.Errorf("failed to query transaction: %v", err) - // } - // fmt.Printf("Transaction details: %v\n", txResponse) - // fmt.Printf("Transaction events: %v\n", txResponse.Events) +func QueryPendingPacketCommitments(txHash string) error { + fmt.Printf("Querying for pending packet commitments...\n") + + clientCtx, err := utils.SetupClientContext() + if err != nil { + return err + } + // Need to execute: + // simd query ibc channelv2 packet-commitments channel-0 + + packetCommitments, err := queryPendingPacketCommitments(clientCtx, channelID) + if err != nil { + return err + } + fmt.Printf("Pending packet commitments: %v\n", packetCommitments) return nil } + +func queryPendingPacketCommitments(clientCtx client.Context, channelID string) ([]*channeltypesv2.PacketState, error) { + queryClient := channeltypesv2.NewQueryClient(clientCtx) + request := channeltypesv2.QueryPacketCommitmentsRequest{ + ChannelId: channelID, + } + response, err := queryClient.PacketCommitments(context.Background(), &request) + if err != nil { + return nil, fmt.Errorf("failed to query packet commitments: %v", err) + } + return response.Commitments, nil +} From d50952337ba777e60b4d6e34391467d2a3fb9e20 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 15:56:41 -0500 Subject: [PATCH 07/98] refactor --- testing/demo/pkg/transfer/main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 0af38e2..4fa2e74 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -123,18 +123,16 @@ func QueryPendingPacketCommitments(txHash string) error { if err != nil { return err } - // Need to execute: - // simd query ibc channelv2 packet-commitments channel-0 - - packetCommitments, err := queryPendingPacketCommitments(clientCtx, channelID) + packets, err := queryPacketCommitments(clientCtx, channelID) if err != nil { return err } - fmt.Printf("Pending packet commitments: %v\n", packetCommitments) + fmt.Printf("Pending packet commitments: %v\n", packets) + // TODO what to do with these packets? return nil } -func queryPendingPacketCommitments(clientCtx client.Context, channelID string) ([]*channeltypesv2.PacketState, error) { +func queryPacketCommitments(clientCtx client.Context, channelID string) ([]*channeltypesv2.PacketState, error) { queryClient := channeltypesv2.NewQueryClient(clientCtx) request := channeltypesv2.QueryPacketCommitmentsRequest{ ChannelId: channelID, From d7221cadd7d32f392d3577cc053f2137e6a831cc Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:03:52 -0500 Subject: [PATCH 08/98] start querying last trusted state root on EVM contract --- testing/demo/pkg/transfer/main.go | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 4fa2e74..91721a6 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -40,16 +40,23 @@ func main() { os.Exit(1) } - // 2a -> Listen for events that SimApp has emitted that there are pending - // packets ready to be sent to other chains. It queries the chain for the - // receipt based on a predetermined location. - err = QueryPendingPacketCommitments(txHash) + err = QueryPacketCommitments(txHash) if err != nil { fmt.Println(err) os.Exit(1) } - // 2b -> The relayer needs to prove to the EVM rollup that SimApp has actually successfully executed the first part of the transfer: locking up the tokens. Proving this requires two steps: First the relayer queries a state transition proof from the prover process. This will prove the latest state root from the last trusted state root stored in the state of the ICS07 Tendermint smart contract on the EVM. Now the EVM has an up to date record of SimApp's current state (which includes the receipt). Second, the relayer asks the prover for a proof that the receipt is a merkle leaf of the state root i.e. it's part of state + // We need to query the EVM contract for the last trusted state root that exists in the ICS07 Tendermint smart contract on the EVM. + err = QueryLastTrustedStateRoot() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + // 2b -> The relayer needs to prove to the EVM rollup that SimApp has actually successfully executed the first part of the transfer: locking up the tokens. Proving this requires two steps: + // 1. the relayer queries a state transition proof from the prover process. This will prove the latest state root from the last trusted state root stored in the state of the ICS07 Tendermint smart contract on the EVM. Now the EVM has an up to date record of SimApp's current state (which includes the receipt). + // 2. the relayer asks the prover for a proof that the receipt is a merkle leaf of the state root i.e. it's part of state + // 2c -> The prover has a zk circuit for generating both proofs. One takes tendermint headers and uses the SkippingVerification algorithm to assert the latest header. The other takes IAVL merkle proofs and proves some leaf key as part of the root. These are both STARK proofs which can be processed by the smart contracts on the EVM. // 2d -> The last step of the relayer is to combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. @@ -116,30 +123,30 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { }, nil } -func QueryPendingPacketCommitments(txHash string) error { - fmt.Printf("Querying for pending packet commitments...\n") +func QueryPacketCommitments(txHash string) error { + fmt.Printf("Querying packet commitments on SimApp...\n") clientCtx, err := utils.SetupClientContext() if err != nil { return err } - packets, err := queryPacketCommitments(clientCtx, channelID) - if err != nil { - return err - } - fmt.Printf("Pending packet commitments: %v\n", packets) - // TODO what to do with these packets? - return nil -} -func queryPacketCommitments(clientCtx client.Context, channelID string) ([]*channeltypesv2.PacketState, error) { queryClient := channeltypesv2.NewQueryClient(clientCtx) request := channeltypesv2.QueryPacketCommitmentsRequest{ ChannelId: channelID, } response, err := queryClient.PacketCommitments(context.Background(), &request) if err != nil { - return nil, fmt.Errorf("failed to query packet commitments: %v", err) + return fmt.Errorf("failed to query packet commitments: %v", err) } - return response.Commitments, nil + + // TODO what to do with these packets? + fmt.Printf("Packet commitments: %v\n", response.Commitments) + return nil +} + +func QueryLastTrustedStateRoot() error { + fmt.Printf("Querying last trusted state root on EVM...\n") + + return nil } From 4be1be962a1d29b6bfd624f36e1c46e444901f26 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:23:12 -0500 Subject: [PATCH 09/98] more todos --- testing/demo/pkg/setup/initialise_groth16_client.go | 1 + testing/demo/pkg/setup/initialise_sp1tm_client.go | 1 + testing/demo/pkg/transfer/main.go | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/testing/demo/pkg/setup/initialise_groth16_client.go b/testing/demo/pkg/setup/initialise_groth16_client.go index fa4fc7a..0cfa9df 100644 --- a/testing/demo/pkg/setup/initialise_groth16_client.go +++ b/testing/demo/pkg/setup/initialise_groth16_client.go @@ -59,6 +59,7 @@ func InitializeGroth16LightClientOnSimapp() error { } func createClientAndConsensusState(genesisBlock, latestBlock *ethtypes.Block) (*cdctypes.Any, *cdctypes.Any, error) { + // TODO: this clientState isn't created with a state transition verifier key or state inclusion verifier key. clientState := groth16.NewClientState(latestBlock.Number().Uint64(), []byte{}, []byte{}, []byte{}, genesisBlock.Root().Bytes()) clientStateAny, err := cdctypes.NewAnyWithValue(clientState) if err != nil { diff --git a/testing/demo/pkg/setup/initialise_sp1tm_client.go b/testing/demo/pkg/setup/initialise_sp1tm_client.go index 3287347..9de6706 100644 --- a/testing/demo/pkg/setup/initialise_sp1tm_client.go +++ b/testing/demo/pkg/setup/initialise_sp1tm_client.go @@ -72,6 +72,7 @@ func InitializeSp1TendermintLightClientOnReth() error { } +// runDeploymentCommand deploys the SP1 ICS07 Tendermint light client contract on the EVM roll-up. func runDeploymentCommand() error { cmd := exec.Command("forge", "script", "E2ETestDeploy.s.sol:E2ETestDeploy", "--rpc-url", "http://localhost:8545", "--private-key", "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a", "--broadcast") cmd.Env = append(cmd.Env, "PRIVATE_KEY=0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a") diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 91721a6..cd8b301 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -147,6 +147,10 @@ func QueryPacketCommitments(txHash string) error { func QueryLastTrustedStateRoot() error { fmt.Printf("Querying last trusted state root on EVM...\n") + // The SP1 TM light client on the EVM roll-up has two pieces of state that we want to query: + // 1. trusted client state + // 2. trusted consensus state + // I think we want to query inside the trusted client state to get the last height of SimApp that the light client knows about.. return nil } From a5923370d118a4833ea3c42354b89a4e75633372 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:30:21 -0500 Subject: [PATCH 10/98] make sense of todos --- testing/demo/pkg/transfer/main.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index cd8b301..d40dcf6 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -47,18 +47,17 @@ func main() { } // We need to query the EVM contract for the last trusted state root that exists in the ICS07 Tendermint smart contract on the EVM. - err = QueryLastTrustedStateRoot() + err = QueryLastTrustedHeight() if err != nil { fmt.Println(err) os.Exit(1) } - // 2b -> The relayer needs to prove to the EVM rollup that SimApp has actually successfully executed the first part of the transfer: locking up the tokens. Proving this requires two steps: - // 1. the relayer queries a state transition proof from the prover process. This will prove the latest state root from the last trusted state root stored in the state of the ICS07 Tendermint smart contract on the EVM. Now the EVM has an up to date record of SimApp's current state (which includes the receipt). - // 2. the relayer asks the prover for a proof that the receipt is a merkle leaf of the state root i.e. it's part of state - - // 2c -> The prover has a zk circuit for generating both proofs. One takes tendermint headers and uses the SkippingVerification algorithm to assert the latest header. The other takes IAVL merkle proofs and proves some leaf key as part of the root. These are both STARK proofs which can be processed by the smart contracts on the EVM. - // 2d -> The last step of the relayer is to combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. + // TODO + // Query the ICS07 light client on the EVM roll-up for the client state's latest height. + // Ask the Celestia prover for a state transition proof from the last height (previous step) to the most recent height on SimApp. + // Ask the Celestia prover for a state membership proof that the receipt is a merkle leaf of the state root. + // Combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. } @@ -145,7 +144,7 @@ func QueryPacketCommitments(txHash string) error { return nil } -func QueryLastTrustedStateRoot() error { +func QueryLastTrustedHeight() error { fmt.Printf("Querying last trusted state root on EVM...\n") // The SP1 TM light client on the EVM roll-up has two pieces of state that we want to query: // 1. trusted client state From 095f29c0a92e78a0b7901fe7fbaf9a0b70f9b38b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:33:31 -0500 Subject: [PATCH 11/98] more cleanup --- testing/demo/pkg/transfer/main.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index d40dcf6..690633e 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -46,15 +46,13 @@ func main() { os.Exit(1) } - // We need to query the EVM contract for the last trusted state root that exists in the ICS07 Tendermint smart contract on the EVM. - err = QueryLastTrustedHeight() + err = QueryLightClientLatestHeight() if err != nil { fmt.Println(err) os.Exit(1) } // TODO - // Query the ICS07 light client on the EVM roll-up for the client state's latest height. // Ask the Celestia prover for a state transition proof from the last height (previous step) to the most recent height on SimApp. // Ask the Celestia prover for a state membership proof that the receipt is a merkle leaf of the state root. // Combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. @@ -122,6 +120,7 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { }, nil } +// QueryPacketCommitments queries the packet commitments on the SimApp. func QueryPacketCommitments(txHash string) error { fmt.Printf("Querying packet commitments on SimApp...\n") @@ -144,12 +143,10 @@ func QueryPacketCommitments(txHash string) error { return nil } -func QueryLastTrustedHeight() error { - fmt.Printf("Querying last trusted state root on EVM...\n") - // The SP1 TM light client on the EVM roll-up has two pieces of state that we want to query: - // 1. trusted client state - // 2. trusted consensus state - // I think we want to query inside the trusted client state to get the last height of SimApp that the light client knows about.. +// QueryLightClientLatestHeight queries the ICS07 light client on the EVM roll-up for the client state's latest height. +func QueryLightClientLatestHeight() error { + fmt.Printf("Querying ICS07 light client for the client state's latest height...\n") + // The SP1 TM light client on the EVM roll-up has a field for client state and inside that is the latest height. return nil } From e5683ef73e3c06dcabbd9856935117f3f2125597 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:40:49 -0500 Subject: [PATCH 12/98] debug: ICS07 light client has unique addresses --- testing/demo/pkg/transfer/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 690633e..14266a2 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -150,3 +150,7 @@ func QueryLightClientLatestHeight() error { // The SP1 TM light client on the EVM roll-up has a field for client state and inside that is the latest height. return nil } + +// Unfortunately the ICS07 light client on the EVM roll-up doesn't have a fixed contract address. Everytime we deploy it, it appears unique: +// 0x67cff9B0F9F25c00C71bd8300c3f38553088e234 +// 0x83b466f5856dc4f531bb5af45045de06889d63cb From be9ba01f5629e53f7bc4e41cfe6bf4f05bc94348 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:48:39 -0500 Subject: [PATCH 13/98] query client state latest height --- testing/demo/pkg/transfer/main.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 14266a2..c8f5693 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -14,6 +14,9 @@ import ( channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" + "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" ) const ( @@ -146,11 +149,24 @@ func QueryPacketCommitments(txHash string) error { // QueryLightClientLatestHeight queries the ICS07 light client on the EVM roll-up for the client state's latest height. func QueryLightClientLatestHeight() error { fmt.Printf("Querying ICS07 light client for the client state's latest height...\n") + ethClient, err := ethclient.Dial("http://localhost:8545") + if err != nil { + return err + } - // The SP1 TM light client on the EVM roll-up has a field for client state and inside that is the latest height. + // HACKHACK + // Unfortunately the ICS07 light client on the EVM roll-up doesn't have a fixed contract address. Everytime we deploy it, it appears unique: + // 0x67cff9B0F9F25c00C71bd8300c3f38553088e234 + lightClient := "0x83b466f5856dc4f531bb5af45045de06889d63cb" + sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(lightClient), ethClient) + if err != nil { + return err + } + clientState, err := sp1Ics07Contract.GetClientState(nil) + if err != nil { + return err + } + + fmt.Printf("Client state latest height: %v\n", clientState.LatestHeight) return nil } - -// Unfortunately the ICS07 light client on the EVM roll-up doesn't have a fixed contract address. Everytime we deploy it, it appears unique: -// 0x67cff9B0F9F25c00C71bd8300c3f38553088e234 -// 0x83b466f5856dc4f531bb5af45045de06889d63cb From fc893cf3f0b8d8860fc85a2469310be54c972a7e Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 16:51:59 -0500 Subject: [PATCH 14/98] refactor --- testing/demo/pkg/transfer/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index c8f5693..f14de9a 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -34,6 +34,9 @@ const ( // channelID is the channel ID on SimApp that was created by the `make setup` command. channelID = "channel-0" + + // ethereumRPC is the RPC endpoint of the EVM chain. + ethereumRPC = "http://localhost:8545" ) func main() { @@ -148,8 +151,9 @@ func QueryPacketCommitments(txHash string) error { // QueryLightClientLatestHeight queries the ICS07 light client on the EVM roll-up for the client state's latest height. func QueryLightClientLatestHeight() error { - fmt.Printf("Querying ICS07 light client for the client state's latest height...\n") - ethClient, err := ethclient.Dial("http://localhost:8545") + fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") + + ethClient, err := ethclient.Dial(ethereumRPC) if err != nil { return err } From 154de99b27826f983ed0bc37dd478c8697c88573 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 17:02:50 -0500 Subject: [PATCH 15/98] start querying the celestia prover --- testing/demo/pkg/transfer/main.go | 51 ++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index f14de9a..a4d8558 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -37,6 +37,8 @@ const ( // ethereumRPC is the RPC endpoint of the EVM chain. ethereumRPC = "http://localhost:8545" + + celestiaProverEndpoint = "http://localhost:50051" ) func main() { @@ -52,17 +54,24 @@ func main() { os.Exit(1) } - err = QueryLightClientLatestHeight() + clientHeight, err := QueryLightClientLatestHeight() if err != nil { fmt.Println(err) os.Exit(1) } + latestHeight, err := QueryLatestHeight() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + stateTransitionProof = GetStateTransitionProof(clientHeight, latestHeight) + // TODO // Ask the Celestia prover for a state transition proof from the last height (previous step) to the most recent height on SimApp. // Ask the Celestia prover for a state membership proof that the receipt is a merkle leaf of the state root. // Combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. - } func SubmitMsgTransfer() (txHash string, err error) { @@ -150,12 +159,12 @@ func QueryPacketCommitments(txHash string) error { } // QueryLightClientLatestHeight queries the ICS07 light client on the EVM roll-up for the client state's latest height. -func QueryLightClientLatestHeight() error { +func QueryLightClientLatestHeight() (latestHeight uint32, err error) { fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") ethClient, err := ethclient.Dial(ethereumRPC) if err != nil { - return err + return 0, err } // HACKHACK @@ -164,13 +173,39 @@ func QueryLightClientLatestHeight() error { lightClient := "0x83b466f5856dc4f531bb5af45045de06889d63cb" sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(lightClient), ethClient) if err != nil { - return err + return 0, err } clientState, err := sp1Ics07Contract.GetClientState(nil) if err != nil { - return err + return 0, err } - fmt.Printf("Client state latest height: %v\n", clientState.LatestHeight) - return nil + fmt.Printf("Client state latest height: %v, revision height %v, revision number %v.\n", clientState.LatestHeight, clientState.LatestHeight.RevisionHeight, clientState.LatestHeight.RevisionNumber) + return clientState.LatestHeight.RevisionHeight, nil +} + +// QueryLatestHeight queries the latest height on SimApp. +func QueryLatestHeight() (height uint32, err error) { + clientCtx, err := utils.SetupClientContext() + if err != nil { + return 0, err + } + + node, err := clientCtx.GetNode() + if err != nil { + return 0, err + } + + status, err := node.Status(context.Background()) + if err != nil { + return 0, err + } + + return uint32(status.SyncInfo.LatestBlockHeight), nil +} + +// GetStateTransitionProof gets the state transition proof from the Celestia prover. +func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTransitionProof []byte, err error) { + + return []byte{}, nil } From 653b53bd563d6565895eb5f1518306b3688a6b5c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 17:27:03 -0500 Subject: [PATCH 16/98] debug: celestia prover fails to query EVM roll-up failed to request state transition proof: rpc error: code = Internal desc = error sending request for url (http://localhost:8545/) --- docker-compose.yml | 6 +- testing/demo/pkg/client/prover.pb.go | 523 ++++++++++++++++++++++ testing/demo/pkg/client/prover_grpc.pb.go | 197 ++++++++ testing/demo/pkg/transfer/main.go | 74 ++- 4 files changed, 778 insertions(+), 22 deletions(-) create mode 100644 testing/demo/pkg/client/prover.pb.go create mode 100644 testing/demo/pkg/client/prover_grpc.pb.go diff --git a/docker-compose.yml b/docker-compose.yml index 2124718..424eb32 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,13 +103,15 @@ services: image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/celestia-prover:latest container_name: celestia-prover environment: - - TENDERMINT_RPC_URL=http://celestia-network-validator:26657 - - RPC_URL=http://reth:8545 + - TENDERMINT_RPC_URL=http://localhost:26657 + - RPC_URL=http://localhost:8545 ports: - "50051:50051" depends_on: beacond: condition: service_started + networks: + - beacon-network networks: beacon-network: diff --git a/testing/demo/pkg/client/prover.pb.go b/testing/demo/pkg/client/prover.pb.go new file mode 100644 index 0000000..f3f4388 --- /dev/null +++ b/testing/demo/pkg/client/prover.pb.go @@ -0,0 +1,523 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: prover/v1/prover.proto + +package client + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type InfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *InfoRequest) Reset() { + *x = InfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoRequest) ProtoMessage() {} + +func (x *InfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoRequest.ProtoReflect.Descriptor instead. +func (*InfoRequest) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{0} +} + +type InfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // TODO: add more info here as is relevant such as the circuit and state machine types + StateTransitionVerifierKey []byte `protobuf:"bytes,1,opt,name=state_transition_verifier_key,json=stateTransitionVerifierKey,proto3" json:"state_transition_verifier_key,omitempty"` + StateMembershipVerifierKey []byte `protobuf:"bytes,2,opt,name=state_membership_verifier_key,json=stateMembershipVerifierKey,proto3" json:"state_membership_verifier_key,omitempty"` +} + +func (x *InfoResponse) Reset() { + *x = InfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoResponse) ProtoMessage() {} + +func (x *InfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoResponse.ProtoReflect.Descriptor instead. +func (*InfoResponse) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{1} +} + +func (x *InfoResponse) GetStateTransitionVerifierKey() []byte { + if x != nil { + return x.StateTransitionVerifierKey + } + return nil +} + +func (x *InfoResponse) GetStateMembershipVerifierKey() []byte { + if x != nil { + return x.StateMembershipVerifierKey + } + return nil +} + +type ProveStateTransitionRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // for evm, this is the contract address, for ibc-go this is the client id + ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` +} + +func (x *ProveStateTransitionRequest) Reset() { + *x = ProveStateTransitionRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProveStateTransitionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProveStateTransitionRequest) ProtoMessage() {} + +func (x *ProveStateTransitionRequest) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProveStateTransitionRequest.ProtoReflect.Descriptor instead. +func (*ProveStateTransitionRequest) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{2} +} + +func (x *ProveStateTransitionRequest) GetClientId() string { + if x != nil { + return x.ClientId + } + return "" +} + +type ProveStateTransitionResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + PublicValues []byte `protobuf:"bytes,2,opt,name=public_values,json=publicValues,proto3" json:"public_values,omitempty"` +} + +func (x *ProveStateTransitionResponse) Reset() { + *x = ProveStateTransitionResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProveStateTransitionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProveStateTransitionResponse) ProtoMessage() {} + +func (x *ProveStateTransitionResponse) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProveStateTransitionResponse.ProtoReflect.Descriptor instead. +func (*ProveStateTransitionResponse) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{3} +} + +func (x *ProveStateTransitionResponse) GetProof() []byte { + if x != nil { + return x.Proof + } + return nil +} + +func (x *ProveStateTransitionResponse) GetPublicValues() []byte { + if x != nil { + return x.PublicValues + } + return nil +} + +type ProveStateMembershipRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + KeyPaths []string `protobuf:"bytes,2,rep,name=key_paths,json=keyPaths,proto3" json:"key_paths,omitempty"` +} + +func (x *ProveStateMembershipRequest) Reset() { + *x = ProveStateMembershipRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProveStateMembershipRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProveStateMembershipRequest) ProtoMessage() {} + +func (x *ProveStateMembershipRequest) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProveStateMembershipRequest.ProtoReflect.Descriptor instead. +func (*ProveStateMembershipRequest) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{4} +} + +func (x *ProveStateMembershipRequest) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *ProveStateMembershipRequest) GetKeyPaths() []string { + if x != nil { + return x.KeyPaths + } + return nil +} + +type ProveStateMembershipResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` +} + +func (x *ProveStateMembershipResponse) Reset() { + *x = ProveStateMembershipResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_prover_v1_prover_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProveStateMembershipResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProveStateMembershipResponse) ProtoMessage() {} + +func (x *ProveStateMembershipResponse) ProtoReflect() protoreflect.Message { + mi := &file_prover_v1_prover_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProveStateMembershipResponse.ProtoReflect.Descriptor instead. +func (*ProveStateMembershipResponse) Descriptor() ([]byte, []int) { + return file_prover_v1_prover_proto_rawDescGZIP(), []int{5} +} + +func (x *ProveStateMembershipResponse) GetProof() []byte { + if x != nil { + return x.Proof + } + return nil +} + +func (x *ProveStateMembershipResponse) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +var File_prover_v1_prover_proto protoreflect.FileDescriptor + +var file_prover_v1_prover_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x76, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, + 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x94, 0x01, 0x0a, 0x0c, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x1d, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, + 0x41, 0x0a, 0x1d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x68, 0x69, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, + 0x65, 0x79, 0x22, 0x3a, 0x0a, 0x1b, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x59, + 0x0a, 0x1c, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, + 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x52, 0x0a, 0x1b, 0x50, 0x72, 0x6f, + 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, + 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x12, 0x1b, 0x0a, 0x09, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x08, 0x6b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x73, 0x22, 0x4c, 0x0a, + 0x1c, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, + 0x6f, 0x6f, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x32, 0xc9, 0x02, 0x0a, 0x06, + 0x50, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, + 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, + 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x20, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, + 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x79, 0x0a, 0x14, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x2e, 0x63, 0x65, 0x6c, 0x65, + 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x65, 0x6c, + 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, + 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x14, + 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x68, 0x69, 0x70, 0x12, 0x2f, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, + 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x10, 0x5a, 0x0e, 0x70, 0x72, 0x6f, 0x76, 0x65, + 0x72, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_prover_v1_prover_proto_rawDescOnce sync.Once + file_prover_v1_prover_proto_rawDescData = file_prover_v1_prover_proto_rawDesc +) + +func file_prover_v1_prover_proto_rawDescGZIP() []byte { + file_prover_v1_prover_proto_rawDescOnce.Do(func() { + file_prover_v1_prover_proto_rawDescData = protoimpl.X.CompressGZIP(file_prover_v1_prover_proto_rawDescData) + }) + return file_prover_v1_prover_proto_rawDescData +} + +var file_prover_v1_prover_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_prover_v1_prover_proto_goTypes = []any{ + (*InfoRequest)(nil), // 0: celestia.prover.v1.InfoRequest + (*InfoResponse)(nil), // 1: celestia.prover.v1.InfoResponse + (*ProveStateTransitionRequest)(nil), // 2: celestia.prover.v1.ProveStateTransitionRequest + (*ProveStateTransitionResponse)(nil), // 3: celestia.prover.v1.ProveStateTransitionResponse + (*ProveStateMembershipRequest)(nil), // 4: celestia.prover.v1.ProveStateMembershipRequest + (*ProveStateMembershipResponse)(nil), // 5: celestia.prover.v1.ProveStateMembershipResponse +} +var file_prover_v1_prover_proto_depIdxs = []int32{ + 0, // 0: celestia.prover.v1.Prover.Info:input_type -> celestia.prover.v1.InfoRequest + 2, // 1: celestia.prover.v1.Prover.ProveStateTransition:input_type -> celestia.prover.v1.ProveStateTransitionRequest + 4, // 2: celestia.prover.v1.Prover.ProveStateMembership:input_type -> celestia.prover.v1.ProveStateMembershipRequest + 1, // 3: celestia.prover.v1.Prover.Info:output_type -> celestia.prover.v1.InfoResponse + 3, // 4: celestia.prover.v1.Prover.ProveStateTransition:output_type -> celestia.prover.v1.ProveStateTransitionResponse + 5, // 5: celestia.prover.v1.Prover.ProveStateMembership:output_type -> celestia.prover.v1.ProveStateMembershipResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_prover_v1_prover_proto_init() } +func file_prover_v1_prover_proto_init() { + if File_prover_v1_prover_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_prover_v1_prover_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*InfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prover_v1_prover_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*InfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prover_v1_prover_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*ProveStateTransitionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prover_v1_prover_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*ProveStateTransitionResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prover_v1_prover_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*ProveStateMembershipRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_prover_v1_prover_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*ProveStateMembershipResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_prover_v1_prover_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_prover_v1_prover_proto_goTypes, + DependencyIndexes: file_prover_v1_prover_proto_depIdxs, + MessageInfos: file_prover_v1_prover_proto_msgTypes, + }.Build() + File_prover_v1_prover_proto = out.File + file_prover_v1_prover_proto_rawDesc = nil + file_prover_v1_prover_proto_goTypes = nil + file_prover_v1_prover_proto_depIdxs = nil +} diff --git a/testing/demo/pkg/client/prover_grpc.pb.go b/testing/demo/pkg/client/prover_grpc.pb.go new file mode 100644 index 0000000..228d98c --- /dev/null +++ b/testing/demo/pkg/client/prover_grpc.pb.go @@ -0,0 +1,197 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: prover/v1/prover.proto + +package client + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Prover_Info_FullMethodName = "/celestia.prover.v1.Prover/Info" + Prover_ProveStateTransition_FullMethodName = "/celestia.prover.v1.Prover/ProveStateTransition" + Prover_ProveStateMembership_FullMethodName = "/celestia.prover.v1.Prover/ProveStateMembership" +) + +// ProverClient is the client API for Prover service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ProverClient interface { + Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) + ProveStateTransition(ctx context.Context, in *ProveStateTransitionRequest, opts ...grpc.CallOption) (*ProveStateTransitionResponse, error) + ProveStateMembership(ctx context.Context, in *ProveStateMembershipRequest, opts ...grpc.CallOption) (*ProveStateMembershipResponse, error) +} + +type proverClient struct { + cc grpc.ClientConnInterface +} + +func NewProverClient(cc grpc.ClientConnInterface) ProverClient { + return &proverClient{cc} +} + +func (c *proverClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InfoResponse) + err := c.cc.Invoke(ctx, Prover_Info_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *proverClient) ProveStateTransition(ctx context.Context, in *ProveStateTransitionRequest, opts ...grpc.CallOption) (*ProveStateTransitionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ProveStateTransitionResponse) + err := c.cc.Invoke(ctx, Prover_ProveStateTransition_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *proverClient) ProveStateMembership(ctx context.Context, in *ProveStateMembershipRequest, opts ...grpc.CallOption) (*ProveStateMembershipResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ProveStateMembershipResponse) + err := c.cc.Invoke(ctx, Prover_ProveStateMembership_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProverServer is the server API for Prover service. +// All implementations must embed UnimplementedProverServer +// for forward compatibility. +type ProverServer interface { + Info(context.Context, *InfoRequest) (*InfoResponse, error) + ProveStateTransition(context.Context, *ProveStateTransitionRequest) (*ProveStateTransitionResponse, error) + ProveStateMembership(context.Context, *ProveStateMembershipRequest) (*ProveStateMembershipResponse, error) + mustEmbedUnimplementedProverServer() +} + +// UnimplementedProverServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedProverServer struct{} + +func (UnimplementedProverServer) Info(context.Context, *InfoRequest) (*InfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") +} +func (UnimplementedProverServer) ProveStateTransition(context.Context, *ProveStateTransitionRequest) (*ProveStateTransitionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProveStateTransition not implemented") +} +func (UnimplementedProverServer) ProveStateMembership(context.Context, *ProveStateMembershipRequest) (*ProveStateMembershipResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ProveStateMembership not implemented") +} +func (UnimplementedProverServer) mustEmbedUnimplementedProverServer() {} +func (UnimplementedProverServer) testEmbeddedByValue() {} + +// UnsafeProverServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ProverServer will +// result in compilation errors. +type UnsafeProverServer interface { + mustEmbedUnimplementedProverServer() +} + +func RegisterProverServer(s grpc.ServiceRegistrar, srv ProverServer) { + // If the following call pancis, it indicates UnimplementedProverServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Prover_ServiceDesc, srv) +} + +func _Prover_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProverServer).Info(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Prover_Info_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProverServer).Info(ctx, req.(*InfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Prover_ProveStateTransition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ProveStateTransitionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProverServer).ProveStateTransition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Prover_ProveStateTransition_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProverServer).ProveStateTransition(ctx, req.(*ProveStateTransitionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Prover_ProveStateMembership_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ProveStateMembershipRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProverServer).ProveStateMembership(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Prover_ProveStateMembership_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProverServer).ProveStateMembership(ctx, req.(*ProveStateMembershipRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Prover_ServiceDesc is the grpc.ServiceDesc for Prover service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Prover_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "celestia.prover.v1.Prover", + HandlerType: (*ProverServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Info", + Handler: _Prover_Info_Handler, + }, + { + MethodName: "ProveStateTransition", + Handler: _Prover_ProveStateTransition_Handler, + }, + { + MethodName: "ProveStateMembership", + Handler: _Prover_ProveStateMembership_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "prover/v1/prover.proto", +} diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index a4d8558..1240cc4 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -3,10 +3,12 @@ package main import ( "context" "fmt" + "log" "os" "time" "cosmossdk.io/math" + proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" "github.com/cosmos/cosmos-sdk/client" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -17,6 +19,8 @@ import ( "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const ( @@ -32,42 +36,56 @@ const ( // amount is the amount of tokens to transfer. amount = 100 - // channelID is the channel ID on SimApp that was created by the `make setup` command. - channelID = "channel-0" - // ethereumRPC is the RPC endpoint of the EVM chain. ethereumRPC = "http://localhost:8545" - celestiaProverEndpoint = "http://localhost:50051" + // celestiaProverEndpoint is the endpoint of the Celestia prover. + celestiaProverEndpoint = "localhost:50051" + + // channelID is the channel ID on SimApp. + // TODO: fetch this from the `make setup` command output. + channelID = "channel-0" + + // clientID is the client ID on SimApp. + // TODO: fetch this from the `make setup` command output. + clientID = "08-groth16-0" + + // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. + // TODO: fetch this from the `make setup` command output. + ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" ) func main() { - txHash, err := SubmitMsgTransfer() - if err != nil { - fmt.Println(err) - os.Exit(1) - } + // txHash, err := SubmitMsgTransfer() + // if err != nil { + // fmt.Println(err) + // os.Exit(1) + // } + + // err = QueryPacketCommitments(txHash) + // if err != nil { + // fmt.Println(err) + // os.Exit(1) + // } - err = QueryPacketCommitments(txHash) + clientHeight, err := QueryLightClientLatestHeight() if err != nil { fmt.Println(err) os.Exit(1) } - clientHeight, err := QueryLightClientLatestHeight() + latestHeight, err := QueryLatestHeight() if err != nil { fmt.Println(err) os.Exit(1) } - latestHeight, err := QueryLatestHeight() + _, err = GetStateTransitionProof(clientHeight, latestHeight) if err != nil { fmt.Println(err) os.Exit(1) } - stateTransitionProof = GetStateTransitionProof(clientHeight, latestHeight) - // TODO // Ask the Celestia prover for a state transition proof from the last height (previous step) to the most recent height on SimApp. // Ask the Celestia prover for a state membership proof that the receipt is a merkle leaf of the state root. @@ -167,11 +185,7 @@ func QueryLightClientLatestHeight() (latestHeight uint32, err error) { return 0, err } - // HACKHACK - // Unfortunately the ICS07 light client on the EVM roll-up doesn't have a fixed contract address. Everytime we deploy it, it appears unique: - // 0x67cff9B0F9F25c00C71bd8300c3f38553088e234 - lightClient := "0x83b466f5856dc4f531bb5af45045de06889d63cb" - sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(lightClient), ethClient) + sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(ics07TMContractAddress), ethClient) if err != nil { return 0, err } @@ -206,6 +220,26 @@ func QueryLatestHeight() (height uint32, err error) { // GetStateTransitionProof gets the state transition proof from the Celestia prover. func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTransitionProof []byte, err error) { + conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatalf("Failed to connect to the prover service: %v", err) + } + defer conn.Close() + + client := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateTransitionRequest{ + ClientId: clientID, + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() + + response, err := client.ProveStateTransition(ctx, request) + if err != nil { + return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) + } - return []byte{}, nil + fmt.Printf("Proof: %x\n", response.Proof) + fmt.Printf("Public Values: %x\n", response.PublicValues) + return response.Proof, nil } From 3604855e06763e4247c74ef467008a1551c829bf Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Sat, 4 Jan 2025 17:28:28 -0500 Subject: [PATCH 17/98] cleanup --- Makefile | 2 +- testing/demo/pkg/transfer/main.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 9805f67..e328610 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ install-simapp: .PHONY: install-simapp ## install: Install the simapp binary into the $GOPATH/bin directory. -install: install-simapp install-relayer +install: install-simapp .PHONY: install ## mod: Update all go.mod files. diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 1240cc4..a4924ad 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -56,17 +56,17 @@ const ( ) func main() { - // txHash, err := SubmitMsgTransfer() - // if err != nil { - // fmt.Println(err) - // os.Exit(1) - // } - - // err = QueryPacketCommitments(txHash) - // if err != nil { - // fmt.Println(err) - // os.Exit(1) - // } + txHash, err := SubmitMsgTransfer() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + err = QueryPacketCommitments(txHash) + if err != nil { + fmt.Println(err) + os.Exit(1) + } clientHeight, err := QueryLightClientLatestHeight() if err != nil { From 9f9f526a4cb2867e74bc6af3360776e8cb5cdbc9 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 14:39:13 -0500 Subject: [PATCH 18/98] debug: add curl to celestia-prover to test connectivity --- docker/celestia_prover.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/celestia_prover.Dockerfile b/docker/celestia_prover.Dockerfile index d6d66cf..740718a 100644 --- a/docker/celestia_prover.Dockerfile +++ b/docker/celestia_prover.Dockerfile @@ -33,6 +33,7 @@ FROM debian:bookworm-slim RUN apt-get update && apt-get install -y \ libssl3 \ ca-certificates \ + curl \ && rm -rf /var/lib/apt/lists/* # Copy binary from builder From 195198f6c84ced037e3b7daaca254b77b404659d Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 15:22:25 -0500 Subject: [PATCH 19/98] revert URL changes --- docker/celestia_prover.Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/celestia_prover.Dockerfile b/docker/celestia_prover.Dockerfile index 740718a..0d3ced0 100644 --- a/docker/celestia_prover.Dockerfile +++ b/docker/celestia_prover.Dockerfile @@ -48,8 +48,8 @@ WORKDIR /home/prover COPY --from=builder /celestia_zkevm_ibc_demo/provers/celestia-prover/proto_descriptor.bin . # Default environment variables that can be overridden -ENV TENDERMINT_RPC_URL=http://localhost:5123 -ENV RPC_URL=http://localhost:8545 +ENV TENDERMINT_RPC_URL=http://celestia-network-validator:26657 +ENV RPC_URL=http://reth:8545 ENV CONTRACT_ADDRESS=0x2854CFaC53FCaB6C95E28de8C91B96a31f0af8DD ENV PROVER_PORT=50051 From 8bc7605469686c195e478e6fb0f7f04eedca22f3 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 15:30:21 -0500 Subject: [PATCH 20/98] fix: provide SP1 contract address as client ID in request --- testing/demo/pkg/transfer/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index a4924ad..4705145 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -228,7 +228,7 @@ func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTra client := proverclient.NewProverClient(conn) request := &proverclient.ProveStateTransitionRequest{ - ClientId: clientID, + ClientId: ics07TMContractAddress, } ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) From 36ca6dc32431267eb2d3797a6ba3f4505f4e38cd Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 15:35:16 -0500 Subject: [PATCH 21/98] fix: one error, now another --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 424eb32..574e2c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -104,7 +104,7 @@ services: container_name: celestia-prover environment: - TENDERMINT_RPC_URL=http://localhost:26657 - - RPC_URL=http://localhost:8545 + # - RPC_URL=http://localhost:8545 ports: - "50051:50051" depends_on: From 4cb4331fe5837e51195b76d4000a556a14dcf925 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 15:46:44 -0500 Subject: [PATCH 22/98] fix: connect celestia-prover to simapp --- docker-compose.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 574e2c3..7579a68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,8 +103,9 @@ services: image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/celestia-prover:latest container_name: celestia-prover environment: - - TENDERMINT_RPC_URL=http://localhost:26657 - # - RPC_URL=http://localhost:8545 + # In this demo, connect the Celestia prover to SimApp which is acting as a + # substitute for Celestia with IBC Eurekea enabled. + - TENDERMINT_RPC_URL=http://simapp-validator:26657 ports: - "50051:50051" depends_on: From 1b381c66ab0cd13463b29308de7069528a8ddf3d Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 16:02:53 -0500 Subject: [PATCH 23/98] debug: bump timeout --- testing/demo/pkg/transfer/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 4705145..43ce164 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -231,7 +231,7 @@ func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTra ClientId: ics07TMContractAddress, } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) defer cancel() response, err := client.ProveStateTransition(ctx, request) From 962cf359077ea8c80115031a21e904925ed3208c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 6 Jan 2025 16:20:52 -0500 Subject: [PATCH 24/98] revert: dockerfile overrides and override via docker compose --- docker-compose.yml | 5 +++-- docker/celestia_prover.Dockerfile | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7579a68..7868928 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,8 +103,9 @@ services: image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/celestia-prover:latest container_name: celestia-prover environment: - # In this demo, connect the Celestia prover to SimApp which is acting as a - # substitute for Celestia with IBC Eurekea enabled. + - RPC_URL=http://reth:8545 + # TENDERMINT_RPC_URL should be the SimApp which is acting as a substitute + # for Celestia (with IBC Eurekea enabled). - TENDERMINT_RPC_URL=http://simapp-validator:26657 ports: - "50051:50051" diff --git a/docker/celestia_prover.Dockerfile b/docker/celestia_prover.Dockerfile index 0d3ced0..740718a 100644 --- a/docker/celestia_prover.Dockerfile +++ b/docker/celestia_prover.Dockerfile @@ -48,8 +48,8 @@ WORKDIR /home/prover COPY --from=builder /celestia_zkevm_ibc_demo/provers/celestia-prover/proto_descriptor.bin . # Default environment variables that can be overridden -ENV TENDERMINT_RPC_URL=http://celestia-network-validator:26657 -ENV RPC_URL=http://reth:8545 +ENV TENDERMINT_RPC_URL=http://localhost:5123 +ENV RPC_URL=http://localhost:8545 ENV CONTRACT_ADDRESS=0x2854CFaC53FCaB6C95E28de8C91B96a31f0af8DD ENV PROVER_PORT=50051 From 5871af5b6303fb387396b378ad19536110284e43 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:37:39 -0500 Subject: [PATCH 25/98] boilerplate for requesting membership proof --- testing/demo/pkg/setup-env/setup-env.go | 1 + testing/demo/pkg/transfer/main.go | 86 +++++++++++++------------ 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/testing/demo/pkg/setup-env/setup-env.go b/testing/demo/pkg/setup-env/setup-env.go index e2093ac..474b27e 100644 --- a/testing/demo/pkg/setup-env/setup-env.go +++ b/testing/demo/pkg/setup-env/setup-env.go @@ -63,6 +63,7 @@ func copyFile(src, dest string) error { // replaceEnvVars replaces the specified environment variables in the file func replaceEnvVars(filePath string, envVars map[string]string) error { + fmt.Printf("envVars %v\n", envVars) input, err := os.ReadFile(filePath) if err != nil { return err diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 43ce164..838536c 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -10,7 +10,6 @@ import ( "cosmossdk.io/math" proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" - "github.com/cosmos/cosmos-sdk/client" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" @@ -62,33 +61,36 @@ func main() { os.Exit(1) } - err = QueryPacketCommitments(txHash) + resp, err := QueryPacketCommitments(txHash) if err != nil { fmt.Println(err) os.Exit(1) } + latestHeight := resp.GetHeight() clientHeight, err := QueryLightClientLatestHeight() if err != nil { fmt.Println(err) os.Exit(1) } - latestHeight, err := QueryLatestHeight() + // Ask the Celestia prover for a state transition proof from the client + // height to the most recent height on SimApp (should be >= latestHeight). + _, err = GetStateTransitionProof(clientHeight) if err != nil { fmt.Println(err) os.Exit(1) } - _, err = GetStateTransitionProof(clientHeight, latestHeight) + // Ask the Celestia prover for a state membership proof that the packet commitments are part of the state root at the latest block height. + keyPaths := getKeyPaths(resp.Commitments) + _, err = GetMembershipProof(int64(latestHeight.RevisionHeight), keyPaths) if err != nil { fmt.Println(err) os.Exit(1) } // TODO - // Ask the Celestia prover for a state transition proof from the last height (previous step) to the most recent height on SimApp. - // Ask the Celestia prover for a state membership proof that the receipt is a merkle leaf of the state root. // Combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. } @@ -98,15 +100,6 @@ func SubmitMsgTransfer() (txHash string, err error) { return "", fmt.Errorf("failed to setup client context: %v", err) } - txHash, err = submitMsgTransfer(clientCtx) - if err != nil { - return "", fmt.Errorf("failed to submit MsgTransfer: %v", err) - } - - return txHash, nil -} - -func submitMsgTransfer(clientCtx client.Context) (txHash string, err error) { msgTransfer, err := createMsgTransfer() if err != nil { return "", fmt.Errorf("failed to create MsgTransfer: %w", err) @@ -154,12 +147,12 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { } // QueryPacketCommitments queries the packet commitments on the SimApp. -func QueryPacketCommitments(txHash string) error { +func QueryPacketCommitments(txHash string) (*channeltypesv2.QueryPacketCommitmentsResponse, error) { fmt.Printf("Querying packet commitments on SimApp...\n") clientCtx, err := utils.SetupClientContext() if err != nil { - return err + return nil, err } queryClient := channeltypesv2.NewQueryClient(clientCtx) @@ -168,15 +161,15 @@ func QueryPacketCommitments(txHash string) error { } response, err := queryClient.PacketCommitments(context.Background(), &request) if err != nil { - return fmt.Errorf("failed to query packet commitments: %v", err) + return nil, fmt.Errorf("failed to query packet commitments: %v", err) } - // TODO what to do with these packets? - fmt.Printf("Packet commitments: %v\n", response.Commitments) - return nil + fmt.Printf("Packet commitments: %v, packet height %v\n", response.GetCommitments(), response.GetHeight()) + return response, nil } -// QueryLightClientLatestHeight queries the ICS07 light client on the EVM roll-up for the client state's latest height. +// QueryLightClientLatestHeight queries the ICS07 light client on the EVM +// roll-up for the client state's latest height. func QueryLightClientLatestHeight() (latestHeight uint32, err error) { fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") @@ -198,28 +191,33 @@ func QueryLightClientLatestHeight() (latestHeight uint32, err error) { return clientState.LatestHeight.RevisionHeight, nil } -// QueryLatestHeight queries the latest height on SimApp. -func QueryLatestHeight() (height uint32, err error) { - clientCtx, err := utils.SetupClientContext() +// GetStateTransitionProof gets the state transition proof from the Celestia prover. +func GetStateTransitionProof(clientHeight uint32) (stateTransitionProof []byte, err error) { + conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - return 0, err + log.Fatalf("Failed to connect to the prover service: %v", err) } + defer conn.Close() - node, err := clientCtx.GetNode() - if err != nil { - return 0, err + client := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateTransitionRequest{ + ClientId: ics07TMContractAddress, } - status, err := node.Status(context.Background()) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) + defer cancel() + + response, err := client.ProveStateTransition(ctx, request) if err != nil { - return 0, err + return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) } - return uint32(status.SyncInfo.LatestBlockHeight), nil + fmt.Printf("State transition proof: %x, public values %v\n", response.GetProof(), response.GetPublicValues()) + return response.GetProof(), nil } -// GetStateTransitionProof gets the state transition proof from the Celestia prover. -func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTransitionProof []byte, err error) { +// GetMembershipProof gets a membership proof that the key at keyPaths is a Merkle leaf of the state root at a particular block height. +func GetMembershipProof(height int64, keyPaths []string) (membershipProof []byte, err error) { conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatalf("Failed to connect to the prover service: %v", err) @@ -227,19 +225,25 @@ func GetStateTransitionProof(clientHeight uint32, latestHeight uint32) (stateTra defer conn.Close() client := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ - ClientId: ics07TMContractAddress, + request := &proverclient.ProveStateMembershipRequest{ + Height: height, + KeyPaths: keyPaths, } ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) defer cancel() - response, err := client.ProveStateTransition(ctx, request) + response, err := client.ProveStateMembership(ctx, request) if err != nil { - return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) + return []byte{}, fmt.Errorf("failed to request state membership proof: %w", err) } - fmt.Printf("Proof: %x\n", response.Proof) - fmt.Printf("Public Values: %x\n", response.PublicValues) - return response.Proof, nil + fmt.Printf("Membership proof: %x, Height %v\n", response.GetProof(), response.GetHeight()) + return response.GetProof(), nil +} + +// getKeyPaths returns the Merkle path to packets. +func getKeyPaths(_ []*channeltypesv2.PacketState) []string { + // TODO: implement + return []string{} } From 35bef2c311c3eb50e557a83cf8afa5abc3ffe395 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:38:23 -0500 Subject: [PATCH 26/98] refactor: remove unused var --- testing/demo/pkg/transfer/main.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 838536c..a283173 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -45,10 +45,6 @@ const ( // TODO: fetch this from the `make setup` command output. channelID = "channel-0" - // clientID is the client ID on SimApp. - // TODO: fetch this from the `make setup` command output. - clientID = "08-groth16-0" - // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. // TODO: fetch this from the `make setup` command output. ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" From 2917244c07e516a102520fd4848112cf32a57cad Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:40:11 -0500 Subject: [PATCH 27/98] revert --- testing/demo/pkg/setup-env/setup-env.go | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/demo/pkg/setup-env/setup-env.go b/testing/demo/pkg/setup-env/setup-env.go index 474b27e..e2093ac 100644 --- a/testing/demo/pkg/setup-env/setup-env.go +++ b/testing/demo/pkg/setup-env/setup-env.go @@ -63,7 +63,6 @@ func copyFile(src, dest string) error { // replaceEnvVars replaces the specified environment variables in the file func replaceEnvVars(filePath string, envVars map[string]string) error { - fmt.Printf("envVars %v\n", envVars) input, err := os.ReadFile(filePath) if err != nil { return err From 167bb562b561db1700e84f11a50212310b83bc10 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:43:31 -0500 Subject: [PATCH 28/98] add a doc --- testing/demo/pkg/client/doc.go | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 testing/demo/pkg/client/doc.go diff --git a/testing/demo/pkg/client/doc.go b/testing/demo/pkg/client/doc.go new file mode 100644 index 0000000..656fb42 --- /dev/null +++ b/testing/demo/pkg/client/doc.go @@ -0,0 +1,3 @@ +// client exports the proto generated Go types from celestia-prover. +// TODO: de-duplicate with the types in celestia-prover after they are exported from there. +package client From ab14fc8dc4c23bafedd3cf14c1d43583b6b2bc6b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:46:06 -0500 Subject: [PATCH 29/98] resolve todo --- testing/demo/pkg/client/doc.go | 3 - testing/demo/pkg/client/prover.pb.go | 523 ---------------------- testing/demo/pkg/client/prover_grpc.pb.go | 197 -------- testing/demo/pkg/transfer/main.go | 2 +- 4 files changed, 1 insertion(+), 724 deletions(-) delete mode 100644 testing/demo/pkg/client/doc.go delete mode 100644 testing/demo/pkg/client/prover.pb.go delete mode 100644 testing/demo/pkg/client/prover_grpc.pb.go diff --git a/testing/demo/pkg/client/doc.go b/testing/demo/pkg/client/doc.go deleted file mode 100644 index 656fb42..0000000 --- a/testing/demo/pkg/client/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// client exports the proto generated Go types from celestia-prover. -// TODO: de-duplicate with the types in celestia-prover after they are exported from there. -package client diff --git a/testing/demo/pkg/client/prover.pb.go b/testing/demo/pkg/client/prover.pb.go deleted file mode 100644 index f3f4388..0000000 --- a/testing/demo/pkg/client/prover.pb.go +++ /dev/null @@ -1,523 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc (unknown) -// source: prover/v1/prover.proto - -package client - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type InfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *InfoRequest) Reset() { - *x = InfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InfoRequest) ProtoMessage() {} - -func (x *InfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InfoRequest.ProtoReflect.Descriptor instead. -func (*InfoRequest) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{0} -} - -type InfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // TODO: add more info here as is relevant such as the circuit and state machine types - StateTransitionVerifierKey []byte `protobuf:"bytes,1,opt,name=state_transition_verifier_key,json=stateTransitionVerifierKey,proto3" json:"state_transition_verifier_key,omitempty"` - StateMembershipVerifierKey []byte `protobuf:"bytes,2,opt,name=state_membership_verifier_key,json=stateMembershipVerifierKey,proto3" json:"state_membership_verifier_key,omitempty"` -} - -func (x *InfoResponse) Reset() { - *x = InfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InfoResponse) ProtoMessage() {} - -func (x *InfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InfoResponse.ProtoReflect.Descriptor instead. -func (*InfoResponse) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{1} -} - -func (x *InfoResponse) GetStateTransitionVerifierKey() []byte { - if x != nil { - return x.StateTransitionVerifierKey - } - return nil -} - -func (x *InfoResponse) GetStateMembershipVerifierKey() []byte { - if x != nil { - return x.StateMembershipVerifierKey - } - return nil -} - -type ProveStateTransitionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // for evm, this is the contract address, for ibc-go this is the client id - ClientId string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty"` -} - -func (x *ProveStateTransitionRequest) Reset() { - *x = ProveStateTransitionRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProveStateTransitionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProveStateTransitionRequest) ProtoMessage() {} - -func (x *ProveStateTransitionRequest) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProveStateTransitionRequest.ProtoReflect.Descriptor instead. -func (*ProveStateTransitionRequest) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{2} -} - -func (x *ProveStateTransitionRequest) GetClientId() string { - if x != nil { - return x.ClientId - } - return "" -} - -type ProveStateTransitionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` - PublicValues []byte `protobuf:"bytes,2,opt,name=public_values,json=publicValues,proto3" json:"public_values,omitempty"` -} - -func (x *ProveStateTransitionResponse) Reset() { - *x = ProveStateTransitionResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProveStateTransitionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProveStateTransitionResponse) ProtoMessage() {} - -func (x *ProveStateTransitionResponse) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProveStateTransitionResponse.ProtoReflect.Descriptor instead. -func (*ProveStateTransitionResponse) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{3} -} - -func (x *ProveStateTransitionResponse) GetProof() []byte { - if x != nil { - return x.Proof - } - return nil -} - -func (x *ProveStateTransitionResponse) GetPublicValues() []byte { - if x != nil { - return x.PublicValues - } - return nil -} - -type ProveStateMembershipRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` - KeyPaths []string `protobuf:"bytes,2,rep,name=key_paths,json=keyPaths,proto3" json:"key_paths,omitempty"` -} - -func (x *ProveStateMembershipRequest) Reset() { - *x = ProveStateMembershipRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProveStateMembershipRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProveStateMembershipRequest) ProtoMessage() {} - -func (x *ProveStateMembershipRequest) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProveStateMembershipRequest.ProtoReflect.Descriptor instead. -func (*ProveStateMembershipRequest) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{4} -} - -func (x *ProveStateMembershipRequest) GetHeight() int64 { - if x != nil { - return x.Height - } - return 0 -} - -func (x *ProveStateMembershipRequest) GetKeyPaths() []string { - if x != nil { - return x.KeyPaths - } - return nil -} - -type ProveStateMembershipResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Proof []byte `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` -} - -func (x *ProveStateMembershipResponse) Reset() { - *x = ProveStateMembershipResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_prover_v1_prover_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProveStateMembershipResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProveStateMembershipResponse) ProtoMessage() {} - -func (x *ProveStateMembershipResponse) ProtoReflect() protoreflect.Message { - mi := &file_prover_v1_prover_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProveStateMembershipResponse.ProtoReflect.Descriptor instead. -func (*ProveStateMembershipResponse) Descriptor() ([]byte, []int) { - return file_prover_v1_prover_proto_rawDescGZIP(), []int{5} -} - -func (x *ProveStateMembershipResponse) GetProof() []byte { - if x != nil { - return x.Proof - } - return nil -} - -func (x *ProveStateMembershipResponse) GetHeight() int64 { - if x != nil { - return x.Height - } - return 0 -} - -var File_prover_v1_prover_proto protoreflect.FileDescriptor - -var file_prover_v1_prover_proto_rawDesc = []byte{ - 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x76, - 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, - 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x22, 0x0d, 0x0a, 0x0b, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x94, 0x01, 0x0a, 0x0c, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x1d, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, - 0x41, 0x0a, 0x1d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, - 0x68, 0x69, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, - 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, - 0x65, 0x79, 0x22, 0x3a, 0x0a, 0x1b, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x59, - 0x0a, 0x1c, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, - 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0c, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x52, 0x0a, 0x1b, 0x50, 0x72, 0x6f, - 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, - 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x12, 0x1b, 0x0a, 0x09, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x08, 0x6b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x73, 0x22, 0x4c, 0x0a, - 0x1c, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x70, 0x72, - 0x6f, 0x6f, 0x66, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x32, 0xc9, 0x02, 0x0a, 0x06, - 0x50, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, - 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, - 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x20, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, - 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x79, 0x0a, 0x14, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x2e, 0x63, 0x65, 0x6c, 0x65, - 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, - 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x65, 0x6c, - 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, - 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x14, - 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, - 0x73, 0x68, 0x69, 0x70, 0x12, 0x2f, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, 0x2e, - 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x63, 0x65, 0x6c, 0x65, 0x73, 0x74, 0x69, 0x61, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x10, 0x5a, 0x0e, 0x70, 0x72, 0x6f, 0x76, 0x65, - 0x72, 0x73, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_prover_v1_prover_proto_rawDescOnce sync.Once - file_prover_v1_prover_proto_rawDescData = file_prover_v1_prover_proto_rawDesc -) - -func file_prover_v1_prover_proto_rawDescGZIP() []byte { - file_prover_v1_prover_proto_rawDescOnce.Do(func() { - file_prover_v1_prover_proto_rawDescData = protoimpl.X.CompressGZIP(file_prover_v1_prover_proto_rawDescData) - }) - return file_prover_v1_prover_proto_rawDescData -} - -var file_prover_v1_prover_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_prover_v1_prover_proto_goTypes = []any{ - (*InfoRequest)(nil), // 0: celestia.prover.v1.InfoRequest - (*InfoResponse)(nil), // 1: celestia.prover.v1.InfoResponse - (*ProveStateTransitionRequest)(nil), // 2: celestia.prover.v1.ProveStateTransitionRequest - (*ProveStateTransitionResponse)(nil), // 3: celestia.prover.v1.ProveStateTransitionResponse - (*ProveStateMembershipRequest)(nil), // 4: celestia.prover.v1.ProveStateMembershipRequest - (*ProveStateMembershipResponse)(nil), // 5: celestia.prover.v1.ProveStateMembershipResponse -} -var file_prover_v1_prover_proto_depIdxs = []int32{ - 0, // 0: celestia.prover.v1.Prover.Info:input_type -> celestia.prover.v1.InfoRequest - 2, // 1: celestia.prover.v1.Prover.ProveStateTransition:input_type -> celestia.prover.v1.ProveStateTransitionRequest - 4, // 2: celestia.prover.v1.Prover.ProveStateMembership:input_type -> celestia.prover.v1.ProveStateMembershipRequest - 1, // 3: celestia.prover.v1.Prover.Info:output_type -> celestia.prover.v1.InfoResponse - 3, // 4: celestia.prover.v1.Prover.ProveStateTransition:output_type -> celestia.prover.v1.ProveStateTransitionResponse - 5, // 5: celestia.prover.v1.Prover.ProveStateMembership:output_type -> celestia.prover.v1.ProveStateMembershipResponse - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_prover_v1_prover_proto_init() } -func file_prover_v1_prover_proto_init() { - if File_prover_v1_prover_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_prover_v1_prover_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*InfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_prover_v1_prover_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*InfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_prover_v1_prover_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ProveStateTransitionRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_prover_v1_prover_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ProveStateTransitionResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_prover_v1_prover_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*ProveStateMembershipRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_prover_v1_prover_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ProveStateMembershipResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_prover_v1_prover_proto_rawDesc, - NumEnums: 0, - NumMessages: 6, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_prover_v1_prover_proto_goTypes, - DependencyIndexes: file_prover_v1_prover_proto_depIdxs, - MessageInfos: file_prover_v1_prover_proto_msgTypes, - }.Build() - File_prover_v1_prover_proto = out.File - file_prover_v1_prover_proto_rawDesc = nil - file_prover_v1_prover_proto_goTypes = nil - file_prover_v1_prover_proto_depIdxs = nil -} diff --git a/testing/demo/pkg/client/prover_grpc.pb.go b/testing/demo/pkg/client/prover_grpc.pb.go deleted file mode 100644 index 228d98c..0000000 --- a/testing/demo/pkg/client/prover_grpc.pb.go +++ /dev/null @@ -1,197 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: prover/v1/prover.proto - -package client - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - Prover_Info_FullMethodName = "/celestia.prover.v1.Prover/Info" - Prover_ProveStateTransition_FullMethodName = "/celestia.prover.v1.Prover/ProveStateTransition" - Prover_ProveStateMembership_FullMethodName = "/celestia.prover.v1.Prover/ProveStateMembership" -) - -// ProverClient is the client API for Prover service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ProverClient interface { - Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) - ProveStateTransition(ctx context.Context, in *ProveStateTransitionRequest, opts ...grpc.CallOption) (*ProveStateTransitionResponse, error) - ProveStateMembership(ctx context.Context, in *ProveStateMembershipRequest, opts ...grpc.CallOption) (*ProveStateMembershipResponse, error) -} - -type proverClient struct { - cc grpc.ClientConnInterface -} - -func NewProverClient(cc grpc.ClientConnInterface) ProverClient { - return &proverClient{cc} -} - -func (c *proverClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(InfoResponse) - err := c.cc.Invoke(ctx, Prover_Info_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *proverClient) ProveStateTransition(ctx context.Context, in *ProveStateTransitionRequest, opts ...grpc.CallOption) (*ProveStateTransitionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ProveStateTransitionResponse) - err := c.cc.Invoke(ctx, Prover_ProveStateTransition_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *proverClient) ProveStateMembership(ctx context.Context, in *ProveStateMembershipRequest, opts ...grpc.CallOption) (*ProveStateMembershipResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ProveStateMembershipResponse) - err := c.cc.Invoke(ctx, Prover_ProveStateMembership_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ProverServer is the server API for Prover service. -// All implementations must embed UnimplementedProverServer -// for forward compatibility. -type ProverServer interface { - Info(context.Context, *InfoRequest) (*InfoResponse, error) - ProveStateTransition(context.Context, *ProveStateTransitionRequest) (*ProveStateTransitionResponse, error) - ProveStateMembership(context.Context, *ProveStateMembershipRequest) (*ProveStateMembershipResponse, error) - mustEmbedUnimplementedProverServer() -} - -// UnimplementedProverServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedProverServer struct{} - -func (UnimplementedProverServer) Info(context.Context, *InfoRequest) (*InfoResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Info not implemented") -} -func (UnimplementedProverServer) ProveStateTransition(context.Context, *ProveStateTransitionRequest) (*ProveStateTransitionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProveStateTransition not implemented") -} -func (UnimplementedProverServer) ProveStateMembership(context.Context, *ProveStateMembershipRequest) (*ProveStateMembershipResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ProveStateMembership not implemented") -} -func (UnimplementedProverServer) mustEmbedUnimplementedProverServer() {} -func (UnimplementedProverServer) testEmbeddedByValue() {} - -// UnsafeProverServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ProverServer will -// result in compilation errors. -type UnsafeProverServer interface { - mustEmbedUnimplementedProverServer() -} - -func RegisterProverServer(s grpc.ServiceRegistrar, srv ProverServer) { - // If the following call pancis, it indicates UnimplementedProverServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&Prover_ServiceDesc, srv) -} - -func _Prover_Info_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InfoRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProverServer).Info(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Prover_Info_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProverServer).Info(ctx, req.(*InfoRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Prover_ProveStateTransition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ProveStateTransitionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProverServer).ProveStateTransition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Prover_ProveStateTransition_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProverServer).ProveStateTransition(ctx, req.(*ProveStateTransitionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Prover_ProveStateMembership_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ProveStateMembershipRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProverServer).ProveStateMembership(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Prover_ProveStateMembership_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProverServer).ProveStateMembership(ctx, req.(*ProveStateMembershipRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Prover_ServiceDesc is the grpc.ServiceDesc for Prover service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Prover_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "celestia.prover.v1.Prover", - HandlerType: (*ProverServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Info", - Handler: _Prover_Info_Handler, - }, - { - MethodName: "ProveStateTransition", - Handler: _Prover_ProveStateTransition_Handler, - }, - { - MethodName: "ProveStateMembership", - Handler: _Prover_ProveStateMembership_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "prover/v1/prover.proto", -} diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index a283173..4395910 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -8,7 +8,7 @@ import ( "time" "cosmossdk.io/math" - proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/client" + proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" From 372e9282a65d508349f10e61c7d389e4b3f488af Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:46:32 -0500 Subject: [PATCH 30/98] reorder --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7868928..19b1fe4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -103,10 +103,10 @@ services: image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/celestia-prover:latest container_name: celestia-prover environment: - - RPC_URL=http://reth:8545 # TENDERMINT_RPC_URL should be the SimApp which is acting as a substitute # for Celestia (with IBC Eurekea enabled). - TENDERMINT_RPC_URL=http://simapp-validator:26657 + - RPC_URL=http://reth:8545 ports: - "50051:50051" depends_on: From 59b0a239d234b8e83cafa030e2cc08785b80d9be Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:48:26 -0500 Subject: [PATCH 31/98] refactor: tx hash is not needed --- testing/demo/pkg/transfer/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 4395910..3941b0e 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -51,13 +51,13 @@ const ( ) func main() { - txHash, err := SubmitMsgTransfer() + _, err := SubmitMsgTransfer() if err != nil { fmt.Println(err) os.Exit(1) } - resp, err := QueryPacketCommitments(txHash) + resp, err := QueryPacketCommitments() if err != nil { fmt.Println(err) os.Exit(1) @@ -143,7 +143,7 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { } // QueryPacketCommitments queries the packet commitments on the SimApp. -func QueryPacketCommitments(txHash string) (*channeltypesv2.QueryPacketCommitmentsResponse, error) { +func QueryPacketCommitments() (*channeltypesv2.QueryPacketCommitmentsResponse, error) { fmt.Printf("Querying packet commitments on SimApp...\n") clientCtx, err := utils.SetupClientContext() From d9a81ae4b7cd529773c3e307db1341d393303f92 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 15:49:02 -0500 Subject: [PATCH 32/98] remove unnecessary util --- testing/demo/pkg/utils/utils.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/testing/demo/pkg/utils/utils.go b/testing/demo/pkg/utils/utils.go index 09e4bc3..a61548b 100644 --- a/testing/demo/pkg/utils/utils.go +++ b/testing/demo/pkg/utils/utils.go @@ -227,11 +227,3 @@ func WaitForCondition(timeoutAfter, pollingInterval time.Duration, fn func() (bo } } } - -func QueryTx(clientContext client.Context, txHash string) (*sdk.TxResponse, error) { - txResponse, err := authtx.QueryTx(clientContext, txHash) - if err != nil { - return nil, fmt.Errorf("failed to query transaction: %v", err) - } - return txResponse, nil -} From 35a7f258a511d06fa33565e752695e3a25e60f4c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 16:06:02 -0500 Subject: [PATCH 33/98] refactor: extract out relay --- Makefile | 9 ++ testing/demo/pkg/relay/main.go | 161 +++++++++++++++++++++++ testing/demo/pkg/transfer/main.go | 207 ++++-------------------------- 3 files changed, 193 insertions(+), 184 deletions(-) create mode 100644 testing/demo/pkg/relay/main.go diff --git a/Makefile b/Makefile index e328610..d1e282c 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,14 @@ transfer: @go run ./testing/demo/pkg/transfer/ .PHONY: transfer +## relay: Relay the token transfer from simapp to the EVM roll-up. +relay: +# Note: this is split out from transfer to speed up local development. This +# command can be merged into transfer to make the demo fewer steps to run. + @echo "--> Relaying the token transfer" + @go run ./testing/demo/pkg/relay/ +.PHONY: relay + ## stop: Stop all processes and remove the tmp directory. stop: @echo "--> Stopping all processes" @@ -226,4 +234,5 @@ demo: @make start @make setup @make transfer + @make relay .PHONY: demo diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go new file mode 100644 index 0000000..0104d47 --- /dev/null +++ b/testing/demo/pkg/relay/main.go @@ -0,0 +1,161 @@ +package main + +import ( + "context" + "fmt" + "log" + "time" + + proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +const ( + // ethereumRPC is the RPC endpoint of the EVM chain. + ethereumRPC = "http://localhost:8545" + // celestiaProverEndpoint is the endpoint of the Celestia prover. + celestiaProverEndpoint = "localhost:50051" + // channelID is the channel ID on SimApp. + // TODO: fetch this from the `make setup` command output. + channelID = "channel-0" + // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. + // TODO: fetch this from the `make setup` command output. + ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" +) + +func main() { + resp, err := QueryPacketCommitments() + if err != nil { + log.Fatal(err) + } + + latestHeight := resp.GetHeight() + clientHeight, err := QueryLightClientLatestHeight() + if err != nil { + log.Fatal(err) + } + + // Ask the Celestia prover for a state transition proof from the client + // height to the most recent height on SimApp which should be >= latestHeight. + _, err = GetStateTransitionProof(clientHeight) + if err != nil { + log.Fatal(err) + } + + // Ask the Celestia prover for a state membership proof that the packet + // commitments are part of the state root at the latest block height. + keyPaths := getKeyPaths(resp.Commitments) + _, err = GetMembershipProof(int64(latestHeight.RevisionHeight), keyPaths) + if err != nil { + log.Fatal(err) + } + + // TODO: combine these proofs and packets and submit a MsgUpdateClient and + // MsgRecvPacket to the EVM rollup. +} + +// QueryPacketCommitments queries the packet commitments on the SimApp. +func QueryPacketCommitments() (*channeltypesv2.QueryPacketCommitmentsResponse, error) { + fmt.Printf("Querying packet commitments on SimApp...\n") + + clientCtx, err := utils.SetupClientContext() + if err != nil { + return nil, err + } + + queryClient := channeltypesv2.NewQueryClient(clientCtx) + request := channeltypesv2.QueryPacketCommitmentsRequest{ChannelId: channelID} + response, err := queryClient.PacketCommitments(context.Background(), &request) + if err != nil { + return nil, fmt.Errorf("failed to query packet commitments: %v", err) + } + + fmt.Printf("Packet commitments: %v, packet height %v\n", response.GetCommitments(), response.GetHeight()) + return response, nil +} + +// QueryLightClientLatestHeight queries the ICS07 light client on the EVM +// roll-up for the client state's latest height. +func QueryLightClientLatestHeight() (latestHeight uint32, err error) { + fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") + + ethClient, err := ethclient.Dial(ethereumRPC) + if err != nil { + return 0, err + } + + sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(ics07TMContractAddress), ethClient) + if err != nil { + return 0, err + } + clientState, err := sp1Ics07Contract.GetClientState(nil) + if err != nil { + return 0, err + } + + fmt.Printf("Client state latest height: %v, revision height %v, revision number %v.\n", clientState.LatestHeight, clientState.LatestHeight.RevisionHeight, clientState.LatestHeight.RevisionNumber) + return clientState.LatestHeight.RevisionHeight, nil +} + +// GetStateTransitionProof gets the state transition proof from the Celestia prover. +func GetStateTransitionProof(clientHeight uint32) (stateTransitionProof []byte, err error) { + conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatalf("Failed to connect to the prover service: %v", err) + } + defer conn.Close() + + client := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateTransitionRequest{ + ClientId: ics07TMContractAddress, + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) + defer cancel() + + response, err := client.ProveStateTransition(ctx, request) + if err != nil { + return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) + } + + fmt.Printf("State transition proof: %x, public values %v\n", response.GetProof(), response.GetPublicValues()) + return response.GetProof(), nil +} + +// GetMembershipProof gets a membership proof that the key at keyPaths is a Merkle leaf of the state root at a particular block height. +func GetMembershipProof(height int64, keyPaths []string) (membershipProof []byte, err error) { + conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatalf("Failed to connect to the prover service: %v", err) + } + defer conn.Close() + + client := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateMembershipRequest{ + Height: height, + KeyPaths: keyPaths, + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) + defer cancel() + + response, err := client.ProveStateMembership(ctx, request) + if err != nil { + return []byte{}, fmt.Errorf("failed to request state membership proof: %w", err) + } + + fmt.Printf("Membership proof: %x, Height %v\n", response.GetProof(), response.GetHeight()) + return response.GetProof(), nil +} + +// getKeyPaths returns the Merkle path to packets. +func getKeyPaths(_ []*channeltypesv2.PacketState) []string { + // TODO: implement + return []string{} +} diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 3941b0e..181c219 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -1,126 +1,48 @@ package main import ( - "context" "fmt" "log" - "os" "time" "cosmossdk.io/math" - proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" - "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" ) const ( - // senderAddress is an address on SimApp that will send funds via the MsgTransfer. - senderAddress = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" - - // receiverAddress is an address on the EVM chain that will receive funds via the MsgTransfer. - receiverAddress = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" - + // sender is an address on SimApp that will send funds via the MsgTransfer. + sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" + // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. + receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" // denom is the denomination of the token on SimApp. denom = "stake" - - // amount is the amount of tokens to transfer. - amount = 100 - - // ethereumRPC is the RPC endpoint of the EVM chain. - ethereumRPC = "http://localhost:8545" - - // celestiaProverEndpoint is the endpoint of the Celestia prover. - celestiaProverEndpoint = "localhost:50051" - - // channelID is the channel ID on SimApp. - // TODO: fetch this from the `make setup` command output. - channelID = "channel-0" - - // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. - // TODO: fetch this from the `make setup` command output. - ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" ) func main() { - _, err := SubmitMsgTransfer() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - resp, err := QueryPacketCommitments() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - latestHeight := resp.GetHeight() - clientHeight, err := QueryLightClientLatestHeight() - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - // Ask the Celestia prover for a state transition proof from the client - // height to the most recent height on SimApp (should be >= latestHeight). - _, err = GetStateTransitionProof(clientHeight) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - // Ask the Celestia prover for a state membership proof that the packet commitments are part of the state root at the latest block height. - keyPaths := getKeyPaths(resp.Commitments) - _, err = GetMembershipProof(int64(latestHeight.RevisionHeight), keyPaths) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - // TODO - // Combine these proofs and packets and submit a MsgUpdateClient and MsgRecvPacket to the EVM rollup. -} - -func SubmitMsgTransfer() (txHash string, err error) { - clientCtx, err := utils.SetupClientContext() + msg, err := createMsgSendPacket() if err != nil { - return "", fmt.Errorf("failed to setup client context: %v", err) + log.Fatal(err) } - msgTransfer, err := createMsgTransfer() - if err != nil { - return "", fmt.Errorf("failed to create MsgTransfer: %w", err) - } - - fmt.Printf("Broadcasting MsgTransfer...\n") - response, err := utils.BroadcastMessages(clientCtx, senderAddress, 200_000, &msgTransfer) + _, err = submitMsgTransfer(msg) if err != nil { - return "", fmt.Errorf("failed to broadcast MsgTransfer %w", err) - } - - if response.Code != 0 { - return "", fmt.Errorf("failed to execute MsgTransfer %v", response.RawLog) + log.Fatal(err) } - fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) - return response.TxHash, nil } -func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(amount)) +// createMsgSendPacket returns a msg that sends 100stake over IBC. +func createMsgSendPacket() (channeltypesv2.MsgSendPacket, error) { + coin := sdktypes.NewCoin(denom, math.NewInt(100)) transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ Denom: coin.Denom, Amount: coin.Amount.BigInt(), - Sender: senderAddress, - Receiver: receiverAddress, + Sender: sender, + Receiver: receiver, Memo: "test transfer", } transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) @@ -138,108 +60,25 @@ func createMsgTransfer() (channeltypesv2.MsgSendPacket, error) { SourceChannel: ibctesting.FirstChannelID, TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), Payloads: []channeltypesv2.Payload{payload}, - Signer: senderAddress, + Signer: sender, }, nil } -// QueryPacketCommitments queries the packet commitments on the SimApp. -func QueryPacketCommitments() (*channeltypesv2.QueryPacketCommitmentsResponse, error) { - fmt.Printf("Querying packet commitments on SimApp...\n") - +func submitMsgTransfer(msg channeltypesv2.MsgSendPacket) (txHash string, err error) { clientCtx, err := utils.SetupClientContext() if err != nil { - return nil, err - } - - queryClient := channeltypesv2.NewQueryClient(clientCtx) - request := channeltypesv2.QueryPacketCommitmentsRequest{ - ChannelId: channelID, - } - response, err := queryClient.PacketCommitments(context.Background(), &request) - if err != nil { - return nil, fmt.Errorf("failed to query packet commitments: %v", err) - } - - fmt.Printf("Packet commitments: %v, packet height %v\n", response.GetCommitments(), response.GetHeight()) - return response, nil -} - -// QueryLightClientLatestHeight queries the ICS07 light client on the EVM -// roll-up for the client state's latest height. -func QueryLightClientLatestHeight() (latestHeight uint32, err error) { - fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") - - ethClient, err := ethclient.Dial(ethereumRPC) - if err != nil { - return 0, err - } - - sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(ics07TMContractAddress), ethClient) - if err != nil { - return 0, err - } - clientState, err := sp1Ics07Contract.GetClientState(nil) - if err != nil { - return 0, err - } - - fmt.Printf("Client state latest height: %v, revision height %v, revision number %v.\n", clientState.LatestHeight, clientState.LatestHeight.RevisionHeight, clientState.LatestHeight.RevisionNumber) - return clientState.LatestHeight.RevisionHeight, nil -} - -// GetStateTransitionProof gets the state transition proof from the Celestia prover. -func GetStateTransitionProof(clientHeight uint32) (stateTransitionProof []byte, err error) { - conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - log.Fatalf("Failed to connect to the prover service: %v", err) - } - defer conn.Close() - - client := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ - ClientId: ics07TMContractAddress, - } - - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) - defer cancel() - - response, err := client.ProveStateTransition(ctx, request) - if err != nil { - return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) + return "", fmt.Errorf("failed to setup client context: %v", err) } - fmt.Printf("State transition proof: %x, public values %v\n", response.GetProof(), response.GetPublicValues()) - return response.GetProof(), nil -} - -// GetMembershipProof gets a membership proof that the key at keyPaths is a Merkle leaf of the state root at a particular block height. -func GetMembershipProof(height int64, keyPaths []string) (membershipProof []byte, err error) { - conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) + fmt.Printf("Broadcasting MsgTransfer...\n") + response, err := utils.BroadcastMessages(clientCtx, sender, 200_000, &msg) if err != nil { - log.Fatalf("Failed to connect to the prover service: %v", err) - } - defer conn.Close() - - client := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateMembershipRequest{ - Height: height, - KeyPaths: keyPaths, + return "", fmt.Errorf("failed to broadcast MsgTransfer %w", err) } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) - defer cancel() - - response, err := client.ProveStateMembership(ctx, request) - if err != nil { - return []byte{}, fmt.Errorf("failed to request state membership proof: %w", err) + if response.Code != 0 { + return "", fmt.Errorf("failed to execute MsgTransfer %v", response.RawLog) } - - fmt.Printf("Membership proof: %x, Height %v\n", response.GetProof(), response.GetHeight()) - return response.GetProof(), nil -} - -// getKeyPaths returns the Merkle path to packets. -func getKeyPaths(_ []*channeltypesv2.PacketState) []string { - // TODO: implement - return []string{} + fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) + return response.TxHash, nil } From 54f855af0355c35305b5b632e39707e0b01c292b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 16:07:21 -0500 Subject: [PATCH 34/98] sort commands in help output --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d1e282c..9a52284 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ BUILD_FLAGS := -tags "ledger" -ldflags '$(ldflags)' ## help: Get more info on make commands. help: Makefile @echo " Choose a command run in "$(PROJECT_NAME)":" - @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' + @sed -n 's/^##//p' $< | sort | column -t -s ':' | sed -e 's/^/ /' .PHONY: help ## install-dependencies: Install all dependencies needed for the demo. From 984d2eccc08070c118ed7a35d7658b8999817466 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 16:35:16 -0500 Subject: [PATCH 35/98] refactor more --- testing/demo/pkg/relay/main.go | 52 +++++++++++++++------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 0104d47..e0a6fd8 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -30,28 +30,20 @@ const ( ) func main() { - resp, err := QueryPacketCommitments() + // Ask the Celestia prover for a state transition proof. + _, err := GetStateTransitionProof() if err != nil { log.Fatal(err) } - latestHeight := resp.GetHeight() - clientHeight, err := QueryLightClientLatestHeight() - if err != nil { - log.Fatal(err) - } - - // Ask the Celestia prover for a state transition proof from the client - // height to the most recent height on SimApp which should be >= latestHeight. - _, err = GetStateTransitionProof(clientHeight) + packetResp, err := QueryPacketCommitments() if err != nil { log.Fatal(err) } // Ask the Celestia prover for a state membership proof that the packet - // commitments are part of the state root at the latest block height. - keyPaths := getKeyPaths(resp.Commitments) - _, err = GetMembershipProof(int64(latestHeight.RevisionHeight), keyPaths) + // commitments are part of the state root at a particular block height. + _, err = GetMembershipProof(packetResp) if err != nil { log.Fatal(err) } @@ -103,43 +95,45 @@ func QueryLightClientLatestHeight() (latestHeight uint32, err error) { return clientState.LatestHeight.RevisionHeight, nil } -// GetStateTransitionProof gets the state transition proof from the Celestia prover. -func GetStateTransitionProof(clientHeight uint32) (stateTransitionProof []byte, err error) { +// GetStateTransitionProof returns a state transition proof from the Celestia +// prover. The prover will query the Tendermint light client on the EVM roll-up +// for it's last known height and generate a proof from that height all the way +// up to the latest height on SimApp. +func GetStateTransitionProof() (proof []byte, err error) { conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatalf("Failed to connect to the prover service: %v", err) } defer conn.Close() - client := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ - ClientId: ics07TMContractAddress, - } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) defer cancel() - response, err := client.ProveStateTransition(ctx, request) + client := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateTransitionRequest{ClientId: ics07TMContractAddress} + + resp, err := client.ProveStateTransition(ctx, request) if err != nil { return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) } - fmt.Printf("State transition proof: %x, public values %v\n", response.GetProof(), response.GetPublicValues()) - return response.GetProof(), nil + fmt.Printf("Got state transition proof: %x, public values %v\n", resp.GetProof(), resp.GetPublicValues()) + return resp.GetProof(), nil } -// GetMembershipProof gets a membership proof that the key at keyPaths is a Merkle leaf of the state root at a particular block height. -func GetMembershipProof(height int64, keyPaths []string) (membershipProof []byte, err error) { +// GetMembershipProof gets a membership proof that the packets in the input are +// present in the state root at the input block height on SimApp. +func GetMembershipProof(input *channeltypesv2.QueryPacketCommitmentsResponse) (proof []byte, err error) { conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - log.Fatalf("Failed to connect to the prover service: %v", err) + return []byte{}, fmt.Errorf("failed to connect to the prover service: %w", err) } defer conn.Close() client := proverclient.NewProverClient(conn) request := &proverclient.ProveStateMembershipRequest{ - Height: height, - KeyPaths: keyPaths, + Height: int64(input.GetHeight().RevisionHeight), + KeyPaths: getKeyPaths(input.Commitments), } ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) @@ -150,7 +144,7 @@ func GetMembershipProof(height int64, keyPaths []string) (membershipProof []byte return []byte{}, fmt.Errorf("failed to request state membership proof: %w", err) } - fmt.Printf("Membership proof: %x, Height %v\n", response.GetProof(), response.GetHeight()) + fmt.Printf("Got membership proof: %x, height %v\n", response.GetProof(), response.GetHeight()) return response.GetProof(), nil } From 63edd3eb34770688fcee9319e73dbafd2e77319b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 16:42:36 -0500 Subject: [PATCH 36/98] refactor: delete query light client height --- testing/demo/pkg/relay/main.go | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index e0a6fd8..06854ea 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -9,16 +9,11 @@ import ( proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) const ( - // ethereumRPC is the RPC endpoint of the EVM chain. - ethereumRPC = "http://localhost:8545" // celestiaProverEndpoint is the endpoint of the Celestia prover. celestiaProverEndpoint = "localhost:50051" // channelID is the channel ID on SimApp. @@ -72,29 +67,6 @@ func QueryPacketCommitments() (*channeltypesv2.QueryPacketCommitmentsResponse, e return response, nil } -// QueryLightClientLatestHeight queries the ICS07 light client on the EVM -// roll-up for the client state's latest height. -func QueryLightClientLatestHeight() (latestHeight uint32, err error) { - fmt.Printf("Querying SP1 ICS07 tendermint light client for the client state's latest height...\n") - - ethClient, err := ethclient.Dial(ethereumRPC) - if err != nil { - return 0, err - } - - sp1Ics07Contract, err := sp1ics07tendermint.NewContract(ethcommon.HexToAddress(ics07TMContractAddress), ethClient) - if err != nil { - return 0, err - } - clientState, err := sp1Ics07Contract.GetClientState(nil) - if err != nil { - return 0, err - } - - fmt.Printf("Client state latest height: %v, revision height %v, revision number %v.\n", clientState.LatestHeight, clientState.LatestHeight.RevisionHeight, clientState.LatestHeight.RevisionNumber) - return clientState.LatestHeight.RevisionHeight, nil -} - // GetStateTransitionProof returns a state transition proof from the Celestia // prover. The prover will query the Tendermint light client on the EVM roll-up // for it's last known height and generate a proof from that height all the way From bb1ad699a2ee105c9196cfa1703ead1b487bb5e2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 7 Jan 2025 16:44:47 -0500 Subject: [PATCH 37/98] todo --- testing/demo/pkg/relay/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 06854ea..e527058 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -103,6 +103,8 @@ func GetMembershipProof(input *channeltypesv2.QueryPacketCommitmentsResponse) (p defer conn.Close() client := proverclient.NewProverClient(conn) + // Are packet commitments the correct data type to be proving here? + // TODO: investigate existing IBC relayer implementations. request := &proverclient.ProveStateMembershipRequest{ Height: int64(input.GetHeight().RevisionHeight), KeyPaths: getKeyPaths(input.Commitments), @@ -120,7 +122,8 @@ func GetMembershipProof(input *channeltypesv2.QueryPacketCommitmentsResponse) (p return response.GetProof(), nil } -// getKeyPaths returns the Merkle path to packets. +// getKeyPaths returns a list of strings where each string is a Merkle path for +// a leaf to the state root. func getKeyPaths(_ []*channeltypesv2.PacketState) []string { // TODO: implement return []string{} From 7899f96c587ddff00192029ccc7d61c2e82dc30a Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 8 Jan 2025 15:39:10 -0500 Subject: [PATCH 38/98] debug: assert that balance changes it does so going to revert this commit --- testing/demo/pkg/transfer/main.go | 51 ++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 181c219..c1e221e 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -1,13 +1,16 @@ package main import ( + "context" "fmt" "log" "time" "cosmossdk.io/math" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" + "github.com/cosmos/cosmos-sdk/client" sdktypes "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -19,11 +22,18 @@ const ( sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" + // amount is the number of tokens to send via the MsgTransfer. + amount = 100 // denom is the denomination of the token on SimApp. denom = "stake" ) func main() { + initialBalance, err := getBalance(sender) + if err != nil { + log.Fatal(err) + } + msg, err := createMsgSendPacket() if err != nil { log.Fatal(err) @@ -33,11 +43,20 @@ func main() { if err != nil { log.Fatal(err) } + + balance, err := getBalance(sender) + if err != nil { + log.Fatal(err) + } + + if initialBalance == balance { + log.Fatalf("initialBalance %v == balance %v", initialBalance, balance) + } } // createMsgSendPacket returns a msg that sends 100stake over IBC. func createMsgSendPacket() (channeltypesv2.MsgSendPacket, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(100)) + coin := sdktypes.NewCoin(denom, math.NewInt(amount)) transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ Denom: coin.Denom, Amount: coin.Amount.BigInt(), @@ -82,3 +101,33 @@ func submitMsgTransfer(msg channeltypesv2.MsgSendPacket) (txHash string, err err fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) return response.TxHash, nil } + +func getBalance(address string) (int64, error) { + clientCtx, err := utils.SetupClientContext() + if err != nil { + return 0, fmt.Errorf("failed to setup client context: %v", err) + } + + balance, err := queryBalance(clientCtx, address) + if err != nil { + return 0, err + } + return balance, nil +} + +func queryBalance(clientCtx client.Context, address string) (int64, error) { + bankQueryClient := banktypes.NewQueryClient(clientCtx) + + res, err := bankQueryClient.Balance( + context.Background(), + &banktypes.QueryBalanceRequest{ + Address: address, + Denom: denom, + }, + ) + if err != nil { + return 0, err + } + + return res.Balance.Amount.Int64(), nil +} From 1934fea677394c291fe12897b349e2741801df85 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 8 Jan 2025 15:39:39 -0500 Subject: [PATCH 39/98] Revert "debug: assert that balance changes" This reverts commit 7899f96c587ddff00192029ccc7d61c2e82dc30a. --- testing/demo/pkg/transfer/main.go | 51 +------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index c1e221e..181c219 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -1,16 +1,13 @@ package main import ( - "context" "fmt" "log" "time" "cosmossdk.io/math" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" - "github.com/cosmos/cosmos-sdk/client" sdktypes "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" ibctesting "github.com/cosmos/ibc-go/v9/testing" @@ -22,18 +19,11 @@ const ( sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" - // amount is the number of tokens to send via the MsgTransfer. - amount = 100 // denom is the denomination of the token on SimApp. denom = "stake" ) func main() { - initialBalance, err := getBalance(sender) - if err != nil { - log.Fatal(err) - } - msg, err := createMsgSendPacket() if err != nil { log.Fatal(err) @@ -43,20 +33,11 @@ func main() { if err != nil { log.Fatal(err) } - - balance, err := getBalance(sender) - if err != nil { - log.Fatal(err) - } - - if initialBalance == balance { - log.Fatalf("initialBalance %v == balance %v", initialBalance, balance) - } } // createMsgSendPacket returns a msg that sends 100stake over IBC. func createMsgSendPacket() (channeltypesv2.MsgSendPacket, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(amount)) + coin := sdktypes.NewCoin(denom, math.NewInt(100)) transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ Denom: coin.Denom, Amount: coin.Amount.BigInt(), @@ -101,33 +82,3 @@ func submitMsgTransfer(msg channeltypesv2.MsgSendPacket) (txHash string, err err fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) return response.TxHash, nil } - -func getBalance(address string) (int64, error) { - clientCtx, err := utils.SetupClientContext() - if err != nil { - return 0, fmt.Errorf("failed to setup client context: %v", err) - } - - balance, err := queryBalance(clientCtx, address) - if err != nil { - return 0, err - } - return balance, nil -} - -func queryBalance(clientCtx client.Context, address string) (int64, error) { - bankQueryClient := banktypes.NewQueryClient(clientCtx) - - res, err := bankQueryClient.Balance( - context.Background(), - &banktypes.QueryBalanceRequest{ - Address: address, - Denom: denom, - }, - ) - if err != nil { - return 0, err - } - - return res.Balance.Amount.Int64(), nil -} From 6e4a9ffc3019a08c30babba5ecf82b698ee19807 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 8 Jan 2025 15:42:35 -0500 Subject: [PATCH 40/98] add a note --- testing/demo/pkg/transfer/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 181c219..2a543d1 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -56,6 +56,11 @@ func createMsgSendPacket() (channeltypesv2.MsgSendPacket, error) { Encoding: transfertypes.EncodingABI, Value: transferBz, } + + // Note: solidity-ibc-eureka tests wrap the MsgSendPacket in an ordinary + // packet but this wrapping seems unnecessary. + // + // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L779-L787 return channeltypesv2.MsgSendPacket{ SourceChannel: ibctesting.FirstChannelID, TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), From 7ffa2f6be38d94391761d5b099d2af27966aecc1 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 8 Jan 2025 16:38:11 -0500 Subject: [PATCH 41/98] wip: inspiration from ibctesting e2e test --- testing/demo/pkg/relay/main.go | 38 ++++++++++++++++++++++++++++++- testing/demo/pkg/transfer/main.go | 8 +++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index e527058..56adbd3 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -9,6 +9,8 @@ import ( proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + ibctesting "github.com/cosmos/ibc-go/v9/testing" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -22,6 +24,10 @@ const ( // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. // TODO: fetch this from the `make setup` command output. ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" + // sourceChannel is hard-coded to the name used by the first channel. + sourceChannel = ibctesting.FirstChannelID + // sequence is hard-coded to the first sequence number used by the MsgSendPacket. + sequence = 1 ) func main() { @@ -44,7 +50,37 @@ func main() { } // TODO: combine these proofs and packets and submit a MsgUpdateClient and - // MsgRecvPacket to the EVM rollup. + // MsgRecvPacket to the EVM rollup. See solidity-ibc-eureka for example. + // + // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L816 + packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) + fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) + + // Note: solidity-ibc-eureka tests wrap the MsgSendPacket that we have in transfer. + // + // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L779-L787 + + // proofHeight, ucAndMemProof := updateClientAndMembershipProof(ctx, simd, pt, [][]byte{packetCommitmentPath}) + // packet := ics26router.IICS26RouterMsgsPacket{ + // Sequence: uint32(sendPacket.Sequence), + // SourceChannel: sendPacket.SourceChannel, + // DestChannel: sendPacket.DestinationChannel, + // TimeoutTimestamp: sendPacket.TimeoutTimestamp, + // Payloads: []ics26router.IICS26RouterMsgsPayload{ + // { + // SourcePort: sendPacket.Payloads[0].SourcePort, + // DestPort: sendPacket.Payloads[0].DestinationPort, + // Version: transfertypes.V1, + // Encoding: transfertypes.EncodingABI, + // Value: sendPacket.Payloads[0].Value, + // }, + // }, + // } + // msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ + // Packet: packet, + // ProofCommitment: ucAndMemProof, + // ProofHeight: *proofHeight, + // } } // QueryPacketCommitments queries the packet commitments on the SimApp. diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 2a543d1..f03d700 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -21,6 +21,8 @@ const ( receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" // denom is the denomination of the token on SimApp. denom = "stake" + // sourceChannel is hard-coded to the name used by the first channel. + sourceChannel = ibctesting.FirstChannelID ) func main() { @@ -57,12 +59,8 @@ func createMsgSendPacket() (channeltypesv2.MsgSendPacket, error) { Value: transferBz, } - // Note: solidity-ibc-eureka tests wrap the MsgSendPacket in an ordinary - // packet but this wrapping seems unnecessary. - // - // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L779-L787 return channeltypesv2.MsgSendPacket{ - SourceChannel: ibctesting.FirstChannelID, + SourceChannel: sourceChannel, TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), Payloads: []channeltypesv2.Payload{payload}, Signer: sender, From acc687352317228b69995560a064ada5f592d5e3 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 8 Jan 2025 17:22:37 -0500 Subject: [PATCH 42/98] wip: trying to copy ibc testing combined proof --- testing/demo/pkg/relay/main.go | 33 --------------------- testing/demo/pkg/transfer/main.go | 48 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 56adbd3..5e30f93 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -9,7 +9,6 @@ import ( proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibctesting "github.com/cosmos/ibc-go/v9/testing" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -49,38 +48,6 @@ func main() { log.Fatal(err) } - // TODO: combine these proofs and packets and submit a MsgUpdateClient and - // MsgRecvPacket to the EVM rollup. See solidity-ibc-eureka for example. - // - // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L816 - packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) - fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) - - // Note: solidity-ibc-eureka tests wrap the MsgSendPacket that we have in transfer. - // - // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L779-L787 - - // proofHeight, ucAndMemProof := updateClientAndMembershipProof(ctx, simd, pt, [][]byte{packetCommitmentPath}) - // packet := ics26router.IICS26RouterMsgsPacket{ - // Sequence: uint32(sendPacket.Sequence), - // SourceChannel: sendPacket.SourceChannel, - // DestChannel: sendPacket.DestinationChannel, - // TimeoutTimestamp: sendPacket.TimeoutTimestamp, - // Payloads: []ics26router.IICS26RouterMsgsPayload{ - // { - // SourcePort: sendPacket.Payloads[0].SourcePort, - // DestPort: sendPacket.Payloads[0].DestinationPort, - // Version: transfertypes.V1, - // Encoding: transfertypes.EncodingABI, - // Value: sendPacket.Payloads[0].Value, - // }, - // }, - // } - // msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ - // Packet: packet, - // ProofCommitment: ucAndMemProof, - // ProofHeight: *proofHeight, - // } } // QueryPacketCommitments queries the packet commitments on the SimApp. diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index f03d700..87a2710 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -10,6 +10,7 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" ) @@ -23,6 +24,8 @@ const ( denom = "stake" // sourceChannel is hard-coded to the name used by the first channel. sourceChannel = ibctesting.FirstChannelID + // sequence is hard-coded to the first sequence number. + sequence = 1 ) func main() { @@ -35,6 +38,20 @@ func main() { if err != nil { log.Fatal(err) } + + packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) + fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) + + // TODO: combine these proofs and packets and submit a MsgUpdateClient and + // MsgRecvPacket to the EVM rollup. See solidity-ibc-eureka for example. + // + // sendPacket, err := createSendPacket() + // if err != nil { + // log.Fatal(err) + // } + // + // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L816 + // proofHeight, ucAndMemProof := updateClientAndMembershipProof(ctx, simd, pt, [][]byte{packetCommitmentPath}) } // createMsgSendPacket returns a msg that sends 100stake over IBC. @@ -85,3 +102,34 @@ func submitMsgTransfer(msg channeltypesv2.MsgSendPacket) (txHash string, err err fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) return response.TxHash, nil } + +// TODO: refactor this to de-duplicate code from createMsgSendPacket +func createSendPacket() (channeltypesv2.Packet, error) { + coin := sdktypes.NewCoin(denom, math.NewInt(100)) + transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: coin.Denom, + Amount: coin.Amount.BigInt(), + Sender: sender, + Receiver: receiver, + Memo: "test transfer", + } + transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) + if err != nil { + return channeltypesv2.Packet{}, err + } + payload := channeltypesv2.Payload{ + SourcePort: transfertypes.PortID, + DestinationPort: transfertypes.PortID, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingABI, + Value: transferBz, + } + + return channeltypesv2.Packet{ + Sequence: sequence, + SourceChannel: ibctesting.FirstChannelID, + DestinationChannel: ibctesting.FirstClientID, + TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), + Payloads: []channeltypesv2.Payload{payload}, + }, nil +} From 7c5e42083124b3a6b2eeae8a90856a6e3db6efb0 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 9 Jan 2025 16:04:57 -0500 Subject: [PATCH 43/98] error fetching github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum --- testing/demo/pkg/relay-v2/ethereum.go | 139 ++++++++++++++++ testing/demo/pkg/relay-v2/main.go | 220 ++++++++++++++++++++++++++ testing/demo/pkg/transfer/main.go | 47 ------ 3 files changed, 359 insertions(+), 47 deletions(-) create mode 100644 testing/demo/pkg/relay-v2/ethereum.go create mode 100644 testing/demo/pkg/relay-v2/main.go diff --git a/testing/demo/pkg/relay-v2/ethereum.go b/testing/demo/pkg/relay-v2/ethereum.go new file mode 100644 index 0000000..c0648c0 --- /dev/null +++ b/testing/demo/pkg/relay-v2/ethereum.go @@ -0,0 +1,139 @@ +package main + +import ( + "bytes" + "context" + "crypto/ecdsa" + "encoding/hex" + "fmt" + "io" + "math/big" + "os" + "os/exec" + "strconv" + "strings" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" + + "cosmossdk.io/math" + + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" +) + +type Ethereum struct { + ChainID *big.Int + RPC string + EthAPI EthAPI + BeaconAPIClient *BeaconAPIClient + + Faucet *ecdsa.PrivateKey +} + +func NewEthereum(ctx context.Context, rpc string, beaconAPIClient *BeaconAPIClient, faucet *ecdsa.PrivateKey) (Ethereum, error) { + ethClient, err := ethclient.Dial(rpc) + if err != nil { + return Ethereum{}, err + } + chainID, err := ethClient.ChainID(ctx) + if err != nil { + return Ethereum{}, err + } + ethAPI, err := NewEthAPI(rpc) + if err != nil { + return Ethereum{}, err + } + + return Ethereum{ + ChainID: chainID, + RPC: rpc, + EthAPI: ethAPI, + BeaconAPIClient: beaconAPIClient, + Faucet: faucet, + }, nil +} + +func (e Ethereum) ForgeScript(deployer *ecdsa.PrivateKey, solidityContract string, args ...string) ([]byte, error) { + args = append(args, "script", "--rpc-url", e.RPC, "--private-key", + hex.EncodeToString(deployer.D.Bytes()), "--broadcast", + "--non-interactive", "-vvvv", solidityContract, + ) + cmd := exec.Command( + "forge", args..., + ) + + faucetAddress := crypto.PubkeyToAddress(e.Faucet.PublicKey) + extraEnv := []string{ + fmt.Sprintf("%s=%s", testvalues.EnvKeyE2EFacuetAddress, faucetAddress.Hex()), + } + + cmd.Env = os.Environ() + cmd.Env = append(cmd.Env, extraEnv...) + + var stdoutBuf bytes.Buffer + + // Create a MultiWriter to write to both os.Stdout and the buffer + multiWriter := io.MultiWriter(os.Stdout, &stdoutBuf) + + // Set the command's stdout to the MultiWriter + cmd.Stdout = multiWriter + cmd.Stderr = os.Stderr + + // Run the command + if err := cmd.Run(); err != nil { + fmt.Println("Error start command", cmd.Args, err) + return nil, err + } + + // Get the output as byte slices + stdoutBytes := stdoutBuf.Bytes() + + return stdoutBytes, nil +} + +func (e Ethereum) CreateAndFundUser() (*ecdsa.PrivateKey, error) { + key, err := crypto.GenerateKey() + if err != nil { + return nil, err + } + + address := crypto.PubkeyToAddress(key.PublicKey).Hex() + if err := e.FundUser(address, testvalues.StartingEthBalance); err != nil { + return nil, err + } + + return key, nil +} + +func (e Ethereum) FundUser(address string, amount math.Int) error { + return e.SendEth(e.Faucet, address, amount) +} + +func (e Ethereum) SendEth(key *ecdsa.PrivateKey, toAddress string, amount math.Int) error { + cmd := exec.Command( + "cast", + "send", + toAddress, + "--value", amount.String(), + "--private-key", fmt.Sprintf("0x%s", ethcommon.Bytes2Hex(key.D.Bytes())), + "--rpc-url", e.RPC, + ) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + return fmt.Errorf("failed to send eth with %s: %w", strings.Join(cmd.Args, " "), err) + } + + return nil +} + +func (e *Ethereum) Height() (int64, error) { + cmd := exec.Command("cast", "block-number", "--rpc-url", e.RPC) + stdout, err := cmd.Output() + if err != nil { + return 0, err + } + return strconv.ParseInt(strings.TrimSpace(string(stdout)), 10, 64) +} diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go new file mode 100644 index 0000000..5c6be68 --- /dev/null +++ b/testing/demo/pkg/relay-v2/main.go @@ -0,0 +1,220 @@ +package main + +import ( + "context" + "crypto/ecdsa" + "fmt" + "log" + "math/big" + "time" + + "cosmossdk.io/math" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" + sdktypes "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" + channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" +) + +// TODO: fetch these from the `make setup` command output. +const ( + erc20 = "0x94b9b5bd518109db400adc62ab2022d2f0008ff7" + escrow = "0x51488819811d51c7a3efcc5f0756740e252da783" + ibcstore = "0x686bd6a5be8a2d9d923814b8e9a3957c3c103573" + ics07Tendermint = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" + ics20Transfer = "0xe2c1756b8825c54638f98425c113b51730cc47f6" + ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" + icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" +) + +const ( + // sender is an address on SimApp that will send funds via the MsgTransfer. + sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" + // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. + receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" + // denom is the denomination of the token on SimApp. + denom = "stake" + // sourceChannel is hard-coded to the name used by the first channel. + sourceChannel = ibctesting.FirstChannelID + // sequence is hard-coded to the first sequence number. + sequence = 1 + // ethereumRPC is the Reth RPC endpoint. + ethereumRPC = "http://localhost:8545/" + // TODO: verify if this works + anvilFaucetPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" +) + +func main() { + // Update the Tendermint light client on the EVM roll-up with the stateTransitionProof + stateTransitionProof := []byte{} + err := updateTendermintLightClient(stateTransitionProof) + if err != nil { + log.Fatal(err) + } + + // Receive packet on EVM + err = receivePacketOnEVM() + if err != nil { + log.Fatal(err) + } +} + +func updateTendermintLightClient(stateTransitionProof []byte) error { + return nil +} + +func receivePacketOnEVM() error { + sendPacket, err := createSendPacket() + if err != nil { + return err + } + + packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) + fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) + + packet := ics26router.IICS26RouterMsgsPacket{ + Sequence: uint32(sendPacket.Sequence), + SourceChannel: sendPacket.SourceChannel, + DestChannel: sendPacket.DestinationChannel, + TimeoutTimestamp: sendPacket.TimeoutTimestamp, + Payloads: []ics26router.IICS26RouterMsgsPayload{ + { + SourcePort: sendPacket.Payloads[0].SourcePort, + DestPort: sendPacket.Payloads[0].DestinationPort, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingABI, + Value: sendPacket.Payloads[0].Value, + }, + }, + } + + // TODO: replace this with query to celestia-prover after mock circuits + // are implemented. + membershipProof := []byte{} + + // TODO: replace this with a real proof height. + proofHeight := ics26router.IICS02ClientMsgsHeight{ + RevisionNumber: uint32(0), + RevisionHeight: uint32(10), + } + msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ + Packet: packet, + ProofCommitment: membershipProof, + ProofHeight: proofHeight, + } + + ethClient, err := ethclient.Dial(ethereumRPC) + if err != nil { + return err + } + ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(ics26Router), ethClient) + if err != nil { + return err + } + + faucet, err := crypto.ToECDSA(ethcommon.FromHex(anvilFaucetPrivateKey)) + if err != nil { + return err + } + eth := ethereum.NewEthereum(context.Background, ethereumRPC, nil, faucet) + tx, err := ics26Contract.RecvPacket(GetTransactOpts(faucet, eth), msg) + if err != nil { + return err + } + + receipt := GetTxReciept(context.Background(), eth, tx.Hash()) + if ethtypes.ReceiptStatusSuccessful != receipt.Status { + return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) + } + recvBlockNumber := receipt.BlockNumber.Uint64() + fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) + return nil +} + +// TODO: refactor this to de-duplicate code from createMsgSendPacket +func createSendPacket() (channeltypesv2.Packet, error) { + coin := sdktypes.NewCoin(denom, math.NewInt(100)) + transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: coin.Denom, + Amount: coin.Amount.BigInt(), + Sender: sender, + Receiver: receiver, + Memo: "test transfer", + } + transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) + if err != nil { + return channeltypesv2.Packet{}, err + } + payload := channeltypesv2.Payload{ + SourcePort: transfertypes.PortID, + DestinationPort: transfertypes.PortID, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingABI, + Value: transferBz, + } + + return channeltypesv2.Packet{ + Sequence: sequence, + SourceChannel: ibctesting.FirstChannelID, + DestinationChannel: ibctesting.FirstClientID, + TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), + Payloads: []channeltypesv2.Payload{payload}, + }, nil +} + +func GetTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { + ethClient, err := ethclient.Dial(chain.RPC) + if err != nil { + log.Fatal(err) + } + + fromAddress := crypto.PubkeyToAddress(key.PublicKey) + nonce, err := ethClient.PendingNonceAt(context.Background(), fromAddress) + if err != nil { + nonce = 0 + } + + gasPrice, err := ethClient.SuggestGasPrice(context.Background()) + if err != nil { + panic(err) + } + + txOpts, err := bind.NewKeyedTransactorWithChainID(key, chain.ChainID) + if err != nil { + log.Fatal(err) + } + txOpts.Nonce = big.NewInt(int64(nonce)) + txOpts.GasPrice = gasPrice + + return txOpts +} + +func GetTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.Hash) *ethtypes.Receipt { + ethClient, err := ethclient.Dial(chain.RPC) + if err != nil { + log.Fatal(err) + } + + var receipt *ethtypes.Receipt + err = utils.WaitForCondition(time.Second*30, time.Second, func() (bool, error) { + receipt, err = ethClient.TransactionReceipt(ctx, hash) + if err != nil { + return false, nil + } + + return receipt != nil, nil + }) + if err != nil { + log.Fatal(err) + } + return receipt +} diff --git a/testing/demo/pkg/transfer/main.go b/testing/demo/pkg/transfer/main.go index 87a2710..bbde551 100644 --- a/testing/demo/pkg/transfer/main.go +++ b/testing/demo/pkg/transfer/main.go @@ -10,7 +10,6 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" ) @@ -24,8 +23,6 @@ const ( denom = "stake" // sourceChannel is hard-coded to the name used by the first channel. sourceChannel = ibctesting.FirstChannelID - // sequence is hard-coded to the first sequence number. - sequence = 1 ) func main() { @@ -39,19 +36,6 @@ func main() { log.Fatal(err) } - packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) - fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) - - // TODO: combine these proofs and packets and submit a MsgUpdateClient and - // MsgRecvPacket to the EVM rollup. See solidity-ibc-eureka for example. - // - // sendPacket, err := createSendPacket() - // if err != nil { - // log.Fatal(err) - // } - // - // https://github.com/cosmos/solidity-ibc-eureka/blob/febaabb6915eccfd3e1922793bc0936cd0b4fdfb/e2e/interchaintestv8/ibc_eureka_test.go#L816 - // proofHeight, ucAndMemProof := updateClientAndMembershipProof(ctx, simd, pt, [][]byte{packetCommitmentPath}) } // createMsgSendPacket returns a msg that sends 100stake over IBC. @@ -102,34 +86,3 @@ func submitMsgTransfer(msg channeltypesv2.MsgSendPacket) (txHash string, err err fmt.Printf("Broadcasted MsgTransfer. Response code: %v, tx hash: %v\n", response.Code, response.TxHash) return response.TxHash, nil } - -// TODO: refactor this to de-duplicate code from createMsgSendPacket -func createSendPacket() (channeltypesv2.Packet, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(100)) - transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ - Denom: coin.Denom, - Amount: coin.Amount.BigInt(), - Sender: sender, - Receiver: receiver, - Memo: "test transfer", - } - transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) - if err != nil { - return channeltypesv2.Packet{}, err - } - payload := channeltypesv2.Payload{ - SourcePort: transfertypes.PortID, - DestinationPort: transfertypes.PortID, - Version: transfertypes.V1, - Encoding: transfertypes.EncodingABI, - Value: transferBz, - } - - return channeltypesv2.Packet{ - Sequence: sequence, - SourceChannel: ibctesting.FirstChannelID, - DestinationChannel: ibctesting.FirstClientID, - TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), - Payloads: []channeltypesv2.Payload{payload}, - }, nil -} From 141cda26c86d47fc2a856f8baefcbdce799e103f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 9 Jan 2025 16:18:55 -0500 Subject: [PATCH 44/98] fix: copy ethereum package --- testing/demo/pkg/ethereum/beaconapi.go | 299 ++++++++++++++++++++++++ testing/demo/pkg/ethereum/doc.go | 5 + testing/demo/pkg/ethereum/ethapi.go | 61 +++++ testing/demo/pkg/ethereum/ethereum.go | 139 +++++++++++ testing/demo/pkg/ethereum/types.go | 136 +++++++++++ testing/demo/pkg/ethereum/utils.go | 112 +++++++++ testing/demo/pkg/ethereum/utils_test.go | 136 +++++++++++ testing/demo/pkg/relay-v2/main.go | 7 +- 8 files changed, 893 insertions(+), 2 deletions(-) create mode 100644 testing/demo/pkg/ethereum/beaconapi.go create mode 100644 testing/demo/pkg/ethereum/doc.go create mode 100644 testing/demo/pkg/ethereum/ethapi.go create mode 100644 testing/demo/pkg/ethereum/ethereum.go create mode 100644 testing/demo/pkg/ethereum/types.go create mode 100644 testing/demo/pkg/ethereum/utils.go create mode 100644 testing/demo/pkg/ethereum/utils_test.go diff --git a/testing/demo/pkg/ethereum/beaconapi.go b/testing/demo/pkg/ethereum/beaconapi.go new file mode 100644 index 0000000..f1f1d32 --- /dev/null +++ b/testing/demo/pkg/ethereum/beaconapi.go @@ -0,0 +1,299 @@ +package ethereum + +import ( + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "time" + + eth2client "github.com/attestantio/go-eth2-client" + "github.com/attestantio/go-eth2-client/api" + apiv1 "github.com/attestantio/go-eth2-client/api/v1" + ethttp "github.com/attestantio/go-eth2-client/http" + "github.com/attestantio/go-eth2-client/spec/phase0" + "github.com/rs/zerolog" + + ethcommon "github.com/ethereum/go-ethereum/common" + + ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" +) + +type BeaconAPIClient struct { + ctx context.Context + cancel context.CancelFunc + + client eth2client.Service + url string + + Retries int + RetryWait time.Duration +} + +func (s Spec) ToForkParameters() ethereumtypes.ForkParameters { + return ethereumtypes.ForkParameters{ + GenesisForkVersion: ethcommon.Bytes2Hex(s.GenesisForkVersion[:]), + GenesisSlot: s.GenesisSlot, + Altair: ethereumtypes.Fork{ + Version: ethcommon.Bytes2Hex(s.AltairForkVersion[:]), + Epoch: s.AltairForkEpoch, + }, + Bellatrix: ethereumtypes.Fork{ + Version: ethcommon.Bytes2Hex(s.BellatrixForkVersion[:]), + Epoch: s.BellatrixForkEpoch, + }, + Capella: ethereumtypes.Fork{ + Version: ethcommon.Bytes2Hex(s.CapellaForkVersion[:]), + Epoch: s.CapellaForkEpoch, + }, + Deneb: ethereumtypes.Fork{ + Version: ethcommon.Bytes2Hex(s.DenebForkVersion[:]), + Epoch: s.DenebForkEpoch, + }, + } +} + +func (s Spec) Period() uint64 { + return s.EpochsPerSyncCommitteePeriod * s.SlotsPerEpoch +} + +func (b BeaconAPIClient) Close() { + b.cancel() +} + +func NewBeaconAPIClient(beaconAPIAddress string) BeaconAPIClient { + ctx, cancel := context.WithCancel(context.Background()) + client, err := ethttp.New(ctx, + // WithAddress supplies the address of the beacon node, as a URL. + ethttp.WithAddress(beaconAPIAddress), + // LogLevel supplies the level of logging to carry out. + ethttp.WithLogLevel(zerolog.WarnLevel), + ) + if err != nil { + panic(err) + } + + return BeaconAPIClient{ + ctx: ctx, + cancel: cancel, + client: client, + url: beaconAPIAddress, + Retries: 60, + RetryWait: 10 * time.Second, + } +} + +func retry[T any](retries int, waitTime time.Duration, fn func() (T, error)) (T, error) { + var err error + var result T + for i := 0; i < retries; i++ { + result, err = fn() + if err == nil { + return result, nil + } + + fmt.Printf("Retrying for %T: %s in %f seconds\n", result, err, waitTime.Seconds()) + time.Sleep(waitTime) + } + return result, err +} + +func (b BeaconAPIClient) GetHeader(blockID string) (*apiv1.BeaconBlockHeader, error) { + return retry(b.Retries, b.RetryWait, func() (*apiv1.BeaconBlockHeader, error) { + headerResponse, err := b.client.(eth2client.BeaconBlockHeadersProvider).BeaconBlockHeader(b.ctx, &api.BeaconBlockHeaderOpts{ + Block: blockID, + }) + if err != nil { + return nil, err + } + + return headerResponse.Data, nil + }) +} + +func (b BeaconAPIClient) GetBootstrap(finalizedRoot phase0.Root) (Bootstrap, error) { + return retry(b.Retries, b.RetryWait, func() (Bootstrap, error) { + finalizedRootStr := finalizedRoot.String() + url := fmt.Sprintf("%s/eth/v1/beacon/light_client/bootstrap/%s", b.url, finalizedRootStr) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return Bootstrap{}, err + } + req.Header.Set("Accept", "application/json") + resp, err := http.DefaultClient.Do(req) + if err != nil { + return Bootstrap{}, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return Bootstrap{}, err + } + + if resp.StatusCode != 200 { + return Bootstrap{}, fmt.Errorf("get bootstrap (%s) failed with status code: %d, body: %s", url, resp.StatusCode, body) + } + + var bootstrap Bootstrap + if err := json.Unmarshal(body, &bootstrap); err != nil { + return Bootstrap{}, err + } + + return bootstrap, nil + }) +} + +func (b BeaconAPIClient) GetLightClientUpdates(startPeriod uint64, count uint64) (LightClientUpdatesResponse, error) { + return retry(b.Retries, b.RetryWait, func() (LightClientUpdatesResponse, error) { + url := fmt.Sprintf("%s/eth/v1/beacon/light_client/updates?start_period=%d&count=%d", b.url, startPeriod, count) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return LightClientUpdatesResponse{}, err + } + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return LightClientUpdatesResponse{}, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return LightClientUpdatesResponse{}, err + } + + var lightClientUpdatesResponse LightClientUpdatesResponse + if err := json.Unmarshal(body, &lightClientUpdatesResponse); err != nil { + return LightClientUpdatesResponse{}, err + } + + return lightClientUpdatesResponse, nil + }) +} + +func (b BeaconAPIClient) GetGenesis() (*apiv1.Genesis, error) { + return retry(b.Retries, b.RetryWait, func() (*apiv1.Genesis, error) { + genesisResponse, err := b.client.(eth2client.GenesisProvider).Genesis(b.ctx, &api.GenesisOpts{}) + if err != nil { + return nil, err + } + + return genesisResponse.Data, nil + }) +} + +func (b BeaconAPIClient) GetSpec() (Spec, error) { + return retry(b.Retries, b.RetryWait, func() (Spec, error) { + specResponse, err := b.client.(eth2client.SpecProvider).Spec(b.ctx, &api.SpecOpts{}) + if err != nil { + return Spec{}, err + } + + specJsonBz, err := json.Marshal(specResponse.Data) + if err != nil { + return Spec{}, err + } + var spec Spec + if err := json.Unmarshal(specJsonBz, &spec); err != nil { + return Spec{}, err + } + + return spec, nil + }) +} + +func (b BeaconAPIClient) GetFinalityUpdate() (FinalityUpdateJSONResponse, error) { + return retry(b.Retries, b.RetryWait, func() (FinalityUpdateJSONResponse, error) { + url := fmt.Sprintf("%s/eth/v1/beacon/light_client/finality_update", b.url) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return FinalityUpdateJSONResponse{}, err + } + req.Header.Set("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return FinalityUpdateJSONResponse{}, err + } + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return FinalityUpdateJSONResponse{}, err + } + + var finalityUpdate FinalityUpdateJSONResponse + if err := json.Unmarshal(body, &finalityUpdate); err != nil { + return FinalityUpdateJSONResponse{}, err + } + + return finalityUpdate, nil + }) +} + +func (b BeaconAPIClient) GetBeaconBlocks(blockID string) (BeaconBlocksResponseJSON, error) { + return retry(b.Retries, b.RetryWait, func() (BeaconBlocksResponseJSON, error) { + url := fmt.Sprintf("%s/eth/v2/beacon/blocks/%s", b.url, blockID) + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return BeaconBlocksResponseJSON{}, err + } + + req.Header.Set("Accept", "application/json") + resp, err := http.DefaultClient.Do(req) + if err != nil { + return BeaconBlocksResponseJSON{}, err + } + + defer resp.Body.Close() + + body, err := io.ReadAll(resp.Body) + if err != nil { + return BeaconBlocksResponseJSON{}, err + } + + if resp.StatusCode != 200 { + return BeaconBlocksResponseJSON{}, fmt.Errorf("get execution height (%s) failed with status code: %d, body: %s", url, resp.StatusCode, body) + } + + var beaconBlocksResponse BeaconBlocksResponseJSON + if err := json.Unmarshal(body, &beaconBlocksResponse); err != nil { + return BeaconBlocksResponseJSON{}, err + } + + return beaconBlocksResponse, nil + }) +} + +func (b BeaconAPIClient) GetFinalizedBlocks() (BeaconBlocksResponseJSON, error) { + return retry(b.Retries, b.RetryWait, func() (BeaconBlocksResponseJSON, error) { + resp, err := b.GetBeaconBlocks("finalized") + if err != nil { + return BeaconBlocksResponseJSON{}, err + } + + if !resp.Finalized { + return BeaconBlocksResponseJSON{}, fmt.Errorf("block is not finalized") + } + + return resp, nil + }) +} + +func (b BeaconAPIClient) GetExecutionHeight(blockID string) (uint64, error) { + return retry(b.Retries, b.RetryWait, func() (uint64, error) { + resp, err := b.GetBeaconBlocks(blockID) + if err != nil { + return 0, err + } + + if blockID == "finalized" && !resp.Finalized { + return 0, fmt.Errorf("block is not finalized") + } + + return resp.Data.Message.Body.ExecutionPayload.BlockNumber, nil + }) +} diff --git a/testing/demo/pkg/ethereum/doc.go b/testing/demo/pkg/ethereum/doc.go new file mode 100644 index 0000000..61cd924 --- /dev/null +++ b/testing/demo/pkg/ethereum/doc.go @@ -0,0 +1,5 @@ +// The ethereum package was copy + pasted because an exported Go module does not exist for it. +// https://github.com/cosmos/solidity-ibc-eureka/tree/3b81a89e5785f486a84d333f6f1b23f56c1bfb40/e2e/interchaintestv8/ethereum +// +// TODO: delete this package. +package ethereum diff --git a/testing/demo/pkg/ethereum/ethapi.go b/testing/demo/pkg/ethereum/ethapi.go new file mode 100644 index 0000000..eb8cb69 --- /dev/null +++ b/testing/demo/pkg/ethereum/ethapi.go @@ -0,0 +1,61 @@ +package ethereum + +import ( + "strconv" + "time" + + "github.com/ethereum/go-ethereum/ethclient" + + ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" +) + +type EthAPI struct { + client *ethclient.Client + + Retries int + RetryWait time.Duration +} + +type EthGetProofResponse struct { + StorageHash string `json:"storageHash"` + StorageProof []ethereumtypes.StorageProof `json:"storageProof"` + AccountProof []string `json:"accountProof"` +} + +func NewEthAPI(rpc string) (EthAPI, error) { + ethClient, err := ethclient.Dial(rpc) + if err != nil { + return EthAPI{}, err + } + + return EthAPI{ + client: ethClient, + Retries: 6, + RetryWait: 10 * time.Second, + }, nil +} + +func (e EthAPI) GetProof(address string, storageKeys []string, blockHex string) (EthGetProofResponse, error) { + return retry(e.Retries, e.RetryWait, func() (EthGetProofResponse, error) { + var proofResponse EthGetProofResponse + if err := e.client.Client().Call(&proofResponse, "eth_getProof", address, storageKeys, blockHex); err != nil { + return EthGetProofResponse{}, err + } + + return proofResponse, nil + }) +} + +func (e EthAPI) GetBlockNumber() (string, uint64, error) { + var blockNumberHex string + if err := e.client.Client().Call(&blockNumberHex, "eth_blockNumber"); err != nil { + return "", 0, err + } + + blockNumber, err := strconv.ParseInt(blockNumberHex, 0, 0) + if err != nil { + return "", 0, err + } + + return blockNumberHex, uint64(blockNumber), nil +} diff --git a/testing/demo/pkg/ethereum/ethereum.go b/testing/demo/pkg/ethereum/ethereum.go new file mode 100644 index 0000000..c2eff02 --- /dev/null +++ b/testing/demo/pkg/ethereum/ethereum.go @@ -0,0 +1,139 @@ +package ethereum + +import ( + "bytes" + "context" + "crypto/ecdsa" + "encoding/hex" + "fmt" + "io" + "math/big" + "os" + "os/exec" + "strconv" + "strings" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" + + "cosmossdk.io/math" + + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" +) + +type Ethereum struct { + ChainID *big.Int + RPC string + EthAPI EthAPI + BeaconAPIClient *BeaconAPIClient + + Faucet *ecdsa.PrivateKey +} + +func NewEthereum(ctx context.Context, rpc string, beaconAPIClient *BeaconAPIClient, faucet *ecdsa.PrivateKey) (Ethereum, error) { + ethClient, err := ethclient.Dial(rpc) + if err != nil { + return Ethereum{}, err + } + chainID, err := ethClient.ChainID(ctx) + if err != nil { + return Ethereum{}, err + } + ethAPI, err := NewEthAPI(rpc) + if err != nil { + return Ethereum{}, err + } + + return Ethereum{ + ChainID: chainID, + RPC: rpc, + EthAPI: ethAPI, + BeaconAPIClient: beaconAPIClient, + Faucet: faucet, + }, nil +} + +func (e Ethereum) ForgeScript(deployer *ecdsa.PrivateKey, solidityContract string, args ...string) ([]byte, error) { + args = append(args, "script", "--rpc-url", e.RPC, "--private-key", + hex.EncodeToString(deployer.D.Bytes()), "--broadcast", + "--non-interactive", "-vvvv", solidityContract, + ) + cmd := exec.Command( + "forge", args..., + ) + + faucetAddress := crypto.PubkeyToAddress(e.Faucet.PublicKey) + extraEnv := []string{ + fmt.Sprintf("%s=%s", testvalues.EnvKeyE2EFacuetAddress, faucetAddress.Hex()), + } + + cmd.Env = os.Environ() + cmd.Env = append(cmd.Env, extraEnv...) + + var stdoutBuf bytes.Buffer + + // Create a MultiWriter to write to both os.Stdout and the buffer + multiWriter := io.MultiWriter(os.Stdout, &stdoutBuf) + + // Set the command's stdout to the MultiWriter + cmd.Stdout = multiWriter + cmd.Stderr = os.Stderr + + // Run the command + if err := cmd.Run(); err != nil { + fmt.Println("Error start command", cmd.Args, err) + return nil, err + } + + // Get the output as byte slices + stdoutBytes := stdoutBuf.Bytes() + + return stdoutBytes, nil +} + +func (e Ethereum) CreateAndFundUser() (*ecdsa.PrivateKey, error) { + key, err := crypto.GenerateKey() + if err != nil { + return nil, err + } + + address := crypto.PubkeyToAddress(key.PublicKey).Hex() + if err := e.FundUser(address, testvalues.StartingEthBalance); err != nil { + return nil, err + } + + return key, nil +} + +func (e Ethereum) FundUser(address string, amount math.Int) error { + return e.SendEth(e.Faucet, address, amount) +} + +func (e Ethereum) SendEth(key *ecdsa.PrivateKey, toAddress string, amount math.Int) error { + cmd := exec.Command( + "cast", + "send", + toAddress, + "--value", amount.String(), + "--private-key", fmt.Sprintf("0x%s", ethcommon.Bytes2Hex(key.D.Bytes())), + "--rpc-url", e.RPC, + ) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + return fmt.Errorf("failed to send eth with %s: %w", strings.Join(cmd.Args, " "), err) + } + + return nil +} + +func (e *Ethereum) Height() (int64, error) { + cmd := exec.Command("cast", "block-number", "--rpc-url", e.RPC) + stdout, err := cmd.Output() + if err != nil { + return 0, err + } + return strconv.ParseInt(strings.TrimSpace(string(stdout)), 10, 64) +} diff --git a/testing/demo/pkg/ethereum/types.go b/testing/demo/pkg/ethereum/types.go new file mode 100644 index 0000000..75c3b33 --- /dev/null +++ b/testing/demo/pkg/ethereum/types.go @@ -0,0 +1,136 @@ +package ethereum + +import ( + "time" + + "github.com/attestantio/go-eth2-client/spec/phase0" + + ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" +) + +type Spec struct { + SecondsPerSlot time.Duration `json:"SECONDS_PER_SLOT"` + SlotsPerEpoch uint64 `json:"SLOTS_PER_EPOCH"` + EpochsPerSyncCommitteePeriod uint64 `json:"EPOCHS_PER_SYNC_COMMITTEE_PERIOD"` + + // Fork Parameters + GenesisForkVersion phase0.Version `json:"GENESIS_FORK_VERSION"` + GenesisSlot uint64 `json:"GENESIS_SLOT"` + AltairForkVersion phase0.Version `json:"ALTAIR_FORK_VERSION"` + AltairForkEpoch uint64 `json:"ALTAIR_FORK_EPOCH"` + BellatrixForkVersion phase0.Version `json:"BELLATRIX_FORK_VERSION"` + BellatrixForkEpoch uint64 `json:"BELLATRIX_FORK_EPOCH"` + CapellaForkVersion phase0.Version `json:"CAPELLA_FORK_VERSION"` + CapellaForkEpoch uint64 `json:"CAPELLA_FORK_EPOCH"` + DenebForkVersion phase0.Version `json:"DENEB_FORK_VERSION"` + DenebForkEpoch uint64 `json:"DENEB_FORK_EPOCH"` +} + +type Bootstrap struct { + Data struct { + Header BootstrapHeader `json:"header"` + CurrentSyncCommittee SyncCommittee `json:"current_sync_committee"` + } `json:"data"` +} + +type BootstrapHeader struct { + Beacon BeaconJSON `json:"beacon"` + Execution ExecutionJSON `json:"execution"` +} + +type SyncCommittee struct { + Pubkeys []string `json:"pubkeys"` + AggregatePubkey string `json:"aggregate_pubkey"` +} + +type LightClientUpdatesResponse []LightClientUpdateJSON + +type BeaconJSON struct { + Slot uint64 `json:"slot,string"` + ProposerIndex uint64 `json:"proposer_index,string"` + ParentRoot string `json:"parent_root"` + StateRoot string `json:"state_root"` + BodyRoot string `json:"body_root"` +} + +type ExecutionJSON struct { + ParentHash string `json:"parent_hash"` + FeeRecipient string `json:"fee_recipient"` + StateRoot string `json:"state_root"` + ReceiptsRoot string `json:"receipts_root"` + LogsBloom string `json:"logs_bloom"` + PrevRandao string `json:"prev_randao"` + BlockNumber uint64 `json:"block_number,string"` + GasLimit uint64 `json:"gas_limit,string"` + GasUsed uint64 `json:"gas_used,string"` + Timestamp uint64 `json:"timestamp,string"` + ExtraData string `json:"extra_data"` + BaseFeePerGas uint64 `json:"base_fee_per_gas,string"` + BlockHash string `json:"block_hash"` + TransactionsRoot string `json:"transactions_root"` + WithdrawalsRoot string `json:"withdrawals_root"` + BlobGasUsed uint64 `json:"blob_gas_used,string"` + ExcessBlobGas uint64 `json:"excess_blob_gas,string"` +} + +type FinalityUpdateJSONResponse struct { + Version string `json:"version"` + Data ethereumtypes.LightClientUpdate `json:"data"` +} + +type BeaconBlocksResponseJSON struct { + ExecutionOptimistic bool `json:"execution_optimistic"` + Finalized bool `json:"finalized"` + Data struct { + Message struct { + Slot string `json:"slot"` + ProposerIndex string `json:"proposer_index"` + ParentRoot string `json:"parent_root"` + StateRoot string `json:"state_root"` + Body struct { + RandaoReveal string `json:"randao_reveal"` + Eth1Data struct { + DepositRoot string `json:"deposit_root"` + DepositCount string `json:"deposit_count"` + BlockHash string `json:"block_hash"` + } `json:"eth1_data"` + Graffiti string `json:"graffiti"` + ProposerSlashings []any `json:"proposer_slashings"` + AttesterSlashings []any `json:"attester_slashings"` + Attestations []any `json:"attestations"` + Deposits []any `json:"deposits"` + VoluntaryExits []any `json:"voluntary_exits"` + SyncAggregate struct { + SyncCommitteeBits string `json:"sync_committee_bits"` + SyncCommitteeSignature string `json:"sync_committee_signature"` + } `json:"sync_aggregate"` + ExecutionPayload struct { + ParentHash string `json:"parent_hash"` + FeeRecipient string `json:"fee_recipient"` + StateRoot string `json:"state_root"` + ReceiptsRoot string `json:"receipts_root"` + LogsBloom string `json:"logs_bloom"` + PrevRandao string `json:"prev_randao"` + BlockNumber uint64 `json:"block_number,string"` + GasLimit string `json:"gas_limit"` + GasUsed string `json:"gas_used"` + Timestamp string `json:"timestamp"` + ExtraData string `json:"extra_data"` + BaseFeePerGas string `json:"base_fee_per_gas"` + BlockHash string `json:"block_hash"` + Transactions []any `json:"transactions"` + Withdrawals []any `json:"withdrawals"` + BlobGasUsed string `json:"blob_gas_used"` + ExcessBlobGas string `json:"excess_blob_gas"` + } `json:"execution_payload"` + BlsToExecutionChanges []any `json:"bls_to_execution_changes"` + BlobKzgCommitments []any `json:"blob_kzg_commitments"` + } `json:"body"` + } `json:"message"` + Signature string `json:"signature"` + } `json:"data"` +} + +type LightClientUpdateJSON struct { + Data ethereumtypes.LightClientUpdate `json:"data"` +} diff --git a/testing/demo/pkg/ethereum/utils.go b/testing/demo/pkg/ethereum/utils.go new file mode 100644 index 0000000..19aa0c7 --- /dev/null +++ b/testing/demo/pkg/ethereum/utils.go @@ -0,0 +1,112 @@ +package ethereum + +import ( + "encoding/json" + "fmt" + "math/big" + "regexp" + "strings" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" +) + +type ForgeScriptReturnValues struct { + InternalType string `json:"internal_type"` + Value string `json:"value"` +} + +type ForgeDeployOutput struct { + Returns map[string]ForgeScriptReturnValues `json:"returns"` +} + +type DeployedContracts struct { + Ics07Tendermint string `json:"ics07Tendermint"` + IcsCore string `json:"icsCore"` + Ics26Router string `json:"ics26Router"` + Ics20Transfer string `json:"ics20Transfer"` + Erc20 string `json:"erc20"` + Escrow string `json:"escrow"` + IbcStore string `json:"ibcstore"` +} + +func GetEthContractsFromDeployOutput(stdout string) (DeployedContracts, error) { + // Remove everything above the JSON part + cutOff := "== Return ==" + cutoffIndex := strings.Index(stdout, cutOff) + stdout = stdout[cutoffIndex+len(cutOff):] + + // Extract the JSON part using regex + re := regexp.MustCompile(`\{.*\}`) + jsonPart := re.FindString(stdout) + + jsonPart = strings.ReplaceAll(jsonPart, `\"`, `"`) + jsonPart = strings.Trim(jsonPart, `"`) + + var embeddedContracts DeployedContracts + err := json.Unmarshal([]byte(jsonPart), &embeddedContracts) + if err != nil { + return DeployedContracts{}, err + } + + if embeddedContracts.Erc20 == "" || + embeddedContracts.IcsCore == "" || + embeddedContracts.Ics07Tendermint == "" || + embeddedContracts.Ics20Transfer == "" || + embeddedContracts.Ics26Router == "" || + embeddedContracts.Escrow == "" || + embeddedContracts.IbcStore == "" { + + return DeployedContracts{}, fmt.Errorf("one or more contracts missing: %+v", embeddedContracts) + } + + return embeddedContracts, nil +} + +func GetOnlySp1Ics07AddressFromStdout(stdout string) (string, error) { + // Define the regular expression pattern + re := regexp.MustCompile(`"value":"(0x[0-9a-fA-F]+)"`) + + // Find the first match + matches := re.FindStringSubmatch(stdout) + if len(matches) <= 1 { + return "", fmt.Errorf("no matches found in stdout") + } + // Extract the value + return matches[1], nil +} + +// From https://medium.com/@zhuytt4/verify-the-owner-of-safe-wallet-with-eth-getproof-7edc450504ff +func GetCommitmentsStorageKey(path []byte) ethcommon.Hash { + commitmentStorageSlot := ethcommon.FromHex(testvalues.IbcCommitmentSlotHex) + + pathHash := crypto.Keccak256(path) + + // zero pad both to 32 bytes + paddedSlot := ethcommon.LeftPadBytes(commitmentStorageSlot, 32) + + // keccak256(h(k) . slot) + return crypto.Keccak256Hash(pathHash, paddedSlot) +} + +func HexToBeBytes(hex string) []byte { + bz := ethcommon.FromHex(hex) + if len(bz) == 32 { + return bz + } + if len(bz) > 32 { + panic("TOO BIG!") + } + beBytes := make([]byte, 32) + copy(beBytes[32-len(bz):32], bz) + return beBytes +} + +func BigIntToBeBytes(n *big.Int) [32]byte { + bytes := n.Bytes() + var beBytes [32]byte + copy(beBytes[32-len(bytes):], bytes) + return beBytes +} diff --git a/testing/demo/pkg/ethereum/utils_test.go b/testing/demo/pkg/ethereum/utils_test.go new file mode 100644 index 0000000..dc40f34 --- /dev/null +++ b/testing/demo/pkg/ethereum/utils_test.go @@ -0,0 +1,136 @@ +package ethereum_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" +) + +func TestGetEthAddressFromStdout(t *testing.T) { + exampleOutput := `Compiling 72 files with Solc 0.8.25 +Solc 0.8.25 finished in 2.43s +Compiler run successful! +Traces: + [13132696] E2ETestDeploy::run() + ├─ [0] VM::projectRoot() [staticcall] + │ └─ ← [Return] "/Users/gg/Code/solidity-ibc-eureka" + ├─ [0] VM::readFile("/Users/gg/Code/solidity-ibc-eureka/e2e/genesis.json") [staticcall] + │ └─ ← [Return] + ├─ [0] VM::parseJsonBytes("", ".trustedClientState") [staticcall] + │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000012754500000000000000000000000000000000000000000000000000000000001baf800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673696d642d310000000000000000000000000000000000000000000000000000 + ├─ [0] VM::parseJsonBytes("", ".trustedConsensusState") [staticcall] + │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000006708142974c0681a0dbf3e340cedb56abacacec3f01106cd13d1d240e6eb7fc60a34c31250d828ba2c80c290ee3edb5d12ec232dee758f20214af6fbd73a1f636f79d4d7 + ├─ [0] VM::parseJsonBytes32("", ".updateClientVkey") [staticcall] + │ └─ ← [Return] 0x00787fed71dce3ac5685c23cb727f0bbe41c9c40977506f33530f52eabab6c86 + ├─ [0] VM::parseJsonBytes32("", ".membershipVkey") [staticcall] + │ └─ ← [Return] 0x00a8f49c50bcef3ffaef3e8018be59281904d5951d6e20e0a824b9504da18c7f + ├─ [0] VM::parseJsonBytes32("", ".ucAndMembershipVkey") [staticcall] + │ └─ ← [Return] 0x0037bf750186b666717a245012144eb63d1c8675134c9a9c81133535c4f76656 + ├─ [0] VM::envUint("PRIVATE_KEY") [staticcall] + │ └─ ← [Return] + ├─ [0] VM::startBroadcast() + │ └─ ← [Return] + ├─ [2404781] → new SP1Verifier@0x867EBEE8fB04ef90a4161fe21b89420B0aeEF8f2 + │ └─ ← [Return] 12011 bytes of code + ├─ [2442427] → new SP1ICS07Tendermint@0x65cE09e5864dD1f45F4ae50396A307291AaD6631 + │ └─ ← [Return] 11624 bytes of code + ├─ [1171142] → new ICS02Client@0xEBC7C68E032d765e392CFf5B2a11E76C2C43BbbF + │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) + │ └─ ← [Return] 5730 bytes of code + ├─ [2953720] → new ICS26Router@0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501 + │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) + │ └─ ← [Return] 14411 bytes of code + ├─ [3299657] → new ICS20Transfer@0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22 + │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: ICS26Router: [0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501]) + │ └─ ← [Return] 16250 bytes of code + ├─ [531853] → new TestERC20@0x022b667cC0D57836CCb12669ce93Ae1e15d4f8BC + │ └─ ← [Return] 2431 bytes of code + ├─ [28083] ICS26Router::addIBCApp("transfer", ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) + │ ├─ emit IBCAppAdded(portId: "transfer", app: ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) + │ └─ ← [Stop] + ├─ [0] VM::stopBroadcast() + │ └─ ← [Return] + ├─ [0] VM::serializeString("", "ics07Tendermint", "0x65ce09e5864dd1f45f4ae50396a307291aad6631") + │ └─ ← [Return] "{\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\"}" + ├─ [0] VM::serializeString("", "ics02Client", "0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf") + │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\"}" + ├─ [0] VM::serializeString("", "ics26Router", "0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501") + │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" + ├─ [0] VM::serializeString("", "ics20Transfer", "0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22") + │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" + ├─ [0] VM::serializeString("", "erc20", "0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc") + │ └─ ← [Return] "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" + └─ ← [Return] "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" + + +Script ran successfully. + +== Return == +0: string "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" + +## Setting up 1 EVM. +========================== +Simulated On-chain Traces: + + [521379] → new ICS20Lib@0xDcC1FffeC88e1Fa830604047fad1Aa8D957A7DC7 + └─ ← [Return] 2604 bytes of code + + [2404781] → new SP1Verifier@0x867EBEE8fB04ef90a4161fe21b89420B0aeEF8f2 + └─ ← [Return] 12011 bytes of code + + [2442427] → new SP1ICS07Tendermint@0x65cE09e5864dD1f45F4ae50396A307291AaD6631 + └─ ← [Return] 11624 bytes of code + + [1171142] → new ICS02Client@0xEBC7C68E032d765e392CFf5B2a11E76C2C43BbbF + ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) + └─ ← [Return] 5730 bytes of code + + [2953720] → new ICS26Router@0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501 + ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) + └─ ← [Return] 14411 bytes of code + + [3299657] → new ICS20Transfer@0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22 + ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: ICS26Router: [0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501]) + └─ ← [Return] 16250 bytes of code + + [531853] → new TestERC20@0x022b667cC0D57836CCb12669ce93Ae1e15d4f8BC + └─ ← [Return] 2431 bytes of code + + [30083] ICS26Router::addIBCApp("transfer", ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) + ├─ emit IBCAppAdded(portId: "transfer", app: ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) + └─ ← [Stop] + + +========================== + +Chain 3151908 + +Estimated gas price: 0.460566435 gwei + +Estimated total gas used for script: 19196301 + +Estimated amount required: 0.008841171916756935 ETH + +========================== + + +========================== + +ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. + +Transactions saved to: /Users/gg/Code/solidity-ibc-eureka/broadcast/E2ETestDeploy.s.sol/3151908/run-latest.json + +Sensitive values saved to: /Users/gg/Code/solidity-ibc-eureka/cache/E2ETestDeploy.s.sol/3151908/run-latest.json +` + + deployedContracts, err := ethereum.GetEthContractsFromDeployOutput(exampleOutput) + require.NoError(t, err) + + require.Equal(t, "0x65ce09e5864dd1f45f4ae50396a307291aad6631", deployedContracts.Ics07Tendermint) + require.Equal(t, "0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf", deployedContracts.IcsCore) + require.Equal(t, "0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501", deployedContracts.Ics26Router) + require.Equal(t, "0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22", deployedContracts.Ics20Transfer) + require.Equal(t, "0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc", deployedContracts.Erc20) +} diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 5c6be68..e34c936 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -9,6 +9,7 @@ import ( "time" "cosmossdk.io/math" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/ethereum" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -22,7 +23,6 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" ) // TODO: fetch these from the `make setup` command output. @@ -125,7 +125,10 @@ func receivePacketOnEVM() error { if err != nil { return err } - eth := ethereum.NewEthereum(context.Background, ethereumRPC, nil, faucet) + eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) + if err != nil { + return err + } tx, err := ics26Contract.RecvPacket(GetTransactOpts(faucet, eth), msg) if err != nil { return err From d337e17e651b0448b7bbd0169a25a05a584b7525 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 9 Jan 2025 16:40:11 -0500 Subject: [PATCH 45/98] fill in boilerplate for updateTendermintLightClient --- testing/demo/pkg/relay-v2/main.go | 51 +++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index e34c936..38e889b 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -18,6 +18,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v9/testing" "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" + "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -51,24 +52,56 @@ const ( ethereumRPC = "http://localhost:8545/" // TODO: verify if this works anvilFaucetPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" + // TODO: get the tendermint clientID that is deployed on the EVM roll-up + clientID = "TBD" ) func main() { - // Update the Tendermint light client on the EVM roll-up with the stateTransitionProof - stateTransitionProof := []byte{} - err := updateTendermintLightClient(stateTransitionProof) + err := updateTendermintLightClient() if err != nil { log.Fatal(err) } - // Receive packet on EVM err = receivePacketOnEVM() if err != nil { log.Fatal(err) } } -func updateTendermintLightClient(stateTransitionProof []byte) error { +// updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. +func updateTendermintLightClient() error { + ethClient, err := ethclient.Dial(ethereumRPC) + if err != nil { + return err + } + icsCore, err := icscore.NewContract(ethcommon.HexToAddress(icsCore), ethClient) + if err != nil { + return err + } + faucet, err := crypto.ToECDSA(ethcommon.FromHex(anvilFaucetPrivateKey)) + if err != nil { + return err + } + eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) + if err != nil { + return err + } + // sendPacket, err := createSendPacket() + // if err != nil { + // return err + // } + // fmt.Printf("sendPacket %v\n", sendPacket) + // Update the Tendermint light client on the EVM roll-up with the stateTransitionProof + // stateTransitionProof := []byte{} + // TODO: figure out how to encode the state transition proof into this msg + msg := []byte{} + tx, err := icsCore.UpgradeClient(getTransactOpts(faucet, eth), clientID, msg) + receipt := getTxReciept(context.Background(), eth, tx.Hash()) + if ethtypes.ReceiptStatusSuccessful != receipt.Status { + return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) + } + recvBlockNumber := receipt.BlockNumber.Uint64() + fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) return nil } @@ -129,12 +162,12 @@ func receivePacketOnEVM() error { if err != nil { return err } - tx, err := ics26Contract.RecvPacket(GetTransactOpts(faucet, eth), msg) + tx, err := ics26Contract.RecvPacket(getTransactOpts(faucet, eth), msg) if err != nil { return err } - receipt := GetTxReciept(context.Background(), eth, tx.Hash()) + receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) } @@ -174,7 +207,7 @@ func createSendPacket() (channeltypesv2.Packet, error) { }, nil } -func GetTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { +func getTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { ethClient, err := ethclient.Dial(chain.RPC) if err != nil { log.Fatal(err) @@ -201,7 +234,7 @@ func GetTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.Trans return txOpts } -func GetTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.Hash) *ethtypes.Receipt { +func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.Hash) *ethtypes.Receipt { ethClient, err := ethclient.Dial(chain.RPC) if err != nil { log.Fatal(err) From ec8cee613a515e2044df1d9070bbd999bc8712f2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 9 Jan 2025 16:54:53 -0500 Subject: [PATCH 46/98] go mod tidy --- go.mod | 41 ++- go.sum | 182 +++++++++++++- testing/demo/pkg/ethereum/beaconapi.go | 27 -- testing/demo/pkg/ethereum/ethapi.go | 8 +- testing/demo/pkg/ethereum/ethereum.go | 2 +- testing/demo/pkg/ethereum/types.gen.go | 316 ++++++++++++++++++++++++ testing/demo/pkg/ethereum/types.go | 141 +---------- testing/demo/pkg/ethereum/utils.go | 2 +- testing/demo/pkg/ethereum/utils_test.go | 136 ---------- testing/demo/pkg/relay-v2/ethereum.go | 2 +- testing/demo/pkg/testvalues/doc.go | 3 + testing/demo/pkg/testvalues/values.go | 98 ++++++++ 12 files changed, 645 insertions(+), 313 deletions(-) create mode 100644 testing/demo/pkg/ethereum/types.gen.go delete mode 100644 testing/demo/pkg/ethereum/utils_test.go create mode 100644 testing/demo/pkg/testvalues/doc.go create mode 100644 testing/demo/pkg/testvalues/values.go diff --git a/go.mod b/go.mod index 673e079..251e558 100644 --- a/go.mod +++ b/go.mod @@ -30,11 +30,14 @@ require ( require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.4.0 + github.com/attestantio/go-eth2-client v0.22.0 github.com/consensys/gnark v0.11.0 github.com/consensys/gnark-crypto v0.14.0 github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241207083532-66bed7cfbbe1 github.com/ethereum/go-ethereum v1.14.12 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/rs/zerolog v1.33.0 + github.com/strangelove-ventures/interchaintest/v8 v8.8.1 google.golang.org/grpc v1.68.1 google.golang.org/protobuf v1.35.2 ) @@ -51,10 +54,12 @@ require ( filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect github.com/DataDog/datadog-go v4.8.3+incompatible // indirect github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/avast/retry-go/v4 v4.5.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect @@ -78,6 +83,8 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect + github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect + github.com/cosmos/ibc-go/v8 v8.4.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect @@ -91,6 +98,10 @@ require ( github.com/desertbit/timer v1.0.1 // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/docker/docker v24.0.9+incompatible // indirect + github.com/docker/go-connections v0.5.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/emicklei/dot v1.6.2 // indirect @@ -98,6 +109,7 @@ require ( github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fatih/color v1.17.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/ferranbt/fastssz v0.1.3 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/getsentry/sentry-go v0.28.1 // indirect @@ -107,10 +119,11 @@ require ( github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/goccy/go-yaml v1.9.2 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/googleapis v1.4.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect + github.com/gogo/protobuf v1.3.3 // indirect github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/mock v1.6.0 // indirect @@ -137,13 +150,14 @@ require ( github.com/hashicorp/go-metrics v0.5.3 // indirect github.com/hashicorp/go-plugin v1.6.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hdevalence/ed25519consensus v0.2.0 // indirect github.com/holiman/uint256 v1.3.1 // indirect + github.com/huandu/go-clone v1.6.0 // indirect github.com/huandu/skiplist v1.2.0 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect @@ -153,6 +167,7 @@ require ( github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/lib/pq v1.10.9 // indirect @@ -163,30 +178,36 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/minio/highwayhash v1.0.3 // indirect + github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect + github.com/morikuni/aec v1.0.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onsi/ginkgo v1.16.5 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc2 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect + github.com/pk910/dynamic-ssz v0.0.3 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect + github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e // indirect + github.com/r3labs/sse/v2 v2.10.0 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/rivo/uniseg v0.4.3 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/ronanh/intcomp v1.1.0 // indirect github.com/rs/cors v1.11.1 // indirect - github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect @@ -213,6 +234,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.28.0 // indirect golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect golang.org/x/net v0.30.0 // indirect @@ -222,10 +244,13 @@ require ( golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.186.0 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + gopkg.in/Knetic/govaluate.v3 v3.0.0 // indirect + gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -244,3 +269,11 @@ replace ( github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) + +// Copied from solidity-ibc-eureka +// TODO: using version v1.0.0 causes a build failure. This is the previous version which compiles successfully. +replace ( + github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d + github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 + github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 +) diff --git a/go.sum b/go.sum index c185954..ea2f148 100644 --- a/go.sum +++ b/go.sum @@ -226,12 +226,24 @@ github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTB github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM= +github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= +github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 h1:oknQF/iIhf5lVjbwjsVDzDByupRhga8nhA3NAmwyHDA= +github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420/go.mod h1:KYkiMX5AbOlXXYfxkrYPrRPV6EbVUALTQh5ptUOJzu8= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q= github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc= +github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw= +github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc= +github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= @@ -242,6 +254,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/StirlingMarketingGroup/go-namecase v1.0.0 h1:2CzaNtCzc4iNHirR+5ru9OzGg8rQp860gqLBFqRI02Y= +github.com/StirlingMarketingGroup/go-namecase v1.0.0/go.mod h1:ZsoSKcafcAzuBx+sndbxHu/RjDcDTrEdT4UvhniHfio= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= @@ -261,6 +275,10 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/attestantio/go-eth2-client v0.22.0 h1:KmF9kPNNWWGfE7l1BP7pXps4EOXgKnYeFGR0/WbyFhY= +github.com/attestantio/go-eth2-client v0.22.0/go.mod h1:d7ZPNrMX8jLfIgML5u7QZxFo2AukLM+5m08iMaLdqb8= +github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o= +github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= @@ -281,6 +299,8 @@ github.com/bits-and-blooms/bitset v1.14.2 h1:YXVoyPndbdvcEVcseEovVfp0qjJp7S+i5+x github.com/bits-and-blooms/bitset v1.14.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= +github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -326,8 +346,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o= +github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a h1:f52TdbU4D5nozMAhO9TvTJ2ZMCXtN4VIAmfrrZ0JXQ4= @@ -374,10 +394,16 @@ github.com/cosmos/gogoproto v1.7.0 h1:79USr0oyXAbxg3rspGh/m4SWNyoz/GLaAh0QlCe2fr github.com/cosmos/gogoproto v1.7.0/go.mod h1:yWChEv5IUEYURQasfyBW5ffkMHR/90hiHgbNgrtp4j0= github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= +github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= +github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= +github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE= +github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs= github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55 h1:tvvb3EXXVrYaCOFGuS1awUBEfoI9a0qjhJaQnbkagZ4= github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55/go.mod h1:6+3if3nHW38kA8P2Lcb4UIDpt5BIUPbrCGAD8kGIli8= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= +github.com/cosmos/interchain-security/v5 v5.1.1 h1:xmRRMeE4xoc+JAZUh0XzXFYWaGBtzFFj5SETuOgnEnY= +github.com/cosmos/interchain-security/v5 v5.1.1/go.mod h1:vmeTcTxFCl1eV0o6xpl/IRT7Basz0szVVGzbppnInMg= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241207083532-66bed7cfbbe1 h1:yN6MSjZK9ljUUVAbXx6yKqpEQsgnEldS07kX1MdRDpY= @@ -401,10 +427,16 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/base58 v1.0.4 h1:QJC6B0E0rXOPA8U/kw2rP+qiRJsUaE2Er+pYb3siUeA= +github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38oGd9E= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1 h1:18HurQ6DfHeNvwIjvOmrgr44bPdtVaQAe/WWwHg9goM= +github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1/go.mod h1:XmyzkaXBy7ZvHdrTAlXAjpog8qKSAWa3ze7yqzWmgmc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= @@ -418,8 +450,12 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= +github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -452,11 +488,14 @@ github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokg github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo= +github.com/ferranbt/fastssz v0.1.3/go.mod h1:0Y9TEd/9XuFlh7mskMPfXiI2Dkw4Ddg9EyXt1W7MRvE= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -502,14 +541,23 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= +github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/goccy/go-yaml v1.9.2 h1:2Njwzw+0+pjU2gb805ZC1B/uBuAs2VcZ3K+ZgHwDs7w= +github.com/goccy/go-yaml v1.9.2/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -665,6 +713,10 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= +github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= +github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= +github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -695,11 +747,12 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= -github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -726,6 +779,10 @@ github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXei github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= +github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc= +github.com/huandu/go-clone v1.6.0/go.mod h1:ReGivhG6op3GYr+UY3lS6mxjKp7MIGTknuU5TbTVaXE= +github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U= +github.com/huandu/go-clone/generic v1.6.0/go.mod h1:xgd9ZebcMsBWWcBx5mVMCoqMX24gLWr5lQicr+nVXNs= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= @@ -735,6 +792,8 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 h1:H+uM0Bv88eur3ZSsd2NGKg3YIiuXxwxtlN7HjE66UTU= +github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845/go.mod h1:c1tRKs5Tx7E2+uHGSyyncziFjvGpgv4H2HrqXeUQ/Uk= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -745,6 +804,8 @@ github.com/ingonyama-zk/icicle v1.1.0 h1:a2MUIaF+1i4JY2Lnb961ZMvaC8GFs9GqZgSnd9e github.com/ingonyama-zk/icicle v1.1.0/go.mod h1:kAK8/EoN7fUEmakzgZIYdWy1a2rBnpCaZLqSHwZWxEk= github.com/ingonyama-zk/iciclegnark v0.1.0 h1:88MkEghzjQBMjrYRJFxZ9oR9CTIpB8NG2zLeCJSvXKQ= github.com/ingonyama-zk/iciclegnark v0.1.0/go.mod h1:wz6+IpyHKs6UhMMoQpNqz1VY+ddfKqC/gRwR/64W6WU= +github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= +github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= @@ -775,6 +836,8 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -790,8 +853,14 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4= github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= +github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-libp2p v0.31.0 h1:LFShhP8F6xthWiBBq3euxbKjZsoRajVEyBS9snfHxYg= +github.com/libp2p/go-libp2p v0.31.0/go.mod h1:W/FEK1c/t04PbRH3fA9i5oucu5YcgrG0JVoBWT1B7Eg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/linxGnu/grocksdb v1.9.2 h1:O3mzvO0wuzQ9mtlHbDrShixyVjVbmuqTjFrzlf43wZ8= @@ -802,6 +871,7 @@ github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3v github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -821,8 +891,14 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b h1:QrHweqAtyJ9EwCaGHBu1fghwxIPiopAHV06JlXrMHjk= +github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b/go.mod h1:xxLb2ip6sSUts3g1irPVHyk/DGslwQsNOo9I7smJfNU= github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= +github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe h1:0fcCSfvBgbagEsEMkZuxgA3Ex7IN9i1Hon0fwgMLpQw= +github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -841,12 +917,32 @@ github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8oh github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= +github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= +github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multiaddr v0.11.0 h1:XqGyJ8ufbCE0HmTDwx2kPdsrQ36AGPZNZX6s6xfJH10= +github.com/multiformats/go-multiaddr v0.11.0/go.mod h1:gWUm0QLR4thQ6+ZF6SXUw8YjtwQSPapICM+NmCkxHSM= +github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= +github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= +github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= +github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= +github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -860,6 +956,8 @@ github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzE github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -883,8 +981,8 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042 github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= -github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -907,6 +1005,8 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= @@ -914,8 +1014,12 @@ github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo= +github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= +github.com/pk910/dynamic-ssz v0.0.3 h1:fCWzFowq9P6SYCc7NtJMkZcIHk+r5hSVD+32zVi6Aio= +github.com/pk910/dynamic-ssz v0.0.3/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -958,13 +1062,20 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e h1:ATgOe+abbzfx9kCPeXIW4fiWyDdxlwHw07j8UGhdTd4= +github.com/prysmaticlabs/go-bitfield v0.0.0-20240328144219-a1caa50c3a1e/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= +github.com/r3labs/sse/v2 v2.10.0 h1:hFEkLLFY4LDifoHdiCN/LlGBAdVJYsANaLqNYa1l/v0= +github.com/r3labs/sse/v2 v2.10.0/go.mod h1:Igau6Whc+F17QUgML1fYe1VPZzTV6EMCnYktEmkNJ7I= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -979,6 +1090,7 @@ github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -1007,6 +1119,8 @@ github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= @@ -1019,6 +1133,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= +github.com/strangelove-ventures/interchaintest/v8 v8.8.1 h1:F7xqxZ8Nl9ttKHQqVjgJ2lCQrQxiRjJq6EVdA/YaGeY= +github.com/strangelove-ventures/interchaintest/v8 v8.8.1/go.mod h1:AFFimVWInij/cZMjNbKYMW6EgX0SjHKmIl/GS/akMd8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -1050,19 +1166,33 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tendermint v0.38.0-dev h1:yX4zsEgTF9PxlLmhx9XAPTGH2E9FSlqSpHcY7sW7Vb8= +github.com/tendermint/tendermint v0.38.0-dev/go.mod h1:EHKmaqObmcGysoRr7krxXoxxhUDyYWbKvvRYJ9tCGWY= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= +github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= +github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJdv5KE= +github.com/tyler-smith/go-bip32 v1.0.0/go.mod h1:onot+eHknzV4BVPwrzqY5OoVpyCvnwD7lMawL5aQupE= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/umbracle/gohashtree v0.0.2-alpha.0.20230207094856-5b775a815c10 h1:CQh33pStIp/E30b7TxDlXfM0145bn2e8boI30IxAhTg= +github.com/umbracle/gohashtree v0.0.2-alpha.0.20230207094856-5b775a815c10/go.mod h1:x/Pa0FF5Te9kdrlZKJK82YmAkvL8+f989USgz6Jiw7M= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -1116,6 +1246,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1125,6 +1257,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1176,6 +1310,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1196,6 +1332,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1373,6 +1510,7 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1464,6 +1602,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1707,7 +1847,11 @@ google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +gopkg.in/Knetic/govaluate.v3 v3.0.0 h1:18mUyIt4ZlRlFZAAfVetz4/rzlJs9yhN+U02F4u1AOc= +gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= +gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1723,6 +1867,8 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -1751,6 +1897,22 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= +modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U= +modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= +modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= +modernc.org/sqlite v1.31.1 h1:XVU0VyzxrYHlBhIs1DiEgSl0ZtdnPtbLVy8hSkzxGrs= +modernc.org/sqlite v1.31.1/go.mod h1:UqoylwmTb9F+IqXERT8bW9zzOWN8qwAIcLdzeBZs4hA= +modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= +modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0= nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= diff --git a/testing/demo/pkg/ethereum/beaconapi.go b/testing/demo/pkg/ethereum/beaconapi.go index f1f1d32..530383b 100644 --- a/testing/demo/pkg/ethereum/beaconapi.go +++ b/testing/demo/pkg/ethereum/beaconapi.go @@ -14,10 +14,6 @@ import ( ethttp "github.com/attestantio/go-eth2-client/http" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/rs/zerolog" - - ethcommon "github.com/ethereum/go-ethereum/common" - - ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" ) type BeaconAPIClient struct { @@ -31,29 +27,6 @@ type BeaconAPIClient struct { RetryWait time.Duration } -func (s Spec) ToForkParameters() ethereumtypes.ForkParameters { - return ethereumtypes.ForkParameters{ - GenesisForkVersion: ethcommon.Bytes2Hex(s.GenesisForkVersion[:]), - GenesisSlot: s.GenesisSlot, - Altair: ethereumtypes.Fork{ - Version: ethcommon.Bytes2Hex(s.AltairForkVersion[:]), - Epoch: s.AltairForkEpoch, - }, - Bellatrix: ethereumtypes.Fork{ - Version: ethcommon.Bytes2Hex(s.BellatrixForkVersion[:]), - Epoch: s.BellatrixForkEpoch, - }, - Capella: ethereumtypes.Fork{ - Version: ethcommon.Bytes2Hex(s.CapellaForkVersion[:]), - Epoch: s.CapellaForkEpoch, - }, - Deneb: ethereumtypes.Fork{ - Version: ethcommon.Bytes2Hex(s.DenebForkVersion[:]), - Epoch: s.DenebForkEpoch, - }, - } -} - func (s Spec) Period() uint64 { return s.EpochsPerSyncCommitteePeriod * s.SlotsPerEpoch } diff --git a/testing/demo/pkg/ethereum/ethapi.go b/testing/demo/pkg/ethereum/ethapi.go index eb8cb69..68c98e7 100644 --- a/testing/demo/pkg/ethereum/ethapi.go +++ b/testing/demo/pkg/ethereum/ethapi.go @@ -5,8 +5,6 @@ import ( "time" "github.com/ethereum/go-ethereum/ethclient" - - ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" ) type EthAPI struct { @@ -17,9 +15,9 @@ type EthAPI struct { } type EthGetProofResponse struct { - StorageHash string `json:"storageHash"` - StorageProof []ethereumtypes.StorageProof `json:"storageProof"` - AccountProof []string `json:"accountProof"` + StorageHash string `json:"storageHash"` + StorageProof []StorageProof `json:"storageProof"` + AccountProof []string `json:"accountProof"` } func NewEthAPI(rpc string) (EthAPI, error) { diff --git a/testing/demo/pkg/ethereum/ethereum.go b/testing/demo/pkg/ethereum/ethereum.go index c2eff02..5fb6041 100644 --- a/testing/demo/pkg/ethereum/ethereum.go +++ b/testing/demo/pkg/ethereum/ethereum.go @@ -19,7 +19,7 @@ import ( "cosmossdk.io/math" - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" ) type Ethereum struct { diff --git a/testing/demo/pkg/ethereum/types.gen.go b/testing/demo/pkg/ethereum/types.gen.go new file mode 100644 index 0000000..67a825f --- /dev/null +++ b/testing/demo/pkg/ethereum/types.gen.go @@ -0,0 +1,316 @@ +package ethereum + +// The Ethereum types to export to JSON Schema and used to generate types in other languages +// The structure itself is not used for anything else than being able to generate a single +// schema +type GeneratedTypes struct { + ClientState ClientState `json:"client_state"` + ConsensusState ConsensusState `json:"consensus_state"` + Header Header `json:"header"` + StorageProof StorageProof `json:"storage_proof"` + TestFixtures TestFixtures `json:"test_fixtures"` +} + +// The ethereum client state +// +// # The client state at the time of the proof +// +// # The client state at the initial state +// +// The client state after the update +type ClientState struct { + // The chain ID + ChainID uint64 `json:"chain_id"` + // The number of epochs per sync committee period + EpochsPerSyncCommitteePeriod uint64 `json:"epochs_per_sync_committee_period"` + // The fork parameters + ForkParameters ForkParameters `json:"fork_parameters"` + // The slot at which the client was frozen + FrozenSlot uint64 `json:"frozen_slot"` + // The time of genesis (unix timestamp) + GenesisTime uint64 `json:"genesis_time"` + // The genesis validators root + GenesisValidatorsRoot string `json:"genesis_validators_root"` + // The storage slot of the IBC commitment in the Ethereum contract + IbcCommitmentSlot string `json:"ibc_commitment_slot"` + // The address of the IBC contract being tracked on Ethereum + IbcContractAddress string `json:"ibc_contract_address"` + // The latest slot of this client + LatestSlot uint64 `json:"latest_slot"` + // The minimum number of participants in the sync committee + MinSyncCommitteeParticipants uint64 `json:"min_sync_committee_participants"` + // The slot duration in seconds + SecondsPerSlot uint64 `json:"seconds_per_slot"` + // The number of slots per epoch + SlotsPerEpoch uint64 `json:"slots_per_epoch"` +} + +// The fork parameters +type ForkParameters struct { + // The altair fork + Altair Fork `json:"altair"` + // The bellatrix fork + Bellatrix Fork `json:"bellatrix"` + // The capella fork + Capella Fork `json:"capella"` + // The deneb fork + Deneb Fork `json:"deneb"` + // The genesis fork version + GenesisForkVersion string `json:"genesis_fork_version"` + // The genesis slot + GenesisSlot uint64 `json:"genesis_slot"` +} + +// The altair fork +// +// # The fork data +// +// # The bellatrix fork +// +// # The capella fork +// +// The deneb fork +type Fork struct { + // The epoch at which this fork is activated + Epoch uint64 `json:"epoch"` + // The version of the fork + Version string `json:"version"` +} + +// The consensus state of the Ethereum light client +// +// # The consensus state at the time of the proof +// +// # The consensus state at the initial state +// +// The consensus state after the update +type ConsensusState struct { + // aggregate public key of current sync committee + CurrentSyncCommittee string `json:"current_sync_committee"` + // aggregate public key of next sync committee + NextSyncCommittee string `json:"next_sync_committee"` + // The slot number + Slot uint64 `json:"slot"` + // The state merkle root + StateRoot string `json:"state_root"` + // The storage merkle root + StorageRoot string `json:"storage_root"` + // The unix timestamp at the time of the slot. It is calculated from the genesis time and + // slots per. + Timestamp uint64 `json:"timestamp"` +} + +// The header of a light client update +type Header struct { + // The account update + AccountUpdate AccountUpdate `json:"account_update"` + // The consensus update + ConsensusUpdate LightClientUpdate `json:"consensus_update"` + // The trusted sync committee + TrustedSyncCommittee TrustedSyncCommittee `json:"trusted_sync_committee"` +} + +// The account update +type AccountUpdate struct { + // The account proof + AccountProof AccountProof `json:"account_proof"` +} + +// The account proof +type AccountProof struct { + // The account proof + Proof []string `json:"proof"` + // The account storage root + StorageRoot string `json:"storage_root"` +} + +// The consensus update +// +// A light client update +type LightClientUpdate struct { + // Header attested to by the sync committee + AttestedHeader LightClientHeader `json:"attested_header"` + // Branch of the finalized header + FinalityBranch []string `json:"finality_branch"` + // Finalized header corresponding to `attested_header.state_root` + FinalizedHeader LightClientHeader `json:"finalized_header"` + // Next sync committee corresponding to `attested_header.state_root` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee"` + // The branch of the next sync committee + NextSyncCommitteeBranch []string `json:"next_sync_committee_branch"` + // Slot at which the aggregate signature was created (untrusted) + SignatureSlot string `json:"signature_slot"` + // Sync committee aggregate signature + SyncAggregate SyncAggregate `json:"sync_aggregate"` +} + +// Header attested to by the sync committee +// +// # The header of a light client +// +// Finalized header corresponding to `attested_header.state_root` +type LightClientHeader struct { + // The beacon block header + Beacon BeaconBlockHeader `json:"beacon"` + // The execution payload header + Execution ExecutionPayloadHeader `json:"execution"` + // The execution branch + ExecutionBranch []string `json:"execution_branch"` +} + +// The beacon block header +type BeaconBlockHeader struct { + // The tree hash merkle root of the `BeaconBlockBody` for the `BeaconBlock` + BodyRoot string `json:"body_root"` + // The signing merkle root of the parent `BeaconBlock` + ParentRoot string `json:"parent_root"` + // The index of validator in validator registry + ProposerIndex string `json:"proposer_index"` + // The slot to which this block corresponds + Slot string `json:"slot"` + // The tree hash merkle root of the `BeaconState` for the `BeaconBlock` + StateRoot string `json:"state_root"` +} + +// The execution payload header +// +// Header to track the execution block +type ExecutionPayloadHeader struct { + // Block base fee per gas + BaseFeePerGas string `json:"base_fee_per_gas"` + // Blob gas used (new in Deneb) + BlobGasUsed string `json:"blob_gas_used"` + // The block hash + BlockHash string `json:"block_hash"` + // The block number of the execution payload + BlockNumber string `json:"block_number"` + // Excess blob gas (new in Deneb) + ExcessBlobGas string `json:"excess_blob_gas"` + // The extra data of the execution payload + ExtraData string `json:"extra_data"` + // Block fee recipient + FeeRecipient string `json:"fee_recipient"` + // Execution block gas limit + GasLimit string `json:"gas_limit"` + // Execution block gas used + GasUsed string `json:"gas_used"` + // The logs bloom filter + LogsBloom string `json:"logs_bloom"` + // The parent hash of the execution payload header + ParentHash string `json:"parent_hash"` + // The previous Randao value, used to compute the randomness on the execution layer. + PrevRandao string `json:"prev_randao"` + // The root of the receipts trie + ReceiptsRoot string `json:"receipts_root"` + // The state root + StateRoot string `json:"state_root"` + // The timestamp of the execution payload + Timestamp string `json:"timestamp"` + // SSZ hash tree root of the transaction list + TransactionsRoot string `json:"transactions_root"` + // Tree root of the withdrawals list + WithdrawalsRoot string `json:"withdrawals_root"` +} + +// The sync committee data +type SyncCommittee struct { + // The aggregate public key of the sync committee + AggregatePubkey string `json:"aggregate_pubkey"` + // The public keys of the sync committee + Pubkeys []string `json:"pubkeys"` +} + +// Sync committee aggregate signature +// +// The sync committee aggregate +type SyncAggregate struct { + // The bits representing the sync committee's participation. + SyncCommitteeBits string `json:"sync_committee_bits"` + // The aggregated signature of the sync committee. + SyncCommitteeSignature string `json:"sync_committee_signature"` +} + +// The trusted sync committee +type TrustedSyncCommittee struct { + // The current sync committee + SyncCommittee ActiveSyncCommittee `json:"sync_committee"` + // The trusted slot + TrustedSlot uint64 `json:"trusted_slot"` +} + +// The current sync committee +// +// # The active sync committee +// +// The next sync committee +type ActiveSyncCommittee struct { + Current *SyncCommittee `json:"Current,omitempty"` + Next *SyncCommittee `json:"Next,omitempty"` +} + +// The key-value storage proof for a smart contract account +// +// The storage proof used to verify membership +type StorageProof struct { + // The key of the storage + Key string `json:"key"` + // The proof of the storage + Proof []string `json:"proof"` + // The value of the storage + Value string `json:"value"` +} + +type TestFixtures struct { + CommitmentProof CommitmentProof `json:"commitment_proof"` + InitialState InitialState `json:"initial_state"` + Step Step `json:"step"` + StepsFixture StepsFixture `json:"steps_fixture"` + UpdateClient UpdateClient `json:"update_client"` +} + +// The proof used to verify membership +type CommitmentProof struct { + // The client state at the time of the proof + ClientState ClientState `json:"client_state"` + // The consensus state at the time of the proof + ConsensusState ConsensusState `json:"consensus_state"` + // The IBC path sent to verify membership + Path string `json:"path"` + // The slot of the proof (ibc height) + ProofSlot uint64 `json:"proof_slot"` + // The storage proof used to verify membership + StorageProof StorageProof `json:"storage_proof"` +} + +// The initial state of the light client in the e2e tests +type InitialState struct { + // The client state at the initial state + ClientState ClientState `json:"client_state"` + // The consensus state at the initial state + ConsensusState ConsensusState `json:"consensus_state"` +} + +// Step is a light client operation such as an initial state, commitment proof, or update +// client +type Step struct { + // data is the operation data as a JSON object to be deserialized into the appropriate type + Data interface{} `json:"data"` + // name is the name of the operation, only used for documentation and easy of reading + Name string `json:"name"` +} + +// A test fixture with an ordered list of light client operations from the e2e test +type StepsFixture struct { + // steps is a list of light client operations + Steps []Step `json:"steps"` +} + +// Operation to update the light client +type UpdateClient struct { + // The client state after the update + ClientState ClientState `json:"client_state"` + // The consensus state after the update + ConsensusState ConsensusState `json:"consensus_state"` + // The headers used to update the light client, in order + Updates []Header `json:"updates"` +} diff --git a/testing/demo/pkg/ethereum/types.go b/testing/demo/pkg/ethereum/types.go index 75c3b33..050039a 100644 --- a/testing/demo/pkg/ethereum/types.go +++ b/testing/demo/pkg/ethereum/types.go @@ -1,136 +1,21 @@ package ethereum -import ( - "time" +import "strconv" - "github.com/attestantio/go-eth2-client/spec/phase0" +func (h BeaconBlockHeader) GetSlot() uint64 { + slot, err := strconv.ParseUint(h.Slot, 0, 0) + if err != nil { + panic(err) + } - ethereumtypes "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/types/ethereum" -) - -type Spec struct { - SecondsPerSlot time.Duration `json:"SECONDS_PER_SLOT"` - SlotsPerEpoch uint64 `json:"SLOTS_PER_EPOCH"` - EpochsPerSyncCommitteePeriod uint64 `json:"EPOCHS_PER_SYNC_COMMITTEE_PERIOD"` - - // Fork Parameters - GenesisForkVersion phase0.Version `json:"GENESIS_FORK_VERSION"` - GenesisSlot uint64 `json:"GENESIS_SLOT"` - AltairForkVersion phase0.Version `json:"ALTAIR_FORK_VERSION"` - AltairForkEpoch uint64 `json:"ALTAIR_FORK_EPOCH"` - BellatrixForkVersion phase0.Version `json:"BELLATRIX_FORK_VERSION"` - BellatrixForkEpoch uint64 `json:"BELLATRIX_FORK_EPOCH"` - CapellaForkVersion phase0.Version `json:"CAPELLA_FORK_VERSION"` - CapellaForkEpoch uint64 `json:"CAPELLA_FORK_EPOCH"` - DenebForkVersion phase0.Version `json:"DENEB_FORK_VERSION"` - DenebForkEpoch uint64 `json:"DENEB_FORK_EPOCH"` -} - -type Bootstrap struct { - Data struct { - Header BootstrapHeader `json:"header"` - CurrentSyncCommittee SyncCommittee `json:"current_sync_committee"` - } `json:"data"` -} - -type BootstrapHeader struct { - Beacon BeaconJSON `json:"beacon"` - Execution ExecutionJSON `json:"execution"` -} - -type SyncCommittee struct { - Pubkeys []string `json:"pubkeys"` - AggregatePubkey string `json:"aggregate_pubkey"` + return slot } -type LightClientUpdatesResponse []LightClientUpdateJSON - -type BeaconJSON struct { - Slot uint64 `json:"slot,string"` - ProposerIndex uint64 `json:"proposer_index,string"` - ParentRoot string `json:"parent_root"` - StateRoot string `json:"state_root"` - BodyRoot string `json:"body_root"` -} - -type ExecutionJSON struct { - ParentHash string `json:"parent_hash"` - FeeRecipient string `json:"fee_recipient"` - StateRoot string `json:"state_root"` - ReceiptsRoot string `json:"receipts_root"` - LogsBloom string `json:"logs_bloom"` - PrevRandao string `json:"prev_randao"` - BlockNumber uint64 `json:"block_number,string"` - GasLimit uint64 `json:"gas_limit,string"` - GasUsed uint64 `json:"gas_used,string"` - Timestamp uint64 `json:"timestamp,string"` - ExtraData string `json:"extra_data"` - BaseFeePerGas uint64 `json:"base_fee_per_gas,string"` - BlockHash string `json:"block_hash"` - TransactionsRoot string `json:"transactions_root"` - WithdrawalsRoot string `json:"withdrawals_root"` - BlobGasUsed uint64 `json:"blob_gas_used,string"` - ExcessBlobGas uint64 `json:"excess_blob_gas,string"` -} - -type FinalityUpdateJSONResponse struct { - Version string `json:"version"` - Data ethereumtypes.LightClientUpdate `json:"data"` -} - -type BeaconBlocksResponseJSON struct { - ExecutionOptimistic bool `json:"execution_optimistic"` - Finalized bool `json:"finalized"` - Data struct { - Message struct { - Slot string `json:"slot"` - ProposerIndex string `json:"proposer_index"` - ParentRoot string `json:"parent_root"` - StateRoot string `json:"state_root"` - Body struct { - RandaoReveal string `json:"randao_reveal"` - Eth1Data struct { - DepositRoot string `json:"deposit_root"` - DepositCount string `json:"deposit_count"` - BlockHash string `json:"block_hash"` - } `json:"eth1_data"` - Graffiti string `json:"graffiti"` - ProposerSlashings []any `json:"proposer_slashings"` - AttesterSlashings []any `json:"attester_slashings"` - Attestations []any `json:"attestations"` - Deposits []any `json:"deposits"` - VoluntaryExits []any `json:"voluntary_exits"` - SyncAggregate struct { - SyncCommitteeBits string `json:"sync_committee_bits"` - SyncCommitteeSignature string `json:"sync_committee_signature"` - } `json:"sync_aggregate"` - ExecutionPayload struct { - ParentHash string `json:"parent_hash"` - FeeRecipient string `json:"fee_recipient"` - StateRoot string `json:"state_root"` - ReceiptsRoot string `json:"receipts_root"` - LogsBloom string `json:"logs_bloom"` - PrevRandao string `json:"prev_randao"` - BlockNumber uint64 `json:"block_number,string"` - GasLimit string `json:"gas_limit"` - GasUsed string `json:"gas_used"` - Timestamp string `json:"timestamp"` - ExtraData string `json:"extra_data"` - BaseFeePerGas string `json:"base_fee_per_gas"` - BlockHash string `json:"block_hash"` - Transactions []any `json:"transactions"` - Withdrawals []any `json:"withdrawals"` - BlobGasUsed string `json:"blob_gas_used"` - ExcessBlobGas string `json:"excess_blob_gas"` - } `json:"execution_payload"` - BlsToExecutionChanges []any `json:"bls_to_execution_changes"` - BlobKzgCommitments []any `json:"blob_kzg_commitments"` - } `json:"body"` - } `json:"message"` - Signature string `json:"signature"` - } `json:"data"` -} +func (u LightClientUpdate) GetSignatureSlot() uint64 { + slot, err := strconv.ParseUint(u.SignatureSlot, 0, 0) + if err != nil { + panic(err) + } -type LightClientUpdateJSON struct { - Data ethereumtypes.LightClientUpdate `json:"data"` + return slot } diff --git a/testing/demo/pkg/ethereum/utils.go b/testing/demo/pkg/ethereum/utils.go index 19aa0c7..5819bac 100644 --- a/testing/demo/pkg/ethereum/utils.go +++ b/testing/demo/pkg/ethereum/utils.go @@ -10,7 +10,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" ) type ForgeScriptReturnValues struct { diff --git a/testing/demo/pkg/ethereum/utils_test.go b/testing/demo/pkg/ethereum/utils_test.go deleted file mode 100644 index dc40f34..0000000 --- a/testing/demo/pkg/ethereum/utils_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package ethereum_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" -) - -func TestGetEthAddressFromStdout(t *testing.T) { - exampleOutput := `Compiling 72 files with Solc 0.8.25 -Solc 0.8.25 finished in 2.43s -Compiler run successful! -Traces: - [13132696] E2ETestDeploy::run() - ├─ [0] VM::projectRoot() [staticcall] - │ └─ ← [Return] "/Users/gg/Code/solidity-ibc-eureka" - ├─ [0] VM::readFile("/Users/gg/Code/solidity-ibc-eureka/e2e/genesis.json") [staticcall] - │ └─ ← [Return] - ├─ [0] VM::parseJsonBytes("", ".trustedClientState") [staticcall] - │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000013000000000000000000000000000000000000000000000000000000000012754500000000000000000000000000000000000000000000000000000000001baf800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673696d642d310000000000000000000000000000000000000000000000000000 - ├─ [0] VM::parseJsonBytes("", ".trustedConsensusState") [staticcall] - │ └─ ← [Return] 0x000000000000000000000000000000000000000000000000000000006708142974c0681a0dbf3e340cedb56abacacec3f01106cd13d1d240e6eb7fc60a34c31250d828ba2c80c290ee3edb5d12ec232dee758f20214af6fbd73a1f636f79d4d7 - ├─ [0] VM::parseJsonBytes32("", ".updateClientVkey") [staticcall] - │ └─ ← [Return] 0x00787fed71dce3ac5685c23cb727f0bbe41c9c40977506f33530f52eabab6c86 - ├─ [0] VM::parseJsonBytes32("", ".membershipVkey") [staticcall] - │ └─ ← [Return] 0x00a8f49c50bcef3ffaef3e8018be59281904d5951d6e20e0a824b9504da18c7f - ├─ [0] VM::parseJsonBytes32("", ".ucAndMembershipVkey") [staticcall] - │ └─ ← [Return] 0x0037bf750186b666717a245012144eb63d1c8675134c9a9c81133535c4f76656 - ├─ [0] VM::envUint("PRIVATE_KEY") [staticcall] - │ └─ ← [Return] - ├─ [0] VM::startBroadcast() - │ └─ ← [Return] - ├─ [2404781] → new SP1Verifier@0x867EBEE8fB04ef90a4161fe21b89420B0aeEF8f2 - │ └─ ← [Return] 12011 bytes of code - ├─ [2442427] → new SP1ICS07Tendermint@0x65cE09e5864dD1f45F4ae50396A307291AaD6631 - │ └─ ← [Return] 11624 bytes of code - ├─ [1171142] → new ICS02Client@0xEBC7C68E032d765e392CFf5B2a11E76C2C43BbbF - │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) - │ └─ ← [Return] 5730 bytes of code - ├─ [2953720] → new ICS26Router@0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501 - │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) - │ └─ ← [Return] 14411 bytes of code - ├─ [3299657] → new ICS20Transfer@0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22 - │ ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: ICS26Router: [0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501]) - │ └─ ← [Return] 16250 bytes of code - ├─ [531853] → new TestERC20@0x022b667cC0D57836CCb12669ce93Ae1e15d4f8BC - │ └─ ← [Return] 2431 bytes of code - ├─ [28083] ICS26Router::addIBCApp("transfer", ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) - │ ├─ emit IBCAppAdded(portId: "transfer", app: ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) - │ └─ ← [Stop] - ├─ [0] VM::stopBroadcast() - │ └─ ← [Return] - ├─ [0] VM::serializeString("", "ics07Tendermint", "0x65ce09e5864dd1f45f4ae50396a307291aad6631") - │ └─ ← [Return] "{\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\"}" - ├─ [0] VM::serializeString("", "ics02Client", "0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf") - │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\"}" - ├─ [0] VM::serializeString("", "ics26Router", "0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501") - │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" - ├─ [0] VM::serializeString("", "ics20Transfer", "0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22") - │ └─ ← [Return] "{\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" - ├─ [0] VM::serializeString("", "erc20", "0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc") - │ └─ ← [Return] "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" - └─ ← [Return] "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" - - -Script ran successfully. - -== Return == -0: string "{\"erc20\":\"0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc\",\"ics02Client\":\"0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf\",\"ics07Tendermint\":\"0x65ce09e5864dd1f45f4ae50396a307291aad6631\",\"ics20Transfer\":\"0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22\",\"ics26Router\":\"0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501\"}" - -## Setting up 1 EVM. -========================== -Simulated On-chain Traces: - - [521379] → new ICS20Lib@0xDcC1FffeC88e1Fa830604047fad1Aa8D957A7DC7 - └─ ← [Return] 2604 bytes of code - - [2404781] → new SP1Verifier@0x867EBEE8fB04ef90a4161fe21b89420B0aeEF8f2 - └─ ← [Return] 12011 bytes of code - - [2442427] → new SP1ICS07Tendermint@0x65cE09e5864dD1f45F4ae50396A307291AaD6631 - └─ ← [Return] 11624 bytes of code - - [1171142] → new ICS02Client@0xEBC7C68E032d765e392CFf5B2a11E76C2C43BbbF - ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) - └─ ← [Return] 5730 bytes of code - - [2953720] → new ICS26Router@0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501 - ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: 0x51A4283eBaeC10B9B764AE8B021BcAA30C0631Ff) - └─ ← [Return] 14411 bytes of code - - [3299657] → new ICS20Transfer@0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22 - ├─ emit OwnershipTransferred(previousOwner: 0x0000000000000000000000000000000000000000, newOwner: ICS26Router: [0xfcf4c2FAc206cFABE9C2B68AefE5D0a9fA038501]) - └─ ← [Return] 16250 bytes of code - - [531853] → new TestERC20@0x022b667cC0D57836CCb12669ce93Ae1e15d4f8BC - └─ ← [Return] 2431 bytes of code - - [30083] ICS26Router::addIBCApp("transfer", ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) - ├─ emit IBCAppAdded(portId: "transfer", app: ICS20Transfer: [0xD6D4C57D09bA13C9535Ee2d6BdB100231d793a22]) - └─ ← [Stop] - - -========================== - -Chain 3151908 - -Estimated gas price: 0.460566435 gwei - -Estimated total gas used for script: 19196301 - -Estimated amount required: 0.008841171916756935 ETH - -========================== - - -========================== - -ONCHAIN EXECUTION COMPLETE & SUCCESSFUL. - -Transactions saved to: /Users/gg/Code/solidity-ibc-eureka/broadcast/E2ETestDeploy.s.sol/3151908/run-latest.json - -Sensitive values saved to: /Users/gg/Code/solidity-ibc-eureka/cache/E2ETestDeploy.s.sol/3151908/run-latest.json -` - - deployedContracts, err := ethereum.GetEthContractsFromDeployOutput(exampleOutput) - require.NoError(t, err) - - require.Equal(t, "0x65ce09e5864dd1f45f4ae50396a307291aad6631", deployedContracts.Ics07Tendermint) - require.Equal(t, "0xebc7c68e032d765e392cff5b2a11e76c2c43bbbf", deployedContracts.IcsCore) - require.Equal(t, "0xfcf4c2fac206cfabe9c2b68aefe5d0a9fa038501", deployedContracts.Ics26Router) - require.Equal(t, "0xd6d4c57d09ba13c9535ee2d6bdb100231d793a22", deployedContracts.Ics20Transfer) - require.Equal(t, "0x022b667cc0d57836ccb12669ce93ae1e15d4f8bc", deployedContracts.Erc20) -} diff --git a/testing/demo/pkg/relay-v2/ethereum.go b/testing/demo/pkg/relay-v2/ethereum.go index c0648c0..eb57373 100644 --- a/testing/demo/pkg/relay-v2/ethereum.go +++ b/testing/demo/pkg/relay-v2/ethereum.go @@ -19,7 +19,7 @@ import ( "cosmossdk.io/math" - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/testvalues" + "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" ) type Ethereum struct { diff --git a/testing/demo/pkg/testvalues/doc.go b/testing/demo/pkg/testvalues/doc.go new file mode 100644 index 0000000..85d41b2 --- /dev/null +++ b/testing/demo/pkg/testvalues/doc.go @@ -0,0 +1,3 @@ +// testvalues was copied from solidity-ibc-eureka. +// TODO: delete it. +package testvalues diff --git a/testing/demo/pkg/testvalues/values.go b/testing/demo/pkg/testvalues/values.go new file mode 100644 index 0000000..a544aef --- /dev/null +++ b/testing/demo/pkg/testvalues/values.go @@ -0,0 +1,98 @@ +package testvalues + +import ( + "time" + + "cosmossdk.io/math" + + ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" + + "github.com/strangelove-ventures/interchaintest/v8/chain/ethereum" +) + +const ( + // InitialBalance is the amount of tokens to give to each user at the start of the test. + InitialBalance int64 = 1_000_000_000_000 + + // TransferAmount is the default transfer amount + TransferAmount int64 = 1_000_000_000 + + // EnvKeyTendermintRPC Tendermint RPC URL. + EnvKeyTendermintRPC = "TENDERMINT_RPC_URL" + // EnvKeyEthRPC Ethereum RPC URL. + EnvKeyEthRPC = "RPC_URL" + // EnvKeyOperatorPrivateKey Private key used to submit transactions by the operator. + EnvKeyOperatorPrivateKey = "PRIVATE_KEY" + // EnvKeySp1Prover The prover type (local|network|mock). + EnvKeySp1Prover = "SP1_PROVER" + // EnvKeySp1PrivateKey Private key for the prover network. + EnvKeySp1PrivateKey = "SP1_PRIVATE_KEY" + // EnvKeyGenerateSolidityFixtures Generate fixtures for the solidity tests if set to true. + EnvKeyGenerateSolidityFixtures = "GENERATE_SOLIDITY_FIXTURES" + // EnvKeyGenerateSolidityFixtures Generate fixtures for the solidity tests if set to true. + EnvKeyGenerateRustFixtures = "GENERATE_RUST_FIXTURES" + // The log level for the Rust logger. + EnvKeyRustLog = "RUST_LOG" + // Address of the SP1ICS07Tendermint contract for operator. + EnvKeyContractAddress = "CONTRACT_ADDRESS" + + // Log level for the Rust logger. + EnvValueRustLog_Info = "info" + // EnvValueSp1Prover_Network is the prover type for the network prover. + EnvValueSp1Prover_Network = "network" + // EnvValueSp1Prover_Mock is the prover type for the mock prover. + EnvValueSp1Prover_Mock = "mock" + // EnvValueGenerateFixtures_True is the value to set to generate fixtures for the solidity tests. + EnvValueGenerateFixtures_True = "true" + + // EthTestnetTypePoW is the Ethereum testnet type for using a proof of work chain (anvil). + EthTestnetTypePoW = "pow" + // EthTestnetTypePoS is the Ethereum testnet type for using a proof of stake chain + EthTestnetTypePoS = "pos" + // EthTestnetTypeNone is the Ethereum testnet type for using no chain. + EthTestnetTypeNone = "none" + // EnvKeyEthTestnetType The Ethereum testnet type (pow|pos). + EnvKeyEthTestnetType = "ETH_TESTNET_TYPE" + // EnvE2EFacuetAddress The address of the faucet + EnvKeyE2EFacuetAddress = "E2E_FAUCET_ADDRESS" + + // Sp1GenesisFilePath is the path to the genesis file for the SP1 chain. + // This file is generated and then deleted by the test. + Sp1GenesisFilePath = "scripts/genesis.json" + // SolidityFixturesDir is the directory where the Solidity fixtures are stored. + SolidityFixturesDir = "test/solidity-ibc/fixtures/" + // SP1ICS07FixturesDir is the directory where the SP1ICS07 fixtures are stored. + SP1ICS07FixturesDir = "test/sp1-ics07/fixtures" + // RustFixturesDir is the directory where the Rust fixtures are stored. + RustFixturesDir = "packages/ethereum-light-client/src/test_utils/fixtures" + // RelayerConfigFilePath is the path to generate the relayer config file. + RelayerConfigFilePath = "programs/relayer/config.json" + // E2EDeployScriptPath is the path to the E2E deploy script. + E2EDeployScriptPath = "scripts/E2ETestDeploy.s.sol:E2ETestDeploy" + // SP1ICS07DeployScriptPath is the path to the SP1ICS07 deploy script. + SP1ICS07DeployScriptPath = "scripts/SP1ICS07Tendermint.s.sol:SP1TendermintScript" + + // DefaultGovV1ProposalTokenAmount is the default amount of tokens used to submit a proposal. + DefaultGovV1ProposalTokenAmount = 500_000_000 + + // IbcCommitmentSlotHex is the storage slot in the IBC solidity contract for the IBC commitments. + IbcCommitmentSlotHex = "0x1" +) + +var ( + // MaxDepositPeriod Maximum period to deposit on a proposal. + // This value overrides the default value in the gov module using the `modifyGovV1AppState` function. + MaxDepositPeriod = time.Second * 10 + // VotingPeriod Duration of the voting period. + // This value overrides the default value in the gov module using the `modifyGovV1AppState` function. + VotingPeriod = time.Second * 30 + + // StartingEthBalance is the amount of ETH to give to each user at the start of the test. + StartingEthBalance = math.NewInt(2 * ethereum.ETHER) + + // DefaultTrustLevel is the trust level used by the SP1ICS07Tendermint contract. + DefaultTrustLevel = ibctm.Fraction{Numerator: 2, Denominator: 3}.ToTendermint() + + // DefaultTrustPeriod is the trust period used by the SP1ICS07Tendermint contract. + DefaultTrustPeriod = 1209669 +) From 1a3353b5a6f4359fd22395d8db11c5411b87dd70 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 10:38:55 -0500 Subject: [PATCH 47/98] revert: ethereum copy, instead use go.mod replace --- go.mod | 17 +- go.sum | 48 ++-- solidity-ibc-eureka | 2 +- testing/demo/pkg/ethereum/beaconapi.go | 272 --------------------- testing/demo/pkg/ethereum/doc.go | 5 - testing/demo/pkg/ethereum/ethapi.go | 59 ----- testing/demo/pkg/ethereum/ethereum.go | 139 ----------- testing/demo/pkg/ethereum/types.gen.go | 316 ------------------------- testing/demo/pkg/ethereum/types.go | 21 -- testing/demo/pkg/ethereum/utils.go | 112 --------- testing/demo/pkg/relay-v2/ethereum.go | 139 ----------- testing/demo/pkg/relay-v2/main.go | 2 +- testing/demo/pkg/testvalues/doc.go | 3 - testing/demo/pkg/testvalues/values.go | 98 -------- 14 files changed, 29 insertions(+), 1204 deletions(-) delete mode 100644 testing/demo/pkg/ethereum/beaconapi.go delete mode 100644 testing/demo/pkg/ethereum/doc.go delete mode 100644 testing/demo/pkg/ethereum/ethapi.go delete mode 100644 testing/demo/pkg/ethereum/ethereum.go delete mode 100644 testing/demo/pkg/ethereum/types.gen.go delete mode 100644 testing/demo/pkg/ethereum/types.go delete mode 100644 testing/demo/pkg/ethereum/utils.go delete mode 100644 testing/demo/pkg/relay-v2/ethereum.go delete mode 100644 testing/demo/pkg/testvalues/doc.go delete mode 100644 testing/demo/pkg/testvalues/values.go diff --git a/go.mod b/go.mod index 251e558..c54afb0 100644 --- a/go.mod +++ b/go.mod @@ -30,14 +30,12 @@ require ( require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.4.0 - github.com/attestantio/go-eth2-client v0.22.0 github.com/consensys/gnark v0.11.0 github.com/consensys/gnark-crypto v0.14.0 - github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241207083532-66bed7cfbbe1 + github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0 github.com/ethereum/go-ethereum v1.14.12 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/rs/zerolog v1.33.0 - github.com/strangelove-ventures/interchaintest/v8 v8.8.1 + github.com/srdtrk/solidity-ibc-eureka/e2e/v8 v8.0.0-00010101000000-000000000000 google.golang.org/grpc v1.68.1 google.golang.org/protobuf v1.35.2 ) @@ -59,6 +57,7 @@ require ( github.com/DataDog/zstd v1.5.5 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/attestantio/go-eth2-client v0.21.11 // indirect github.com/avast/retry-go/v4 v4.5.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -84,7 +83,7 @@ require ( github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect - github.com/cosmos/ibc-go/v8 v8.4.0 // indirect + github.com/cosmos/ibc-go/v8 v8.2.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect @@ -183,7 +182,6 @@ require ( github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect - github.com/morikuni/aec v1.0.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect @@ -208,6 +206,7 @@ require ( github.com/rogpeppe/go-internal v1.12.0 // indirect github.com/ronanh/intcomp v1.1.0 // indirect github.com/rs/cors v1.11.1 // indirect + github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect @@ -215,6 +214,7 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/strangelove-ventures/interchaintest/v8 v8.3.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect @@ -270,10 +270,11 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 ) -// Copied from solidity-ibc-eureka -// TODO: using version v1.0.0 causes a build failure. This is the previous version which compiles successfully. replace ( + // TODO: using version v1.0.0 causes a build failure. This is the previous version which compiles successfully. github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 + github.com/cosmos/solidity-ibc-eureka/abigen => ./solidity-ibc-eureka/abigen + github.com/srdtrk/solidity-ibc-eureka/e2e/v8 => ./solidity-ibc-eureka/e2e/interchaintestv8 github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 ) diff --git a/go.sum b/go.sum index ea2f148..14a0142 100644 --- a/go.sum +++ b/go.sum @@ -275,8 +275,8 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= -github.com/attestantio/go-eth2-client v0.22.0 h1:KmF9kPNNWWGfE7l1BP7pXps4EOXgKnYeFGR0/WbyFhY= -github.com/attestantio/go-eth2-client v0.22.0/go.mod h1:d7ZPNrMX8jLfIgML5u7QZxFo2AukLM+5m08iMaLdqb8= +github.com/attestantio/go-eth2-client v0.21.11 h1:0ZYP69O8rJz41055WOf3n1C1NA4jNh2iME/NuTVfgmQ= +github.com/attestantio/go-eth2-client v0.21.11/go.mod h1:d7ZPNrMX8jLfIgML5u7QZxFo2AukLM+5m08iMaLdqb8= github.com/avast/retry-go/v4 v4.5.1 h1:AxIx0HGi4VZ3I02jr78j5lZ3M6x1E0Ivxa6b0pUUh7o= github.com/avast/retry-go/v4 v4.5.1/go.mod h1:/sipNsvNB3RRuT5iNcb6h73nw3IBmXJ/H3XrCQYSOpc= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= @@ -299,8 +299,6 @@ github.com/bits-and-blooms/bitset v1.14.2 h1:YXVoyPndbdvcEVcseEovVfp0qjJp7S+i5+x github.com/bits-and-blooms/bitset v1.14.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= -github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= @@ -396,18 +394,16 @@ github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= -github.com/cosmos/ibc-go/v8 v8.4.0 h1:K2PfX0AZ+1XKZytHGEMuSjQXG/MZshPb83RSTQt2+cE= -github.com/cosmos/ibc-go/v8 v8.4.0/go.mod h1:zh6x1osR0hNvEcFrC/lhGD08sMfQmr9wHVvZ/mRWMCs= +github.com/cosmos/ibc-go/v8 v8.2.0 h1:7oCzyy1sZCcgpeQLnHxC56brsSz3KWwQGKXalXwXFzE= +github.com/cosmos/ibc-go/v8 v8.2.0/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8= github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55 h1:tvvb3EXXVrYaCOFGuS1awUBEfoI9a0qjhJaQnbkagZ4= github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55/go.mod h1:6+3if3nHW38kA8P2Lcb4UIDpt5BIUPbrCGAD8kGIli8= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/interchain-security/v5 v5.1.1 h1:xmRRMeE4xoc+JAZUh0XzXFYWaGBtzFFj5SETuOgnEnY= -github.com/cosmos/interchain-security/v5 v5.1.1/go.mod h1:vmeTcTxFCl1eV0o6xpl/IRT7Basz0szVVGzbppnInMg= +github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74 h1:6atU/xizTL10q6EprP7oRuvfgUP2F6puvutnVoE+FRc= +github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74/go.mod h1:h/RkwOppo5AJj+1pkQyfjqU1MPdpohD/S6oEeAXpGZY= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241207083532-66bed7cfbbe1 h1:yN6MSjZK9ljUUVAbXx6yKqpEQsgnEldS07kX1MdRDpY= -github.com/cosmos/solidity-ibc-eureka/abigen v0.0.0-20241207083532-66bed7cfbbe1/go.mod h1:gfJFGujP9PIuiyu9AfewNjtVx6cqUh6cNFXjEa3RObo= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -897,8 +893,8 @@ github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe h1:0fcCSfvBgbagEsEMkZuxgA3Ex7IN9i1Hon0fwgMLpQw= -github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20240603204351-26b456ae3afe/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU= +github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2 h1:G/cVeTAbB9S/6FSWWqpFV0v49hiuHLbJPu9hTZ0UR2A= +github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -981,8 +977,8 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042 github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -1133,8 +1129,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= -github.com/strangelove-ventures/interchaintest/v8 v8.8.1 h1:F7xqxZ8Nl9ttKHQqVjgJ2lCQrQxiRjJq6EVdA/YaGeY= -github.com/strangelove-ventures/interchaintest/v8 v8.8.1/go.mod h1:AFFimVWInij/cZMjNbKYMW6EgX0SjHKmIl/GS/akMd8= +github.com/strangelove-ventures/interchaintest/v8 v8.3.0 h1:1XyATc0JkvzDhBS71CdpM5z1t6bmO9PgH/5/nffoM9Q= +github.com/strangelove-ventures/interchaintest/v8 v8.3.0/go.mod h1:5goHQtgWO9khoUO/SfR//w3uaw/uYVriDR1OY6PyydM= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -1166,16 +1162,8 @@ github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70 github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.38.0-dev h1:yX4zsEgTF9PxlLmhx9XAPTGH2E9FSlqSpHcY7sW7Vb8= -github.com/tendermint/tendermint v0.38.0-dev/go.mod h1:EHKmaqObmcGysoRr7krxXoxxhUDyYWbKvvRYJ9tCGWY= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= @@ -1901,14 +1889,14 @@ lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= -modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U= -modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w= +modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= +modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= -modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= -modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= -modernc.org/sqlite v1.31.1 h1:XVU0VyzxrYHlBhIs1DiEgSl0ZtdnPtbLVy8hSkzxGrs= -modernc.org/sqlite v1.31.1/go.mod h1:UqoylwmTb9F+IqXERT8bW9zzOWN8qwAIcLdzeBZs4hA= +modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= +modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= +modernc.org/sqlite v1.29.5 h1:8l/SQKAjDtZFo9lkJLdk8g9JEOeYRG4/ghStDCCTiTE= +modernc.org/sqlite v1.29.5/go.mod h1:S02dvcmm7TnTRvGhv8IGYyLnIt7AS2KPaB1F/71p75U= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= diff --git a/solidity-ibc-eureka b/solidity-ibc-eureka index 66bed7c..3b81a89 160000 --- a/solidity-ibc-eureka +++ b/solidity-ibc-eureka @@ -1 +1 @@ -Subproject commit 66bed7cfbbe19b979e3a2fa06a4f098f6fe7c200 +Subproject commit 3b81a89e5785f486a84d333f6f1b23f56c1bfb40 diff --git a/testing/demo/pkg/ethereum/beaconapi.go b/testing/demo/pkg/ethereum/beaconapi.go deleted file mode 100644 index 530383b..0000000 --- a/testing/demo/pkg/ethereum/beaconapi.go +++ /dev/null @@ -1,272 +0,0 @@ -package ethereum - -import ( - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "time" - - eth2client "github.com/attestantio/go-eth2-client" - "github.com/attestantio/go-eth2-client/api" - apiv1 "github.com/attestantio/go-eth2-client/api/v1" - ethttp "github.com/attestantio/go-eth2-client/http" - "github.com/attestantio/go-eth2-client/spec/phase0" - "github.com/rs/zerolog" -) - -type BeaconAPIClient struct { - ctx context.Context - cancel context.CancelFunc - - client eth2client.Service - url string - - Retries int - RetryWait time.Duration -} - -func (s Spec) Period() uint64 { - return s.EpochsPerSyncCommitteePeriod * s.SlotsPerEpoch -} - -func (b BeaconAPIClient) Close() { - b.cancel() -} - -func NewBeaconAPIClient(beaconAPIAddress string) BeaconAPIClient { - ctx, cancel := context.WithCancel(context.Background()) - client, err := ethttp.New(ctx, - // WithAddress supplies the address of the beacon node, as a URL. - ethttp.WithAddress(beaconAPIAddress), - // LogLevel supplies the level of logging to carry out. - ethttp.WithLogLevel(zerolog.WarnLevel), - ) - if err != nil { - panic(err) - } - - return BeaconAPIClient{ - ctx: ctx, - cancel: cancel, - client: client, - url: beaconAPIAddress, - Retries: 60, - RetryWait: 10 * time.Second, - } -} - -func retry[T any](retries int, waitTime time.Duration, fn func() (T, error)) (T, error) { - var err error - var result T - for i := 0; i < retries; i++ { - result, err = fn() - if err == nil { - return result, nil - } - - fmt.Printf("Retrying for %T: %s in %f seconds\n", result, err, waitTime.Seconds()) - time.Sleep(waitTime) - } - return result, err -} - -func (b BeaconAPIClient) GetHeader(blockID string) (*apiv1.BeaconBlockHeader, error) { - return retry(b.Retries, b.RetryWait, func() (*apiv1.BeaconBlockHeader, error) { - headerResponse, err := b.client.(eth2client.BeaconBlockHeadersProvider).BeaconBlockHeader(b.ctx, &api.BeaconBlockHeaderOpts{ - Block: blockID, - }) - if err != nil { - return nil, err - } - - return headerResponse.Data, nil - }) -} - -func (b BeaconAPIClient) GetBootstrap(finalizedRoot phase0.Root) (Bootstrap, error) { - return retry(b.Retries, b.RetryWait, func() (Bootstrap, error) { - finalizedRootStr := finalizedRoot.String() - url := fmt.Sprintf("%s/eth/v1/beacon/light_client/bootstrap/%s", b.url, finalizedRootStr) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return Bootstrap{}, err - } - req.Header.Set("Accept", "application/json") - resp, err := http.DefaultClient.Do(req) - if err != nil { - return Bootstrap{}, err - } - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return Bootstrap{}, err - } - - if resp.StatusCode != 200 { - return Bootstrap{}, fmt.Errorf("get bootstrap (%s) failed with status code: %d, body: %s", url, resp.StatusCode, body) - } - - var bootstrap Bootstrap - if err := json.Unmarshal(body, &bootstrap); err != nil { - return Bootstrap{}, err - } - - return bootstrap, nil - }) -} - -func (b BeaconAPIClient) GetLightClientUpdates(startPeriod uint64, count uint64) (LightClientUpdatesResponse, error) { - return retry(b.Retries, b.RetryWait, func() (LightClientUpdatesResponse, error) { - url := fmt.Sprintf("%s/eth/v1/beacon/light_client/updates?start_period=%d&count=%d", b.url, startPeriod, count) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return LightClientUpdatesResponse{}, err - } - req.Header.Set("Accept", "application/json") - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return LightClientUpdatesResponse{}, err - } - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return LightClientUpdatesResponse{}, err - } - - var lightClientUpdatesResponse LightClientUpdatesResponse - if err := json.Unmarshal(body, &lightClientUpdatesResponse); err != nil { - return LightClientUpdatesResponse{}, err - } - - return lightClientUpdatesResponse, nil - }) -} - -func (b BeaconAPIClient) GetGenesis() (*apiv1.Genesis, error) { - return retry(b.Retries, b.RetryWait, func() (*apiv1.Genesis, error) { - genesisResponse, err := b.client.(eth2client.GenesisProvider).Genesis(b.ctx, &api.GenesisOpts{}) - if err != nil { - return nil, err - } - - return genesisResponse.Data, nil - }) -} - -func (b BeaconAPIClient) GetSpec() (Spec, error) { - return retry(b.Retries, b.RetryWait, func() (Spec, error) { - specResponse, err := b.client.(eth2client.SpecProvider).Spec(b.ctx, &api.SpecOpts{}) - if err != nil { - return Spec{}, err - } - - specJsonBz, err := json.Marshal(specResponse.Data) - if err != nil { - return Spec{}, err - } - var spec Spec - if err := json.Unmarshal(specJsonBz, &spec); err != nil { - return Spec{}, err - } - - return spec, nil - }) -} - -func (b BeaconAPIClient) GetFinalityUpdate() (FinalityUpdateJSONResponse, error) { - return retry(b.Retries, b.RetryWait, func() (FinalityUpdateJSONResponse, error) { - url := fmt.Sprintf("%s/eth/v1/beacon/light_client/finality_update", b.url) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return FinalityUpdateJSONResponse{}, err - } - req.Header.Set("Accept", "application/json") - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return FinalityUpdateJSONResponse{}, err - } - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return FinalityUpdateJSONResponse{}, err - } - - var finalityUpdate FinalityUpdateJSONResponse - if err := json.Unmarshal(body, &finalityUpdate); err != nil { - return FinalityUpdateJSONResponse{}, err - } - - return finalityUpdate, nil - }) -} - -func (b BeaconAPIClient) GetBeaconBlocks(blockID string) (BeaconBlocksResponseJSON, error) { - return retry(b.Retries, b.RetryWait, func() (BeaconBlocksResponseJSON, error) { - url := fmt.Sprintf("%s/eth/v2/beacon/blocks/%s", b.url, blockID) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return BeaconBlocksResponseJSON{}, err - } - - req.Header.Set("Accept", "application/json") - resp, err := http.DefaultClient.Do(req) - if err != nil { - return BeaconBlocksResponseJSON{}, err - } - - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return BeaconBlocksResponseJSON{}, err - } - - if resp.StatusCode != 200 { - return BeaconBlocksResponseJSON{}, fmt.Errorf("get execution height (%s) failed with status code: %d, body: %s", url, resp.StatusCode, body) - } - - var beaconBlocksResponse BeaconBlocksResponseJSON - if err := json.Unmarshal(body, &beaconBlocksResponse); err != nil { - return BeaconBlocksResponseJSON{}, err - } - - return beaconBlocksResponse, nil - }) -} - -func (b BeaconAPIClient) GetFinalizedBlocks() (BeaconBlocksResponseJSON, error) { - return retry(b.Retries, b.RetryWait, func() (BeaconBlocksResponseJSON, error) { - resp, err := b.GetBeaconBlocks("finalized") - if err != nil { - return BeaconBlocksResponseJSON{}, err - } - - if !resp.Finalized { - return BeaconBlocksResponseJSON{}, fmt.Errorf("block is not finalized") - } - - return resp, nil - }) -} - -func (b BeaconAPIClient) GetExecutionHeight(blockID string) (uint64, error) { - return retry(b.Retries, b.RetryWait, func() (uint64, error) { - resp, err := b.GetBeaconBlocks(blockID) - if err != nil { - return 0, err - } - - if blockID == "finalized" && !resp.Finalized { - return 0, fmt.Errorf("block is not finalized") - } - - return resp.Data.Message.Body.ExecutionPayload.BlockNumber, nil - }) -} diff --git a/testing/demo/pkg/ethereum/doc.go b/testing/demo/pkg/ethereum/doc.go deleted file mode 100644 index 61cd924..0000000 --- a/testing/demo/pkg/ethereum/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// The ethereum package was copy + pasted because an exported Go module does not exist for it. -// https://github.com/cosmos/solidity-ibc-eureka/tree/3b81a89e5785f486a84d333f6f1b23f56c1bfb40/e2e/interchaintestv8/ethereum -// -// TODO: delete this package. -package ethereum diff --git a/testing/demo/pkg/ethereum/ethapi.go b/testing/demo/pkg/ethereum/ethapi.go deleted file mode 100644 index 68c98e7..0000000 --- a/testing/demo/pkg/ethereum/ethapi.go +++ /dev/null @@ -1,59 +0,0 @@ -package ethereum - -import ( - "strconv" - "time" - - "github.com/ethereum/go-ethereum/ethclient" -) - -type EthAPI struct { - client *ethclient.Client - - Retries int - RetryWait time.Duration -} - -type EthGetProofResponse struct { - StorageHash string `json:"storageHash"` - StorageProof []StorageProof `json:"storageProof"` - AccountProof []string `json:"accountProof"` -} - -func NewEthAPI(rpc string) (EthAPI, error) { - ethClient, err := ethclient.Dial(rpc) - if err != nil { - return EthAPI{}, err - } - - return EthAPI{ - client: ethClient, - Retries: 6, - RetryWait: 10 * time.Second, - }, nil -} - -func (e EthAPI) GetProof(address string, storageKeys []string, blockHex string) (EthGetProofResponse, error) { - return retry(e.Retries, e.RetryWait, func() (EthGetProofResponse, error) { - var proofResponse EthGetProofResponse - if err := e.client.Client().Call(&proofResponse, "eth_getProof", address, storageKeys, blockHex); err != nil { - return EthGetProofResponse{}, err - } - - return proofResponse, nil - }) -} - -func (e EthAPI) GetBlockNumber() (string, uint64, error) { - var blockNumberHex string - if err := e.client.Client().Call(&blockNumberHex, "eth_blockNumber"); err != nil { - return "", 0, err - } - - blockNumber, err := strconv.ParseInt(blockNumberHex, 0, 0) - if err != nil { - return "", 0, err - } - - return blockNumberHex, uint64(blockNumber), nil -} diff --git a/testing/demo/pkg/ethereum/ethereum.go b/testing/demo/pkg/ethereum/ethereum.go deleted file mode 100644 index 5fb6041..0000000 --- a/testing/demo/pkg/ethereum/ethereum.go +++ /dev/null @@ -1,139 +0,0 @@ -package ethereum - -import ( - "bytes" - "context" - "crypto/ecdsa" - "encoding/hex" - "fmt" - "io" - "math/big" - "os" - "os/exec" - "strconv" - "strings" - - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" - - "cosmossdk.io/math" - - "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" -) - -type Ethereum struct { - ChainID *big.Int - RPC string - EthAPI EthAPI - BeaconAPIClient *BeaconAPIClient - - Faucet *ecdsa.PrivateKey -} - -func NewEthereum(ctx context.Context, rpc string, beaconAPIClient *BeaconAPIClient, faucet *ecdsa.PrivateKey) (Ethereum, error) { - ethClient, err := ethclient.Dial(rpc) - if err != nil { - return Ethereum{}, err - } - chainID, err := ethClient.ChainID(ctx) - if err != nil { - return Ethereum{}, err - } - ethAPI, err := NewEthAPI(rpc) - if err != nil { - return Ethereum{}, err - } - - return Ethereum{ - ChainID: chainID, - RPC: rpc, - EthAPI: ethAPI, - BeaconAPIClient: beaconAPIClient, - Faucet: faucet, - }, nil -} - -func (e Ethereum) ForgeScript(deployer *ecdsa.PrivateKey, solidityContract string, args ...string) ([]byte, error) { - args = append(args, "script", "--rpc-url", e.RPC, "--private-key", - hex.EncodeToString(deployer.D.Bytes()), "--broadcast", - "--non-interactive", "-vvvv", solidityContract, - ) - cmd := exec.Command( - "forge", args..., - ) - - faucetAddress := crypto.PubkeyToAddress(e.Faucet.PublicKey) - extraEnv := []string{ - fmt.Sprintf("%s=%s", testvalues.EnvKeyE2EFacuetAddress, faucetAddress.Hex()), - } - - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, extraEnv...) - - var stdoutBuf bytes.Buffer - - // Create a MultiWriter to write to both os.Stdout and the buffer - multiWriter := io.MultiWriter(os.Stdout, &stdoutBuf) - - // Set the command's stdout to the MultiWriter - cmd.Stdout = multiWriter - cmd.Stderr = os.Stderr - - // Run the command - if err := cmd.Run(); err != nil { - fmt.Println("Error start command", cmd.Args, err) - return nil, err - } - - // Get the output as byte slices - stdoutBytes := stdoutBuf.Bytes() - - return stdoutBytes, nil -} - -func (e Ethereum) CreateAndFundUser() (*ecdsa.PrivateKey, error) { - key, err := crypto.GenerateKey() - if err != nil { - return nil, err - } - - address := crypto.PubkeyToAddress(key.PublicKey).Hex() - if err := e.FundUser(address, testvalues.StartingEthBalance); err != nil { - return nil, err - } - - return key, nil -} - -func (e Ethereum) FundUser(address string, amount math.Int) error { - return e.SendEth(e.Faucet, address, amount) -} - -func (e Ethereum) SendEth(key *ecdsa.PrivateKey, toAddress string, amount math.Int) error { - cmd := exec.Command( - "cast", - "send", - toAddress, - "--value", amount.String(), - "--private-key", fmt.Sprintf("0x%s", ethcommon.Bytes2Hex(key.D.Bytes())), - "--rpc-url", e.RPC, - ) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to send eth with %s: %w", strings.Join(cmd.Args, " "), err) - } - - return nil -} - -func (e *Ethereum) Height() (int64, error) { - cmd := exec.Command("cast", "block-number", "--rpc-url", e.RPC) - stdout, err := cmd.Output() - if err != nil { - return 0, err - } - return strconv.ParseInt(strings.TrimSpace(string(stdout)), 10, 64) -} diff --git a/testing/demo/pkg/ethereum/types.gen.go b/testing/demo/pkg/ethereum/types.gen.go deleted file mode 100644 index 67a825f..0000000 --- a/testing/demo/pkg/ethereum/types.gen.go +++ /dev/null @@ -1,316 +0,0 @@ -package ethereum - -// The Ethereum types to export to JSON Schema and used to generate types in other languages -// The structure itself is not used for anything else than being able to generate a single -// schema -type GeneratedTypes struct { - ClientState ClientState `json:"client_state"` - ConsensusState ConsensusState `json:"consensus_state"` - Header Header `json:"header"` - StorageProof StorageProof `json:"storage_proof"` - TestFixtures TestFixtures `json:"test_fixtures"` -} - -// The ethereum client state -// -// # The client state at the time of the proof -// -// # The client state at the initial state -// -// The client state after the update -type ClientState struct { - // The chain ID - ChainID uint64 `json:"chain_id"` - // The number of epochs per sync committee period - EpochsPerSyncCommitteePeriod uint64 `json:"epochs_per_sync_committee_period"` - // The fork parameters - ForkParameters ForkParameters `json:"fork_parameters"` - // The slot at which the client was frozen - FrozenSlot uint64 `json:"frozen_slot"` - // The time of genesis (unix timestamp) - GenesisTime uint64 `json:"genesis_time"` - // The genesis validators root - GenesisValidatorsRoot string `json:"genesis_validators_root"` - // The storage slot of the IBC commitment in the Ethereum contract - IbcCommitmentSlot string `json:"ibc_commitment_slot"` - // The address of the IBC contract being tracked on Ethereum - IbcContractAddress string `json:"ibc_contract_address"` - // The latest slot of this client - LatestSlot uint64 `json:"latest_slot"` - // The minimum number of participants in the sync committee - MinSyncCommitteeParticipants uint64 `json:"min_sync_committee_participants"` - // The slot duration in seconds - SecondsPerSlot uint64 `json:"seconds_per_slot"` - // The number of slots per epoch - SlotsPerEpoch uint64 `json:"slots_per_epoch"` -} - -// The fork parameters -type ForkParameters struct { - // The altair fork - Altair Fork `json:"altair"` - // The bellatrix fork - Bellatrix Fork `json:"bellatrix"` - // The capella fork - Capella Fork `json:"capella"` - // The deneb fork - Deneb Fork `json:"deneb"` - // The genesis fork version - GenesisForkVersion string `json:"genesis_fork_version"` - // The genesis slot - GenesisSlot uint64 `json:"genesis_slot"` -} - -// The altair fork -// -// # The fork data -// -// # The bellatrix fork -// -// # The capella fork -// -// The deneb fork -type Fork struct { - // The epoch at which this fork is activated - Epoch uint64 `json:"epoch"` - // The version of the fork - Version string `json:"version"` -} - -// The consensus state of the Ethereum light client -// -// # The consensus state at the time of the proof -// -// # The consensus state at the initial state -// -// The consensus state after the update -type ConsensusState struct { - // aggregate public key of current sync committee - CurrentSyncCommittee string `json:"current_sync_committee"` - // aggregate public key of next sync committee - NextSyncCommittee string `json:"next_sync_committee"` - // The slot number - Slot uint64 `json:"slot"` - // The state merkle root - StateRoot string `json:"state_root"` - // The storage merkle root - StorageRoot string `json:"storage_root"` - // The unix timestamp at the time of the slot. It is calculated from the genesis time and - // slots per. - Timestamp uint64 `json:"timestamp"` -} - -// The header of a light client update -type Header struct { - // The account update - AccountUpdate AccountUpdate `json:"account_update"` - // The consensus update - ConsensusUpdate LightClientUpdate `json:"consensus_update"` - // The trusted sync committee - TrustedSyncCommittee TrustedSyncCommittee `json:"trusted_sync_committee"` -} - -// The account update -type AccountUpdate struct { - // The account proof - AccountProof AccountProof `json:"account_proof"` -} - -// The account proof -type AccountProof struct { - // The account proof - Proof []string `json:"proof"` - // The account storage root - StorageRoot string `json:"storage_root"` -} - -// The consensus update -// -// A light client update -type LightClientUpdate struct { - // Header attested to by the sync committee - AttestedHeader LightClientHeader `json:"attested_header"` - // Branch of the finalized header - FinalityBranch []string `json:"finality_branch"` - // Finalized header corresponding to `attested_header.state_root` - FinalizedHeader LightClientHeader `json:"finalized_header"` - // Next sync committee corresponding to `attested_header.state_root` - NextSyncCommittee *SyncCommittee `json:"next_sync_committee"` - // The branch of the next sync committee - NextSyncCommitteeBranch []string `json:"next_sync_committee_branch"` - // Slot at which the aggregate signature was created (untrusted) - SignatureSlot string `json:"signature_slot"` - // Sync committee aggregate signature - SyncAggregate SyncAggregate `json:"sync_aggregate"` -} - -// Header attested to by the sync committee -// -// # The header of a light client -// -// Finalized header corresponding to `attested_header.state_root` -type LightClientHeader struct { - // The beacon block header - Beacon BeaconBlockHeader `json:"beacon"` - // The execution payload header - Execution ExecutionPayloadHeader `json:"execution"` - // The execution branch - ExecutionBranch []string `json:"execution_branch"` -} - -// The beacon block header -type BeaconBlockHeader struct { - // The tree hash merkle root of the `BeaconBlockBody` for the `BeaconBlock` - BodyRoot string `json:"body_root"` - // The signing merkle root of the parent `BeaconBlock` - ParentRoot string `json:"parent_root"` - // The index of validator in validator registry - ProposerIndex string `json:"proposer_index"` - // The slot to which this block corresponds - Slot string `json:"slot"` - // The tree hash merkle root of the `BeaconState` for the `BeaconBlock` - StateRoot string `json:"state_root"` -} - -// The execution payload header -// -// Header to track the execution block -type ExecutionPayloadHeader struct { - // Block base fee per gas - BaseFeePerGas string `json:"base_fee_per_gas"` - // Blob gas used (new in Deneb) - BlobGasUsed string `json:"blob_gas_used"` - // The block hash - BlockHash string `json:"block_hash"` - // The block number of the execution payload - BlockNumber string `json:"block_number"` - // Excess blob gas (new in Deneb) - ExcessBlobGas string `json:"excess_blob_gas"` - // The extra data of the execution payload - ExtraData string `json:"extra_data"` - // Block fee recipient - FeeRecipient string `json:"fee_recipient"` - // Execution block gas limit - GasLimit string `json:"gas_limit"` - // Execution block gas used - GasUsed string `json:"gas_used"` - // The logs bloom filter - LogsBloom string `json:"logs_bloom"` - // The parent hash of the execution payload header - ParentHash string `json:"parent_hash"` - // The previous Randao value, used to compute the randomness on the execution layer. - PrevRandao string `json:"prev_randao"` - // The root of the receipts trie - ReceiptsRoot string `json:"receipts_root"` - // The state root - StateRoot string `json:"state_root"` - // The timestamp of the execution payload - Timestamp string `json:"timestamp"` - // SSZ hash tree root of the transaction list - TransactionsRoot string `json:"transactions_root"` - // Tree root of the withdrawals list - WithdrawalsRoot string `json:"withdrawals_root"` -} - -// The sync committee data -type SyncCommittee struct { - // The aggregate public key of the sync committee - AggregatePubkey string `json:"aggregate_pubkey"` - // The public keys of the sync committee - Pubkeys []string `json:"pubkeys"` -} - -// Sync committee aggregate signature -// -// The sync committee aggregate -type SyncAggregate struct { - // The bits representing the sync committee's participation. - SyncCommitteeBits string `json:"sync_committee_bits"` - // The aggregated signature of the sync committee. - SyncCommitteeSignature string `json:"sync_committee_signature"` -} - -// The trusted sync committee -type TrustedSyncCommittee struct { - // The current sync committee - SyncCommittee ActiveSyncCommittee `json:"sync_committee"` - // The trusted slot - TrustedSlot uint64 `json:"trusted_slot"` -} - -// The current sync committee -// -// # The active sync committee -// -// The next sync committee -type ActiveSyncCommittee struct { - Current *SyncCommittee `json:"Current,omitempty"` - Next *SyncCommittee `json:"Next,omitempty"` -} - -// The key-value storage proof for a smart contract account -// -// The storage proof used to verify membership -type StorageProof struct { - // The key of the storage - Key string `json:"key"` - // The proof of the storage - Proof []string `json:"proof"` - // The value of the storage - Value string `json:"value"` -} - -type TestFixtures struct { - CommitmentProof CommitmentProof `json:"commitment_proof"` - InitialState InitialState `json:"initial_state"` - Step Step `json:"step"` - StepsFixture StepsFixture `json:"steps_fixture"` - UpdateClient UpdateClient `json:"update_client"` -} - -// The proof used to verify membership -type CommitmentProof struct { - // The client state at the time of the proof - ClientState ClientState `json:"client_state"` - // The consensus state at the time of the proof - ConsensusState ConsensusState `json:"consensus_state"` - // The IBC path sent to verify membership - Path string `json:"path"` - // The slot of the proof (ibc height) - ProofSlot uint64 `json:"proof_slot"` - // The storage proof used to verify membership - StorageProof StorageProof `json:"storage_proof"` -} - -// The initial state of the light client in the e2e tests -type InitialState struct { - // The client state at the initial state - ClientState ClientState `json:"client_state"` - // The consensus state at the initial state - ConsensusState ConsensusState `json:"consensus_state"` -} - -// Step is a light client operation such as an initial state, commitment proof, or update -// client -type Step struct { - // data is the operation data as a JSON object to be deserialized into the appropriate type - Data interface{} `json:"data"` - // name is the name of the operation, only used for documentation and easy of reading - Name string `json:"name"` -} - -// A test fixture with an ordered list of light client operations from the e2e test -type StepsFixture struct { - // steps is a list of light client operations - Steps []Step `json:"steps"` -} - -// Operation to update the light client -type UpdateClient struct { - // The client state after the update - ClientState ClientState `json:"client_state"` - // The consensus state after the update - ConsensusState ConsensusState `json:"consensus_state"` - // The headers used to update the light client, in order - Updates []Header `json:"updates"` -} diff --git a/testing/demo/pkg/ethereum/types.go b/testing/demo/pkg/ethereum/types.go deleted file mode 100644 index 050039a..0000000 --- a/testing/demo/pkg/ethereum/types.go +++ /dev/null @@ -1,21 +0,0 @@ -package ethereum - -import "strconv" - -func (h BeaconBlockHeader) GetSlot() uint64 { - slot, err := strconv.ParseUint(h.Slot, 0, 0) - if err != nil { - panic(err) - } - - return slot -} - -func (u LightClientUpdate) GetSignatureSlot() uint64 { - slot, err := strconv.ParseUint(u.SignatureSlot, 0, 0) - if err != nil { - panic(err) - } - - return slot -} diff --git a/testing/demo/pkg/ethereum/utils.go b/testing/demo/pkg/ethereum/utils.go deleted file mode 100644 index 5819bac..0000000 --- a/testing/demo/pkg/ethereum/utils.go +++ /dev/null @@ -1,112 +0,0 @@ -package ethereum - -import ( - "encoding/json" - "fmt" - "math/big" - "regexp" - "strings" - - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" -) - -type ForgeScriptReturnValues struct { - InternalType string `json:"internal_type"` - Value string `json:"value"` -} - -type ForgeDeployOutput struct { - Returns map[string]ForgeScriptReturnValues `json:"returns"` -} - -type DeployedContracts struct { - Ics07Tendermint string `json:"ics07Tendermint"` - IcsCore string `json:"icsCore"` - Ics26Router string `json:"ics26Router"` - Ics20Transfer string `json:"ics20Transfer"` - Erc20 string `json:"erc20"` - Escrow string `json:"escrow"` - IbcStore string `json:"ibcstore"` -} - -func GetEthContractsFromDeployOutput(stdout string) (DeployedContracts, error) { - // Remove everything above the JSON part - cutOff := "== Return ==" - cutoffIndex := strings.Index(stdout, cutOff) - stdout = stdout[cutoffIndex+len(cutOff):] - - // Extract the JSON part using regex - re := regexp.MustCompile(`\{.*\}`) - jsonPart := re.FindString(stdout) - - jsonPart = strings.ReplaceAll(jsonPart, `\"`, `"`) - jsonPart = strings.Trim(jsonPart, `"`) - - var embeddedContracts DeployedContracts - err := json.Unmarshal([]byte(jsonPart), &embeddedContracts) - if err != nil { - return DeployedContracts{}, err - } - - if embeddedContracts.Erc20 == "" || - embeddedContracts.IcsCore == "" || - embeddedContracts.Ics07Tendermint == "" || - embeddedContracts.Ics20Transfer == "" || - embeddedContracts.Ics26Router == "" || - embeddedContracts.Escrow == "" || - embeddedContracts.IbcStore == "" { - - return DeployedContracts{}, fmt.Errorf("one or more contracts missing: %+v", embeddedContracts) - } - - return embeddedContracts, nil -} - -func GetOnlySp1Ics07AddressFromStdout(stdout string) (string, error) { - // Define the regular expression pattern - re := regexp.MustCompile(`"value":"(0x[0-9a-fA-F]+)"`) - - // Find the first match - matches := re.FindStringSubmatch(stdout) - if len(matches) <= 1 { - return "", fmt.Errorf("no matches found in stdout") - } - // Extract the value - return matches[1], nil -} - -// From https://medium.com/@zhuytt4/verify-the-owner-of-safe-wallet-with-eth-getproof-7edc450504ff -func GetCommitmentsStorageKey(path []byte) ethcommon.Hash { - commitmentStorageSlot := ethcommon.FromHex(testvalues.IbcCommitmentSlotHex) - - pathHash := crypto.Keccak256(path) - - // zero pad both to 32 bytes - paddedSlot := ethcommon.LeftPadBytes(commitmentStorageSlot, 32) - - // keccak256(h(k) . slot) - return crypto.Keccak256Hash(pathHash, paddedSlot) -} - -func HexToBeBytes(hex string) []byte { - bz := ethcommon.FromHex(hex) - if len(bz) == 32 { - return bz - } - if len(bz) > 32 { - panic("TOO BIG!") - } - beBytes := make([]byte, 32) - copy(beBytes[32-len(bz):32], bz) - return beBytes -} - -func BigIntToBeBytes(n *big.Int) [32]byte { - bytes := n.Bytes() - var beBytes [32]byte - copy(beBytes[32-len(bytes):], bytes) - return beBytes -} diff --git a/testing/demo/pkg/relay-v2/ethereum.go b/testing/demo/pkg/relay-v2/ethereum.go deleted file mode 100644 index eb57373..0000000 --- a/testing/demo/pkg/relay-v2/ethereum.go +++ /dev/null @@ -1,139 +0,0 @@ -package main - -import ( - "bytes" - "context" - "crypto/ecdsa" - "encoding/hex" - "fmt" - "io" - "math/big" - "os" - "os/exec" - "strconv" - "strings" - - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" - - "cosmossdk.io/math" - - "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/testvalues" -) - -type Ethereum struct { - ChainID *big.Int - RPC string - EthAPI EthAPI - BeaconAPIClient *BeaconAPIClient - - Faucet *ecdsa.PrivateKey -} - -func NewEthereum(ctx context.Context, rpc string, beaconAPIClient *BeaconAPIClient, faucet *ecdsa.PrivateKey) (Ethereum, error) { - ethClient, err := ethclient.Dial(rpc) - if err != nil { - return Ethereum{}, err - } - chainID, err := ethClient.ChainID(ctx) - if err != nil { - return Ethereum{}, err - } - ethAPI, err := NewEthAPI(rpc) - if err != nil { - return Ethereum{}, err - } - - return Ethereum{ - ChainID: chainID, - RPC: rpc, - EthAPI: ethAPI, - BeaconAPIClient: beaconAPIClient, - Faucet: faucet, - }, nil -} - -func (e Ethereum) ForgeScript(deployer *ecdsa.PrivateKey, solidityContract string, args ...string) ([]byte, error) { - args = append(args, "script", "--rpc-url", e.RPC, "--private-key", - hex.EncodeToString(deployer.D.Bytes()), "--broadcast", - "--non-interactive", "-vvvv", solidityContract, - ) - cmd := exec.Command( - "forge", args..., - ) - - faucetAddress := crypto.PubkeyToAddress(e.Faucet.PublicKey) - extraEnv := []string{ - fmt.Sprintf("%s=%s", testvalues.EnvKeyE2EFacuetAddress, faucetAddress.Hex()), - } - - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, extraEnv...) - - var stdoutBuf bytes.Buffer - - // Create a MultiWriter to write to both os.Stdout and the buffer - multiWriter := io.MultiWriter(os.Stdout, &stdoutBuf) - - // Set the command's stdout to the MultiWriter - cmd.Stdout = multiWriter - cmd.Stderr = os.Stderr - - // Run the command - if err := cmd.Run(); err != nil { - fmt.Println("Error start command", cmd.Args, err) - return nil, err - } - - // Get the output as byte slices - stdoutBytes := stdoutBuf.Bytes() - - return stdoutBytes, nil -} - -func (e Ethereum) CreateAndFundUser() (*ecdsa.PrivateKey, error) { - key, err := crypto.GenerateKey() - if err != nil { - return nil, err - } - - address := crypto.PubkeyToAddress(key.PublicKey).Hex() - if err := e.FundUser(address, testvalues.StartingEthBalance); err != nil { - return nil, err - } - - return key, nil -} - -func (e Ethereum) FundUser(address string, amount math.Int) error { - return e.SendEth(e.Faucet, address, amount) -} - -func (e Ethereum) SendEth(key *ecdsa.PrivateKey, toAddress string, amount math.Int) error { - cmd := exec.Command( - "cast", - "send", - toAddress, - "--value", amount.String(), - "--private-key", fmt.Sprintf("0x%s", ethcommon.Bytes2Hex(key.D.Bytes())), - "--rpc-url", e.RPC, - ) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - if err := cmd.Run(); err != nil { - return fmt.Errorf("failed to send eth with %s: %w", strings.Join(cmd.Args, " "), err) - } - - return nil -} - -func (e *Ethereum) Height() (int64, error) { - cmd := exec.Command("cast", "block-number", "--rpc-url", e.RPC) - stdout, err := cmd.Output() - if err != nil { - return 0, err - } - return strconv.ParseInt(strings.TrimSpace(string(stdout)), 10, 64) -} diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 38e889b..9c5604c 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -9,7 +9,6 @@ import ( "time" "cosmossdk.io/math" - "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/ethereum" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -24,6 +23,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" ) // TODO: fetch these from the `make setup` command output. diff --git a/testing/demo/pkg/testvalues/doc.go b/testing/demo/pkg/testvalues/doc.go deleted file mode 100644 index 85d41b2..0000000 --- a/testing/demo/pkg/testvalues/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// testvalues was copied from solidity-ibc-eureka. -// TODO: delete it. -package testvalues diff --git a/testing/demo/pkg/testvalues/values.go b/testing/demo/pkg/testvalues/values.go deleted file mode 100644 index a544aef..0000000 --- a/testing/demo/pkg/testvalues/values.go +++ /dev/null @@ -1,98 +0,0 @@ -package testvalues - -import ( - "time" - - "cosmossdk.io/math" - - ibctm "github.com/cosmos/ibc-go/v9/modules/light-clients/07-tendermint" - - "github.com/strangelove-ventures/interchaintest/v8/chain/ethereum" -) - -const ( - // InitialBalance is the amount of tokens to give to each user at the start of the test. - InitialBalance int64 = 1_000_000_000_000 - - // TransferAmount is the default transfer amount - TransferAmount int64 = 1_000_000_000 - - // EnvKeyTendermintRPC Tendermint RPC URL. - EnvKeyTendermintRPC = "TENDERMINT_RPC_URL" - // EnvKeyEthRPC Ethereum RPC URL. - EnvKeyEthRPC = "RPC_URL" - // EnvKeyOperatorPrivateKey Private key used to submit transactions by the operator. - EnvKeyOperatorPrivateKey = "PRIVATE_KEY" - // EnvKeySp1Prover The prover type (local|network|mock). - EnvKeySp1Prover = "SP1_PROVER" - // EnvKeySp1PrivateKey Private key for the prover network. - EnvKeySp1PrivateKey = "SP1_PRIVATE_KEY" - // EnvKeyGenerateSolidityFixtures Generate fixtures for the solidity tests if set to true. - EnvKeyGenerateSolidityFixtures = "GENERATE_SOLIDITY_FIXTURES" - // EnvKeyGenerateSolidityFixtures Generate fixtures for the solidity tests if set to true. - EnvKeyGenerateRustFixtures = "GENERATE_RUST_FIXTURES" - // The log level for the Rust logger. - EnvKeyRustLog = "RUST_LOG" - // Address of the SP1ICS07Tendermint contract for operator. - EnvKeyContractAddress = "CONTRACT_ADDRESS" - - // Log level for the Rust logger. - EnvValueRustLog_Info = "info" - // EnvValueSp1Prover_Network is the prover type for the network prover. - EnvValueSp1Prover_Network = "network" - // EnvValueSp1Prover_Mock is the prover type for the mock prover. - EnvValueSp1Prover_Mock = "mock" - // EnvValueGenerateFixtures_True is the value to set to generate fixtures for the solidity tests. - EnvValueGenerateFixtures_True = "true" - - // EthTestnetTypePoW is the Ethereum testnet type for using a proof of work chain (anvil). - EthTestnetTypePoW = "pow" - // EthTestnetTypePoS is the Ethereum testnet type for using a proof of stake chain - EthTestnetTypePoS = "pos" - // EthTestnetTypeNone is the Ethereum testnet type for using no chain. - EthTestnetTypeNone = "none" - // EnvKeyEthTestnetType The Ethereum testnet type (pow|pos). - EnvKeyEthTestnetType = "ETH_TESTNET_TYPE" - // EnvE2EFacuetAddress The address of the faucet - EnvKeyE2EFacuetAddress = "E2E_FAUCET_ADDRESS" - - // Sp1GenesisFilePath is the path to the genesis file for the SP1 chain. - // This file is generated and then deleted by the test. - Sp1GenesisFilePath = "scripts/genesis.json" - // SolidityFixturesDir is the directory where the Solidity fixtures are stored. - SolidityFixturesDir = "test/solidity-ibc/fixtures/" - // SP1ICS07FixturesDir is the directory where the SP1ICS07 fixtures are stored. - SP1ICS07FixturesDir = "test/sp1-ics07/fixtures" - // RustFixturesDir is the directory where the Rust fixtures are stored. - RustFixturesDir = "packages/ethereum-light-client/src/test_utils/fixtures" - // RelayerConfigFilePath is the path to generate the relayer config file. - RelayerConfigFilePath = "programs/relayer/config.json" - // E2EDeployScriptPath is the path to the E2E deploy script. - E2EDeployScriptPath = "scripts/E2ETestDeploy.s.sol:E2ETestDeploy" - // SP1ICS07DeployScriptPath is the path to the SP1ICS07 deploy script. - SP1ICS07DeployScriptPath = "scripts/SP1ICS07Tendermint.s.sol:SP1TendermintScript" - - // DefaultGovV1ProposalTokenAmount is the default amount of tokens used to submit a proposal. - DefaultGovV1ProposalTokenAmount = 500_000_000 - - // IbcCommitmentSlotHex is the storage slot in the IBC solidity contract for the IBC commitments. - IbcCommitmentSlotHex = "0x1" -) - -var ( - // MaxDepositPeriod Maximum period to deposit on a proposal. - // This value overrides the default value in the gov module using the `modifyGovV1AppState` function. - MaxDepositPeriod = time.Second * 10 - // VotingPeriod Duration of the voting period. - // This value overrides the default value in the gov module using the `modifyGovV1AppState` function. - VotingPeriod = time.Second * 30 - - // StartingEthBalance is the amount of ETH to give to each user at the start of the test. - StartingEthBalance = math.NewInt(2 * ethereum.ETHER) - - // DefaultTrustLevel is the trust level used by the SP1ICS07Tendermint contract. - DefaultTrustLevel = ibctm.Fraction{Numerator: 2, Denominator: 3}.ToTendermint() - - // DefaultTrustPeriod is the trust period used by the SP1ICS07Tendermint contract. - DefaultTrustPeriod = 1209669 -) From 29065fb0a84a846fe8c4bf21e1f2200ba48853cc Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 10:59:30 -0500 Subject: [PATCH 48/98] bump commit of solidity-ibc-eureka --- go.mod | 19 +++++++------------ go.sum | 24 ++++++++++-------------- solidity-ibc-eureka | 2 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index c54afb0..b3754ff 100644 --- a/go.mod +++ b/go.mod @@ -82,8 +82,6 @@ require ( github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/iavl v1.2.0 // indirect - github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect - github.com/cosmos/ibc-go/v8 v8.2.0 // indirect github.com/cosmos/ics23/go v0.11.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect @@ -261,20 +259,17 @@ require ( sigs.k8s.io/yaml v1.4.0 // indirect ) +// Replaces directives copied from solidity-ibc-eureka. replace ( - // Replace ibc-go with the most recent commit on the feat/ibc-eureka branch. - // ea4e73629c55e35537467d9f032da5be8082b468 is the recent commit as of this writing. - // See https://github.com/cosmos/ibc-go/tree/feat/ibc-eureka - github.com/cosmos/ibc-go/v9 => github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55 - github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 -) - -replace ( - // TODO: using version v1.0.0 causes a build failure. This is the previous version which compiles successfully. github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0 + github.com/cosmos/ibc-go/modules/light-clients/08-wasm => github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.0.0-20241123151201-3d84b47307b9 + github.com/cosmos/ibc-go/v9 => github.com/cosmos/ibc-go/v9 v9.0.0-20241123151201-3d84b47307b9 github.com/cosmos/solidity-ibc-eureka/abigen => ./solidity-ibc-eureka/abigen + github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 + github.com/misko9/go-substrate-rpc-client/v4 => github.com/DimitrisJim/go-substrate-rpc-client/v4 v4.0.0-20240717100841-406da076c1d5 github.com/srdtrk/solidity-ibc-eureka/e2e/v8 => ./solidity-ibc-eureka/e2e/interchaintestv8 + github.com/strangelove-ventures/interchaintest/v8 => github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240717102845-beba523a47ff + github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7 ) diff --git a/go.sum b/go.sum index 14a0142..78dd7eb 100644 --- a/go.sum +++ b/go.sum @@ -240,6 +240,10 @@ github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bp github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/DimitrisJim/go-substrate-rpc-client/v4 v4.0.0-20240717100841-406da076c1d5 h1:u0DTEVAbtD6ZecV9gAgzC6f7sfW+vi+BgdHivIb43Bk= +github.com/DimitrisJim/go-substrate-rpc-client/v4 v4.0.0-20240717100841-406da076c1d5/go.mod h1:vJqS/VE2+iAiQlp0O2l+wW9QkHDotcaSQWaU4Ako6Ss= +github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240717102845-beba523a47ff h1:ITEAJekoSKe5kVo2vUwf37XxnuPwTTzqfd4wLaR2bkk= +github.com/DimitrisJim/interchaintest/v8 v8.0.0-20240717102845-beba523a47ff/go.mod h1:5AnXR5CAbB/Q0syC0akZR4pyPov4nOaB8eifZPz6Pds= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc= github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw= github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc= @@ -344,8 +348,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877 h1:1MLK4YpFtIEo3ZtMA5C795Wtv5VuUnrXX7mQG+aHg6o= -github.com/cockroachdb/datadriven v1.0.3-0.20230801171734-e384cf455877/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= +github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a h1:f52TdbU4D5nozMAhO9TvTJ2ZMCXtN4VIAmfrrZ0JXQ4= @@ -394,14 +398,10 @@ github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= github.com/cosmos/ibc-go/modules/capability v1.0.1 h1:ibwhrpJ3SftEEZRxCRkH0fQZ9svjthrX2+oXdZvzgGI= github.com/cosmos/ibc-go/modules/capability v1.0.1/go.mod h1:rquyOV262nGJplkumH+/LeYs04P3eV8oB7ZM4Ygqk4E= -github.com/cosmos/ibc-go/v8 v8.2.0 h1:7oCzyy1sZCcgpeQLnHxC56brsSz3KWwQGKXalXwXFzE= -github.com/cosmos/ibc-go/v8 v8.2.0/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8= -github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55 h1:tvvb3EXXVrYaCOFGuS1awUBEfoI9a0qjhJaQnbkagZ4= -github.com/cosmos/ibc-go/v9 v9.0.0-20241218142801-ea4e73629c55/go.mod h1:6+3if3nHW38kA8P2Lcb4UIDpt5BIUPbrCGAD8kGIli8= +github.com/cosmos/ibc-go/v9 v9.0.0-20241123151201-3d84b47307b9 h1:30NCjBSKgVa4/mXj063EPBQ26ZR35EuxiSKmYXJ4sv0= +github.com/cosmos/ibc-go/v9 v9.0.0-20241123151201-3d84b47307b9/go.mod h1:TYSpg74CWeTP35UnmhqvMeFcHFp4KdTfHN3Q9IDDjtQ= github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5RtnU= github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= -github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74 h1:6atU/xizTL10q6EprP7oRuvfgUP2F6puvutnVoE+FRc= -github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74/go.mod h1:h/RkwOppo5AJj+1pkQyfjqU1MPdpohD/S6oEeAXpGZY= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -743,8 +743,8 @@ github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerX github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= @@ -893,8 +893,6 @@ github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= -github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2 h1:G/cVeTAbB9S/6FSWWqpFV0v49hiuHLbJPu9hTZ0UR2A= -github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2/go.mod h1:Q5BxOd9FxJqYp4vCiLGVdetecPcWTmUQIu0bRigYosU= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -1129,8 +1127,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= -github.com/strangelove-ventures/interchaintest/v8 v8.3.0 h1:1XyATc0JkvzDhBS71CdpM5z1t6bmO9PgH/5/nffoM9Q= -github.com/strangelove-ventures/interchaintest/v8 v8.3.0/go.mod h1:5goHQtgWO9khoUO/SfR//w3uaw/uYVriDR1OY6PyydM= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= diff --git a/solidity-ibc-eureka b/solidity-ibc-eureka index 3b81a89..febaabb 160000 --- a/solidity-ibc-eureka +++ b/solidity-ibc-eureka @@ -1 +1 @@ -Subproject commit 3b81a89e5785f486a84d333f6f1b23f56c1bfb40 +Subproject commit febaabb6915eccfd3e1922793bc0936cd0b4fdfb From 4aec54990a5c339eebc81b229b2ce3fbfb31a848 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 11:03:51 -0500 Subject: [PATCH 49/98] ci: attempt to fix test --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95439a2..6840e0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' From bf0c7d68494f47e2c46f49f8a68fe27f59ef9827 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 11:09:17 -0500 Subject: [PATCH 50/98] ci: make lint check out submodule --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c42993c..7e5a34c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,6 +9,8 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - uses: actions/setup-go@v5 with: go-version-file: 'go.mod' From 2b3457135d96586d126ca439d5c0596d012f2223 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 11:10:27 -0500 Subject: [PATCH 51/98] fix: lint --- Makefile | 6 ++++++ README.md | 2 +- testing/demo/pkg/relay-v2/main.go | 3 +++ testing/demo/pkg/relay/main.go | 5 ----- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9a52284..9f08197 100644 --- a/Makefile +++ b/Makefile @@ -99,6 +99,12 @@ relay: @go run ./testing/demo/pkg/relay/ .PHONY: relay +## relay2: Relay the token transfer from simapp to the EVM roll-up. +relay2: + @echo "--> Relaying the token transfer using relay-v2" + @go run ./testing/demo/pkg/relay-v2/ +.PHONY: relay + ## stop: Stop all processes and remove the tmp directory. stop: @echo "--> Stopping all processes" diff --git a/README.md b/README.md index 5c474ed..affeb52 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ If someone were to send tokens from the EVM rollup back to SimApp, the source ch This repo uses protobuf to define the interfaces between several services. To help with this, this repo relies on [buf](https://buf.build). If you modify the protos you can regenerate them using: -``` +```shell make proto-gen ``` diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 9c5604c..b8683a6 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -96,6 +96,9 @@ func updateTendermintLightClient() error { // TODO: figure out how to encode the state transition proof into this msg msg := []byte{} tx, err := icsCore.UpgradeClient(getTransactOpts(faucet, eth), clientID, msg) + if err != nil { + return err + } receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 5e30f93..45d1817 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -9,7 +9,6 @@ import ( proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibctesting "github.com/cosmos/ibc-go/v9/testing" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -23,10 +22,6 @@ const ( // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. // TODO: fetch this from the `make setup` command output. ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" - // sourceChannel is hard-coded to the name used by the first channel. - sourceChannel = ibctesting.FirstChannelID - // sequence is hard-coded to the first sequence number used by the MsgSendPacket. - sequence = 1 ) func main() { From 84b60f577c0820ac8af5b558c5d347710bedd53e Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 16:30:00 -0500 Subject: [PATCH 52/98] fix: need to find an account with balance on EVM --- testing/demo/pkg/relay-v2/main.go | 8 ++++++-- testing/demo/pkg/setup/initialise_groth16_client.go | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index b8683a6..e99e07c 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -99,9 +99,10 @@ func updateTendermintLightClient() error { if err != nil { return err } + fmt.Printf("tx gas %v\n", tx.Gas()) receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { - return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) + return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) } recvBlockNumber := receipt.BlockNumber.Uint64() fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) @@ -172,7 +173,7 @@ func receivePacketOnEVM() error { receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { - return fmt.Errorf("Want %v, got %v\n", ethtypes.ReceiptStatusSuccessful, receipt.Status) + return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) } recvBlockNumber := receipt.BlockNumber.Uint64() fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) @@ -234,6 +235,9 @@ func getTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.Trans txOpts.Nonce = big.NewInt(int64(nonce)) txOpts.GasPrice = gasPrice + // Set a specific gas limit + txOpts.GasLimit = 3000000 // Example gas limit; adjust as needed + return txOpts } diff --git a/testing/demo/pkg/setup/initialise_groth16_client.go b/testing/demo/pkg/setup/initialise_groth16_client.go index 0cfa9df..20a3222 100644 --- a/testing/demo/pkg/setup/initialise_groth16_client.go +++ b/testing/demo/pkg/setup/initialise_groth16_client.go @@ -60,6 +60,8 @@ func InitializeGroth16LightClientOnSimapp() error { func createClientAndConsensusState(genesisBlock, latestBlock *ethtypes.Block) (*cdctypes.Any, *cdctypes.Any, error) { // TODO: this clientState isn't created with a state transition verifier key or state inclusion verifier key. + // Query the EVM prover for the verifier keys + // See: https://github.com/celestiaorg/celestia-zkevm-ibc-demo/blob/main/proto/prover/v1/prover.proto#L16-L20 clientState := groth16.NewClientState(latestBlock.Number().Uint64(), []byte{}, []byte{}, []byte{}, genesisBlock.Root().Bytes()) clientStateAny, err := cdctypes.NewAnyWithValue(clientState) if err != nil { From ace4c4666063c0394880eeddba457e1a7559a65d Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 16:45:52 -0500 Subject: [PATCH 53/98] receipt status want 1, got 0 --- testing/demo/pkg/debug-key/main.go | 27 +++++++++++++++++++++++++++ testing/demo/pkg/relay-v2/main.go | 14 ++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 testing/demo/pkg/debug-key/main.go diff --git a/testing/demo/pkg/debug-key/main.go b/testing/demo/pkg/debug-key/main.go new file mode 100644 index 0000000..6e02fd6 --- /dev/null +++ b/testing/demo/pkg/debug-key/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "crypto/ecdsa" + "fmt" + "log" + + "github.com/ethereum/go-ethereum/crypto" +) + +func main() { + // Replace with your private key + privateKeyHex := "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" + + // Parse the private key + privateKey, err := crypto.HexToECDSA(privateKeyHex[2:]) // Strip "0x" prefix + if err != nil { + log.Fatalf("Failed to parse private key: %v", err) + } + + // Derive the public key + publicKey := privateKey.Public().(*ecdsa.PublicKey) + + // Compute the Ethereum address + address := crypto.PubkeyToAddress(*publicKey) + fmt.Printf("Derived Ethereum address: %s\n", address.Hex()) +} diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index e99e07c..c9af74d 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -50,10 +50,12 @@ const ( sequence = 1 // ethereumRPC is the Reth RPC endpoint. ethereumRPC = "http://localhost:8545/" - // TODO: verify if this works - anvilFaucetPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - // TODO: get the tendermint clientID that is deployed on the EVM roll-up - clientID = "TBD" + // ethereumAddress is an address on the EVM chain. + // ethereumAddress = "0xaF9053bB6c4346381C77C2FeD279B17ABAfCDf4d" + // ethPrivateKey is the private key for ethereumAddress. + ethPrivateKey = "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" + // cliendID is for the SP1 Tendermint light client on the EVM roll-up. + clientID = "07-tendermint-0" ) func main() { @@ -78,7 +80,7 @@ func updateTendermintLightClient() error { if err != nil { return err } - faucet, err := crypto.ToECDSA(ethcommon.FromHex(anvilFaucetPrivateKey)) + faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) if err != nil { return err } @@ -158,7 +160,7 @@ func receivePacketOnEVM() error { return err } - faucet, err := crypto.ToECDSA(ethcommon.FromHex(anvilFaucetPrivateKey)) + faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) if err != nil { return err } From 9db085ccaf3451b158f1a25cea2db6b86786c36f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 16:55:32 -0500 Subject: [PATCH 54/98] Failed to trace transaction: Method not found --- testing/demo/pkg/debug-txhash/main.go | 29 +++++++++++++++++++++++++++ testing/demo/pkg/relay-v2/main.go | 15 ++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 testing/demo/pkg/debug-txhash/main.go diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go new file mode 100644 index 0000000..3257def --- /dev/null +++ b/testing/demo/pkg/debug-txhash/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "fmt" + "log" + + ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/rpc" +) + +func getRevertReason(txHash ethcommon.Hash, rpcURL string) string { + client, err := rpc.Dial(rpcURL) + if err != nil { + log.Fatalf("Failed to connect to RPC: %v", err) + } + var result string + err = client.Call(&result, "debug_traceTransaction", txHash.Hex(), map[string]interface{}{}) + if err != nil { + log.Fatalf("Failed to trace transaction: %v", err) + } + return result +} + +func main() { + txHash := ethcommon.HexToHash("0x4fa612350e69087839ac4dcb60247d93bc2f739de618bc81829208c21a18a19d") + rpcURL := "http://localhost:8545/" + result := getRevertReason(txHash, rpcURL) + fmt.Printf("result %v\n", result) +} diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index c9af74d..e5b4e35 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -101,9 +101,10 @@ func updateTendermintLightClient() error { if err != nil { return err } - fmt.Printf("tx gas %v\n", tx.Gas()) receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { + fmt.Printf("receipt %v\n", receipt) + fmt.Printf("receipt logs %v\n", receipt.Logs) return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) } recvBlockNumber := receipt.BlockNumber.Uint64() @@ -259,7 +260,17 @@ func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.H return receipt != nil, nil }) if err != nil { - log.Fatal(err) + log.Fatalf("Failed to fetch receipt: %v", err) + } + + // Log more details about the receipt + fmt.Printf("Transaction hash: %s\n", hash.Hex()) + fmt.Printf("Block number: %d\n", receipt.BlockNumber.Uint64()) + fmt.Printf("Gas used: %d\n", receipt.GasUsed) + fmt.Printf("Logs: %v\n", receipt.Logs) + if receipt.Status != ethtypes.ReceiptStatusSuccessful { + fmt.Println("Transaction failed. Inspect logs or contract.") } + return receipt } From d6bc84da91b567e4af57d7c4a42a3238e5612d7a Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 17:06:10 -0500 Subject: [PATCH 55/98] figured out revert reason! --- testing/demo/pkg/debug-txhash/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 3257def..3586058 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -1,6 +1,7 @@ package main import ( + "encoding/json" "fmt" "log" @@ -8,22 +9,22 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -func getRevertReason(txHash ethcommon.Hash, rpcURL string) string { +func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { client, err := rpc.Dial(rpcURL) if err != nil { log.Fatalf("Failed to connect to RPC: %v", err) } - var result string - err = client.Call(&result, "debug_traceTransaction", txHash.Hex(), map[string]interface{}{}) + var raw json.RawMessage + err = client.Call(&raw, "debug_traceTransaction", txHash.Hex(), map[string]interface{}{}) if err != nil { log.Fatalf("Failed to trace transaction: %v", err) } - return result + return raw } func main() { - txHash := ethcommon.HexToHash("0x4fa612350e69087839ac4dcb60247d93bc2f739de618bc81829208c21a18a19d") + txHash := ethcommon.HexToHash("0xdbbe9a1c3569ca3c0274bb0b6d01d85af5d708437d44b6de7658eeec08cb6dbe") rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) - fmt.Printf("result %v\n", result) + fmt.Printf("result %v\n", string(result)) } From 9bd5194e822e75591336e1a34422091c49d3891d Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 17:17:43 -0500 Subject: [PATCH 56/98] enable debug API on reth node --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 19b1fe4..c352b11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: --chain /testapp_files/eth-genesis.json --http --http.addr 0.0.0.0 - --http.api eth,net + --http.api eth,net,debug --authrpc.addr 0.0.0.0 --authrpc.jwtsecret /testapp_files/jwt.hex --datadir /.tmp/eth-home From e372c33e5a7aaec7572e39c7d98de8435d71133f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 17:17:58 -0500 Subject: [PATCH 57/98] contract addresses change on each deployment --- testing/demo/pkg/relay-v2/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index e5b4e35..c24a699 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -28,13 +28,13 @@ import ( // TODO: fetch these from the `make setup` command output. const ( - erc20 = "0x94b9b5bd518109db400adc62ab2022d2f0008ff7" - escrow = "0x51488819811d51c7a3efcc5f0756740e252da783" - ibcstore = "0x686bd6a5be8a2d9d923814b8e9a3957c3c103573" + erc20 = "0xb1c938f5ba4b3593377f399e12175e8db0c787ff" + escrow = "0xf73bd8a7184bec941b3f9ef5e6f6df981e105535" + ibcstore = "0x5bbab04b4740275903edb0fdb4e9d0e9a25abfef" ics07Tendermint = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" - ics20Transfer = "0xe2c1756b8825c54638f98425c113b51730cc47f6" - ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" - icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" + ics20Transfer = "0x48fd1226d797400779bbfaf1706f5fb8da04ae91" + ics26Router = "0x7e7ad18adc99b94d4c728fdf13d4de97b926a0d8" + icsCore = "0x70ac5980099d71f4cb561bbc0fcfef08aa6279ec" ) const ( From b5cf7a2b4cbec048eb5a44af00a375ce5a5f58c7 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 10 Jan 2025 17:31:00 -0500 Subject: [PATCH 58/98] fix: update client --- testing/demo/pkg/relay-v2/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index c24a699..9d6a8cf 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -97,7 +97,7 @@ func updateTendermintLightClient() error { // stateTransitionProof := []byte{} // TODO: figure out how to encode the state transition proof into this msg msg := []byte{} - tx, err := icsCore.UpgradeClient(getTransactOpts(faucet, eth), clientID, msg) + tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, msg) if err != nil { return err } From 359960ea6c04c23e9e113144ebeee5730a68897b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 15 Jan 2025 09:45:19 -0500 Subject: [PATCH 59/98] wip: debugging from before --- testing/demo/pkg/debug-txhash/main.go | 2 +- testing/demo/pkg/relay-v2/main.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 3586058..1098f26 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -23,7 +23,7 @@ func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { } func main() { - txHash := ethcommon.HexToHash("0xdbbe9a1c3569ca3c0274bb0b6d01d85af5d708437d44b6de7658eeec08cb6dbe") + txHash := ethcommon.HexToHash("0x3c90489acd574285d7a79ad61444b5be05baa52017d5ec2478e7f5b355d6c049") rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) fmt.Printf("result %v\n", string(result)) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 9d6a8cf..1962879 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -95,9 +95,9 @@ func updateTendermintLightClient() error { // fmt.Printf("sendPacket %v\n", sendPacket) // Update the Tendermint light client on the EVM roll-up with the stateTransitionProof // stateTransitionProof := []byte{} - // TODO: figure out how to encode the state transition proof into this msg - msg := []byte{} - tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, msg) + // TODO: figure out how to encode the state transition proof into this updateMsg + updateMsg := []byte{} + tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, updateMsg) if err != nil { return err } From e45700c2ec7aa457a2732591e4b902b6630648de Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 15:07:55 -0500 Subject: [PATCH 60/98] do not wipe containers on start --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9c0ebd0..ef7c8e8 100644 --- a/Makefile +++ b/Makefile @@ -72,8 +72,8 @@ check-dependencies: .PHONY: check-dependencies ## start: Start all processes needed for the demo. -start: stop - @docker compose up -d +start: + @docker compose up --detach .PHONY: start ## setup: Set up the IBC clients and channels. @@ -239,5 +239,5 @@ demo: @make start @make setup @make transfer - @make relay + @make relay2 .PHONY: demo From fb9641321c317f7abcab65a310fbb9019396b9cb Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 15:09:28 -0500 Subject: [PATCH 61/98] wip: debug relay2 --- testing/demo/pkg/relay-v2/main.go | 64 +++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 1962879..0de8046 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -9,6 +9,7 @@ import ( "time" "cosmossdk.io/math" + proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" sdktypes "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" @@ -24,17 +25,14 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" + "google.golang.org/grpc" ) // TODO: fetch these from the `make setup` command output. const ( - erc20 = "0xb1c938f5ba4b3593377f399e12175e8db0c787ff" - escrow = "0xf73bd8a7184bec941b3f9ef5e6f6df981e105535" - ibcstore = "0x5bbab04b4740275903edb0fdb4e9d0e9a25abfef" - ics07Tendermint = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" - ics20Transfer = "0x48fd1226d797400779bbfaf1706f5fb8da04ae91" - ics26Router = "0x7e7ad18adc99b94d4c728fdf13d4de97b926a0d8" - icsCore = "0x70ac5980099d71f4cb561bbc0fcfef08aa6279ec" + ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" + icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" + ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" ) const ( @@ -64,10 +62,10 @@ func main() { log.Fatal(err) } - err = receivePacketOnEVM() - if err != nil { - log.Fatal(err) - } + // err = receivePacketOnEVM() + // if err != nil { + // log.Fatal(err) + // } } // updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. @@ -88,19 +86,51 @@ func updateTendermintLightClient() error { if err != nil { return err } - // sendPacket, err := createSendPacket() + + // Connect to the Celestia prover + conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) + if err != nil { + return fmt.Errorf("failed to connect to prover: %w", err) + } + defer conn.Close() + + proverClient := proverclient.NewProverClient(conn) + request := &proverclient.ProveStateTransitionRequest{ClientId: ics07TMContractAddress} + + // Get state transition proof from Celestia prover with retry logic + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + + var resp *proverclient.ProveStateTransitionResponse + // var err error + for retries := 0; retries < 3; retries++ { + resp, err = proverClient.ProveStateTransition(ctx, request) + if err == nil { + break + } + if ctx.Err() != nil { + return fmt.Errorf("context cancelled while getting state transition proof: %w", ctx.Err()) + } + time.Sleep(time.Second * time.Duration(retries+1)) + } + if err != nil { + return fmt.Errorf("failed to get state transition proof after retries: %w", err) + } + fmt.Printf("got resp %v\n", resp) + + // Create and ABI encode the update message + // updateMsg, err := icscore.PackClientMessage(proof.Proof) // if err != nil { - // return err + // return fmt.Errorf("failed to pack client message: %w", err) // } - // fmt.Printf("sendPacket %v\n", sendPacket) - // Update the Tendermint light client on the EVM roll-up with the stateTransitionProof - // stateTransitionProof := []byte{} - // TODO: figure out how to encode the state transition proof into this updateMsg updateMsg := []byte{} + + fmt.Printf("Invoking icsCore.UpdateClient...\n") tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, updateMsg) if err != nil { return err } + fmt.Printf("icsCore.UpdateClient did not error\n") receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { fmt.Printf("receipt %v\n", receipt) From 1a451612aefeda2b423f09de362202399603a6e3 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 15:44:56 -0500 Subject: [PATCH 62/98] devx: fetch deployed contract addresses --- Makefile | 3 +- testing/demo/pkg/relay-v2/main.go | 27 +++++++--- testing/demo/pkg/utils/contract_addresses.go | 55 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 10 deletions(-) create mode 100644 testing/demo/pkg/utils/contract_addresses.go diff --git a/Makefile b/Makefile index ef7c8e8..96d4f9c 100644 --- a/Makefile +++ b/Makefile @@ -100,8 +100,7 @@ relay: ## relay2: Relay the token transfer from simapp to the EVM roll-up. relay2: - @echo "--> Relaying the token transfer using relay-v2" - @go run ./testing/demo/pkg/relay-v2/ + go run testing/demo/pkg/relay-v2/main.go .PHONY: relay ## stop: Stop all processes and remove the tmp directory. diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 0de8046..5b168eb 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -29,11 +29,11 @@ import ( ) // TODO: fetch these from the `make setup` command output. -const ( - ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" - icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" - ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" -) +// const ( +// ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" +// icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" +// ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" +// ) const ( // sender is an address on SimApp that will send funds via the MsgTransfer. @@ -70,11 +70,17 @@ func main() { // updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. func updateTendermintLightClient() error { + addresses, err := utils.ExtractDeployedContractAddresses() + if err != nil { + return err + } + fmt.Printf("addresses %v\n", addresses) + ethClient, err := ethclient.Dial(ethereumRPC) if err != nil { return err } - icsCore, err := icscore.NewContract(ethcommon.HexToAddress(icsCore), ethClient) + icsCore, err := icscore.NewContract(ethcommon.HexToAddress(addresses.ICSCore), ethClient) if err != nil { return err } @@ -95,7 +101,7 @@ func updateTendermintLightClient() error { defer conn.Close() proverClient := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ClientId: ics07TMContractAddress} + request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} // Get state transition proof from Celestia prover with retry logic ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) @@ -143,6 +149,11 @@ func updateTendermintLightClient() error { } func receivePacketOnEVM() error { + addresses, err := utils.ExtractDeployedContractAddresses() + if err != nil { + return err + } + sendPacket, err := createSendPacket() if err != nil { return err @@ -186,7 +197,7 @@ func receivePacketOnEVM() error { if err != nil { return err } - ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(ics26Router), ethClient) + ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(addresses.ICS26Router), ethClient) if err != nil { return err } diff --git a/testing/demo/pkg/utils/contract_addresses.go b/testing/demo/pkg/utils/contract_addresses.go new file mode 100644 index 0000000..f844a2e --- /dev/null +++ b/testing/demo/pkg/utils/contract_addresses.go @@ -0,0 +1,55 @@ +package utils + +import ( + "encoding/json" + "fmt" + "os" + "strings" +) + +type ContractAddresses struct { + ERC20 string `json:"erc20"` + Escrow string `json:"escrow"` + IBCStore string `json:"ibcstore"` + ICS07Tendermint string `json:"ics07Tendermint"` + ICS20Transfer string `json:"ics20Transfer"` + ICS26Router string `json:"ics26Router"` + ICSCore string `json:"icsCore"` +} + +func ExtractDeployedContractAddresses() (ContractAddresses, error) { + filePath := "./solidity-ibc-eureka/broadcast/E2ETestDeploy.s.sol/80087/run-latest.json" + file, err := os.ReadFile(filePath) + if err != nil { + return ContractAddresses{}, fmt.Errorf("error reading file: %v", err) + } + + var runLatest map[string]interface{} + if err := json.Unmarshal(file, &runLatest); err != nil { + return ContractAddresses{}, fmt.Errorf("error unmarshalling JSON: %v", err) + } + + returns, ok := runLatest["returns"].(map[string]interface{}) + if !ok { + return ContractAddresses{}, fmt.Errorf("no valid returns found") + } + + returnValue, ok := returns["0"].(map[string]interface{}) + if !ok { + return ContractAddresses{}, fmt.Errorf("no valid return value found") + } + + value, ok := returnValue["value"].(string) + if !ok { + return ContractAddresses{}, fmt.Errorf("no valid value found") + } + + unescapedValue := strings.ReplaceAll(value, "\\\"", "\"") + + var addresses ContractAddresses + if err := json.Unmarshal([]byte(unescapedValue), &addresses); err != nil { + return ContractAddresses{}, fmt.Errorf("error unmarshalling contract addresses: %v", err) + } + + return addresses, nil +} From 944f710baad181840ecd3c03b559ac7370055df5 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 15:46:32 -0500 Subject: [PATCH 63/98] refactor: delete code moved to utils --- .../demo/pkg/setup/initialise_sp1tm_client.go | 53 +------------------ 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/testing/demo/pkg/setup/initialise_sp1tm_client.go b/testing/demo/pkg/setup/initialise_sp1tm_client.go index 9de6706..99a2496 100644 --- a/testing/demo/pkg/setup/initialise_sp1tm_client.go +++ b/testing/demo/pkg/setup/initialise_sp1tm_client.go @@ -3,13 +3,11 @@ package main import ( "context" "crypto/ecdsa" - "encoding/json" "fmt" "math/big" "os" "os/exec" - "strings" "time" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" @@ -30,16 +28,6 @@ const ( var TendermintLightClientID string -type ContractAddresses struct { - ERC20 string `json:"erc20"` - Escrow string `json:"escrow"` - IBCStore string `json:"ibcstore"` - ICS07Tendermint string `json:"ics07Tendermint"` - ICS20Transfer string `json:"ics20Transfer"` - ICS26Router string `json:"ics26Router"` - ICSCore string `json:"icsCore"` -} - func InitializeSp1TendermintLightClientOnReth() error { fmt.Println("Deploying IBC smart contracts on the reth node...") @@ -47,7 +35,7 @@ func InitializeSp1TendermintLightClientOnReth() error { return err } - addresses, err := extractDeployedContractAddresses() + addresses, err := utils.ExtractDeployedContractAddresses() if err != nil { return err } @@ -87,44 +75,7 @@ func runDeploymentCommand() error { return nil } -func extractDeployedContractAddresses() (ContractAddresses, error) { - filePath := "./solidity-ibc-eureka/broadcast/E2ETestDeploy.s.sol/80087/run-latest.json" - file, err := os.ReadFile(filePath) - if err != nil { - return ContractAddresses{}, fmt.Errorf("error reading file: %v", err) - } - - var runLatest map[string]interface{} - if err := json.Unmarshal(file, &runLatest); err != nil { - return ContractAddresses{}, fmt.Errorf("error unmarshalling JSON: %v", err) - } - - returns, ok := runLatest["returns"].(map[string]interface{}) - if !ok { - return ContractAddresses{}, fmt.Errorf("no valid returns found") - } - - returnValue, ok := returns["0"].(map[string]interface{}) - if !ok { - return ContractAddresses{}, fmt.Errorf("no valid return value found") - } - - value, ok := returnValue["value"].(string) - if !ok { - return ContractAddresses{}, fmt.Errorf("no valid value found") - } - - unescapedValue := strings.ReplaceAll(value, "\\\"", "\"") - - var addresses ContractAddresses - if err := json.Unmarshal([]byte(unescapedValue), &addresses); err != nil { - return ContractAddresses{}, fmt.Errorf("error unmarshalling contract addresses: %v", err) - } - - return addresses, nil -} - -func createChannelAndCounterpartyOnReth(addresses ContractAddresses, ethClient *ethclient.Client) error { +func createChannelAndCounterpartyOnReth(addresses utils.ContractAddresses, ethClient *ethclient.Client) error { ethChainId := big.NewInt(80087) ethPrivateKey := "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" From d296b335e46af4f860e8575c590beb3e64bb39fa Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 16:48:47 -0500 Subject: [PATCH 64/98] panic while abi packing --- testing/demo/pkg/relay-v2/main.go | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 5b168eb..948dc3b 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -123,14 +124,57 @@ func updateTendermintLightClient() error { return fmt.Errorf("failed to get state transition proof after retries: %w", err) } fmt.Printf("got resp %v\n", resp) + // TODO: fetch vKey from some where + vKey := [32]byte{} // Create and ABI encode the update message // updateMsg, err := icscore.PackClientMessage(proof.Proof) // if err != nil { // return fmt.Errorf("failed to pack client message: %w", err) // } - updateMsg := []byte{} + // updateMsg either looks like + // clienttypes.MsgUpdateClient{ + // ClientId: s.EthereumLightClientID, + // ClientMessage: wasmHeaderAny, + // Signer: simdRelayerUser.FormattedAddress(), + // }) + // or + // abi.Encode(sp1Proof) + // updateMsg := abi.Encode() + // struct MsgUpdateClient { + // SP1Proof sp1Proof; + // } + // + // updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ + // Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + // VKey: [32]byte{}, // TODO + // PublicValues: resp.PublicValues, + // Proof: resp.Proof, + // }, + // } + + if err != nil { + return fmt.Errorf("failed to encode update message: %w", err) + } + + abiSp1ProofType := abi.Type{ + T: abi.TupleTy, + TupleElems: []*abi.Type{ + // Field 1 => 'bytes32 vKey' + {T: abi.FixedBytesTy, Size: 32}, + // Field 2 => 'bytes publicValues' + {T: abi.BytesTy}, + // Field 3 => 'bytes proof' + {T: abi.BytesTy}, + }, + } + args := abi.Arguments{{Name: "sp1Proof", Type: abiSp1ProofType}} + updateMsg, err := args.Pack([3]interface{}{vKey, resp.PublicValues, resp.Proof}) // panics here + if err != nil { + return err + } + fmt.Printf("abi encoded updateMsg %v\n", updateMsg) fmt.Printf("Invoking icsCore.UpdateClient...\n") tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, updateMsg) if err != nil { From 517f2cc044b42f4b25f7ed224c3c87b4a4e6f971 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 17 Jan 2025 16:57:08 -0500 Subject: [PATCH 65/98] still panics --- testing/demo/pkg/relay-v2/main.go | 45 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 948dc3b..c725574 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" + "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" @@ -125,7 +126,7 @@ func updateTendermintLightClient() error { } fmt.Printf("got resp %v\n", resp) // TODO: fetch vKey from some where - vKey := [32]byte{} + vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} // Create and ABI encode the update message // updateMsg, err := icscore.PackClientMessage(proof.Proof) @@ -146,37 +147,45 @@ func updateTendermintLightClient() error { // SP1Proof sp1Proof; // } // - // updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ - // Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ - // VKey: [32]byte{}, // TODO - // PublicValues: resp.PublicValues, - // Proof: resp.Proof, - // }, - // } + updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ + Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + VKey: vKey, + PublicValues: resp.PublicValues, + Proof: resp.Proof, + }, + } if err != nil { return fmt.Errorf("failed to encode update message: %w", err) } - abiSp1ProofType := abi.Type{ + // 1) The nested type for SP1Proof + sp1ProofType := abi.Type{ T: abi.TupleTy, TupleElems: []*abi.Type{ - // Field 1 => 'bytes32 vKey' - {T: abi.FixedBytesTy, Size: 32}, - // Field 2 => 'bytes publicValues' - {T: abi.BytesTy}, - // Field 3 => 'bytes proof' - {T: abi.BytesTy}, + {T: abi.FixedBytesTy, Size: 32}, // vKey + {T: abi.BytesTy}, // publicValues + {T: abi.BytesTy}, // proof }, } - args := abi.Arguments{{Name: "sp1Proof", Type: abiSp1ProofType}} - updateMsg, err := args.Pack([3]interface{}{vKey, resp.PublicValues, resp.Proof}) // panics here + + // 2) The top-level type for MsgUpdateClient => has exactly 1 field "sp1Proof" + msgUpdateClientType := abi.Type{ + T: abi.TupleTy, + // one field: + TupleElems: []*abi.Type{ + &sp1ProofType, + }, + } + + args := abi.Arguments{{Name: "msgUpdateClient", Type: msgUpdateClientType}} + abiEncodedUpdateMsg, err := args.Pack(updateMsg) // panics here if err != nil { return err } fmt.Printf("abi encoded updateMsg %v\n", updateMsg) fmt.Printf("Invoking icsCore.UpdateClient...\n") - tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, updateMsg) + tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, abiEncodedUpdateMsg) if err != nil { return err } From 475d17c7ebe0e1d41e1d270edb20bd17db8fadfc Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 14:56:15 -0500 Subject: [PATCH 66/98] still panics --- testing/demo/pkg/relay-v2/main.go | 87 +++++++++++++++++-------------- 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index c725574..32dd628 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -19,7 +19,6 @@ import ( "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" - "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" @@ -70,6 +69,20 @@ func main() { // } } +// Exactly matches the Solidity shape for "MsgUpdateClient" +// +// struct MsgUpdateClient { SP1Proof sp1Proof; } +type GoMsgUpdateClient struct { + Sp1Proof GoSP1Proof +} + +// Exactly matches "SP1Proof { bytes32 vKey; bytes publicValues; bytes proof; }" +type GoSP1Proof struct { + VKey [32]byte + PublicValues []byte + Proof []byte +} + // updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. func updateTendermintLightClient() error { addresses, err := utils.ExtractDeployedContractAddresses() @@ -125,67 +138,63 @@ func updateTendermintLightClient() error { return fmt.Errorf("failed to get state transition proof after retries: %w", err) } fmt.Printf("got resp %v\n", resp) + // TODO: fetch vKey from some where vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} - - // Create and ABI encode the update message - // updateMsg, err := icscore.PackClientMessage(proof.Proof) - // if err != nil { - // return fmt.Errorf("failed to pack client message: %w", err) - // } - - // updateMsg either looks like - // clienttypes.MsgUpdateClient{ - // ClientId: s.EthereumLightClientID, - // ClientMessage: wasmHeaderAny, - // Signer: simdRelayerUser.FormattedAddress(), - // }) - // or - // abi.Encode(sp1Proof) - // updateMsg := abi.Encode() - // struct MsgUpdateClient { - // SP1Proof sp1Proof; + // updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ + // Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + // VKey: vKey, + // PublicValues: resp.PublicValues, + // Proof: resp.Proof, + // }, // } - // - updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ - Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + myMsg := GoMsgUpdateClient{ + Sp1Proof: GoSP1Proof{ VKey: vKey, PublicValues: resp.PublicValues, Proof: resp.Proof, }, } - - if err != nil { - return fmt.Errorf("failed to encode update message: %w", err) - } - - // 1) The nested type for SP1Proof sp1ProofType := abi.Type{ - T: abi.TupleTy, TupleElems: []*abi.Type{ - {T: abi.FixedBytesTy, Size: 32}, // vKey - {T: abi.BytesTy}, // publicValues - {T: abi.BytesTy}, // proof + { + T: abi.FixedBytesTy, + Size: 32, + TupleRawName: "vKey", + }, + { + T: abi.BytesTy, + TupleRawName: "publicValues", + }, + { + T: abi.BytesTy, + TupleRawName: "proof", + }, }, } - // 2) The top-level type for MsgUpdateClient => has exactly 1 field "sp1Proof" + // 2) Outer type: MsgUpdateClient => a single field "sp1Proof" msgUpdateClientType := abi.Type{ T: abi.TupleTy, - // one field: TupleElems: []*abi.Type{ - &sp1ProofType, + { + T: abi.TupleTy, + // also fill in the subelems here or reference sp1ProofType + TupleElems: sp1ProofType.TupleElems, + TupleRawName: "foo", + }, }, + TupleRawName: "bar", + TupleType: } - args := abi.Arguments{{Name: "msgUpdateClient", Type: msgUpdateClientType}} - abiEncodedUpdateMsg, err := args.Pack(updateMsg) // panics here + encoded, err := args.Pack(myMsg) if err != nil { return err } - fmt.Printf("abi encoded updateMsg %v\n", updateMsg) + fmt.Printf("abi encoded updateMsg %v\n", encoded) fmt.Printf("Invoking icsCore.UpdateClient...\n") - tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, abiEncodedUpdateMsg) + tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, encoded) if err != nil { return err } From 917aa0a650e12a22a77dc606800e0a3bf987a5f9 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 15:04:34 -0500 Subject: [PATCH 67/98] new error: argument count mismatch 2025/01/20 15:04:01 argument count mismatch: got 1 for 8 --- testing/demo/pkg/relay-v2/main.go | 84 +++++++++++-------------------- 1 file changed, 28 insertions(+), 56 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 32dd628..6e35710 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -19,6 +19,7 @@ import ( "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" + "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" ethcommon "github.com/ethereum/go-ethereum/common" @@ -69,20 +70,6 @@ func main() { // } } -// Exactly matches the Solidity shape for "MsgUpdateClient" -// -// struct MsgUpdateClient { SP1Proof sp1Proof; } -type GoMsgUpdateClient struct { - Sp1Proof GoSP1Proof -} - -// Exactly matches "SP1Proof { bytes32 vKey; bytes publicValues; bytes proof; }" -type GoSP1Proof struct { - VKey [32]byte - PublicValues []byte - Proof []byte -} - // updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. func updateTendermintLightClient() error { addresses, err := utils.ExtractDeployedContractAddresses() @@ -141,54 +128,21 @@ func updateTendermintLightClient() error { // TODO: fetch vKey from some where vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} - // updateMsg := sp1ics07tendermint.IMembershipMsgsSP1MembershipAndUpdateClientProof{ - // Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ - // VKey: vKey, - // PublicValues: resp.PublicValues, - // Proof: resp.Proof, - // }, - // } - myMsg := GoMsgUpdateClient{ - Sp1Proof: GoSP1Proof{ + + parsedABI, err := getFungibleTokenPacketDataABI() + if err != nil { + return err + } + + msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ + Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ VKey: vKey, PublicValues: resp.PublicValues, Proof: resp.Proof, }, } - sp1ProofType := abi.Type{ - TupleElems: []*abi.Type{ - { - T: abi.FixedBytesTy, - Size: 32, - TupleRawName: "vKey", - }, - { - T: abi.BytesTy, - TupleRawName: "publicValues", - }, - { - T: abi.BytesTy, - TupleRawName: "proof", - }, - }, - } - // 2) Outer type: MsgUpdateClient => a single field "sp1Proof" - msgUpdateClientType := abi.Type{ - T: abi.TupleTy, - TupleElems: []*abi.Type{ - { - T: abi.TupleTy, - // also fill in the subelems here or reference sp1ProofType - TupleElems: sp1ProofType.TupleElems, - TupleRawName: "foo", - }, - }, - TupleRawName: "bar", - TupleType: - } - args := abi.Arguments{{Name: "msgUpdateClient", Type: msgUpdateClientType}} - encoded, err := args.Pack(myMsg) + encoded, err := parsedABI.Pack(msg) if err != nil { return err } @@ -377,3 +331,21 @@ func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.H return receipt } + +func getFungibleTokenPacketDataABI() (abi.Arguments, error) { + parsedABI, err := ContractMetaData.GetAbi() + if err != nil { + return nil, err + } + + return parsedABI.Methods["abiPublicTypes"].Inputs, nil +} + +// LibMetaData contains all meta data concerning the Lib contract. +// +// var LibMetaData = &bind.MetaData{ +// ABI: "[{\"type\":\"function\",\"name\":\"DEFAULT_PORT_ID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"FAILED_ACKNOWLEDGEMENT_JSON\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"IBC_DENOM_PREFIX\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ICS20_ENCODING\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ICS20_VERSION\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"SUCCESSFUL_ACKNOWLEDGEMENT_JSON\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"abiPublicTypes\",\"inputs\":[{\"name\":\"o1\",\"type\":\"tuple\",\"internalType\":\"structICS20Lib.FungibleTokenPacketData\",\"components\":[{\"name\":\"denom\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"sender\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"receiver\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"memo\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"outputs\":[],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"newMsgSendPacketV1\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"msg_\",\"type\":\"tuple\",\"internalType\":\"structIICS20TransferMsgs.SendTransferMsg\",\"components\":[{\"name\":\"denom\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"receiver\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"sourceChannel\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"destPort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"timeoutTimestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"memo\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIICS26RouterMsgs.MsgSendPacket\",\"components\":[{\"name\":\"sourceChannel\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"timeoutTimestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"payloads\",\"type\":\"tuple[]\",\"internalType\":\"structIICS26RouterMsgs.Payload[]\",\"components\":[{\"name\":\"sourcePort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"destPort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"encoding\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"toHexHash\",\"inputs\":[{\"name\":\"str\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"toIBCDenom\",\"inputs\":[{\"name\":\"fullDenomPath\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"pure\"},{\"type\":\"error\",\"name\":\"ICS20InvalidAddress\",\"inputs\":[{\"name\":\"addr\",\"type\":\"string\",\"internalType\":\"string\"}]},{\"type\":\"error\",\"name\":\"ICS20InvalidAmount\",\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"StringsInsufficientHexLength\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"length\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}]", +// } +var ContractMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"updateClientProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"membershipProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"updateClientAndMembershipProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"misbehaviourProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_clientState\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_consensusState\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"ALLOWED_SP1_CLOCK_DRIFT\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"MEMBERSHIP_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"MISBEHAVIOUR_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"UPDATE_CLIENT_AND_MEMBERSHIP_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"UPDATE_CLIENT_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"VERIFIER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractISP1Verifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"abiPublicTypes\",\"inputs\":[{\"name\":\"o1\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.MembershipOutput\",\"components\":[{\"name\":\"commitmentRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"kvPairs\",\"type\":\"tuple[]\",\"internalType\":\"structIMembershipMsgs.KVPair[]\",\"components\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o2\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientAndMembershipMsgs.UcAndMembershipOutput\",\"components\":[{\"name\":\"updateClientOutput\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientMsgs.UpdateClientOutput\",\"components\":[{\"name\":\"clientState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]},{\"name\":\"trustedConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"newConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"time\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"trustedHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"newHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}]},{\"name\":\"kvPairs\",\"type\":\"tuple[]\",\"internalType\":\"structIMembershipMsgs.KVPair[]\",\"components\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o4\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.MembershipProof\",\"components\":[{\"name\":\"proofType\",\"type\":\"uint8\",\"internalType\":\"enumIMembershipMsgs.MembershipProofType\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"o5\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.SP1MembershipProof\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"trustedConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]},{\"name\":\"o6\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.SP1MembershipAndUpdateClientProof\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o7\",\"type\":\"tuple\",\"internalType\":\"structIMisbehaviourMsgs.MisbehaviourOutput\",\"components\":[{\"name\":\"clientState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]},{\"name\":\"time\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"trustedHeight1\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustedHeight2\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustedConsensusState1\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"trustedConsensusState2\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]},{\"name\":\"o8\",\"type\":\"tuple\",\"internalType\":\"structIMisbehaviourMsgs.MsgSubmitMisbehaviour\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getClientState\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getConsensusStateHash\",\"inputs\":[{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"membership\",\"inputs\":[{\"name\":\"msgMembership\",\"type\":\"tuple\",\"internalType\":\"structILightClientMsgs.MsgMembership\",\"components\":[{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proofHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"misbehaviour\",\"inputs\":[{\"name\":\"misbehaviourMsg\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"multicall\",\"inputs\":[{\"name\":\"data\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[{\"name\":\"results\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"updateClient\",\"inputs\":[{\"name\":\"updateMsg\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumILightClientMsgs.UpdateResult\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeClient\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"view\"},{\"type\":\"error\",\"name\":\"AddressEmptyCode\",\"inputs\":[{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"CannotHandleMisbehavior\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ChainIdMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"actual\",\"type\":\"string\",\"internalType\":\"string\"}]},{\"type\":\"error\",\"name\":\"ClientStateMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"actual\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ConsensusStateHashMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"ConsensusStateNotFound\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ConsensusStateRootMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"FailedCall\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FeatureNotSupported\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FrozenClientState\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidMembershipProof\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"KeyValuePairNotInCache\",\"inputs\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"LengthIsOutOfRange\",\"inputs\":[{\"name\":\"length\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"min\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"max\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"MembershipProofKeyNotFound\",\"inputs\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}]},{\"type\":\"error\",\"name\":\"MembershipProofValueMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"actual\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ProofHeightMismatch\",\"inputs\":[{\"name\":\"expectedRevisionNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"expectedRevisionHeight\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"actualRevisionNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"actualRevisionHeight\",\"type\":\"uint64\",\"internalType\":\"uint64\"}]},{\"type\":\"error\",\"name\":\"ProofIsInTheFuture\",\"inputs\":[{\"name\":\"now\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proofTimestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"ProofIsTooOld\",\"inputs\":[{\"name\":\"now\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proofTimestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustThresholdMismatch\",\"inputs\":[{\"name\":\"expectedNumerator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expectedDenominator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actualNumerator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actualDenominator\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustingPeriodMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustingPeriodTooLong\",\"inputs\":[{\"name\":\"trustingPeriod\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UnbondingPeriodMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UnknownMembershipProofType\",\"inputs\":[{\"name\":\"proofType\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"type\":\"error\",\"name\":\"UnknownZkAlgorithm\",\"inputs\":[{\"name\":\"algorithm\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"type\":\"error\",\"name\":\"VerificationKeyMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]", +} From e5b9954b82443761ee68339d344d6317a5a18942 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 15:29:00 -0500 Subject: [PATCH 68/98] no more errors, timed out after 30 seconds --- testing/demo/pkg/relay-v2/main.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 6e35710..0c561ef 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "math/big" + "strings" "time" "cosmossdk.io/math" @@ -129,7 +130,7 @@ func updateTendermintLightClient() error { // TODO: fetch vKey from some where vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} - parsedABI, err := getFungibleTokenPacketDataABI() + parsedABI, err := getParsedABI() if err != nil { return err } @@ -142,11 +143,14 @@ func updateTendermintLightClient() error { }, } + fmt.Printf("Packing msg...\n") encoded, err := parsedABI.Pack(msg) + if err != nil { - return err + return fmt.Errorf("error packing msg %w\n", err) } - fmt.Printf("abi encoded updateMsg %v\n", encoded) + fmt.Printf("Pcaked msg %v\n", encoded) + fmt.Printf("Invoking icsCore.UpdateClient...\n") tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, encoded) if err != nil { @@ -332,20 +336,13 @@ func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.H return receipt } -func getFungibleTokenPacketDataABI() (abi.Arguments, error) { - parsedABI, err := ContractMetaData.GetAbi() +func getParsedABI() (abi.Arguments, error) { + var SingleABI = "[{\"type\":\"function\",\"name\":\"dummyEncode\",\"stateMutability\":\"pure\",\"inputs\":[{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"struct IUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"struct ISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[]}]" + + parsed, err := abi.JSON(strings.NewReader(SingleABI)) if err != nil { return nil, err } - return parsedABI.Methods["abiPublicTypes"].Inputs, nil -} - -// LibMetaData contains all meta data concerning the Lib contract. -// -// var LibMetaData = &bind.MetaData{ -// ABI: "[{\"type\":\"function\",\"name\":\"DEFAULT_PORT_ID\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"FAILED_ACKNOWLEDGEMENT_JSON\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"IBC_DENOM_PREFIX\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ICS20_ENCODING\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"ICS20_VERSION\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"SUCCESSFUL_ACKNOWLEDGEMENT_JSON\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"abiPublicTypes\",\"inputs\":[{\"name\":\"o1\",\"type\":\"tuple\",\"internalType\":\"structICS20Lib.FungibleTokenPacketData\",\"components\":[{\"name\":\"denom\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"sender\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"receiver\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"memo\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"outputs\":[],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"newMsgSendPacketV1\",\"inputs\":[{\"name\":\"sender\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"msg_\",\"type\":\"tuple\",\"internalType\":\"structIICS20TransferMsgs.SendTransferMsg\",\"components\":[{\"name\":\"denom\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"receiver\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"sourceChannel\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"destPort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"timeoutTimestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"memo\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIICS26RouterMsgs.MsgSendPacket\",\"components\":[{\"name\":\"sourceChannel\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"timeoutTimestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"payloads\",\"type\":\"tuple[]\",\"internalType\":\"structIICS26RouterMsgs.Payload[]\",\"components\":[{\"name\":\"sourcePort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"destPort\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"version\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"encoding\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"toHexHash\",\"inputs\":[{\"name\":\"str\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"toIBCDenom\",\"inputs\":[{\"name\":\"fullDenomPath\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"pure\"},{\"type\":\"error\",\"name\":\"ICS20InvalidAddress\",\"inputs\":[{\"name\":\"addr\",\"type\":\"string\",\"internalType\":\"string\"}]},{\"type\":\"error\",\"name\":\"ICS20InvalidAmount\",\"inputs\":[{\"name\":\"amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"StringsInsufficientHexLength\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"length\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}]", -// } -var ContractMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"updateClientProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"membershipProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"updateClientAndMembershipProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"misbehaviourProgramVkey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"_clientState\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_consensusState\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"ALLOWED_SP1_CLOCK_DRIFT\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint16\",\"internalType\":\"uint16\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"MEMBERSHIP_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"MISBEHAVIOUR_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"UPDATE_CLIENT_AND_MEMBERSHIP_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"UPDATE_CLIENT_PROGRAM_VKEY\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"VERIFIER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractISP1Verifier\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"abiPublicTypes\",\"inputs\":[{\"name\":\"o1\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.MembershipOutput\",\"components\":[{\"name\":\"commitmentRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"kvPairs\",\"type\":\"tuple[]\",\"internalType\":\"structIMembershipMsgs.KVPair[]\",\"components\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o2\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientAndMembershipMsgs.UcAndMembershipOutput\",\"components\":[{\"name\":\"updateClientOutput\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientMsgs.UpdateClientOutput\",\"components\":[{\"name\":\"clientState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]},{\"name\":\"trustedConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"newConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"time\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"trustedHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"newHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]}]},{\"name\":\"kvPairs\",\"type\":\"tuple[]\",\"internalType\":\"structIMembershipMsgs.KVPair[]\",\"components\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"structIUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o4\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.MembershipProof\",\"components\":[{\"name\":\"proofType\",\"type\":\"uint8\",\"internalType\":\"enumIMembershipMsgs.MembershipProofType\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"o5\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.SP1MembershipProof\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"trustedConsensusState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]},{\"name\":\"o6\",\"type\":\"tuple\",\"internalType\":\"structIMembershipMsgs.SP1MembershipAndUpdateClientProof\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"o7\",\"type\":\"tuple\",\"internalType\":\"structIMisbehaviourMsgs.MisbehaviourOutput\",\"components\":[{\"name\":\"clientState\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]},{\"name\":\"time\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"trustedHeight1\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustedHeight2\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustedConsensusState1\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"trustedConsensusState2\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ConsensusState\",\"components\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"root\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextValidatorsHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]},{\"name\":\"o8\",\"type\":\"tuple\",\"internalType\":\"structIMisbehaviourMsgs.MsgSubmitMisbehaviour\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"structISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"getClientState\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.ClientState\",\"components\":[{\"name\":\"chainId\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"trustLevel\",\"type\":\"tuple\",\"internalType\":\"structIICS07TendermintMsgs.TrustThreshold\",\"components\":[{\"name\":\"numerator\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"denominator\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"name\":\"latestHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"trustingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"isFrozen\",\"type\":\"bool\",\"internalType\":\"bool\"},{\"name\":\"zkAlgorithm\",\"type\":\"uint8\",\"internalType\":\"enumISP1Msgs.SupportedZkAlgorithm\"}]}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getConsensusStateHash\",\"inputs\":[{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"membership\",\"inputs\":[{\"name\":\"msgMembership\",\"type\":\"tuple\",\"internalType\":\"structILightClientMsgs.MsgMembership\",\"components\":[{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proofHeight\",\"type\":\"tuple\",\"internalType\":\"structIICS02ClientMsgs.Height\",\"components\":[{\"name\":\"revisionNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"revisionHeight\",\"type\":\"uint32\",\"internalType\":\"uint32\"}]},{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}],\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"misbehaviour\",\"inputs\":[{\"name\":\"misbehaviourMsg\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"multicall\",\"inputs\":[{\"name\":\"data\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"outputs\":[{\"name\":\"results\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"updateClient\",\"inputs\":[{\"name\":\"updateMsg\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumILightClientMsgs.UpdateResult\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"upgradeClient\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"view\"},{\"type\":\"error\",\"name\":\"AddressEmptyCode\",\"inputs\":[{\"name\":\"target\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"CannotHandleMisbehavior\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ChainIdMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"actual\",\"type\":\"string\",\"internalType\":\"string\"}]},{\"type\":\"error\",\"name\":\"ClientStateMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"actual\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ConsensusStateHashMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"ConsensusStateNotFound\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"ConsensusStateRootMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"type\":\"error\",\"name\":\"FailedCall\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FeatureNotSupported\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"FrozenClientState\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidMembershipProof\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"KeyValuePairNotInCache\",\"inputs\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"},{\"name\":\"value\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"LengthIsOutOfRange\",\"inputs\":[{\"name\":\"length\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"min\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"max\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"MembershipProofKeyNotFound\",\"inputs\":[{\"name\":\"path\",\"type\":\"bytes[]\",\"internalType\":\"bytes[]\"}]},{\"type\":\"error\",\"name\":\"MembershipProofValueMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"actual\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"type\":\"error\",\"name\":\"ProofHeightMismatch\",\"inputs\":[{\"name\":\"expectedRevisionNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"expectedRevisionHeight\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"actualRevisionNumber\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"actualRevisionHeight\",\"type\":\"uint64\",\"internalType\":\"uint64\"}]},{\"type\":\"error\",\"name\":\"ProofIsInTheFuture\",\"inputs\":[{\"name\":\"now\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proofTimestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"ProofIsTooOld\",\"inputs\":[{\"name\":\"now\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proofTimestamp\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustThresholdMismatch\",\"inputs\":[{\"name\":\"expectedNumerator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"expectedDenominator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actualNumerator\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actualDenominator\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustingPeriodMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"TrustingPeriodTooLong\",\"inputs\":[{\"name\":\"trustingPeriod\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"unbondingPeriod\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UnbondingPeriodMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"actual\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]},{\"type\":\"error\",\"name\":\"UnknownMembershipProofType\",\"inputs\":[{\"name\":\"proofType\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"type\":\"error\",\"name\":\"UnknownZkAlgorithm\",\"inputs\":[{\"name\":\"algorithm\",\"type\":\"uint8\",\"internalType\":\"uint8\"}]},{\"type\":\"error\",\"name\":\"VerificationKeyMismatch\",\"inputs\":[{\"name\":\"expected\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"actual\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]}]", + return parsed.Methods["dummyEncode"].Inputs, nil } From ac3be0cffdb2dafa72eabdff004df567e8584e59 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 15:30:42 -0500 Subject: [PATCH 69/98] clean up --- testing/demo/pkg/relay-v2/main.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 0c561ef..b265773 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -130,7 +130,7 @@ func updateTendermintLightClient() error { // TODO: fetch vKey from some where vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} - parsedABI, err := getParsedABI() + arguments, err := getUpdateClientArguments() if err != nil { return err } @@ -144,10 +144,9 @@ func updateTendermintLightClient() error { } fmt.Printf("Packing msg...\n") - encoded, err := parsedABI.Pack(msg) - + encoded, err := arguments.Pack(msg) if err != nil { - return fmt.Errorf("error packing msg %w\n", err) + return fmt.Errorf("error packing msg %w", err) } fmt.Printf("Pcaked msg %v\n", encoded) @@ -336,13 +335,13 @@ func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.H return receipt } -func getParsedABI() (abi.Arguments, error) { - var SingleABI = "[{\"type\":\"function\",\"name\":\"dummyEncode\",\"stateMutability\":\"pure\",\"inputs\":[{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"struct IUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"struct ISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[]}]" +func getUpdateClientArguments() (abi.Arguments, error) { + var updateClientABI = "[{\"type\":\"function\",\"name\":\"updateClient\",\"stateMutability\":\"pure\",\"inputs\":[{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"struct IUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"struct ISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[]}]" - parsed, err := abi.JSON(strings.NewReader(SingleABI)) + parsed, err := abi.JSON(strings.NewReader(updateClientABI)) if err != nil { return nil, err } - return parsed.Methods["dummyEncode"].Inputs, nil + return parsed.Methods["updateClient"].Inputs, nil } From 34b0e70f34ea17ea8bba3bd17aea9eca175bea19 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 15:55:03 -0500 Subject: [PATCH 70/98] still fails even with verifier key from genesis.json --- testing/demo/pkg/debug-txhash/main.go | 2 +- testing/demo/pkg/relay-v2/main.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 1098f26..9be082f 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -23,7 +23,7 @@ func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { } func main() { - txHash := ethcommon.HexToHash("0x3c90489acd574285d7a79ad61444b5be05baa52017d5ec2478e7f5b355d6c049") + txHash := ethcommon.HexToHash("0x5985006fc7c5c5487af994e683b6cdf03c0cc8e505ca885e6f427a6389da9af5") rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) fmt.Printf("result %v\n", string(result)) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index b265773..02296ff 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -3,6 +3,7 @@ package main import ( "context" "crypto/ecdsa" + "encoding/hex" "fmt" "log" "math/big" @@ -127,14 +128,21 @@ func updateTendermintLightClient() error { } fmt.Printf("got resp %v\n", resp) - // TODO: fetch vKey from some where - vKey := [32]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21} - arguments, err := getUpdateClientArguments() if err != nil { return err } + // The update client verifier key is set in solidity-ibc-eureka/scripts/genesis.json + updateClientVkey := "00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3" + verifierKey, err := hex.DecodeString(updateClientVkey) + if err != nil { + return fmt.Errorf("error decoding hex: %w", err) + } + // Convert the byte slice into a [32]byte array + var vKey [32]byte + copy(vKey[:], verifierKey) + msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ VKey: vKey, From 59ee2928b27575b1f06d0189e30f0c9d8f39546e Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 16:42:44 -0500 Subject: [PATCH 71/98] fix(celestia-prover): return verifier key as 32 bytes --- provers/celestia-prover/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index a9ab83f..f8ade2e 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -1,5 +1,6 @@ use std::env; use std::fs; +use sp1_sdk::HashableKey; use tonic::{transport::Server, Request, Response, Status}; // Import the generated proto rust code pub mod prover { @@ -52,9 +53,9 @@ impl ProverService { #[tonic::async_trait] impl Prover for ProverService { async fn info(&self, _request: Request) -> Result, Status> { - let state_transition_verifier_key = bincode::serialize(&self.tendermint_prover.vkey) + let state_transition_verifier_key = bincode::serialize(&self.tendermint_prover.vkey.bytes32()) .map_err(|e| Status::internal(e.to_string()))?; - let state_membership_verifier_key = bincode::serialize(&self.membership_prover.vkey) + let state_membership_verifier_key = bincode::serialize(&self.membership_prover.vkey.bytes32()) .map_err(|e| Status::internal(e.to_string()))?; let response = InfoResponse { state_transition_verifier_key, From 45a08bc9555a2c8e16bfad871cfbbf8645309a93 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 16:53:16 -0500 Subject: [PATCH 72/98] docs: info endpoint --- provers/celestia-prover/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/provers/celestia-prover/README.md b/provers/celestia-prover/README.md index 849b65f..fca47e3 100644 --- a/provers/celestia-prover/README.md +++ b/provers/celestia-prover/README.md @@ -30,8 +30,13 @@ After the one-time setup, the following minimum steps are necessary each time yo ``` 1. Make sure to set `SP1_PROVER=network` in `.env` and get sp1 prover network private key from celestia 1Password. +1. Verify it's running by querying an endpoint. -1. Copy the EVM address labeled with `ics07Tendermint` from terminal output which will be used as a `client_id` when querying state transition proofs: + ```shell + grpcurl -plaintext localhost:50051 celestia.prover.v1.Prover/Info + ``` + +1. [Optional] Request a proof. Copy the EVM address labeled with `ics07Tendermint` from terminal output which will be used as a `client_id` when querying state transition proofs: ```shell grpcurl -plaintext -d '{"client_id": ""}' localhost:50051 celestia.prover.v1.Prover/ProveStateTransition @@ -70,5 +75,5 @@ make publish-celestia-prover-docker If you update the circuits please regenerate the `elf` files: ```shell -~/.sp1/bin/cargo-prove prove build --elf-name mock-membership-elf +~/.sp1/bin/cargo-prove prove build --elf-name mock-membership-elf ``` From 4ff6c2d695140cdf0e22e302ce541e0bc7034109 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 17:02:13 -0500 Subject: [PATCH 73/98] fix: use hash_bytes --- provers/celestia-prover/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index f8ade2e..cf7c146 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -53,9 +53,9 @@ impl ProverService { #[tonic::async_trait] impl Prover for ProverService { async fn info(&self, _request: Request) -> Result, Status> { - let state_transition_verifier_key = bincode::serialize(&self.tendermint_prover.vkey.bytes32()) + let state_transition_verifier_key = bincode::serialize(&self.tendermint_prover.vkey.hash_bytes()) .map_err(|e| Status::internal(e.to_string()))?; - let state_membership_verifier_key = bincode::serialize(&self.membership_prover.vkey.bytes32()) + let state_membership_verifier_key = bincode::serialize(&self.membership_prover.vkey.hash_bytes()) .map_err(|e| Status::internal(e.to_string()))?; let response = InfoResponse { state_transition_verifier_key, From bbc809d9031cc61cab0a2b6f287aadbcc1a842bf Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Mon, 20 Jan 2025 17:04:16 -0500 Subject: [PATCH 74/98] try hard-coded verifier key --- testing/demo/pkg/relay-v2/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 02296ff..71e1a73 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -134,7 +134,7 @@ func updateTendermintLightClient() error { } // The update client verifier key is set in solidity-ibc-eureka/scripts/genesis.json - updateClientVkey := "00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3" + updateClientVkey := "409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b" verifierKey, err := hex.DecodeString(updateClientVkey) if err != nil { return fmt.Errorf("error decoding hex: %w", err) From a289ab0953e98f680e136f7d67072eadb0b4d272 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 21 Jan 2025 11:44:18 -0500 Subject: [PATCH 75/98] fix: explicitly set verifier key --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 96d4f9c..39a95c0 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,9 @@ start: ## setup: Set up the IBC clients and channels. setup: + @echo "--> Setting the verifier key in scripts/genesis.json" + @sed -i '' 's|"updateClientVkey": "0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3"|"updateClientVkey": "0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b"|' solidity-ibc-eureka/scripts/genesis.json + @echo "--> Set the verifier key." @echo "--> Deploying tendermint light client contract on the EVM roll-up" @cd ./solidity-ibc-eureka/scripts && just deploy-sp1-ics07 @echo "--> Creating IBC light clients and channel" From b252e0d2c467345b87bd276dfb9944dfe629c58b Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 21 Jan 2025 13:16:05 -0500 Subject: [PATCH 76/98] update client verifier key --- testing/demo/pkg/debug-txhash/main.go | 2 +- testing/demo/pkg/relay-v2/main.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 9be082f..3dee97f 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -23,7 +23,7 @@ func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { } func main() { - txHash := ethcommon.HexToHash("0x5985006fc7c5c5487af994e683b6cdf03c0cc8e505ca885e6f427a6389da9af5") + txHash := ethcommon.HexToHash("0xeb18b1724c3a444658ec02efa0a8084425ad8f1b9e891a8e465fec42949bdcf3") rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) fmt.Printf("result %v\n", string(result)) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 71e1a73..78b9f30 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -134,7 +134,8 @@ func updateTendermintLightClient() error { } // The update client verifier key is set in solidity-ibc-eureka/scripts/genesis.json - updateClientVkey := "409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b" + // hex encoded 0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3 + updateClientVkey := "00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3" verifierKey, err := hex.DecodeString(updateClientVkey) if err != nil { return fmt.Errorf("error decoding hex: %w", err) From 07a9975672729c84efad9431e1f9ce72bb03593f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 21 Jan 2025 13:24:54 -0500 Subject: [PATCH 77/98] query verifier key --- testing/demo/pkg/relay-v2/main.go | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 78b9f30..4152695 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -3,7 +3,6 @@ package main import ( "context" "crypto/ecdsa" - "encoding/hex" "fmt" "log" "math/big" @@ -104,15 +103,23 @@ func updateTendermintLightClient() error { } defer conn.Close() + fmt.Printf("Getting celestia prover info...\n") proverClient := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} + info, err := proverClient.Info(context.Background(), &proverclient.InfoRequest{}) + if err != nil { + return fmt.Errorf("failed to get celestia prover info %w", err) + } + verifierKey := info.StateTransitionVerifierKey + fmt.Printf("Got celestia prover info. State transition verifier key %v\n", verifierKey) + // Convert the verifierKey byte slice into a [32]byte array + var VKey [32]byte + copy(VKey[:], verifierKey) + request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} // Get state transition proof from Celestia prover with retry logic ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() - var resp *proverclient.ProveStateTransitionResponse - // var err error for retries := 0; retries < 3; retries++ { resp, err = proverClient.ProveStateTransition(ctx, request) if err == nil { @@ -128,30 +135,18 @@ func updateTendermintLightClient() error { } fmt.Printf("got resp %v\n", resp) - arguments, err := getUpdateClientArguments() - if err != nil { - return err - } - - // The update client verifier key is set in solidity-ibc-eureka/scripts/genesis.json - // hex encoded 0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3 - updateClientVkey := "00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3" - verifierKey, err := hex.DecodeString(updateClientVkey) - if err != nil { - return fmt.Errorf("error decoding hex: %w", err) - } - // Convert the byte slice into a [32]byte array - var vKey [32]byte - copy(vKey[:], verifierKey) - msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ - VKey: vKey, + VKey: VKey, PublicValues: resp.PublicValues, Proof: resp.Proof, }, } + arguments, err := getUpdateClientArguments() + if err != nil { + return err + } fmt.Printf("Packing msg...\n") encoded, err := arguments.Pack(msg) if err != nil { From 067a5378725e43c5e0317ad0c17752ac86c8d9d2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 21 Jan 2025 13:27:22 -0500 Subject: [PATCH 78/98] log hex encoded verifier key --- testing/demo/pkg/relay-v2/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 4152695..83bad45 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -3,6 +3,7 @@ package main import ( "context" "crypto/ecdsa" + "encoding/hex" "fmt" "log" "math/big" @@ -110,7 +111,7 @@ func updateTendermintLightClient() error { return fmt.Errorf("failed to get celestia prover info %w", err) } verifierKey := info.StateTransitionVerifierKey - fmt.Printf("Got celestia prover info. State transition verifier key %v\n", verifierKey) + fmt.Printf("Got celestia prover info. State transition verifier key %v, hex encoded %v\n", verifierKey, hex.EncodeToString(verifierKey)) // Convert the verifierKey byte slice into a [32]byte array var VKey [32]byte copy(VKey[:], verifierKey) From adc7b91c1ba73180360178a31a92274c3cf48f8a Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Tue, 21 Jan 2025 13:27:37 -0500 Subject: [PATCH 79/98] Log hex encoded key from Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 39a95c0..1165c96 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,7 @@ start: setup: @echo "--> Setting the verifier key in scripts/genesis.json" @sed -i '' 's|"updateClientVkey": "0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3"|"updateClientVkey": "0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b"|' solidity-ibc-eureka/scripts/genesis.json - @echo "--> Set the verifier key." + @echo "--> Set the verifier key to 0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b." @echo "--> Deploying tendermint light client contract on the EVM roll-up" @cd ./solidity-ibc-eureka/scripts && just deploy-sp1-ics07 @echo "--> Creating IBC light clients and channel" From 7816331a25642d242b915d40913e21756780f4f6 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 22 Jan 2025 10:42:48 -0500 Subject: [PATCH 80/98] need to set this in solidity-ibc-eureka justfile --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 1165c96..96d4f9c 100644 --- a/Makefile +++ b/Makefile @@ -78,9 +78,6 @@ start: ## setup: Set up the IBC clients and channels. setup: - @echo "--> Setting the verifier key in scripts/genesis.json" - @sed -i '' 's|"updateClientVkey": "0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3"|"updateClientVkey": "0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b"|' solidity-ibc-eureka/scripts/genesis.json - @echo "--> Set the verifier key to 0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b." @echo "--> Deploying tendermint light client contract on the EVM roll-up" @cd ./solidity-ibc-eureka/scripts && just deploy-sp1-ics07 @echo "--> Creating IBC light clients and channel" From 90a4e07d70aee63f20a3b6f968c974c08e7d2fbc Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 22 Jan 2025 10:55:55 -0500 Subject: [PATCH 81/98] verifier hash mismatch bc EVM trying to use PLONK verifier --- provers/celestia-prover/src/main.rs | 1 + testing/demo/pkg/debug-txhash/main.go | 2 +- testing/demo/pkg/relay-v2/main.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index cf7c146..8aac755 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -120,6 +120,7 @@ impl Prover for ProverService { &proposed_header, now, ); + println!("generated proof {:?}", proof.bytes()); let response = ProveStateTransitionResponse { proof: proof.bytes().to_vec(), diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 3dee97f..6c414f3 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -23,7 +23,7 @@ func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { } func main() { - txHash := ethcommon.HexToHash("0xeb18b1724c3a444658ec02efa0a8084425ad8f1b9e891a8e465fec42949bdcf3") + txHash := ethcommon.HexToHash("0xd69bfa0dc9cd1bf69c2dc38e15a6771354fd387a084e2cb4604f187c55c862a1") rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) fmt.Printf("result %v\n", string(result)) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index 83bad45..b1fcb3d 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -135,6 +135,7 @@ func updateTendermintLightClient() error { return fmt.Errorf("failed to get state transition proof after retries: %w", err) } fmt.Printf("got resp %v\n", resp) + fmt.Printf("got resp.proof %v\n", hex.EncodeToString(resp.Proof)) msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ From e0ee0e080d2b38c0460785afb527840953442b4f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 22 Jan 2025 12:01:33 -0500 Subject: [PATCH 82/98] debug: client state --- testing/demo/pkg/debug-client-state/main.go | 138 ++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 testing/demo/pkg/debug-client-state/main.go diff --git a/testing/demo/pkg/debug-client-state/main.go b/testing/demo/pkg/debug-client-state/main.go new file mode 100644 index 0000000..decdb9b --- /dev/null +++ b/testing/demo/pkg/debug-client-state/main.go @@ -0,0 +1,138 @@ +package main + +import ( + "encoding/hex" + "fmt" + "log" + "strings" + + "github.com/ethereum/go-ethereum/accounts/abi" +) + +func main() { + // clientState is copied from scripts/genesis.json + const clientStateHex = "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000012750000000000000000000000000000000000000000000000000000000000001baf8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a7a6b6962632d64656d6f00000000000000000000000000000000000000000000" + + clientStateBytes, err := hex.DecodeString(clientStateHex) + if err != nil { + log.Fatalf("Failed to decode clientState hex: %v", err) + } + + // ABI JSON string + abiJSON := `[{ + "type": "function", + "name": "getClientState", + "inputs": [], + "outputs": [{ + "name": "", + "type": "tuple", + "components": [ + { "name": "chainId", "type": "string" }, + { "name": "trustLevel", "type": "tuple", "components": [ + { "name": "numerator", "type": "uint8" }, + { "name": "denominator", "type": "uint8" } + ]}, + { "name": "latestHeight", "type": "tuple", "components": [ + { "name": "revisionNumber", "type": "uint32" }, + { "name": "revisionHeight", "type": "uint32" } + ]}, + { "name": "trustingPeriod", "type": "uint32" }, + { "name": "unbondingPeriod", "type": "uint32" }, + { "name": "isFrozen", "type": "bool" }, + { "name": "zkAlgorithm", "type": "uint8" } + ] + }] + }]` + + // Parse the ABI + parsedABI, err := abi.JSON(strings.NewReader(abiJSON)) + if err != nil { + log.Fatalf("Failed to parse ABI: %v", err) + } + + fmt.Println("ABI successfully parsed") + + // var clientState sp1ics07tendermint.IICS07TendermintMsgsClientState + clientState, err := parsedABI.Unpack("getClientState", clientStateBytes) + if err != nil { + log.Fatalf("Failed to unpack clientState: %v", err) + } + + fmt.Printf("Decoded clientState: %#v\n", clientState) +} + +// sp1ics07tendermint.IICS07TendermintMsgsClientStateABI +// { +// "type": "function", +// "name": "getClientState", +// "inputs": [], +// "outputs": [ +// { +// "name": "", +// "type": "tuple", +// "internalType": "struct IICS07TendermintMsgs.ClientState", +// "components": [ +// { +// "name": "chainId", +// "type": "string", +// "internalType": "string" +// }, +// { +// "name": "trustLevel", +// "type": "tuple", +// "internalType": "struct IICS07TendermintMsgs.TrustThreshold", +// "components": [ +// { +// "name": "numerator", +// "type": "uint8", +// "internalType": "uint8" +// }, +// { +// "name": "denominator", +// "type": "uint8", +// "internalType": "uint8" +// } +// ] +// }, +// { +// "name": "latestHeight", +// "type": "tuple", +// "internalType": "struct IICS02ClientMsgs.Height", +// "components": [ +// { +// "name": "revisionNumber", +// "type": "uint32", +// "internalType": "uint32" +// }, +// { +// "name": "revisionHeight", +// "type": "uint32", +// "internalType": "uint32" +// } +// ] +// }, +// { +// "name": "trustingPeriod", +// "type": "uint32", +// "internalType": "uint32" +// }, +// { +// "name": "unbondingPeriod", +// "type": "uint32", +// "internalType": "uint32" +// }, +// { +// "name": "isFrozen", +// "type": "bool", +// "internalType": "bool" +// }, +// { +// "name": "zkAlgorithm", +// "type": "uint8", +// "internalType": "enum ISP1Msgs.SupportedZkAlgorithm" +// } +// ] +// } +// ], +// "stateMutability": "view" +// }, From 5fd7d0314503a2b7135840116b80b5b2f8f272cc Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 22 Jan 2025 12:17:18 -0500 Subject: [PATCH 83/98] debug --- testing/demo/pkg/debug-client-state/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testing/demo/pkg/debug-client-state/main.go b/testing/demo/pkg/debug-client-state/main.go index decdb9b..93bd269 100644 --- a/testing/demo/pkg/debug-client-state/main.go +++ b/testing/demo/pkg/debug-client-state/main.go @@ -59,8 +59,15 @@ func main() { } fmt.Printf("Decoded clientState: %#v\n", clientState) + + parsedABI.Pack("getClientState") + parsedABI.Pack() + // clientState } +// Decoded clientState: []interface {}{struct { ChainId string "json:\"chainId\""; TrustLevel struct { Numerator uint8 "json:\"numerator\""; Denominator uint8 "json:\"denominator\"" } "json:\"trustLevel\""; LatestHeight struct { RevisionNumber uint32 "json:\"revisionNumber\""; RevisionHeight uint32 "json:\"revisionHeight\"" } "json:\"latestHeight\""; TrustingPeriod uint32 "json:\"trustingPeriod\""; UnbondingPeriod uint32 "json:\"unbondingPeriod\""; IsFrozen bool "json:\"isFrozen\""; ZkAlgorithm uint8 "json:\"zkAlgorithm\"" } +// {ChainId:"zkibc-demo", TrustLevel:struct { Numerator uint8 "json:\"numerator\""; Denominator uint8 "json:\"denominator\"" }{Numerator:0x1, Denominator:0x3}, LatestHeight:struct { RevisionNumber uint32 "json:\"revisionNumber\""; RevisionHeight uint32 "json:\"revisionHeight\"" }{RevisionNumber:0x0, RevisionHeight:0x5}, TrustingPeriod:0x127500, UnbondingPeriod:0x1baf80, IsFrozen:false, ZkAlgorithm:0x1}} + // sp1ics07tendermint.IICS07TendermintMsgsClientStateABI // { // "type": "function", From e4c3b17d65faaa6f93fe8fb80c419e89380e4fba Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Wed, 22 Jan 2025 12:17:34 -0500 Subject: [PATCH 84/98] delete debug client state --- testing/demo/pkg/debug-client-state/main.go | 145 -------------------- 1 file changed, 145 deletions(-) delete mode 100644 testing/demo/pkg/debug-client-state/main.go diff --git a/testing/demo/pkg/debug-client-state/main.go b/testing/demo/pkg/debug-client-state/main.go deleted file mode 100644 index 93bd269..0000000 --- a/testing/demo/pkg/debug-client-state/main.go +++ /dev/null @@ -1,145 +0,0 @@ -package main - -import ( - "encoding/hex" - "fmt" - "log" - "strings" - - "github.com/ethereum/go-ethereum/accounts/abi" -) - -func main() { - // clientState is copied from scripts/genesis.json - const clientStateHex = "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000012750000000000000000000000000000000000000000000000000000000000001baf8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a7a6b6962632d64656d6f00000000000000000000000000000000000000000000" - - clientStateBytes, err := hex.DecodeString(clientStateHex) - if err != nil { - log.Fatalf("Failed to decode clientState hex: %v", err) - } - - // ABI JSON string - abiJSON := `[{ - "type": "function", - "name": "getClientState", - "inputs": [], - "outputs": [{ - "name": "", - "type": "tuple", - "components": [ - { "name": "chainId", "type": "string" }, - { "name": "trustLevel", "type": "tuple", "components": [ - { "name": "numerator", "type": "uint8" }, - { "name": "denominator", "type": "uint8" } - ]}, - { "name": "latestHeight", "type": "tuple", "components": [ - { "name": "revisionNumber", "type": "uint32" }, - { "name": "revisionHeight", "type": "uint32" } - ]}, - { "name": "trustingPeriod", "type": "uint32" }, - { "name": "unbondingPeriod", "type": "uint32" }, - { "name": "isFrozen", "type": "bool" }, - { "name": "zkAlgorithm", "type": "uint8" } - ] - }] - }]` - - // Parse the ABI - parsedABI, err := abi.JSON(strings.NewReader(abiJSON)) - if err != nil { - log.Fatalf("Failed to parse ABI: %v", err) - } - - fmt.Println("ABI successfully parsed") - - // var clientState sp1ics07tendermint.IICS07TendermintMsgsClientState - clientState, err := parsedABI.Unpack("getClientState", clientStateBytes) - if err != nil { - log.Fatalf("Failed to unpack clientState: %v", err) - } - - fmt.Printf("Decoded clientState: %#v\n", clientState) - - parsedABI.Pack("getClientState") - parsedABI.Pack() - // clientState -} - -// Decoded clientState: []interface {}{struct { ChainId string "json:\"chainId\""; TrustLevel struct { Numerator uint8 "json:\"numerator\""; Denominator uint8 "json:\"denominator\"" } "json:\"trustLevel\""; LatestHeight struct { RevisionNumber uint32 "json:\"revisionNumber\""; RevisionHeight uint32 "json:\"revisionHeight\"" } "json:\"latestHeight\""; TrustingPeriod uint32 "json:\"trustingPeriod\""; UnbondingPeriod uint32 "json:\"unbondingPeriod\""; IsFrozen bool "json:\"isFrozen\""; ZkAlgorithm uint8 "json:\"zkAlgorithm\"" } -// {ChainId:"zkibc-demo", TrustLevel:struct { Numerator uint8 "json:\"numerator\""; Denominator uint8 "json:\"denominator\"" }{Numerator:0x1, Denominator:0x3}, LatestHeight:struct { RevisionNumber uint32 "json:\"revisionNumber\""; RevisionHeight uint32 "json:\"revisionHeight\"" }{RevisionNumber:0x0, RevisionHeight:0x5}, TrustingPeriod:0x127500, UnbondingPeriod:0x1baf80, IsFrozen:false, ZkAlgorithm:0x1}} - -// sp1ics07tendermint.IICS07TendermintMsgsClientStateABI -// { -// "type": "function", -// "name": "getClientState", -// "inputs": [], -// "outputs": [ -// { -// "name": "", -// "type": "tuple", -// "internalType": "struct IICS07TendermintMsgs.ClientState", -// "components": [ -// { -// "name": "chainId", -// "type": "string", -// "internalType": "string" -// }, -// { -// "name": "trustLevel", -// "type": "tuple", -// "internalType": "struct IICS07TendermintMsgs.TrustThreshold", -// "components": [ -// { -// "name": "numerator", -// "type": "uint8", -// "internalType": "uint8" -// }, -// { -// "name": "denominator", -// "type": "uint8", -// "internalType": "uint8" -// } -// ] -// }, -// { -// "name": "latestHeight", -// "type": "tuple", -// "internalType": "struct IICS02ClientMsgs.Height", -// "components": [ -// { -// "name": "revisionNumber", -// "type": "uint32", -// "internalType": "uint32" -// }, -// { -// "name": "revisionHeight", -// "type": "uint32", -// "internalType": "uint32" -// } -// ] -// }, -// { -// "name": "trustingPeriod", -// "type": "uint32", -// "internalType": "uint32" -// }, -// { -// "name": "unbondingPeriod", -// "type": "uint32", -// "internalType": "uint32" -// }, -// { -// "name": "isFrozen", -// "type": "bool", -// "internalType": "bool" -// }, -// { -// "name": "zkAlgorithm", -// "type": "uint8", -// "internalType": "enum ISP1Msgs.SupportedZkAlgorithm" -// } -// ] -// } -// ], -// "stateMutability": "view" -// }, From 81e0b1d81fbaee3db79ae08f35b88afc9a8cb0b4 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 23 Jan 2025 15:33:35 -0500 Subject: [PATCH 85/98] fix: lint --- provers/celestia-prover/src/main.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index 8aac755..94e04cc 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -1,6 +1,6 @@ +use sp1_sdk::HashableKey; use std::env; use std::fs; -use sp1_sdk::HashableKey; use tonic::{transport::Server, Request, Response, Status}; // Import the generated proto rust code pub mod prover { @@ -53,10 +53,12 @@ impl ProverService { #[tonic::async_trait] impl Prover for ProverService { async fn info(&self, _request: Request) -> Result, Status> { - let state_transition_verifier_key = bincode::serialize(&self.tendermint_prover.vkey.hash_bytes()) - .map_err(|e| Status::internal(e.to_string()))?; - let state_membership_verifier_key = bincode::serialize(&self.membership_prover.vkey.hash_bytes()) - .map_err(|e| Status::internal(e.to_string()))?; + let state_transition_verifier_key = + bincode::serialize(&self.tendermint_prover.vkey.hash_bytes()) + .map_err(|e| Status::internal(e.to_string()))?; + let state_membership_verifier_key = + bincode::serialize(&self.membership_prover.vkey.hash_bytes()) + .map_err(|e| Status::internal(e.to_string()))?; let response = InfoResponse { state_transition_verifier_key, state_membership_verifier_key, @@ -121,10 +123,14 @@ impl Prover for ProverService { now, ); println!("generated proof {:?}", proof.bytes()); + println!( + "generated proof public values {:?}", + proof.public_values.as_slice().to_vec() + ); let response = ProveStateTransitionResponse { proof: proof.bytes().to_vec(), - public_values: proof.public_values.to_vec(), + public_values: proof.public_values.as_slice().to_vec(), }; Ok(Response::new(response)) @@ -161,7 +167,7 @@ impl Prover for ProverService { .map_err(|e| Status::internal(e.to_string()))?; let proof = self.membership_prover.generate_proof( - &trusted_block.signed_header.header.app_hash.as_bytes(), + trusted_block.signed_header.header.app_hash.as_bytes(), key_proofs, ); From 9f1aee8ba8ab53c4a3cc45b373d2bfe66570be5d Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 23 Jan 2025 15:36:14 -0500 Subject: [PATCH 86/98] refactor: accept txhash via CLI argument --- testing/demo/pkg/debug-txhash/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/debug-txhash/main.go b/testing/demo/pkg/debug-txhash/main.go index 6c414f3..40fc3a2 100644 --- a/testing/demo/pkg/debug-txhash/main.go +++ b/testing/demo/pkg/debug-txhash/main.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "log" + "os" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rpc" @@ -23,7 +24,10 @@ func getRevertReason(txHash ethcommon.Hash, rpcURL string) []byte { } func main() { - txHash := ethcommon.HexToHash("0xd69bfa0dc9cd1bf69c2dc38e15a6771354fd387a084e2cb4604f187c55c862a1") + if len(os.Args) < 2 { + log.Fatalf("Usage: %s ", os.Args[0]) + } + txHash := ethcommon.HexToHash(os.Args[1]) rpcURL := "http://localhost:8545/" result := getRevertReason(txHash, rpcURL) fmt.Printf("result %v\n", string(result)) From 4ce4b7f50299c1045de9326fe3d3986974322e19 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 23 Jan 2025 16:16:09 -0500 Subject: [PATCH 87/98] debug: verify that public values are within field --- provers/celestia-prover/Cargo.toml | 6 ++-- provers/celestia-prover/src/main.rs | 52 +++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/provers/celestia-prover/Cargo.toml b/provers/celestia-prover/Cargo.toml index 887d2c1..9001ee7 100644 --- a/provers/celestia-prover/Cargo.toml +++ b/provers/celestia-prover/Cargo.toml @@ -17,15 +17,17 @@ alloy-provider = { workspace = true } ibc-eureka-solidity-types.workspace = true sp1-ics07-tendermint-prover.workspace = true sp1-ics07-tendermint-utils.workspace = true -ibc-core-commitment-types = { workspace = true } +ibc-core-commitment-types = { workspace = true } dotenv = "0.15.0" anyhow = "1.0.94" sp1-prover = "3.4.0" bincode = "1.3.3" -sp1-sdk = { workspace = true, features = ["network"] } +sp1-sdk = { workspace = true, features = ["network"] } ibc-proto = { workspace = true } tracing = { workspace = true } serde_cbor = "0.11.2" +hex = "0.4" +num-bigint = "0.4" [build-dependencies] tonic-build = { workspace = true } diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index 94e04cc..b1880ac 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -25,6 +25,8 @@ use ibc_core_commitment_types::merkle::MerkleProof; use ibc_eureka_solidity_types::sp1_ics07::{ sp1_ics07_tendermint, IICS07TendermintMsgs::ConsensusState, }; +use num_bigint::BigInt; +use num_bigint::Sign; use reqwest::Url; use sp1_ics07_tendermint_utils::{light_block::LightBlockExt, rpc::TendermintRpcExt}; use tendermint_rpc::HttpClient; @@ -122,15 +124,53 @@ impl Prover for ProverService { &proposed_header, now, ); - println!("generated proof {:?}", proof.bytes()); - println!( - "generated proof public values {:?}", - proof.public_values.as_slice().to_vec() - ); + + // Add field reduction and detailed logging + let bn254_field_modulus = BigInt::parse_bytes( + b"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", + 16, + ) + .expect("could not parse bn254 field modules as bytes"); + + let reduced_public_values: Vec = proof + .public_values + .as_slice() + .iter() + .flat_map(|value| { + let value_bigint = BigInt::from_bytes_be(Sign::Plus, &[*value]); + let reduced = value_bigint % &bn254_field_modulus; + reduced.to_bytes_be().1 + }) + .collect(); + + println!("Original public values:"); + for (i, val) in proof.public_values.as_slice().iter().enumerate() { + println!("Input {}: 0x{}", i, hex::encode(&[*val])); + } + + println!("\nReduced public values:"); + for (i, val) in reduced_public_values.iter().enumerate() { + println!("Input {}: 0x{}", i, hex::encode(&[*val])); + } + + assert_eq!(proof.public_values.as_slice(), reduced_public_values); + + let result = self + .tendermint_prover + .prover_client + .verify(&proof, &self.tendermint_prover.vkey); + match result { + Ok(val) => { + println!("proof verified {:?}", val) + } + Err(error) => { + println!("proof failed to verify {:?}", error); + } + } let response = ProveStateTransitionResponse { proof: proof.bytes().to_vec(), - public_values: proof.public_values.as_slice().to_vec(), + public_values: reduced_public_values, }; Ok(Response::new(response)) From db27e82ddb0f188c9807d9f973205e71d3c91da9 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 23 Jan 2025 17:30:43 -0500 Subject: [PATCH 88/98] fix: use hex encoded verifier key --- proto/prover/v1/prover.proto | 6 ++-- provers/celestia-prover/src/main.rs | 56 +++-------------------------- provers/client/prover.pb.go | 18 +++++----- testing/demo/pkg/relay-v2/main.go | 8 +++-- 4 files changed, 25 insertions(+), 63 deletions(-) diff --git a/proto/prover/v1/prover.proto b/proto/prover/v1/prover.proto index 1b6ae4c..450f7e3 100644 --- a/proto/prover/v1/prover.proto +++ b/proto/prover/v1/prover.proto @@ -15,8 +15,10 @@ message InfoRequest { message InfoResponse { // TODO: add more info here as is relevant such as the circuit and state machine types - bytes state_transition_verifier_key = 1; - bytes state_membership_verifier_key = 2; + // hex-encoded state transition verifier key + string state_transition_verifier_key = 1; + // hex-encoded state membership verifier key + string state_membership_verifier_key = 2; } message ProveStateTransitionRequest { diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index b1880ac..4a10207 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -25,8 +25,6 @@ use ibc_core_commitment_types::merkle::MerkleProof; use ibc_eureka_solidity_types::sp1_ics07::{ sp1_ics07_tendermint, IICS07TendermintMsgs::ConsensusState, }; -use num_bigint::BigInt; -use num_bigint::Sign; use reqwest::Url; use sp1_ics07_tendermint_utils::{light_block::LightBlockExt, rpc::TendermintRpcExt}; use tendermint_rpc::HttpClient; @@ -55,12 +53,8 @@ impl ProverService { #[tonic::async_trait] impl Prover for ProverService { async fn info(&self, _request: Request) -> Result, Status> { - let state_transition_verifier_key = - bincode::serialize(&self.tendermint_prover.vkey.hash_bytes()) - .map_err(|e| Status::internal(e.to_string()))?; - let state_membership_verifier_key = - bincode::serialize(&self.membership_prover.vkey.hash_bytes()) - .map_err(|e| Status::internal(e.to_string()))?; + let state_transition_verifier_key = self.tendermint_prover.vkey.bytes32(); + let state_membership_verifier_key = self.membership_prover.vkey.bytes32(); let response = InfoResponse { state_transition_verifier_key, state_membership_verifier_key, @@ -125,52 +119,12 @@ impl Prover for ProverService { now, ); - // Add field reduction and detailed logging - let bn254_field_modulus = BigInt::parse_bytes( - b"30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001", - 16, - ) - .expect("could not parse bn254 field modules as bytes"); - - let reduced_public_values: Vec = proof - .public_values - .as_slice() - .iter() - .flat_map(|value| { - let value_bigint = BigInt::from_bytes_be(Sign::Plus, &[*value]); - let reduced = value_bigint % &bn254_field_modulus; - reduced.to_bytes_be().1 - }) - .collect(); - - println!("Original public values:"); - for (i, val) in proof.public_values.as_slice().iter().enumerate() { - println!("Input {}: 0x{}", i, hex::encode(&[*val])); - } - - println!("\nReduced public values:"); - for (i, val) in reduced_public_values.iter().enumerate() { - println!("Input {}: 0x{}", i, hex::encode(&[*val])); - } - - assert_eq!(proof.public_values.as_slice(), reduced_public_values); - - let result = self - .tendermint_prover - .prover_client - .verify(&proof, &self.tendermint_prover.vkey); - match result { - Ok(val) => { - println!("proof verified {:?}", val) - } - Err(error) => { - println!("proof failed to verify {:?}", error); - } - } + let hash = proof.public_values.hash_bn254().to_string(); + println!("public values hash bn254 {:?}", hash); let response = ProveStateTransitionResponse { proof: proof.bytes().to_vec(), - public_values: reduced_public_values, + public_values: proof.public_values.to_vec(), }; Ok(Response::new(response)) diff --git a/provers/client/prover.pb.go b/provers/client/prover.pb.go index f3f4388..093d59b 100644 --- a/provers/client/prover.pb.go +++ b/provers/client/prover.pb.go @@ -64,8 +64,10 @@ type InfoResponse struct { unknownFields protoimpl.UnknownFields // TODO: add more info here as is relevant such as the circuit and state machine types - StateTransitionVerifierKey []byte `protobuf:"bytes,1,opt,name=state_transition_verifier_key,json=stateTransitionVerifierKey,proto3" json:"state_transition_verifier_key,omitempty"` - StateMembershipVerifierKey []byte `protobuf:"bytes,2,opt,name=state_membership_verifier_key,json=stateMembershipVerifierKey,proto3" json:"state_membership_verifier_key,omitempty"` + // hex-encoded state transition verifier key + StateTransitionVerifierKey string `protobuf:"bytes,1,opt,name=state_transition_verifier_key,json=stateTransitionVerifierKey,proto3" json:"state_transition_verifier_key,omitempty"` + // hex-encoded state membership verifier key + StateMembershipVerifierKey string `protobuf:"bytes,2,opt,name=state_membership_verifier_key,json=stateMembershipVerifierKey,proto3" json:"state_membership_verifier_key,omitempty"` } func (x *InfoResponse) Reset() { @@ -100,18 +102,18 @@ func (*InfoResponse) Descriptor() ([]byte, []int) { return file_prover_v1_prover_proto_rawDescGZIP(), []int{1} } -func (x *InfoResponse) GetStateTransitionVerifierKey() []byte { +func (x *InfoResponse) GetStateTransitionVerifierKey() string { if x != nil { return x.StateTransitionVerifierKey } - return nil + return "" } -func (x *InfoResponse) GetStateMembershipVerifierKey() []byte { +func (x *InfoResponse) GetStateMembershipVerifierKey() string { if x != nil { return x.StateMembershipVerifierKey } - return nil + return "" } type ProveStateTransitionRequest struct { @@ -337,11 +339,11 @@ var file_prover_v1_prover_proto_rawDesc = []byte{ 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x1d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, + 0x01, 0x28, 0x09, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x73, 0x74, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x22, 0x3a, 0x0a, 0x1b, 0x50, 0x72, 0x6f, 0x76, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index b1fcb3d..c52e55d 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -111,10 +111,14 @@ func updateTendermintLightClient() error { return fmt.Errorf("failed to get celestia prover info %w", err) } verifierKey := info.StateTransitionVerifierKey - fmt.Printf("Got celestia prover info. State transition verifier key %v, hex encoded %v\n", verifierKey, hex.EncodeToString(verifierKey)) + fmt.Printf("Got celestia prover info. State transition verifier key %v", verifierKey) + result, err := hex.DecodeString(strings.TrimLeft(verifierKey, "0x")) + if err != nil { + return fmt.Errorf("failed to decode verifier key %w", err) + } // Convert the verifierKey byte slice into a [32]byte array var VKey [32]byte - copy(VKey[:], verifierKey) + copy(VKey[:], result) request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} // Get state transition proof from Celestia prover with retry logic From 4f8dd6cbd67b333e08d3017db997c9975fedfd0c Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 23 Jan 2025 17:46:44 -0500 Subject: [PATCH 89/98] fix: verifier key --- testing/demo/pkg/relay-v2/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go index c52e55d..d39ab7f 100644 --- a/testing/demo/pkg/relay-v2/main.go +++ b/testing/demo/pkg/relay-v2/main.go @@ -112,13 +112,15 @@ func updateTendermintLightClient() error { } verifierKey := info.StateTransitionVerifierKey fmt.Printf("Got celestia prover info. State transition verifier key %v", verifierKey) - result, err := hex.DecodeString(strings.TrimLeft(verifierKey, "0x")) + trimmed := strings.TrimPrefix(verifierKey, "0x") + result, err := hex.DecodeString(trimmed) if err != nil { return fmt.Errorf("failed to decode verifier key %w", err) } // Convert the verifierKey byte slice into a [32]byte array var VKey [32]byte copy(VKey[:], result) + fmt.Printf("VKey %v\n", VKey) request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} // Get state transition proof from Celestia prover with retry logic From 1c0895727f039c9bda34819ab0042917f2f58fce Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 09:54:48 -0500 Subject: [PATCH 90/98] refactor: rename relay2 to relay --- Makefile | 10 +- README.md | 11 +- testing/demo/pkg/relay-v2/main.go | 359 ----------------------------- testing/demo/pkg/relay/main.go | 367 ++++++++++++++++++++++++------ 4 files changed, 306 insertions(+), 441 deletions(-) delete mode 100644 testing/demo/pkg/relay-v2/main.go diff --git a/Makefile b/Makefile index 96d4f9c..0369745 100644 --- a/Makefile +++ b/Makefile @@ -94,13 +94,7 @@ transfer: relay: # Note: this is split out from transfer to speed up local development. This # command can be merged into transfer to make the demo fewer steps to run. - @echo "--> Relaying the token transfer" - @go run ./testing/demo/pkg/relay/ -.PHONY: relay - -## relay2: Relay the token transfer from simapp to the EVM roll-up. -relay2: - go run testing/demo/pkg/relay-v2/main.go + go run testing/demo/pkg/relay/main.go .PHONY: relay ## stop: Stop all processes and remove the tmp directory. @@ -238,5 +232,5 @@ demo: @make start @make setup @make transfer - @make relay2 + @make relay .PHONY: demo diff --git a/README.md b/README.md index 97154ed..8f9ee6b 100644 --- a/README.md +++ b/README.md @@ -62,15 +62,14 @@ For more information refer to the [architecture document](./ARCHITECTURE.md). No make setup ``` -1. Transfer tokens from SimApp to the EVM roll-up. +1. Run the demo ```shell + # Transfer tokens from SimApp to the EVM roll-up. make transfer - ``` - -1. To stop and teardown the test environment (when you're finished) - - ```shell + # Relay the token transfer + make relay + # To stop and teardown the test environment (when you're finished) make stop ``` diff --git a/testing/demo/pkg/relay-v2/main.go b/testing/demo/pkg/relay-v2/main.go deleted file mode 100644 index d39ab7f..0000000 --- a/testing/demo/pkg/relay-v2/main.go +++ /dev/null @@ -1,359 +0,0 @@ -package main - -import ( - "context" - "crypto/ecdsa" - "encoding/hex" - "fmt" - "log" - "math/big" - "strings" - "time" - - "cosmossdk.io/math" - proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" - "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" - sdktypes "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" - ibctesting "github.com/cosmos/ibc-go/v9/testing" - "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" - "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" - "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" - "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - ethcommon "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" - "google.golang.org/grpc" -) - -// TODO: fetch these from the `make setup` command output. -// const ( -// ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" -// icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" -// ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" -// ) - -const ( - // sender is an address on SimApp that will send funds via the MsgTransfer. - sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" - // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. - receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" - // denom is the denomination of the token on SimApp. - denom = "stake" - // sourceChannel is hard-coded to the name used by the first channel. - sourceChannel = ibctesting.FirstChannelID - // sequence is hard-coded to the first sequence number. - sequence = 1 - // ethereumRPC is the Reth RPC endpoint. - ethereumRPC = "http://localhost:8545/" - // ethereumAddress is an address on the EVM chain. - // ethereumAddress = "0xaF9053bB6c4346381C77C2FeD279B17ABAfCDf4d" - // ethPrivateKey is the private key for ethereumAddress. - ethPrivateKey = "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" - // cliendID is for the SP1 Tendermint light client on the EVM roll-up. - clientID = "07-tendermint-0" -) - -func main() { - err := updateTendermintLightClient() - if err != nil { - log.Fatal(err) - } - - // err = receivePacketOnEVM() - // if err != nil { - // log.Fatal(err) - // } -} - -// updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. -func updateTendermintLightClient() error { - addresses, err := utils.ExtractDeployedContractAddresses() - if err != nil { - return err - } - fmt.Printf("addresses %v\n", addresses) - - ethClient, err := ethclient.Dial(ethereumRPC) - if err != nil { - return err - } - icsCore, err := icscore.NewContract(ethcommon.HexToAddress(addresses.ICSCore), ethClient) - if err != nil { - return err - } - faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) - if err != nil { - return err - } - eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) - if err != nil { - return err - } - - // Connect to the Celestia prover - conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) - if err != nil { - return fmt.Errorf("failed to connect to prover: %w", err) - } - defer conn.Close() - - fmt.Printf("Getting celestia prover info...\n") - proverClient := proverclient.NewProverClient(conn) - info, err := proverClient.Info(context.Background(), &proverclient.InfoRequest{}) - if err != nil { - return fmt.Errorf("failed to get celestia prover info %w", err) - } - verifierKey := info.StateTransitionVerifierKey - fmt.Printf("Got celestia prover info. State transition verifier key %v", verifierKey) - trimmed := strings.TrimPrefix(verifierKey, "0x") - result, err := hex.DecodeString(trimmed) - if err != nil { - return fmt.Errorf("failed to decode verifier key %w", err) - } - // Convert the verifierKey byte slice into a [32]byte array - var VKey [32]byte - copy(VKey[:], result) - fmt.Printf("VKey %v\n", VKey) - - request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} - // Get state transition proof from Celestia prover with retry logic - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) - defer cancel() - var resp *proverclient.ProveStateTransitionResponse - for retries := 0; retries < 3; retries++ { - resp, err = proverClient.ProveStateTransition(ctx, request) - if err == nil { - break - } - if ctx.Err() != nil { - return fmt.Errorf("context cancelled while getting state transition proof: %w", ctx.Err()) - } - time.Sleep(time.Second * time.Duration(retries+1)) - } - if err != nil { - return fmt.Errorf("failed to get state transition proof after retries: %w", err) - } - fmt.Printf("got resp %v\n", resp) - fmt.Printf("got resp.proof %v\n", hex.EncodeToString(resp.Proof)) - - msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ - Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ - VKey: VKey, - PublicValues: resp.PublicValues, - Proof: resp.Proof, - }, - } - - arguments, err := getUpdateClientArguments() - if err != nil { - return err - } - fmt.Printf("Packing msg...\n") - encoded, err := arguments.Pack(msg) - if err != nil { - return fmt.Errorf("error packing msg %w", err) - } - fmt.Printf("Pcaked msg %v\n", encoded) - - fmt.Printf("Invoking icsCore.UpdateClient...\n") - tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, encoded) - if err != nil { - return err - } - fmt.Printf("icsCore.UpdateClient did not error\n") - receipt := getTxReciept(context.Background(), eth, tx.Hash()) - if ethtypes.ReceiptStatusSuccessful != receipt.Status { - fmt.Printf("receipt %v\n", receipt) - fmt.Printf("receipt logs %v\n", receipt.Logs) - return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) - } - recvBlockNumber := receipt.BlockNumber.Uint64() - fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) - return nil -} - -func receivePacketOnEVM() error { - addresses, err := utils.ExtractDeployedContractAddresses() - if err != nil { - return err - } - - sendPacket, err := createSendPacket() - if err != nil { - return err - } - - packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) - fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) - - packet := ics26router.IICS26RouterMsgsPacket{ - Sequence: uint32(sendPacket.Sequence), - SourceChannel: sendPacket.SourceChannel, - DestChannel: sendPacket.DestinationChannel, - TimeoutTimestamp: sendPacket.TimeoutTimestamp, - Payloads: []ics26router.IICS26RouterMsgsPayload{ - { - SourcePort: sendPacket.Payloads[0].SourcePort, - DestPort: sendPacket.Payloads[0].DestinationPort, - Version: transfertypes.V1, - Encoding: transfertypes.EncodingABI, - Value: sendPacket.Payloads[0].Value, - }, - }, - } - - // TODO: replace this with query to celestia-prover after mock circuits - // are implemented. - membershipProof := []byte{} - - // TODO: replace this with a real proof height. - proofHeight := ics26router.IICS02ClientMsgsHeight{ - RevisionNumber: uint32(0), - RevisionHeight: uint32(10), - } - msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ - Packet: packet, - ProofCommitment: membershipProof, - ProofHeight: proofHeight, - } - - ethClient, err := ethclient.Dial(ethereumRPC) - if err != nil { - return err - } - ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(addresses.ICS26Router), ethClient) - if err != nil { - return err - } - - faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) - if err != nil { - return err - } - eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) - if err != nil { - return err - } - tx, err := ics26Contract.RecvPacket(getTransactOpts(faucet, eth), msg) - if err != nil { - return err - } - - receipt := getTxReciept(context.Background(), eth, tx.Hash()) - if ethtypes.ReceiptStatusSuccessful != receipt.Status { - return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) - } - recvBlockNumber := receipt.BlockNumber.Uint64() - fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) - return nil -} - -// TODO: refactor this to de-duplicate code from createMsgSendPacket -func createSendPacket() (channeltypesv2.Packet, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(100)) - transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ - Denom: coin.Denom, - Amount: coin.Amount.BigInt(), - Sender: sender, - Receiver: receiver, - Memo: "test transfer", - } - transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) - if err != nil { - return channeltypesv2.Packet{}, err - } - payload := channeltypesv2.Payload{ - SourcePort: transfertypes.PortID, - DestinationPort: transfertypes.PortID, - Version: transfertypes.V1, - Encoding: transfertypes.EncodingABI, - Value: transferBz, - } - - return channeltypesv2.Packet{ - Sequence: sequence, - SourceChannel: ibctesting.FirstChannelID, - DestinationChannel: ibctesting.FirstClientID, - TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), - Payloads: []channeltypesv2.Payload{payload}, - }, nil -} - -func getTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { - ethClient, err := ethclient.Dial(chain.RPC) - if err != nil { - log.Fatal(err) - } - - fromAddress := crypto.PubkeyToAddress(key.PublicKey) - nonce, err := ethClient.PendingNonceAt(context.Background(), fromAddress) - if err != nil { - nonce = 0 - } - - gasPrice, err := ethClient.SuggestGasPrice(context.Background()) - if err != nil { - panic(err) - } - - txOpts, err := bind.NewKeyedTransactorWithChainID(key, chain.ChainID) - if err != nil { - log.Fatal(err) - } - txOpts.Nonce = big.NewInt(int64(nonce)) - txOpts.GasPrice = gasPrice - - // Set a specific gas limit - txOpts.GasLimit = 3000000 // Example gas limit; adjust as needed - - return txOpts -} - -func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.Hash) *ethtypes.Receipt { - ethClient, err := ethclient.Dial(chain.RPC) - if err != nil { - log.Fatal(err) - } - - var receipt *ethtypes.Receipt - err = utils.WaitForCondition(time.Second*30, time.Second, func() (bool, error) { - receipt, err = ethClient.TransactionReceipt(ctx, hash) - if err != nil { - return false, nil - } - - return receipt != nil, nil - }) - if err != nil { - log.Fatalf("Failed to fetch receipt: %v", err) - } - - // Log more details about the receipt - fmt.Printf("Transaction hash: %s\n", hash.Hex()) - fmt.Printf("Block number: %d\n", receipt.BlockNumber.Uint64()) - fmt.Printf("Gas used: %d\n", receipt.GasUsed) - fmt.Printf("Logs: %v\n", receipt.Logs) - if receipt.Status != ethtypes.ReceiptStatusSuccessful { - fmt.Println("Transaction failed. Inspect logs or contract.") - } - - return receipt -} - -func getUpdateClientArguments() (abi.Arguments, error) { - var updateClientABI = "[{\"type\":\"function\",\"name\":\"updateClient\",\"stateMutability\":\"pure\",\"inputs\":[{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"struct IUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"struct ISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[]}]" - - parsed, err := abi.JSON(strings.NewReader(updateClientABI)) - if err != nil { - return nil, err - } - - return parsed.Methods["updateClient"].Inputs, nil -} diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 45d1817..d39ab7f 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -2,127 +2,358 @@ package main import ( "context" + "crypto/ecdsa" + "encoding/hex" "fmt" "log" + "math/big" + "strings" "time" + "cosmossdk.io/math" proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" + sdktypes "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" + ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" + ibctesting "github.com/cosmos/ibc-go/v9/testing" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" + "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" + "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" + "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + ethcommon "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" ) +// TODO: fetch these from the `make setup` command output. +// const ( +// ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" +// icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" +// ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" +// ) + const ( - // celestiaProverEndpoint is the endpoint of the Celestia prover. - celestiaProverEndpoint = "localhost:50051" - // channelID is the channel ID on SimApp. - // TODO: fetch this from the `make setup` command output. - channelID = "channel-0" - // ics07TMContractAddress is the contract address of the ICS07 light client on the EVM roll-up. - // TODO: fetch this from the `make setup` command output. - ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" + // sender is an address on SimApp that will send funds via the MsgTransfer. + sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" + // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. + receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" + // denom is the denomination of the token on SimApp. + denom = "stake" + // sourceChannel is hard-coded to the name used by the first channel. + sourceChannel = ibctesting.FirstChannelID + // sequence is hard-coded to the first sequence number. + sequence = 1 + // ethereumRPC is the Reth RPC endpoint. + ethereumRPC = "http://localhost:8545/" + // ethereumAddress is an address on the EVM chain. + // ethereumAddress = "0xaF9053bB6c4346381C77C2FeD279B17ABAfCDf4d" + // ethPrivateKey is the private key for ethereumAddress. + ethPrivateKey = "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" + // cliendID is for the SP1 Tendermint light client on the EVM roll-up. + clientID = "07-tendermint-0" ) func main() { - // Ask the Celestia prover for a state transition proof. - _, err := GetStateTransitionProof() + err := updateTendermintLightClient() if err != nil { log.Fatal(err) } - packetResp, err := QueryPacketCommitments() + // err = receivePacketOnEVM() + // if err != nil { + // log.Fatal(err) + // } +} + +// updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. +func updateTendermintLightClient() error { + addresses, err := utils.ExtractDeployedContractAddresses() if err != nil { - log.Fatal(err) + return err } + fmt.Printf("addresses %v\n", addresses) - // Ask the Celestia prover for a state membership proof that the packet - // commitments are part of the state root at a particular block height. - _, err = GetMembershipProof(packetResp) + ethClient, err := ethclient.Dial(ethereumRPC) if err != nil { - log.Fatal(err) + return err + } + icsCore, err := icscore.NewContract(ethcommon.HexToAddress(addresses.ICSCore), ethClient) + if err != nil { + return err + } + faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) + if err != nil { + return err + } + eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) + if err != nil { + return err } -} + // Connect to the Celestia prover + conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) + if err != nil { + return fmt.Errorf("failed to connect to prover: %w", err) + } + defer conn.Close() -// QueryPacketCommitments queries the packet commitments on the SimApp. -func QueryPacketCommitments() (*channeltypesv2.QueryPacketCommitmentsResponse, error) { - fmt.Printf("Querying packet commitments on SimApp...\n") + fmt.Printf("Getting celestia prover info...\n") + proverClient := proverclient.NewProverClient(conn) + info, err := proverClient.Info(context.Background(), &proverclient.InfoRequest{}) + if err != nil { + return fmt.Errorf("failed to get celestia prover info %w", err) + } + verifierKey := info.StateTransitionVerifierKey + fmt.Printf("Got celestia prover info. State transition verifier key %v", verifierKey) + trimmed := strings.TrimPrefix(verifierKey, "0x") + result, err := hex.DecodeString(trimmed) + if err != nil { + return fmt.Errorf("failed to decode verifier key %w", err) + } + // Convert the verifierKey byte slice into a [32]byte array + var VKey [32]byte + copy(VKey[:], result) + fmt.Printf("VKey %v\n", VKey) - clientCtx, err := utils.SetupClientContext() + request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} + // Get state transition proof from Celestia prover with retry logic + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + var resp *proverclient.ProveStateTransitionResponse + for retries := 0; retries < 3; retries++ { + resp, err = proverClient.ProveStateTransition(ctx, request) + if err == nil { + break + } + if ctx.Err() != nil { + return fmt.Errorf("context cancelled while getting state transition proof: %w", ctx.Err()) + } + time.Sleep(time.Second * time.Duration(retries+1)) + } if err != nil { - return nil, err + return fmt.Errorf("failed to get state transition proof after retries: %w", err) + } + fmt.Printf("got resp %v\n", resp) + fmt.Printf("got resp.proof %v\n", hex.EncodeToString(resp.Proof)) + + msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ + Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + VKey: VKey, + PublicValues: resp.PublicValues, + Proof: resp.Proof, + }, } - queryClient := channeltypesv2.NewQueryClient(clientCtx) - request := channeltypesv2.QueryPacketCommitmentsRequest{ChannelId: channelID} - response, err := queryClient.PacketCommitments(context.Background(), &request) + arguments, err := getUpdateClientArguments() + if err != nil { + return err + } + fmt.Printf("Packing msg...\n") + encoded, err := arguments.Pack(msg) if err != nil { - return nil, fmt.Errorf("failed to query packet commitments: %v", err) + return fmt.Errorf("error packing msg %w", err) } + fmt.Printf("Pcaked msg %v\n", encoded) - fmt.Printf("Packet commitments: %v, packet height %v\n", response.GetCommitments(), response.GetHeight()) - return response, nil + fmt.Printf("Invoking icsCore.UpdateClient...\n") + tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, encoded) + if err != nil { + return err + } + fmt.Printf("icsCore.UpdateClient did not error\n") + receipt := getTxReciept(context.Background(), eth, tx.Hash()) + if ethtypes.ReceiptStatusSuccessful != receipt.Status { + fmt.Printf("receipt %v\n", receipt) + fmt.Printf("receipt logs %v\n", receipt.Logs) + return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) + } + recvBlockNumber := receipt.BlockNumber.Uint64() + fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) + return nil } -// GetStateTransitionProof returns a state transition proof from the Celestia -// prover. The prover will query the Tendermint light client on the EVM roll-up -// for it's last known height and generate a proof from that height all the way -// up to the latest height on SimApp. -func GetStateTransitionProof() (proof []byte, err error) { - conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) +func receivePacketOnEVM() error { + addresses, err := utils.ExtractDeployedContractAddresses() if err != nil { - log.Fatalf("Failed to connect to the prover service: %v", err) + return err } - defer conn.Close() - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) - defer cancel() + sendPacket, err := createSendPacket() + if err != nil { + return err + } + + packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) + fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) + + packet := ics26router.IICS26RouterMsgsPacket{ + Sequence: uint32(sendPacket.Sequence), + SourceChannel: sendPacket.SourceChannel, + DestChannel: sendPacket.DestinationChannel, + TimeoutTimestamp: sendPacket.TimeoutTimestamp, + Payloads: []ics26router.IICS26RouterMsgsPayload{ + { + SourcePort: sendPacket.Payloads[0].SourcePort, + DestPort: sendPacket.Payloads[0].DestinationPort, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingABI, + Value: sendPacket.Payloads[0].Value, + }, + }, + } - client := proverclient.NewProverClient(conn) - request := &proverclient.ProveStateTransitionRequest{ClientId: ics07TMContractAddress} + // TODO: replace this with query to celestia-prover after mock circuits + // are implemented. + membershipProof := []byte{} - resp, err := client.ProveStateTransition(ctx, request) + // TODO: replace this with a real proof height. + proofHeight := ics26router.IICS02ClientMsgsHeight{ + RevisionNumber: uint32(0), + RevisionHeight: uint32(10), + } + msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ + Packet: packet, + ProofCommitment: membershipProof, + ProofHeight: proofHeight, + } + + ethClient, err := ethclient.Dial(ethereumRPC) + if err != nil { + return err + } + ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(addresses.ICS26Router), ethClient) if err != nil { - return []byte{}, fmt.Errorf("failed to request state transition proof: %w", err) + return err } - fmt.Printf("Got state transition proof: %x, public values %v\n", resp.GetProof(), resp.GetPublicValues()) - return resp.GetProof(), nil + faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) + if err != nil { + return err + } + eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) + if err != nil { + return err + } + tx, err := ics26Contract.RecvPacket(getTransactOpts(faucet, eth), msg) + if err != nil { + return err + } + + receipt := getTxReciept(context.Background(), eth, tx.Hash()) + if ethtypes.ReceiptStatusSuccessful != receipt.Status { + return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) + } + recvBlockNumber := receipt.BlockNumber.Uint64() + fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) + return nil } -// GetMembershipProof gets a membership proof that the packets in the input are -// present in the state root at the input block height on SimApp. -func GetMembershipProof(input *channeltypesv2.QueryPacketCommitmentsResponse) (proof []byte, err error) { - conn, err := grpc.NewClient(celestiaProverEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials())) +// TODO: refactor this to de-duplicate code from createMsgSendPacket +func createSendPacket() (channeltypesv2.Packet, error) { + coin := sdktypes.NewCoin(denom, math.NewInt(100)) + transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ + Denom: coin.Denom, + Amount: coin.Amount.BigInt(), + Sender: sender, + Receiver: receiver, + Memo: "test transfer", + } + transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) if err != nil { - return []byte{}, fmt.Errorf("failed to connect to the prover service: %w", err) + return channeltypesv2.Packet{}, err + } + payload := channeltypesv2.Payload{ + SourcePort: transfertypes.PortID, + DestinationPort: transfertypes.PortID, + Version: transfertypes.V1, + Encoding: transfertypes.EncodingABI, + Value: transferBz, + } + + return channeltypesv2.Packet{ + Sequence: sequence, + SourceChannel: ibctesting.FirstChannelID, + DestinationChannel: ibctesting.FirstClientID, + TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), + Payloads: []channeltypesv2.Payload{payload}, + }, nil +} + +func getTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { + ethClient, err := ethclient.Dial(chain.RPC) + if err != nil { + log.Fatal(err) } - defer conn.Close() - client := proverclient.NewProverClient(conn) - // Are packet commitments the correct data type to be proving here? - // TODO: investigate existing IBC relayer implementations. - request := &proverclient.ProveStateMembershipRequest{ - Height: int64(input.GetHeight().RevisionHeight), - KeyPaths: getKeyPaths(input.Commitments), + fromAddress := crypto.PubkeyToAddress(key.PublicKey) + nonce, err := ethClient.PendingNonceAt(context.Background(), fromAddress) + if err != nil { + nonce = 0 } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*60) - defer cancel() + gasPrice, err := ethClient.SuggestGasPrice(context.Background()) + if err != nil { + panic(err) + } + + txOpts, err := bind.NewKeyedTransactorWithChainID(key, chain.ChainID) + if err != nil { + log.Fatal(err) + } + txOpts.Nonce = big.NewInt(int64(nonce)) + txOpts.GasPrice = gasPrice + + // Set a specific gas limit + txOpts.GasLimit = 3000000 // Example gas limit; adjust as needed + + return txOpts +} + +func getTxReciept(ctx context.Context, chain ethereum.Ethereum, hash ethcommon.Hash) *ethtypes.Receipt { + ethClient, err := ethclient.Dial(chain.RPC) + if err != nil { + log.Fatal(err) + } + + var receipt *ethtypes.Receipt + err = utils.WaitForCondition(time.Second*30, time.Second, func() (bool, error) { + receipt, err = ethClient.TransactionReceipt(ctx, hash) + if err != nil { + return false, nil + } - response, err := client.ProveStateMembership(ctx, request) + return receipt != nil, nil + }) if err != nil { - return []byte{}, fmt.Errorf("failed to request state membership proof: %w", err) + log.Fatalf("Failed to fetch receipt: %v", err) + } + + // Log more details about the receipt + fmt.Printf("Transaction hash: %s\n", hash.Hex()) + fmt.Printf("Block number: %d\n", receipt.BlockNumber.Uint64()) + fmt.Printf("Gas used: %d\n", receipt.GasUsed) + fmt.Printf("Logs: %v\n", receipt.Logs) + if receipt.Status != ethtypes.ReceiptStatusSuccessful { + fmt.Println("Transaction failed. Inspect logs or contract.") } - fmt.Printf("Got membership proof: %x, height %v\n", response.GetProof(), response.GetHeight()) - return response.GetProof(), nil + return receipt } -// getKeyPaths returns a list of strings where each string is a Merkle path for -// a leaf to the state root. -func getKeyPaths(_ []*channeltypesv2.PacketState) []string { - // TODO: implement - return []string{} +func getUpdateClientArguments() (abi.Arguments, error) { + var updateClientABI = "[{\"type\":\"function\",\"name\":\"updateClient\",\"stateMutability\":\"pure\",\"inputs\":[{\"name\":\"o3\",\"type\":\"tuple\",\"internalType\":\"struct IUpdateClientMsgs.MsgUpdateClient\",\"components\":[{\"name\":\"sp1Proof\",\"type\":\"tuple\",\"internalType\":\"struct ISP1Msgs.SP1Proof\",\"components\":[{\"name\":\"vKey\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"publicValues\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"proof\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]}],\"outputs\":[]}]" + + parsed, err := abi.JSON(strings.NewReader(updateClientABI)) + if err != nil { + return nil, err + } + + return parsed.Methods["updateClient"].Inputs, nil } From 9578a3afdea8d8338653f90e16fe4ff4c68fbf8a Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 09:56:46 -0500 Subject: [PATCH 91/98] chore: remove unused deps --- provers/celestia-prover/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/provers/celestia-prover/Cargo.toml b/provers/celestia-prover/Cargo.toml index 9001ee7..86a5983 100644 --- a/provers/celestia-prover/Cargo.toml +++ b/provers/celestia-prover/Cargo.toml @@ -26,8 +26,6 @@ sp1-sdk = { workspace = true, features = ["network"] } ibc-proto = { workspace = true } tracing = { workspace = true } serde_cbor = "0.11.2" -hex = "0.4" -num-bigint = "0.4" [build-dependencies] tonic-build = { workspace = true } From 0dd026ea1d2455307cd346ee548d5538e65865b6 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 09:57:43 -0500 Subject: [PATCH 92/98] chore: remove log --- provers/celestia-prover/src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/provers/celestia-prover/src/main.rs b/provers/celestia-prover/src/main.rs index 4a10207..f9b6bda 100644 --- a/provers/celestia-prover/src/main.rs +++ b/provers/celestia-prover/src/main.rs @@ -119,9 +119,6 @@ impl Prover for ProverService { now, ); - let hash = proof.public_values.hash_bn254().to_string(); - println!("public values hash bn254 {:?}", hash); - let response = ProveStateTransitionResponse { proof: proof.bytes().to_vec(), public_values: proof.public_values.to_vec(), From 6aed08b042cfa5e3f27e03e8f26674453fdfd8a4 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 09:58:43 -0500 Subject: [PATCH 93/98] refactor: remove debug-key --- testing/demo/pkg/debug-key/main.go | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 testing/demo/pkg/debug-key/main.go diff --git a/testing/demo/pkg/debug-key/main.go b/testing/demo/pkg/debug-key/main.go deleted file mode 100644 index 6e02fd6..0000000 --- a/testing/demo/pkg/debug-key/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "crypto/ecdsa" - "fmt" - "log" - - "github.com/ethereum/go-ethereum/crypto" -) - -func main() { - // Replace with your private key - privateKeyHex := "0x82bfcfadbf1712f6550d8d2c00a39f05b33ec78939d0167be2a737d691f33a6a" - - // Parse the private key - privateKey, err := crypto.HexToECDSA(privateKeyHex[2:]) // Strip "0x" prefix - if err != nil { - log.Fatalf("Failed to parse private key: %v", err) - } - - // Derive the public key - publicKey := privateKey.Public().(*ecdsa.PublicKey) - - // Compute the Ethereum address - address := crypto.PubkeyToAddress(*publicKey) - fmt.Printf("Derived Ethereum address: %s\n", address.Hex()) -} From a985bd872e5bea1dde4ba3d2c00a5c73528b1e91 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 10:06:46 -0500 Subject: [PATCH 94/98] refactor: remove debug logs --- testing/demo/pkg/relay/main.go | 46 ++++++++++------------------------ 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index d39ab7f..7969806 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -32,13 +32,6 @@ import ( "google.golang.org/grpc" ) -// TODO: fetch these from the `make setup` command output. -// const ( -// ics26Router = "0xe53275a1fca119e1c5eeb32e7a72e54835a63936" -// icsCore = "0x505f890889415cf041001f5190b7800266b0dddd" -// ics07TMContractAddress = "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" -// ) - const ( // sender is an address on SimApp that will send funds via the MsgTransfer. sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" @@ -78,7 +71,7 @@ func updateTendermintLightClient() error { if err != nil { return err } - fmt.Printf("addresses %v\n", addresses) + fmt.Printf("Extracted deployed contract addresses: %#v\n", addresses) ethClient, err := ethclient.Dial(ethereumRPC) if err != nil { @@ -110,17 +103,13 @@ func updateTendermintLightClient() error { if err != nil { return fmt.Errorf("failed to get celestia prover info %w", err) } - verifierKey := info.StateTransitionVerifierKey - fmt.Printf("Got celestia prover info. State transition verifier key %v", verifierKey) - trimmed := strings.TrimPrefix(verifierKey, "0x") - result, err := hex.DecodeString(trimmed) + fmt.Printf("Got celestia prover info. StateTransitionVerifierKey: %v", info.StateTransitionVerifierKey) + verifierKeyDecoded, err := hex.DecodeString(strings.TrimPrefix(info.StateTransitionVerifierKey, "0x")) if err != nil { return fmt.Errorf("failed to decode verifier key %w", err) } - // Convert the verifierKey byte slice into a [32]byte array - var VKey [32]byte - copy(VKey[:], result) - fmt.Printf("VKey %v\n", VKey) + var verifierKey [32]byte + copy(verifierKey[:], verifierKeyDecoded) request := &proverclient.ProveStateTransitionRequest{ClientId: addresses.ICS07Tendermint} // Get state transition proof from Celestia prover with retry logic @@ -140,38 +129,29 @@ func updateTendermintLightClient() error { if err != nil { return fmt.Errorf("failed to get state transition proof after retries: %w", err) } - fmt.Printf("got resp %v\n", resp) - fmt.Printf("got resp.proof %v\n", hex.EncodeToString(resp.Proof)) - - msg := sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ - Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ - VKey: VKey, - PublicValues: resp.PublicValues, - Proof: resp.Proof, - }, - } - arguments, err := getUpdateClientArguments() if err != nil { return err } - fmt.Printf("Packing msg...\n") - encoded, err := arguments.Pack(msg) + encoded, err := arguments.Pack(sp1ics07tendermint.IUpdateClientMsgsMsgUpdateClient{ + Sp1Proof: sp1ics07tendermint.ISP1MsgsSP1Proof{ + VKey: verifierKey, + PublicValues: resp.PublicValues, + Proof: resp.Proof, + }, + }) if err != nil { return fmt.Errorf("error packing msg %w", err) } - fmt.Printf("Pcaked msg %v\n", encoded) fmt.Printf("Invoking icsCore.UpdateClient...\n") tx, err := icsCore.UpdateClient(getTransactOpts(faucet, eth), clientID, encoded) if err != nil { return err } - fmt.Printf("icsCore.UpdateClient did not error\n") receipt := getTxReciept(context.Background(), eth, tx.Hash()) if ethtypes.ReceiptStatusSuccessful != receipt.Status { - fmt.Printf("receipt %v\n", receipt) - fmt.Printf("receipt logs %v\n", receipt.Logs) + fmt.Printf("receipt %v and logs %v\n", receipt, receipt.Logs) return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) } recvBlockNumber := receipt.BlockNumber.Uint64() From 9c2a7f786703de6b366890880c4afd36b1a68a93 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 10:09:35 -0500 Subject: [PATCH 95/98] refactor: stop using deprecated func --- testing/demo/pkg/relay/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 7969806..0095802 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/srdtrk/solidity-ibc-eureka/e2e/v8/ethereum" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const ( @@ -91,7 +92,7 @@ func updateTendermintLightClient() error { } // Connect to the Celestia prover - conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure()) + conn, err := grpc.NewClient("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return fmt.Errorf("failed to connect to prover: %w", err) } From b4b6a1ccacf1fca7b363e5a3164c1afc0293a25f Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 10:10:42 -0500 Subject: [PATCH 96/98] refactor: remove receive on EVM --- testing/demo/pkg/relay/main.go | 130 --------------------------------- 1 file changed, 130 deletions(-) diff --git a/testing/demo/pkg/relay/main.go b/testing/demo/pkg/relay/main.go index 0095802..03a3cee 100644 --- a/testing/demo/pkg/relay/main.go +++ b/testing/demo/pkg/relay/main.go @@ -10,16 +10,8 @@ import ( "strings" "time" - "cosmossdk.io/math" proverclient "github.com/celestiaorg/celestia-zkevm-ibc-demo/provers/client" "github.com/celestiaorg/celestia-zkevm-ibc-demo/testing/demo/pkg/utils" - sdktypes "github.com/cosmos/cosmos-sdk/types" - transfertypes "github.com/cosmos/ibc-go/v9/modules/apps/transfer/types" - channeltypesv2 "github.com/cosmos/ibc-go/v9/modules/core/04-channel/v2/types" - ibchostv2 "github.com/cosmos/ibc-go/v9/modules/core/24-host/v2" - ibctesting "github.com/cosmos/ibc-go/v9/testing" - "github.com/cosmos/solidity-ibc-eureka/abigen/ics20lib" - "github.com/cosmos/solidity-ibc-eureka/abigen/ics26router" "github.com/cosmos/solidity-ibc-eureka/abigen/icscore" "github.com/cosmos/solidity-ibc-eureka/abigen/sp1ics07tendermint" "github.com/ethereum/go-ethereum/accounts/abi" @@ -34,16 +26,6 @@ import ( ) const ( - // sender is an address on SimApp that will send funds via the MsgTransfer. - sender = "cosmos1ltvzpwf3eg8e9s7wzleqdmw02lesrdex9jgt0q" - // receiver is an address on the EVM chain that will receive funds via the MsgTransfer. - receiver = "0x7f39c581f595b53c5cb19b5a6e5b8f3a0b1f2f6e" - // denom is the denomination of the token on SimApp. - denom = "stake" - // sourceChannel is hard-coded to the name used by the first channel. - sourceChannel = ibctesting.FirstChannelID - // sequence is hard-coded to the first sequence number. - sequence = 1 // ethereumRPC is the Reth RPC endpoint. ethereumRPC = "http://localhost:8545/" // ethereumAddress is an address on the EVM chain. @@ -59,11 +41,6 @@ func main() { if err != nil { log.Fatal(err) } - - // err = receivePacketOnEVM() - // if err != nil { - // log.Fatal(err) - // } } // updateTendermintLightClient submits a MsgUpdateClient to the Tendermint light client on the EVM roll-up. @@ -160,113 +137,6 @@ func updateTendermintLightClient() error { return nil } -func receivePacketOnEVM() error { - addresses, err := utils.ExtractDeployedContractAddresses() - if err != nil { - return err - } - - sendPacket, err := createSendPacket() - if err != nil { - return err - } - - packetCommitmentPath := ibchostv2.PacketCommitmentKey(sourceChannel, sequence) - fmt.Printf("packetCommitmentPath %v\n", packetCommitmentPath) - - packet := ics26router.IICS26RouterMsgsPacket{ - Sequence: uint32(sendPacket.Sequence), - SourceChannel: sendPacket.SourceChannel, - DestChannel: sendPacket.DestinationChannel, - TimeoutTimestamp: sendPacket.TimeoutTimestamp, - Payloads: []ics26router.IICS26RouterMsgsPayload{ - { - SourcePort: sendPacket.Payloads[0].SourcePort, - DestPort: sendPacket.Payloads[0].DestinationPort, - Version: transfertypes.V1, - Encoding: transfertypes.EncodingABI, - Value: sendPacket.Payloads[0].Value, - }, - }, - } - - // TODO: replace this with query to celestia-prover after mock circuits - // are implemented. - membershipProof := []byte{} - - // TODO: replace this with a real proof height. - proofHeight := ics26router.IICS02ClientMsgsHeight{ - RevisionNumber: uint32(0), - RevisionHeight: uint32(10), - } - msg := ics26router.IICS26RouterMsgsMsgRecvPacket{ - Packet: packet, - ProofCommitment: membershipProof, - ProofHeight: proofHeight, - } - - ethClient, err := ethclient.Dial(ethereumRPC) - if err != nil { - return err - } - ics26Contract, err := ics26router.NewContract(ethcommon.HexToAddress(addresses.ICS26Router), ethClient) - if err != nil { - return err - } - - faucet, err := crypto.ToECDSA(ethcommon.FromHex(ethPrivateKey)) - if err != nil { - return err - } - eth, err := ethereum.NewEthereum(context.Background(), ethereumRPC, nil, faucet) - if err != nil { - return err - } - tx, err := ics26Contract.RecvPacket(getTransactOpts(faucet, eth), msg) - if err != nil { - return err - } - - receipt := getTxReciept(context.Background(), eth, tx.Hash()) - if ethtypes.ReceiptStatusSuccessful != receipt.Status { - return fmt.Errorf("receipt status want %v, got %v", ethtypes.ReceiptStatusSuccessful, receipt.Status) - } - recvBlockNumber := receipt.BlockNumber.Uint64() - fmt.Printf("recvBlockNumber %v\n", recvBlockNumber) - return nil -} - -// TODO: refactor this to de-duplicate code from createMsgSendPacket -func createSendPacket() (channeltypesv2.Packet, error) { - coin := sdktypes.NewCoin(denom, math.NewInt(100)) - transferPayload := ics20lib.ICS20LibFungibleTokenPacketData{ - Denom: coin.Denom, - Amount: coin.Amount.BigInt(), - Sender: sender, - Receiver: receiver, - Memo: "test transfer", - } - transferBz, err := ics20lib.EncodeFungibleTokenPacketData(transferPayload) - if err != nil { - return channeltypesv2.Packet{}, err - } - payload := channeltypesv2.Payload{ - SourcePort: transfertypes.PortID, - DestinationPort: transfertypes.PortID, - Version: transfertypes.V1, - Encoding: transfertypes.EncodingABI, - Value: transferBz, - } - - return channeltypesv2.Packet{ - Sequence: sequence, - SourceChannel: ibctesting.FirstChannelID, - DestinationChannel: ibctesting.FirstClientID, - TimeoutTimestamp: uint64(time.Now().Add(30 * time.Minute).Unix()), - Payloads: []channeltypesv2.Payload{payload}, - }, nil -} - func getTransactOpts(key *ecdsa.PrivateKey, chain ethereum.Ethereum) *bind.TransactOpts { ethClient, err := ethclient.Dial(chain.RPC) if err != nil { From 1f1139f0bcd3b8995792b5bad5b1e1fefc5cd381 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 10:14:26 -0500 Subject: [PATCH 97/98] docs: step to apply diff to justfile --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8f9ee6b..35f13b8 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,18 @@ For more information refer to the [architecture document](./ARCHITECTURE.md). No git submodule update ``` +1. Apply this diff to the `solidity-ibc-eureka/justfile`: + + ```diff + genesis-sp1-ics07: build-sp1-programs + @echo "Generating the genesis file..." + - RUST_LOG=info cargo run --bin operator --release -- genesis -o scripts/genesis.json + + RUST_LOG=info cargo run --bin operator --release -- genesis --proof-type groth16 -o scripts/genesis.json + + @echo "--> Setting the verifier key in scripts/genesis.json" + + @sed -i '' 's|"updateClientVkey": "0x00d003b09381282af2781e5ec015aae610d766a08fffd4ac45d2e6dad736ead3"|"updateClientVkey": "0x0081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b"|' scripts/genesis.json + + @echo "--> Set the verifier key to 0x0081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b." + ``` + 1. Create the `.env` file ```shell From eb4cb2ff8d35011488d0077c56ead160e5178e22 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Fri, 24 Jan 2025 10:48:02 -0500 Subject: [PATCH 98/98] docs: add step to modify docker-compose.yml --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 494989a..bf71588 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,22 @@ For more information refer to the [architecture document](./ARCHITECTURE.md). No # Modify the .env file and set `SP1_PROVER=network` and `SP1_PRIVATE_KEY="PRIVATE_KEY"` to the SP1 prover network private key from Celestia 1Password. ``` +1. Modify the `docker-compose.yml` file and set `SP1_PROVER=network` and `SP1_PRIVATE_KEY="PRIVATE_KEY"` to the SP1 prover network private key from Celestia 1Password. + + ```diff + celestia-prover: + image: ghcr.io/celestiaorg/celestia-zkevm-ibc-demo/celestia-prover:latest + container_name: celestia-prover + environment: + # TENDERMINT_RPC_URL should be the SimApp which is acting as a substitute + # for Celestia (with IBC Eurekea enabled). + - TENDERMINT_RPC_URL=http://simapp-validator:26657 + - RPC_URL=http://reth:8545 + - PROTO_DESCRIPTOR_PATH=proto_descriptor.bin + + - SP1_PROVER=network + + - SP1_PRIVATE_KEY=PRIVATE_KEY + ``` + 1. Install contract dependencies and the SP1 Tendermint light client operator binary from solidity-ibc-eureka. ```shell