Skip to content
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

Handle private channel hop hints #487

Merged
merged 41 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b57d66f
Simplify adjust_target_for_route_self
contrun Jan 16, 2025
fe3561f
Make HopHints less like constraints to path-finding
contrun Jan 14, 2025
94b8a42
Comment out some hop hints payment tests
contrun Jan 16, 2025
2fc1557
Use channel outpoint in HopHint
contrun Jan 16, 2025
3829864
Update rpc docs
contrun Jan 16, 2025
3545d75
Refactor updating of heap and distances in finding path
contrun Jan 16, 2025
966e126
Use hop hints to find path
contrun Jan 16, 2025
102b66b
Add unit tests for hop hints
contrun Jan 16, 2025
b60cafd
Fix fee calculation with the wrong ChannelUpdate fee rate
contrun Jan 17, 2025
86af4d6
Add test for pay self fee rate
contrun Jan 17, 2025
75d9874
Use the right ChannelUpdate
contrun Jan 17, 2025
99a09bf
Add comment on we should use outbound channel's fee rate
contrun Jan 17, 2025
78d52a5
Fix balance checking becasue outbound liquidity is used now
contrun Jan 17, 2025
0b6445e
Fix the direction of ChannelUpdate in mock graph environment
contrun Jan 17, 2025
5813c8e
Split test test_channel_update_tlc_sync_up for tlc value and channel …
contrun Jan 18, 2025
d2b5793
Fix use the wrong amount to check tlc_minimum_value limit
contrun Jan 18, 2025
1847ec7
Check tlc forwarding fee
contrun Jan 18, 2025
be2973c
Check payment failure with outdated fee rate
contrun Jan 18, 2025
183a811
Fix TLC validity checking
contrun Jan 18, 2025
356a179
Update rpc documents
contrun Jan 20, 2025
75b1227
Merge branch 'fix-fee-calculation-with-wrong-ChannelUpdate-fee_rate' …
contrun Jan 20, 2025
6bc496f
Fix forwarding fee in finding path with hop hints
contrun Jan 20, 2025
6c90c76
Fix fee calculation while adjusting target
contrun Jan 20, 2025
7ed0faa
Fix using the wrong amount for adjusting target
contrun Jan 20, 2025
0e31287
Remove explicitly obtaining balance from store
contrun Jan 20, 2025
3dd662a
Add migration
contrun Jan 20, 2025
ff2a0c9
Merge remote-tracking branch 'nervosnetwork/develop' into handle-priv…
contrun Jan 22, 2025
5b55482
Remove some unused imports
contrun Jan 22, 2025
8a3ec86
Merge remote-tracking branch 'nervosnetwork/develop' into handle-priv…
contrun Feb 26, 2025
2b5c9a2
Add more debug info
contrun Feb 26, 2025
6b37020
Reproduce error for pending failed tlc calculation
contrun Feb 27, 2025
4e367fc
Do not counted in confirmed failed tlc in check and build settlement …
chenyukang Feb 27, 2025
08c64cd
Merge remote-tracking branch 'nervosnetwork/develop' into handle-priv…
contrun Mar 4, 2025
38003a7
Merge remote-tracking branch 'chenyukang/fix-failed-tlc-error' into h…
contrun Mar 4, 2025
0b4be98
Merge remote-tracking branch 'nervosnetwork/develop' into handle-priv…
contrun Mar 5, 2025
3b5984f
Remove migration
contrun Mar 6, 2025
b8b2ba8
Change log level
contrun Mar 6, 2025
ab161b4
Add TODO for updating test cases
contrun Mar 6, 2025
88bc9d0
Make eval_and_update a function
contrun Mar 6, 2025
2874d91
Remove added trace logs
contrun Mar 6, 2025
45feb5b
Merge remote-tracking branch 'nervosnetwork/develop' into handle-priv…
contrun Mar 6, 2025
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
55 changes: 55 additions & 0 deletions migrate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions migrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ serde_json = "1.0.135"
fiber_v020 = { package = "fnn", git = "https://github.com/nervosnetwork/fiber.git", tag = "v0.2.0" }
fiber_v021 = { package = "fnn", git = "https://github.com/nervosnetwork/fiber.git", tag = "v0.2.1" }
fiber_v030 = { package = "fnn", git = "https://github.com/nervosnetwork/fiber.git", tag = "v0.3.0-rc1" }
fiber_v031 = { package = "fnn", git = "https://github.com/contrun/fiber.git", rev = "102b66b86b11bf961a87ec4a5419e186457f2e48" }

[features]
default = []
Expand Down
96 changes: 96 additions & 0 deletions migrate/src/migrations/mig_20250120.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
use fiber::{store::migration::Migration, Error};
use indicatif::ProgressBar;
use rocksdb::ops::Iterate;
use rocksdb::ops::Put;
use rocksdb::DB;
use std::sync::Arc;
use tracing::info;

use crate::util::convert;

const MIGRATION_DB_VERSION: &str = "20250120090023";

pub use fiber_v030::fiber::graph::PaymentSession as OldPaymentSession;
pub use fiber_v030::fiber::network::SendPaymentData as OldSendPaymentData;
pub use fiber_v031::fiber::graph::PaymentSession as NewPaymentSession;
pub use fiber_v031::fiber::network::SendPaymentData as NewSendPaymentData;

pub struct MigrationObj {
version: String,
}

impl MigrationObj {
pub fn new() -> Self {
Self {
version: MIGRATION_DB_VERSION.to_string(),
}
}
}

impl Migration for MigrationObj {
fn migrate(
&self,
db: Arc<DB>,
_pb: Arc<dyn Fn(u64) -> ProgressBar + Send + Sync>,
) -> Result<Arc<DB>, Error> {
info!(
"MigrationObj::migrate to {} ...........",
MIGRATION_DB_VERSION
);

const PAYMENT_SESSION_PREFIX: u8 = 192;
let prefix = vec![PAYMENT_SESSION_PREFIX];

for (k, v) in db
.prefix_iterator(prefix.as_slice())
.take_while(move |(col_key, _)| col_key.starts_with(prefix.as_slice()))
{
let old_payment_session: OldPaymentSession =
bincode::deserialize(&v).expect("deserialize to old channel state");

let old_request = old_payment_session.request.clone();

let request = NewSendPaymentData {
target_pubkey: convert(old_request.target_pubkey),
amount: old_request.amount,
payment_hash: convert(old_request.payment_hash),
invoice: old_request.invoice,
final_tlc_expiry_delta: old_request.final_tlc_expiry_delta,
tlc_expiry_limit: old_request.tlc_expiry_limit,
timeout: old_request.timeout,
max_fee_amount: old_request.max_fee_amount,
max_parts: old_request.max_parts,
keysend: old_request.keysend,
udt_type_script: old_request.udt_type_script,
preimage: convert(old_request.preimage),
allow_self_payment: old_request.allow_self_payment,
dry_run: old_request.dry_run,
// The meaning of hop_hints changed, we are dropping previous hop hints.
hop_hints: vec![],
};

let new_payment_session = NewPaymentSession {
request: request,
retried_times: old_payment_session.retried_times,
last_error: old_payment_session.last_error,
try_limit: old_payment_session.try_limit,
status: convert(old_payment_session.status),
created_at: old_payment_session.created_at,
last_updated_at: old_payment_session.last_updated_at,
route: convert(old_payment_session.route),
session_key: old_payment_session.session_key,
};

let new_payment_session_bytes =
bincode::serialize(&new_payment_session).expect("serialize to new channel state");

db.put(k, new_payment_session_bytes)
.expect("save new channel state");
}
Ok(db)
}

fn version(&self) -> &str {
&self.version
}
}
1 change: 1 addition & 0 deletions migrate/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@

pub mod mig_20250114;
pub mod mig_20250115;
pub mod mig_20250120;
Loading
Loading