Skip to content

Conversation

dai1975
Copy link
Contributor

@dai1975 dai1975 commented Aug 26, 2025

In case of optimism-bsc relay, at optimism it takes long time to update headers and then failed in querying to bsc node because it drops old state.
This series of pull-req changes current logic to:

  • main logic uses only prove=false query resut
  • move SetupHeadersForUpdate and ProveState to later part
  • SeupHeadersForUpdate and ProveState runs parallel per chain to avoid lost state because of later SetupHeadersForUpdate chain

I plan this series of pull-req constructs below and this is first part of it.

  • testing base
  • handshake connection
  • channel upgrade
  • relay packets

Daisuke Kanda added 2 commits August 22, 2025 15:19
…n state

Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
@dai1975 dai1975 requested a review from Copilot August 26, 2025 02:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces debug chain and prover modules to enable testing of blockchain state synchronization issues in optimism-bsc relay scenarios. The purpose is to simulate state pruning scenarios where nodes drop old state, causing query failures that lead to lost blockchain state.

Key changes:

  • Adds debug wrapper modules for both chains and provers with configurable fake state loss simulation
  • Modifies test configurations to use debug wrappers around existing tendermint configurations
  • Integrates debug modules into the main application for testing support

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/cases/tm2tm/configs/demo/ibc-*.json Updated test configs to wrap tendermint chain/prover with debug variants
provers/debug/* New debug prover module that wraps origin prover with fake state loss simulation
chains/debug/* New debug chain module that wraps origin chain with query-time state loss simulation
main.go Registers new debug modules in the application
coreutil/unwrap.go Adds unwrapping support for debug chain and prover types

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dai1975 dai1975 requested a review from siburu August 26, 2025 03:35
@dai1975 dai1975 marked this pull request as ready for review August 26, 2025 03:41
@dai1975 dai1975 requested a review from a team as a code owner August 26, 2025 03:41
Copy link
Contributor

@siburu siburu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dai1975 Basically OK, but I have put some comments. Please check them.


// Name returns the name of the module
func (Module) Name() string {
return "debug"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no convention to name relayer modules, but I think "debug" is too simple and "debug-client" is a bit confusing because the debug prover does not define any light client.
I suggest "debug.chain" and "debug.prover", which is the same naming style as ethereum-ibc-relay-chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 25 to 27
func (c *Chain) Config() ChainConfig {
return c.config
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this, right?
If so we should do it now because removing dead code becomes more difficult as time passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

logger := log.GetLogger()
env := fmt.Sprintf("DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_CHAIN_%s", chain.ChainID())
if val, ok := os.LookupEnv(env); ok {
logger.Debug(env, "chain", chain.ChainID(), "value", val)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug(env, "chain", chain.ChainID(), "value", val)
logger.DebugContext(ctx, env, "chain", chain.ChainID(), "value", val)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

logger := log.GetLogger()
env := fmt.Sprintf("DEBUG_RELAYER_PRUNE_AFTER_BLOCKS_PROVER_%s", chain.ChainID())
if val, ok := os.LookupEnv(env); ok {
logger.Info(fmt.Sprintf(">%s: chain=%s: '%v'", env, chain.ChainID(), val))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Info(fmt.Sprintf(">%s: chain=%s: '%v'", env, chain.ChainID(), val))
logger.DebugContext(ctx, fmt.Sprintf(">%s: chain=%s: '%v'", env, chain.ChainID(), val))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

env := fmt.Sprintf("DEBUG_RELAYER_SHFU_WAIT_%s", pr.chain.ChainID())

if val, ok := os.LookupEnv(env); ok {
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "value", val)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "value", val)
logger.DebugContext(ctx, env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "value", val)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", (i+1)*intervalSeconds, t))
time.Sleep(time.Duration(intervalSeconds) * time.Second)
}
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", t-n*intervalSeconds, t))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", t-n*intervalSeconds, t))
logger.DebugContext(ctx, env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", t-n*intervalSeconds, t))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

intervalSeconds := 60
n := t / intervalSeconds
for i := 0; i < n; i++ {
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", (i+1)*intervalSeconds, t))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", (i+1)*intervalSeconds, t))
logger.DebugContext(ctx, env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", (i+1)*intervalSeconds, t))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "lap", fmt.Sprintf("%v/%v", t-n*intervalSeconds, t))
time.Sleep(time.Duration(t-n*intervalSeconds) * time.Second)
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "done", t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Debug(env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "done", t)
logger.DebugContext(ctx, env, "chain", pr.chain.ChainID(), "cp", counterparty.ChainID(), "done", t)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


func (pr *Prover) Init(homePath string, timeout time.Duration, codec codec.ProtoCodecMarshaler, debug bool) error {
logger := log.GetLogger()
logger.Info("debug prover is initialized.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.Info("debug prover is initialized.")
logger.Debug("debug prover is initialized.")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

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.

2 participants