-
Notifications
You must be signed in to change notification settings - Fork 19
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
Config: expose swap finality parameters #800
Config: expose swap finality parameters #800
Conversation
ba4d741
to
4e90e98
Compare
@Lederstrumpf @TheCharlatan do we want to expose different finality and safety margin per network? (And are those names good?) |
Makes sense to expose per network and names lgtm |
agree it makes sense to have different finality thresholds per network. for safety, it would be more consistent to call this |
4e90e98
to
94956af
Compare
…ch at compile time
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.
ACK 981c0d1
Really nice work! Would like @Lederstrumpf to ACK this as well, since it touches configuration.
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.
ACK @ bda0705
and I look forward to chains.rs
spreading its claws through the node to make it chain generic 🔪 :D!
pub type BlockHeight = u32; | ||
|
||
/// Represent a block length or a block number | ||
pub type BlockSpan = u32; |
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.
👍
@@ -226,25 +384,44 @@ pub struct SyncerServers { | |||
pub monero_wallet_dir: Option<String>, | |||
} | |||
|
|||
#[derive(Deserialize, Serialize, Default, Debug, Clone)] | |||
#[serde(crate = "serde_crate")] | |||
pub struct Networked<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.
I both hate & love this struct naming xD
I'm guessing you wanted to avoid Network because this here is limited to config? Then might go for NetworkConfig
? Anyway, keen to get your rationale for this one on Monday.
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.
:) yes network is to generic, just wanted to express that it’s a wrapper to “network” a type. NetworkConfig would be fine (if we don’t introduce some [network..] section later) or PerNetwork maybe.
(I'm holding off on merge to get #789 in first since they conflict slightly) |
ok - merging :). And nice new PR docs, @h4sh3d! |
This PR introduce a new section
[swap...]
in the config filefarcasterd.toml
. The swap section, for now, contains finality and safety parameters per chain per network. A chain can acceptarbitrating
parameters oraccordant
parameters, currently we only support btc and xmr:farcaster-node/src/config.rs
Lines 239 to 246 in 981c0d1
The configuration can then return a parsed swap configuration for a given network, arb chain, and acc chain
farcaster-node/src/config.rs
Lines 150 to 156 in 981c0d1
We have default values for mainnent and testnet for Bitcoin and Monero, if no config is found in the file we return those default value (backward compatibility), otherwise an error is returned. The configuration translate the real chain (Btc, Xmr) into its interface (Arb, Acc) as the swap is started with the offer that contains the chains used.
Launching a swap now takes the parsed swap config to
farcaster-node/src/farcasterd/runtime.rs
Lines 1244 to 1260 in 981c0d1
Cli arguments of swapd have been reworked to accept the new arguments. (Breaking change with other bins that use swapd directly)
The new
chains.rs
file contains enums for listing support arb/acc chains in our node (e.g. btc as acc is in theory possible but probably not supported in the current architecture, but that would be a nice test to see where the current design falls apart). These structs can be reused later elsewhere (e.g. make cli args) to ensure we accept only valid params.