Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d56b1f5
feat: deploy sc stress test v1.3.0
nksazonov May 19, 2026
c10af9f
feat(pkg): update channel hub abi
nksazonov May 20, 2026
cf9cad1
fix(nitronode/chart): config stress-v1 base sepolia ch hub address
nksazonov May 20, 2026
d024c33
chore(nitronode/chart): drop unused locking_contract_address for stre…
philanton May 20, 2026
63571c0
fix(nitronode/store): pass applicationId into GetAppSessionKeyOwner
philanton May 20, 2026
640e9b9
fix(deployments): redeploy ChH with 1 min activation delay for stress…
nksazonov May 20, 2026
330671b
feat(contracts/script): add DepositToNode batch top-up scripts
nksazonov May 20, 2026
7438ee0
fix(deployments): redeploy ChH for stress test sepolia with correct d…
nksazonov May 20, 2026
287ec60
feat(contracts/script): take library address params
nksazonov May 20, 2026
a8b9d76
fix(sdk/go): treat finalized state as channel-absent in create/transf…
philanton May 20, 2026
2878aab
feat(sdk/go/examples): expand app_sessions + add channel_session_key …
philanton May 20, 2026
a115b5a
feat(sdk/ts/examples): expand app_sessions + add channel_session_key …
philanton May 20, 2026
9bc21a5
fix(cerebro): clean up REPL exit + restore terminal modes properly
philanton May 21, 2026
2a27193
fix(sdk/ts): tear down WebSocket in Client.close()
philanton May 21, 2026
cce1dfb
fix(sdk/ts/examples): drop unused ChannelDefaultSigner import
philanton May 21, 2026
25770ad
fix(cerebro): surface terminal teardown errors instead of ignoring them
philanton May 21, 2026
1060bd2
chore(examples): strip private keys + revert wsURL to sandbox
philanton May 21, 2026
68927b4
fix(contracts): address coderabbitai review findings
nksazonov May 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cerebro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@ Uses layered architecture:
- Base Client for low-level RPC access
- Local SQLite for secure configuration storage

## Known issues

- **Scrollback loss on macOS Terminal.app / iTerm2.** Cerebro uses
`github.com/c-bata/go-prompt` for the REPL. Its completion-menu renderer
reserves screen rows via `\x1bD` (Index) + `\x1bM` (Reverse Index). On
xterm-strict terminals RI pulls scrolled-out content back from the
scrollback buffer; on macOS Terminal.app and iTerm2 (default settings) RI
inserts a blank line at the top instead, permanently dropping whatever was
scrolled off. Any cerebro session that triggers a completion menu
(including typing `exit`) wipes shell history that existed before cerebro
started. Tracked upstream as
[c-bata/go-prompt#206](https://github.com/c-bata/go-prompt/issues/206) and
unresolved since 2020.

Planned mitigation: replace `c-bata/go-prompt` with `chzyer/readline` or
`peterh/liner`. Both preserve scrollback while still providing Tab
completion; the completion glue in `operator.go` needs to be rewritten
against the new lib's hook surface.

## License

Part of the Nitrolite project. Licensed under the MIT License.
67 changes: 58 additions & 9 deletions cerebro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import (
"log"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"syscall"

"github.com/c-bata/go-prompt"
"golang.org/x/term"
Expand Down Expand Up @@ -70,15 +73,59 @@ func main() {
fmt.Printf("Config directory: %s\n", configDir)
fmt.Println("\nType 'help' for available commands or 'exit' to quit")

// Terminal handling
initialState, _ := term.GetState(int(os.Stdin.Fd()))
// Terminal handling. go-prompt switches the tty into raw mode and emits
// bracketed-paste / alternate-screen / mouse-tracking escapes. Restoring
// the termios is not enough — the terminal also needs the matching
// disable sequences or the next program in the same shell tab inherits
// broken paste behaviour and an unresponsive Ctrl-C.
initialState, stateErr := term.GetState(int(os.Stdin.Fd()))
if stateErr != nil {
log.Printf("warning: failed to capture initial terminal state: %v", stateErr)
}
handleExit := func() {
term.Restore(int(os.Stdin.Fd()), initialState)
exec.Command("stty", "sane").Run()
if stateErr == nil && initialState != nil {
if err := term.Restore(int(os.Stdin.Fd()), initialState); err != nil {
log.Printf("warning: failed to restore terminal state: %v", err)
}
}
if err := exec.Command("stty", "sane").Run(); err != nil {
log.Printf("warning: failed to run 'stty sane': %v", err)
}
// Disable bracketed paste, show cursor, leave alt screen, mouse off,
// then wipe any leftover completion-menu / ghost-prompt rows that
// go-prompt leaves on the screen during its teardown.
fmt.Fprint(os.Stdout, "\x1b[?2004l\x1b[?25h\x1b[?1049l\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l")
// go-prompt leaves on the screen: the redrawn ghost prompt line
// (rendered between Executor return and ExitChecker firing) plus up
// to 6 rows reserved for the completion menu (default maxSuggestion
// = 6 in go-prompt v0.2.6). Cursor is positioned somewhere below
// them. Step cursor up enough rows to land at or above the ghost
// prompt, then erase from there down. Over-erasing into the user's
// "cerebro> exit" line is acceptable — the farewell printed below
// preserves the meaning.
fmt.Fprint(os.Stdout, "\x1b[7A\r\x1b[0J")
}

// Catch SIGINT / SIGTERM / SIGHUP so abnormal termination still restores
// the terminal. The in-prompt Ctrl-C keybind below handles the normal
// "exit by Ctrl-C" path; this handler covers shell-level kills.
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
go func() {
<-sigCh
handleExit()
os.Exit(130)
}()

options := append(getStyleOptions(),
prompt.OptionPrefix("cerebro> "),
// Make go-prompt exit its Run() loop when the user types "exit" so
// its own tty teardown runs before main prints anything below the
// prompt. Without this, exit racing with the prompt redraw leaves
// completion suggestions splattered over the final output.
prompt.OptionSetExitCheckerOnInput(func(in string, breakline bool) bool {
return breakline && strings.TrimSpace(in) == "exit"
}),
prompt.OptionAddKeyBind(prompt.KeyBind{
Key: prompt.ControlC,
Fn: func(_ *prompt.Buffer) {
Expand All @@ -105,15 +152,19 @@ func main() {
close(promptExitCh)
}()

var farewell string
select {
case <-operator.Wait():
log.Println("connection closed.")
farewell = "connection closed."
case <-promptExitCh:
log.Println("session ended.")
farewell = "session ended."
}

// Restore the terminal first so the farewell prints below any leftover
// prompt artefacts in normal mode, not interleaved with go-prompt's
// final redraw.
handleExit()
log.Println("exiting...")
log.Println(farewell)
}

func getStyleOptions() []prompt.Option {
Expand All @@ -133,7 +184,5 @@ func getStyleOptions() []prompt.Option {

prompt.OptionSelectedDescriptionTextColor(prompt.White),
prompt.OptionSelectedDescriptionBGColor(prompt.DarkBlue),

prompt.OptionShowCompletionAtStart(),
}
}
8 changes: 6 additions & 2 deletions cerebro/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,12 @@ func (o *Operator) Execute(s string) {
}

case "exit":
fmt.Println("Exiting...")
close(o.exitCh)
// Actual exit is driven by go-prompt's ExitChecker on "exit" input
// (see cerebro/main.go). Closing exitCh here would race the prompt
// teardown; printing here would print before go-prompt redraws the
// next prompt line, leaving a stray "cerebro> " between the message
// and the farewell. Defer the farewell to main once the prompt has
// torn itself down.
default:
fmt.Printf("ERROR: Unknown command: %s (type 'help' for available commands)\n", args[0])
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

191 changes: 75 additions & 116 deletions contracts/broadcast/DeployChannelHub.s.sol/84532/run-latest.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0x89b81857a46cf290f23f6ff9b24e1031aad65204",
"transactionHash": "0xce57f0cc9f8184819745729a47b8f4a399b1402557a979062a42fe4f7dab90d9",
"commit": "9110ba06",
"timestamp": 1779278401,
"chainId": 11155111,
"contractPath": "src/ChannelEngine.sol:ChannelEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0x7d61ec428cfae560f43647af567ea7c6e2cc5527",
"transactionHash": "0xd74da343a9f1079e3455d9d62396bb9b807a6b8e93e9727cf30c7f91adec5def",
"commit": "104c13df",
"timestamp": 1779286321,
"chainId": 11155111,
"contractPath": "src/ChannelHub.sol:ChannelHub",
"constructorArgs": [
"0x708B3CA8b7Dc0f89Ea5a06709C3b92Dd5843B662",
"0x2B6dc5BB33F3eaAbfd3A8d17fDb7BdB8fEf331f9"
],
"comment": "stress v1.3.0 with VALIDATOR_ACTIVATION_DELAY = 1 minute"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0x708b3ca8b7dc0f89ea5a06709c3b92dd5843b662",
"transactionHash": "0x2ed88fa1af9f0513507fc508bdb9867d337657992a629fe93703318d56960a54",
"commit": "df4e110a",
"timestamp": 1779194593,
"chainId": 11155111,
"contractPath": "src/sigValidators/ECDSAValidator.sol:ECDSAValidator",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0xdccc09e335b87fb506c40a972e76fc7a225e0bf9",
"transactionHash": "0xce9fcc6a0668dbe2025b191360ecb94da8e3d672ae3c1838f7ba3c85c355c3d5",
"commit": "9110ba06",
"timestamp": 1779278401,
"chainId": 11155111,
"contractPath": "src/EscrowDepositEngine.sol:EscrowDepositEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0xdca4ab495188b545cfa919c0cb0a7e2280f2f407",
"transactionHash": "0xa3cd407e3e4288bf59982197df01a2ddfcf2bc91d399a8c5eb1438ee3c825091",
"commit": "9110ba06",
"timestamp": 1779278401,
"chainId": 11155111,
"contractPath": "src/EscrowWithdrawalEngine.sol:EscrowWithdrawalEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xF8bedb0aBa14833e95F29e760487C3d34Bc4Ec64",
"deployedTo": "0xe2B33Aa3922d7ac386e6801Ae7D9498C4DF45F1f",
"transactionHash": "0x7d8ed6acc062b28137ac08e8d1a0ed3368f39b2bf89f18910fec81ae77dffb55",
"commit": "df4e110a38ca3a4b17e46b606cc3233bbb7521c2",
"timestamp": 1779195108,
"chainId": 11155111,
"contractPath": "src/sigValidators/SessionKeyValidator.sol:SessionKeyValidator",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0x89b81857a46cf290f23f6ff9b24e1031aad65204",
"transactionHash": "0xd382762780c6e0661cc1f7bb228f30f6e46461be9efacc3b54750dbe8d27dfa0",
"commit": "9110ba06",
"timestamp": 1779278728,
"chainId": 84532,
"contractPath": "src/ChannelEngine.sol:ChannelEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0x61b9e0767f2eca7e33802e82f9c64b1ebe72ba31",
"transactionHash": "0xb63e91129e4742f33a2e81449b74ddbe783a3c87188f4b2a73062089cae9a37d",
"commit": "9110ba06",
"timestamp": 1779278728,
"chainId": 84532,
"contractPath": "src/ChannelHub.sol:ChannelHub",
"constructorArgs": [
"0xB5E7D2B8DB56A173Ca8c05CDdCC1379852CdC095",
"0x2B6dc5BB33F3eaAbfd3A8d17fDb7BdB8fEf331f9"
],
"comment": "stress v1.3.0 with VALIDATOR_ACTIVATION_DELAY = 1 minute"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0xb5e7d2b8db56a173ca8c05cddcc1379852cdc095",
"transactionHash": "0x6569b61c32d2b85b249a9bb4d221d9312de3691351117c62598df3cb222863c8",
"commit": "df4e110a",
"timestamp": 1779195327,
"chainId": 84532,
"contractPath": "src/sigValidators/ECDSAValidator.sol:ECDSAValidator",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0xdccc09e335b87fb506c40a972e76fc7a225e0bf9",
"transactionHash": "0x3c6043743ee8f39a6fe2b4b40e236755c2dd7da980d4fc5340e3e44fe4f949e4",
"commit": "9110ba06",
"timestamp": 1779278728,
"chainId": 84532,
"contractPath": "src/EscrowDepositEngine.sol:EscrowDepositEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xf8bedb0aba14833e95f29e760487c3d34bc4ec64",
"deployedTo": "0xdca4ab495188b545cfa919c0cb0a7e2280f2f407",
"transactionHash": "0x3a642c4c020499885b2b289bfacabbf19b80a4165e7968109c0cc0536753ae7f",
"commit": "9110ba06",
"timestamp": 1779278728,
"chainId": 84532,
"contractPath": "src/EscrowWithdrawalEngine.sol:EscrowWithdrawalEngine",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"deployer": "0xF8bedb0aBa14833e95F29e760487C3d34Bc4Ec64",
"deployedTo": "0x4085554a56F962b6c8eeeb017Bf2e9D2F3E31131",
"transactionHash": "0x287a20fc93f8a9448e8f7d290471cdb84d38107d73a68e25635a91884775c4a9",
"commit": "df4e110a38ca3a4b17e46b606cc3233bbb7521c2",
"timestamp": 1779195512,
"chainId": 84532,
"contractPath": "src/sigValidators/SessionKeyValidator.sol:SessionKeyValidator",
"constructorArgs": [],
"comment": "stress v1.3.0"
}
Loading
Loading