Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Submit MsgUpdateClient to tendermint light client #67

Open
wants to merge 102 commits into
base: main
Choose a base branch
from

Conversation

rootulp
Copy link
Collaborator

@rootulp rootulp commented Dec 23, 2024

Closes step two of #31.

A few changes in this PR, can split them into separate PRs if reviewers request:

  1. Checkout submodules in CI workflows lint and test.
  2. Sort makefile commands alphabetically. Add a new make relay command that does step 2.
  3. Update README with an important step to apply a diff in solidity-ibc-eureka/justfile. The diff is needed so that the Tendermint light client on the EVM roll-up supports Groth16 and has the correct verifier key (from the celestia-prover)
  4. Enable debug mode on Reth node (can revert if requested)
  5. Add curl to the Celestia-prover for debugging purposes (can revert if requested)
  6. Update solidity-ibc-eureka version
  7. Modify the prover proto to return hex-encoded verifier keys. This made it easier to plumb directly into the EVM contract and Tendermint light client set-up (can revert if requested)
  8. Add a line to celestia-prover README to show example usage of Info endpoint
  9. Add a debug-txhash script to help debug failed EVM transactions (can revert if requested)
  10. Refactor the extractDeployedContractAddresses to utils package so that it can be used in multiple places
  11. Refactor the transfer script

Testing

I can't run the celestia-prover in Docker because #89 but if I run it locally, it works:

$ make relay
go run testing/demo/pkg/relay/main.go
Extracted deployed contract addresses: utils.ContractAddresses{ERC20:"0xa05915fd6e32a1aa7e67d800164cacb12487142d", Escrow:"0xc4515dd838dd640d6839933b33ff8d19640c1231", IBCStore:"0xf73bd8a7184bec941b3f9ef5e6f6df981e105535", ICS07Tendermint:"0xe53275a1fca119e1c5eeb32e7a72e54835a63936", ICS20Transfer:"0xb1c938f5ba4b3593377f399e12175e8db0c787ff", ICS26Router:"0x48fd1226d797400779bbfaf1706f5fb8da04ae91", ICSCore:"0x7e7ad18adc99b94d4c728fdf13d4de97b926a0d8"}
Getting celestia prover info...
Got celestia prover info. StateTransitionVerifierKey: 0x0081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523bInvoking icsCore.UpdateClient...
Transaction hash: 0x6370b144be660a5d8f798c45fe3f1942735e7a86063dc1834b61013f04de3b11
Block number: 170
Gas used: 289132
Logs: []
recvBlockNumber 170

@rootulp rootulp self-assigned this Dec 23, 2024
@rootulp
Copy link
Collaborator Author

rootulp commented Jan 6, 2025

The request is hitting celestia-prover

2025-01-06 15:24:17 Got state transition request: Request { metadata: MetadataMap { headers: {"content-type": "application/grpc", "user-agent": "grpc-go/1.68.1", "te": "trailers", "grpc-timeout": "9979596u"} }, message: ProveStateTransitionRequest { client_id: "08-groth16-0" }, extensions: Extensions }

Getting this error

failed to request state transition proof: rpc error: code = Internal desc = Failed to parse client_id as EVM address: invalid string length

I think the client ID may need to be the SP1 contract address

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 6, 2025

failed to request state transition proof: rpc error: code = Internal desc = error sending request for url (http://localhost:8545/)

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 6, 2025

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 6, 2025

New error unlocked

failed to request state transition proof: rpc error: code = DeadlineExceeded desc = context deadline exceeded

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 6, 2025

I made the celestia-prover crash. Logs from before the crash

2025-01-06 15:40:43 Prover Server listening on [::]:50051
2025-01-06 15:46:09 Got state transition request: Request { metadata: MetadataMap { headers: {"content-type": "application/grpc", "user-agent": "grpc-go/1.68.1", "te": "trailers", "grpc-timeout": "9988714u"} }, message: ProveStateTransitionRequest { client_id: "0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37" }, extensions: Extensions }
2025-01-06 15:46:09 proving from height block::Height(5) to height Height { revision: 0, height: 5 }

Looks like it OOMed

		"OOMKilled": true,

docker-compose.yml Outdated Show resolved Hide resolved
@rootulp
Copy link
Collaborator Author

rootulp commented Jan 22, 2025

forge debugger makes me think the error is in the new trusted client state

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 22, 2025

Old trustedClientState:

000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000012750000000000000000000000000000000000000000000000000000000000001baf8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a7a6b6962632d64656d6f00000000000000000000000000000000000000000000

New trustedClientState:

0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000127500000000000000000000000000000000000000000000000000000000000001baf8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7a6b6962632d64656d6f00000000000000000000000000000000000000000000

Operator generated trustedClientState:

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024c000000000000000000000000000000000000000000000000000000000012750000000000000000000000000000000000000000000000000000000000001baf8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7a6b6962632d64656d6f00000000000000000000000000000000000000000000

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 22, 2025

Can get the operator to create a client state with Groth16 using the --proof-type groth16 flag:

+++ b/justfile
@@ -26,7 +26,7 @@ build-sp1-programs:
 # Build and optimize the eth wasm light client using `cosmwasm/optimizer`. Requires `docker` and `gzip`
 build-cw-ics08-wasm-eth:
        docker run --rm -v "$(pwd)":/code --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry cosmwasm/optimizer:0.16.1 ./programs/cw-ics08-wasm-eth
-       cp artifacts/cw_ics08_wasm_eth.wasm e2e/interchaintestv8/wasm
+       cp artifacts/cw_ics08_wasm_eth.wasm e2e/interchaintestv8/wasm
        gzip e2e/interchaintestv8/wasm/cw_ics08_wasm_eth.wasm -f

 # Clean up the cache and out directories
@@ -67,7 +67,7 @@ lint:
 # Generate the ABI files for the contracts
 generate-abi: build-contracts
        jq '.abi' out/ICS26Router.sol/ICS26Router.json > abi/ICS26Router.json
-       jq '.abi' out/ICSCore.sol/ICSCore.json > abi/ICSCore.json
+       jq '.abi' out/ICSCore.sol/ICSCore.json > abi/ICSCore.json
        jq '.abi' out/ICS20Transfer.sol/ICS20Transfer.json > abi/ICS20Transfer.json
        jq '.abi' ./out/SP1ICS07Tendermint.sol/SP1ICS07Tendermint.json > abi/SP1ICS07Tendermint.json
        jq '.abi' out/ERC20.sol/ERC20.json > abi/ERC20.json
@@ -135,7 +135,10 @@ install-relayer:
 # Note that the `scripts/genesis.json` file is ignored in the `.gitignore` file
 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": "0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b"|' scripts/genesis.json
+  @echo "--> Set the verifier key to 0x409417091e6e4961546661834d83a3f048814cde71efa42b034496540826523b."

 # Deploy the SP1ICS07Tendermint contract to the Eth Sepolia testnet if the `.env` file is present
 deploy-sp1-ics07: genesis-sp1-ics07

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 22, 2025

New error unlocked: a54f8e27 which maps to

PublicInputNotInField()": "a54f8e27",

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 23, 2025

The proof verifies off-chain:

20:48:33 DBG verifier done backend=groth16 curve=bn254 took=1.584417
proof verified ()

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 23, 2025

The original public values are == to "reduced" public values, that is public values that have been modulo'ed the bn254 field limit. See https://www.diffchecker.com/rZxdMTKG/

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 23, 2025

I switched to returning a hex-encoded verifier key from the celestia-prover. Now I'm getting a verifier key mismatch error again.

The logs

$ make relay2
go run testing/demo/pkg/relay-v2/main.go
addresses {0xb1c938f5ba4b3593377f399e12175e8db0c787ff 0xf73bd8a7184bec941b3f9ef5e6f6df981e105535 0x5bbab04b4740275903edb0fdb4e9d0e9a25abfef 0x25cdbd2bf399341f8fee22ecdb06682ac81fdc37 0x48fd1226d797400779bbfaf1706f5fb8da04ae91 0x7e7ad18adc99b94d4c728fdf13d4de97b926a0d8 0x70ac5980099d71f4cb561bbc0fcfef08aa6279ec}
Getting celestia prover info...
Got celestia prover info. State transition verifier key 0x0081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b

To find the verifier key in the contract:

$ cast call 0x70ac5980099d71f4cb561bbc0fcfef08aa6279ec "getClient(string)(address)" "07-tendermint-0" http://localhost:8545
Warning: This is a nightly build of Foundry. It is recommended to use the latest stable version. Visit https://book.getfoundry.sh/announcements for more information.
To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment.

0x25CdBD2bf399341F8FEe22eCdB06682AC81fDC37
$
$ cast call 0x25CdBD2bf399341F8FEe22eCdB06682AC81fDC37 "UPDATE_CLIENT_PROGRAM_VKEY() (bytes32)" http://localhost:8545
Warning: This is a nightly build of Foundry. It is recommended to use the latest stable version. Visit https://book.getfoundry.sh/announcements for more information.
To mute this warning set `FOUNDRY_DISABLE_NIGHTLY_WARNING` in your environment.

0x0081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b

The EVM error

result {"failed":true,"gas":47757,"returnValue":"d56bdc260081282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b81282e1279b92586a3330c1cd83a3f0910299bdc7be90ac1a24b2a0826523b00"

which maps to the error

| Error | VerificationKeyMismatch(bytes32,bytes32)                | 0xd56bdc26 |

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 23, 2025

It looks like one of the verification keys is off by a byte

Screenshot 2025-01-23 at 5 38 16 PM

@rootulp
Copy link
Collaborator Author

rootulp commented Jan 23, 2025

Updating the client finally works:

make relay2

...

Invoking icsCore.UpdateClient...
icsCore.UpdateClient did not error
Transaction hash: 0xc19e6ed524224712c3a40127f5eb00d76c5d5def6030e70f87940e8a9958674f
Block number: 1408
Gas used: 289811
Logs: []
recvBlockNumber 1408

@rootulp rootulp changed the title feat: relayer feat: Submit MsgUpdateClient to tendermint light client Jan 24, 2025
@rootulp rootulp mentioned this pull request Jan 24, 2025
6 tasks
@rootulp rootulp marked this pull request as ready for review January 24, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant