EspressoSystems / espresso-sequencer

93 stars 65 forks source link

update state-prover demo etc that read from or write to the LightClientState #1942

Closed philippecamacho closed 5 days ago

philippecamacho commented 2 weeks ago

Doing a small experiment where we remove the field threshold from the LightClientState struct we reach the following error (after fixing all the compilations issues):

--- TRY 1 STDERR:        hotshot-state-prover service::test::test_submit_state_and_proof ---
Genesis: view_num: 0, block_height: 0, block_comm_root: 1234, fee_ledger_comm: 5678bls_key_comm: "0x219a25b0eb67ec09251a6f5abc377de144a6e81b7f0c4a01aa8eba3801f89dce",schnorr_key_comm: "0x2599254c85754d3eb4cb4f899ae0a9368251832178d80a16ab726e4ad6f3839d",amount_comm: "0x1e0aee7dd5ea868686d43f25e553e9a4b91f9aac89f451f5fc55a66889f3af10",

The application panicked (crashed).
Message:  index out of bounds: the len is 7 but the index is 7
Location: /home/leloup/.cargo-nix/git/checkouts/hotshot-0ac703037ea89b98/165cbad/crates/types/src/light_client.rs:228

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: core::panicking::panic_bounds_check::ha28980b0cc493af1
      at <unknown source file>:<unknown line>
   9: <hotshot_contract_adapter::light_client::ParsedLightClientState as core::convert::From<hotshot_types::light_client::GenericPublicInput<ark_ff::fields::models::fp::Fp<ark_ff::fields::models::fp::montgomery_backend::MontBackend<ark_bn254::fields::fr::FrConfig,4_usize>,4_usize>>>>::from::h2feda5b2ea89af83
      at <unknown source file>:<unknown line>
  10: hotshot_state_prover::service::submit_state_and_proof::{{closure}}::h4cdff872ea2eba1c
      at <unknown source file>:<unknown line>
  11: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::hacde30982eacc043
      at <unknown source file>:<unknown line>
  12: async_global_executor::executor::block_on::hbbc1a7b7c86b57e3
      at <unknown source file>:<unknown line>
  13: hotshot_state_prover::service::test::test_submit_state_and_proof::h84360810e0ed575c
      at <unknown source file>:<unknown line>
  14: core::ops::function::FnOnce::call_once::h273ac854d9c5e315
      at <unknown source file>:<unknown line>
  15: test::__rust_begin_short_backtrace::hae44b86aaeda3a0f
      at <unknown source file>:<unknown line>
  16: test::run_test::{{closure}}::h4148d3c10c6c98f1
      at <unknown source file>:<unknown line>
  17: std::sys_common::backtrace::__rust_begin_short_backtrace::h91e427ea6df4cf63
      at <unknown source file>:<unknown line>
  18: core::ops::function::FnOnce::call_once{{vtable.shim}}::had7513e31342a613
      at <unknown source file>:<unknown line>
  19: std::sys::pal::unix::thread::Thread::new::thread_start::h3b8e81128811868f
      at <unknown source file>:<unknown line>
  20: start_thread<unknown>
      at <unknown source file>:<unknown line>
  21: __clone3<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.

        PASS [  39.475s] sequencer api::test::test_catchup
  TRY 1 SLOW [> 60.000s] espresso-types v0::impls::l1::test::test_wait_for_finalized_block
        PASS [  77.141s] espresso-types v0::impls::l1::test::test_wait_for_finalized_block
------------
     Summary [  77.680s] 164/210 tests run: 161 passed (1 slow), 3 failed, 5 skipped
  TRY 3 FAIL [   3.391s] hotshot-state-prover circuit::tests::test_circuit_building
        FAIL [  28.431s] hotshot-state-prover service::test::test_submit_state_and_proof
        FAIL [  25.533s] hotshot-state-prover snark::tests::test_proof_generation
error: test run failed

So this means we will have to make an update to HotShot as well. See

Location: /home/leloup/.cargo-nix/git/checkouts/hotshot-0ac703037ea89b98/165cbad/crates/types/src/light_client.rs:228
alxiong commented 1 week ago

this should already be fixed in https://github.com/EspressoSystems/espresso-sequencer/pull/1986

philippecamacho commented 6 days ago

this should already be fixed in #1986

Locally the demo looks fine.

> just demo

I can find logs confirming the LC contract state is updated successfully, e.g.:

prover-service-1               | 2024-09-08T11:19:32.522256Z  INFO hotshot_state_prover::service: Submitted state and proof to L1: tx=cfa0a9123393c7c0191a35c1ad55c682b4827cc0743d8d4a19f987de67384edd block=60
prover-service-1               | 2024-09-08T11:19:32.522312Z  INFO hotshot_state_prover::service: Successfully synced light client state.