Skip to content

smite-scenarios: sync target chain view via RPC after mining - #211

Open
NishantBansal2003 wants to merge 1 commit into
lnfuzz:masterfrom
NishantBansal2003:target-cli
Open

smite-scenarios: sync target chain view via RPC after mining#211
NishantBansal2003 wants to merge 1 commit into
lnfuzz:masterfrom
NishantBansal2003:target-cli

Conversation

@NishantBansal2003

Copy link
Copy Markdown
Contributor

ref: #195

Targets (CLN, LDK) previously learned about new blocks through bitcoind's blocknotify, which fires asynchronously. When multiple blocks are mined, this can queue up many sync calls, adding unnecessary load. Instead, explicitly sync the target once after each MineBlocks operation.
Introduce a TargetRpc trait with a chain_sync() method, called by the executor immediately after MineBlocks. CLN and LDK sync explicitly via RPC and signals, respectively, while LND and Eclair use ZMQ and remain no-ops.
Dropping -blocknotify also removes the burst of asynchronous SIGUSR1s during initial block generation, so LDK no longer needs the pre_exec SIG_IGN

The reason I went with an RPC trait is that, in the future, we'll need access to the target's CLI/RPC to add payment hash and preimage information to the target so that it can send an update_fulfill_htlc message.
Also, for now, I only added the CLI as a trait implementation for each target to keep the changes contained and concise. In the future, we can definitely add direct RPC calls over the socket as well to save overhead.

Targets previously learned about new blocks through bitcoind's
blocknotify, which fires asynchronously. When multiple blocks
are mined, this can queue up many sync calls, adding unnecessary
load. Instead, explicitly sync the target once after each
MineBlocks operation.

Introduce a TargetRpc trait with a chain_sync() method, called by
the executor immediately after MineBlocks. CLN and LDK sync
explicitly via RPC and signals, respectively, while LND and Eclair
use ZMQ and remain no-ops.

Dropping -blocknotify also removes the burst of asynchronous SIGUSR1s
during initial block generation, so LDK no longer needs the pre_exec SIG_IGN.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>

@erickcestari erickcestari left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good idea! It's much better that it only calls the sync signal once per MineBlock instead of calling it for every block mined.

Comment on lines +70 to +74
assert!(
out.status.success(),
"pkill -USR1 ldk-node-wrapper failed: {}",
String::from_utf8_lossy(&out.stderr)
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have an assert here? Imagine the executor crashes the target while executing the input. It would probably fail to sync and panic with a pkill error instead of failing with a Violation::Crashed error.

@NishantBansal2003 NishantBansal2003 Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, great point, I think pkill or lightning-cli should always succeed in any case, and they should only error out when the target has already crashed. So, I think we could check whether the target has crashed before asserting this. If it has crashed, we can simply log the failure here, otherwise, we should assert it. I don't think there is any other case where RPC commands should be unresponsive, so I think it's better to be stricter. WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I agree! I also think logging is a good option.

cmd.env("LD_PRELOAD", handler);
}

// Ignore SIGUSR1 for the window between exec and the wrapper blocking

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some comments at workloads/ldk/src/main.rs also need to be updated after the remove of SIG_IGN.

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