-
Notifications
You must be signed in to change notification settings - Fork 34
fix about lost blockchain state: first pr: add debug prover and debug chain module for testing #174
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
base: features/lo7181-2
Are you sure you want to change the base?
fix about lost blockchain state: first pr: add debug prover and debug chain module for testing #174
Conversation
…n state Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
There was a problem hiding this 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.
There was a problem hiding this 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.
chains/debug/module/module.go
Outdated
|
||
// Name returns the name of the module | ||
func (Module) Name() string { | ||
return "debug" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
chains/debug/chain.go
Outdated
func (c *Chain) Config() ChainConfig { | ||
return c.config | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
chains/debug/query.go
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Debug(env, "chain", chain.ChainID(), "value", val) | |
logger.DebugContext(ctx, env, "chain", chain.ChainID(), "value", val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
provers/debug/prover.go
Outdated
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
provers/debug/prover.go
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
provers/debug/prover.go
Outdated
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
provers/debug/prover.go
Outdated
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
provers/debug/prover.go
Outdated
} | ||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Info("debug prover is initialized.") | |
logger.Debug("debug prover is initialized.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
2adc10d
to
ab00d8e
Compare
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:
I plan this series of pull-req constructs below and this is first part of it.