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

Env config names and defaults, merge Chain and Network args #230

Merged
merged 22 commits into from
Nov 29, 2021

Conversation

h4sh3d
Copy link
Member

@h4sh3d h4sh3d commented Nov 23, 2021

  • Shortify configuration names
  • Merge lnpbp Chain and Farcaster Network
  • others minor changes

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2021

Codecov Report

Merging #230 (2d51b21) into main (04b951f) will decrease coverage by 0.1%.
The diff coverage is 3.2%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #230     +/-   ##
=======================================
- Coverage   15.2%   15.1%   -0.1%     
=======================================
  Files         27      27             
  Lines       6371    6472    +101     
=======================================
+ Hits         970     979      +9     
- Misses      5401    5493     +92     
Impacted Files Coverage Δ
src/config.rs 0.0% <0.0%> (-50.0%) ⬇️
src/error.rs 0.0% <0.0%> (-1.8%) ⬇️
src/farcasterd/opts.rs 0.0% <0.0%> (ø)
src/farcasterd/runtime.rs 0.0% <0.0%> (ø)
src/lib.rs 13.2% <0.0%> (+3.8%) ⬆️
src/peerd/opts.rs 0.0% <ø> (ø)
src/peerd/runtime.rs 0.0% <ø> (ø)
src/swapd/opts.rs 0.0% <0.0%> (ø)
src/swapd/runtime.rs 0.0% <0.0%> (ø)
src/syncerd/bitcoin_syncer.rs 0.0% <0.0%> (ø)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 04b951f...2d51b21. Read the comment docs.

@h4sh3d h4sh3d marked this pull request as draft November 23, 2021 11:50
@zkao
Copy link
Member

zkao commented Nov 23, 2021

the configuration chain is not used, afaik

@zkao
Copy link
Member

zkao commented Nov 23, 2021

and shall be removed

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

The configuration network is used in the syncers. And will be used while making an offer in my next PR.

@h4sh3d h4sh3d marked this pull request as ready for review November 23, 2021 13:38
@zkao
Copy link
Member

zkao commented Nov 23, 2021

The configuration network is used in the syncers. And will be used while making an offer in my next PR.

it should not be possible to use global arguments for syncers, because farcasterd might launch 10 different syncers

@zkao
Copy link
Member

zkao commented Nov 23, 2021

running for different coins on different sub networks

@TheCharlatan
Copy link
Member

TheCharlatan commented Nov 23, 2021

I think if I understood @h4sh3d correctly, the configuration is relegated back to whatever is in the offer in his next PR.
EDIT: On seconds thought, you would still need a separate argument for the network the for each syncer, right?

@zkao
Copy link
Member

zkao commented Nov 23, 2021

@TheCharlatan, can u shed some light on this, since u worked on the syncers config?

but my understanding is that chain shall not be a global config, isnt it?

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

Uhm, not really. I thought about a setup where if launched with --testnet farcasterd cannot do mainnet swap in parallel. Do we really want to mix everything (in term of network)?

EDIT: replying to @TheCharlatan

@TheCharlatan
Copy link
Member

Then I misunderstood the purpose @h4sh3d , I agree with @zkao then that farcasterd should give this argument to the syncer manually.

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

Then I misunderstood the purpose @h4sh3d , I agree with @zkao then that farcasterd should give this argument to the syncer manually.

It does, but through the shared flags and not with two parallel values.

So we want to allow running swaps on different networks with the same farcasterd instance?

@zkao
Copy link
Member

zkao commented Nov 23, 2021

a Syncer is:

Syncer(Coin, Network),

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

Yes, obviously. So farcasterd will be able to manage a list of Syncers by tuple (Coin, Network), if I do a make --testnet btc xmr it will check and launch both testnet syncer for btc and xmr, if 1 minute after I do make --mainnet btc xmr it will launch the mainnet ones, correct?

@zkao
Copy link
Member

zkao commented Nov 23, 2021

The obvious thing: syncer config should be local (independent of whether farcasterd mixes networks). <- this is a bug

Farcasterd mixing or not networks is an opinionated detail that has no urgency <- this is an opinion

@zkao
Copy link
Member

zkao commented Nov 23, 2021

merging Coin with the constructs used in core would also be appreciated

@zkao
Copy link
Member

zkao commented Nov 23, 2021

the hard bit is how to make these farcasterd options disappear, any thought, @h4sh3d and @TheCharlatan ?

--electrum-server localhost:60001 --monero-daemon http://localhost:38081 --monero-rpc-wallet http://localhost:18083

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

merging Coin with the constructs used in core would also be appreciated

Yes, I'll open an issue to track that and include it in core.

@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

the hard bit is how to make these farcasterd options disappear, any thought, @h4sh3d and @TheCharlatan ?

--electrum-server localhost:60001 --monero-daemon http://localhost:38081 --monero-rpc-wallet http://localhost:18083

This has to be injected in the config, if we move them out of shared opts like the network syncer could find them through the farcaster.toml config file in the data dir.

And them we extend the config to have one of each per network. I had the problem some days ago when network was testnet but a syncer was connected to a mainnet daemon, no errors were given I just found it in the middle of the swap because the height printed in the logs were weird.

@h4sh3d h4sh3d marked this pull request as draft November 23, 2021 17:45
@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 23, 2021

In my last commit (WIP) I use the config flag in args to parse a toml file containing the syncer configuration in syncerd.

}
if !self.syncers.contains_key(&(coin_acc.clone(), network)) {
launch("syncerd", &[coin_acc.to_string(), network.to_string()])?;
Copy link
Member

Choose a reason for hiding this comment

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

if i were you, i would leave the stuff that is written to the toml to something runtime independent, such as a map btw say

(Monero, Testnet) -> "--monero-daemon http://localhost:38081 --monero-rpc-wallet http://localhost:18083"
(Bitcoin, Testnet) -> "--electrum-server localhost:60001"

Then if the config doesnt have it, it can't run the swap.

@h4sh3d h4sh3d force-pushed the minor-changes-batch-1 branch 2 times, most recently from 7a3fd5c to 35b0e6a Compare November 24, 2021 20:41
@h4sh3d h4sh3d force-pushed the minor-changes-batch-1 branch from 0094f59 to 349d860 Compare November 26, 2021 15:32
@h4sh3d h4sh3d marked this pull request as ready for review November 26, 2021 16:28

fn main() -> Result<(), Error> {
Copy link
Member

Choose a reason for hiding this comment

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

What's up with the return type?

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the problem about returning an error?

Copy link
Member

Choose a reason for hiding this comment

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

This function doesn't return, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

The binary returns eventually, so exit code is not zero and error is printed. You can have main return result in rust :)

Copy link
Member Author

Choose a reason for hiding this comment

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

When I mean eventually: it returns early if it miss some params to start

Copy link
Member

Choose a reason for hiding this comment

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

The binary returns eventually, so exit code is not zero and error is printed. You can have main return result in rust :)

But which statement within this main function actually returns? I only see a panic case here, and no ?, return or omitted ;. So I'm guessing you are just returning for style? But even then, it seems inconsistent with swapd.rs and peerd.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh sorry, I guess the code that was there got removed, run fn can panic but it is handled by the expect so yes I have to removed that. (On the phone, didn’t open the file before now to check)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9e3a5fe

src/config.rs Outdated

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(crate = "serde_crate")]
pub struct Syncers {
Copy link
Member

@TheCharlatan TheCharlatan Nov 26, 2021

Choose a reason for hiding this comment

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

Syncers is too generic a name for my taste, especially since we have other syncer vars in the code. How about just SyncerConfig

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 9e3a5fe

@TheCharlatan TheCharlatan mentioned this pull request Nov 26, 2021
@TheCharlatan TheCharlatan self-requested a review November 27, 2021 09:37
@h4sh3d h4sh3d force-pushed the minor-changes-batch-1 branch from 1256d8d to 9e3a5fe Compare November 29, 2021 13:47
@h4sh3d
Copy link
Member Author

h4sh3d commented Nov 29, 2021

Fixing clippy...

Copy link
Member

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

tACK

@TheCharlatan TheCharlatan merged commit 960478e into farcaster-project:main Nov 29, 2021
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.

4 participants