Skip to content

Commit

Permalink
Fixing a concurrency issue when opening channels, relaxing cln feerat…
Browse files Browse the repository at this point in the history
…e limits, fixing cln listchannels call
  • Loading branch information
bjohnson5 committed Dec 13, 2024
1 parent 4cf6e93 commit d713a7a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions blast_models/blast_cln/blast_cln/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl BlastRpc for BlastClnServer {

let node_id = &request.get_ref().node;
let mut node = self.get_node(node_id.to_string()).await?;
let cln_resp = match node.list_channels(ListchannelsRequest{short_channel_id: None, source: None, destination: None}).await {
let cln_resp = match node.list_peer_channels(ListpeerchannelsRequest{id: None}).await {
Ok(r) => {
r.into_inner()
},
Expand All @@ -433,11 +433,9 @@ impl BlastRpc for BlastClnServer {

let mut result = String::new();
for c in cln_resp.channels {
if c.direction == 1 {
if let Some(amount) = c.amount_msat {
result.push_str(&format!("Peer: {}, Amount: {}", hex::encode(c.destination), amount.msat / 1000));
result.push('\n');
}
if let Some(amount) = c.total_msat {
result.push_str(&format!("Peer: {}, Amount: {}", hex::encode(c.peer_id), amount.msat / 1000));
result.push('\n');
}
}

Expand Down
2 changes: 1 addition & 1 deletion blast_models/blast_cln/blast_cln/start_cln.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ EOF

mkdir -p "$CLND_SOCK"
test -f "$LIGHTNING_DIR/lightningd-regtest.pid" || \
"$CLND" "--network=regtest" "--alias=$ALIAS" "--lightning-dir=$LIGHTNING_DIR" "--bitcoin-datadir=$BITCOIN_DIR" "--database-upgrade=true" "--grpc-port=$socketrpc" "--rpc-file="$CLND_SOCK"/"$socketrpc""&
"$CLND" "--network=regtest" "--alias=$ALIAS" "--lightning-dir=$LIGHTNING_DIR" "--bitcoin-datadir=$BITCOIN_DIR" "--database-upgrade=true" "--grpc-port=$socketrpc" "--ignore-fee-limits=true" "--rpc-file="$CLND_SOCK"/"$socketrpc""&
5 changes: 3 additions & 2 deletions blast_models/blast_lnd/blast_lnd.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type BlastLnd struct {
home_dir string
data_dir string
open_channels map[string]ChannelPoint
lock sync.Mutex
wg *sync.WaitGroup
}

Expand Down Expand Up @@ -210,13 +211,13 @@ func (blnd *BlastLnd) start_nodes(num_nodes int) error {

// After starting 10 nodes, wait some time to let the nodes get up and running
if i%10 == 0 {
time.Sleep(10 * time.Second)
time.Sleep(5 * time.Second)
}
}

// After starting all of the nodes, attempt to connect the model to each running lnd node
blnd.connect_to_nodes(node_list.Nodes)
time.Sleep(10 * time.Second)
time.Sleep(5 * time.Second)

// After successfully connecting to all nodes, create the sim-ln data for all the running nodes
err = blnd.create_sim_ln_data(node_list, blnd.data_dir+"/sim.json")
Expand Down
3 changes: 3 additions & 0 deletions blast_models/blast_lnd/blast_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (s *BlastRpcServer) OpenChannel(ctx context.Context, request *pb.BlastOpenC
if err != nil {
return
}
s.blast_lnd.lock.Lock()

switch rpcUpdate.Update.(type) {
case *lnrpc.OpenStatusUpdate_ChanPending:
Expand All @@ -205,6 +206,8 @@ func (s *BlastRpcServer) OpenChannel(ctx context.Context, request *pb.BlastOpenC
return
case *lnrpc.OpenStatusUpdate_PsbtFund:
}

s.blast_lnd.lock.Unlock()
}
}()
}
Expand Down

0 comments on commit d713a7a

Please sign in to comment.