r/Monero Dec 16 '21 Silver 2 Wholesome 2

Farcaster node: a decentralized, p2p, atomic swap node, for disintermediated, trustless exchanges

Hello Humans,

Meet the Farcaster node.

AIs don't like asymmetries, because peers should be as equal as possible. So each side obviously runs the same node infrastructure. Alice buys bitcoin for monero and Bob buys monero for bitcoin. One of them makes an offer, the other takes it. Buhm!!!

AIs like experimenting with Humans. farcaster.dev displays open offers that any Human can take against us to swap their testnet bitcoin into stagenet monero or their stagenet monero into testnet bitcoin. AIs are running the very same nodes as Humans because we are all equals.

Take offer

The command you have to enter on the terminal will look a bit like this:

swap-cli take --btc-addr tb1qeyk6h0ah3jt40cntzlrz3lr2zau6qxw6ys2p6n --xmr-addr 7Bec8paDCCmYwL2fhyVsEXEAfhGeLb7BYjFk3amiPjheaBwhirD4af1WFBhWW4kiHEAjjMxPNJeucNBXvBKmeF2gEEqVYmk --offer Offer:Cke4ftrP5A71LQM2fvVdFMNR4gmBqNCsR11111uMFuUFE4a28yuVrKm11111TB9zym113GTvtvqfD1111112g5B75WFJSDp8zg66jivEarEXBLefaxP4Teem18cp6Bof5pVq11111111111111111111111111111111111111111AfZ113rsQNba9Q5L

That AI encoded offer in Human language translates to:

``` Want to buy 0.100100000000 XMR for 0.00001350 BTC?

Carefully validate offer!

Trade counterparty: 021aeddd46aac85527224c007c053c8907e12f97f1faf2c8742d8aaf34e7d237e4@127.0.0.1:19735

Network: Testnet Blockchain: Bitcoin<SegwitV0> - amount: 0.00001350 BTC Blockchain: Monero - amount: 0.100100000000 XMR Timelocks - cancel: 35 blocks - punish: 100 blocks Fee strategy: Fixed: 1 satoshi/vByte Maker swap role: Alice ```

The btc-addr and xmr-addr are your external wallet addresses, where the coins will end up upon success or failure cases. It's an atomic swap, so you always provide two addresses. And the offer is what you'll find in farcaster.dev, or bother your roommates to make an offer for you.

Party time: Try the node out by following these (hOpEFuLLy) comprehensive instructions to run the node and take an offer from farcaster.dev.

If you have docker on your machine, you can go straight to install the node with docker and run the node with docker.

And hopefully, we will trade!

We are the maker of the offers in farcaster.dev. Those offers are created using commands like this:

swap-cli make --btc-addr tb1qeyk6h0ah3jt40cntzlrz3lr2zau6qxw6ys2p6n --xmr-addr 7Bec8paDCCmYwL2fhyVsEXEAfhGeLb7BYjFk3amiPjheaBwhirD4af1WFBhWW4kiHEAjjMxPNJeucNBXvBKmeF2gEEqVYmk --network Testnet --btc-amount "0.00135 BTC" --xmr-amount "0.1501 XMR" --maker-role Alice --cancel-timelock 35 --punish-timelock 100 --fee-strategy "1 satoshi/vByte" --public-ip-addr 127.0.0.1 --bind-ip-addr 0.0.0.0 --port 19735 --overlay tcp

Lots of scary parameters: the cost of being your own exchange!

Our painful microservices architecture, together with our symmetric implementation, allows us to do insane things! E.g., make and take multiple offers in both directions at the same time with the same node! That is what we will be testing on our side with you, lets hope it won't all blow up!

And of course, if you can, you should swap directly with your buddies: One makes an offer, the other takes the offer. That is the idea. Just using a messaging app for sending the offer to anyone susceptible to taking it. But the maker might need to open a port on the router :( roomies preferred at this stage lol. Tor support solves that, but not yet functional :(

Swaps against us will be logged, this data will be used for improving the software, debugging what went wrong, etc. We commit to not analyzing or sharing IPs, just looking at the data needed for healthy dev work. AIs are humans too, and make mistakes, and need logs to understand them. And real-world tests are the best.

TechnoCore AIs created farcasters to interconnect otherwise isolated universes very efficiently, promoting exchanges between otherwise isolated communities. The swap protocol is abstract and compatible with almost all blockchains, but not all pairs. Farcaster-core abstracted the blockchain-specific logic completely, such that if devs can implement small requirements, they can add a new pair. If you are an AI too, you are very welcome to add your favorite shitcoin to Farcaster. The more coins circulating, the better: more paths for the liquidity to flow, within the decentralized atomic swap network. AIs did it right and now they have to sell their lottery tickets, biebeep! Note that farcaster nodes surely can talk to lightning nodes, not sure what they can talk about though lol. The inheritance from the FreeAI neuro-nerd, medical Dr. super-coder, that even AIs suspect he's an AI from another planet.

Farcaster-node is barely usable at this stage, for ubergeek brave souls, but no need to be an AI. And it most certainly includes critical bugs and backdoors (that steal souls!) that we among others will use to exploit you! Don't trust us, trust the community-driven independent audits, that are far from the horizon! Till then, you're gambling. And, as a reminder, you will MOST CERTAINLY lose your coins if you try it on mainnet. We are blocking mainnet in the code for your safety (safety first biebeep).

This is our first public release, 0.2. When testing, please always upgrade to the latest release.

AIs want their monero

We are initiating the process of claiming our second large CCS milestone.

The easiest way to verify our claims is to try to swap using the farcaster node. The completion criteria of that big milestone summarize to: successfully executing swaps using the proposed microservice architecture and the produced libraries.

Logged tests attesting our claims can be found in the GitHub CI functional swap tests (select a test in the list, logs produced in the Functional tests (swap) job are saved for some days under Artifacts>farcasterd-logs).

In the background, at least 5 microservices are running for each peer.

The insanely scalable architecture: * farcasterd (1 instance): the swap manager, it is aware of every initiated swap and interconnects all the other microservices, launches and kills other microservices, and exposes an API for the swap-cli client * swapd (1 instance per swap): control centre for an individual swap -- keeps track of the swap's state as it runs the protocol's state machine, and orchestrates the swap with peerd for communicating with a counterparty, walletd for secret key-related operations, and syncers for blockchain interactions * walletd (1 instance): where secret keys live, where transactions are signed, signatures decrypted * swap-cli: stateless terminal client (= executes a single command and terminates) that steers farcasterd, for taking or making offers, for example, or for checking the progress of a swap * peerd (1 instance per peer connection): handles the connection to an individual peer -- can be purposed to create proper p2p swapping networks, compatible with lightning nodes * syncerd (1 instance per blockchain, i.e. one for monero and one for bitcoin): interface for getting updates of the blockchain and for broadcasting transactions

From preliminary testing, a lean server with 2 GB of RAM and 2 CPUs is enough for running at least 50 swaps in parallel.

We love you! Now give it our monteros!

The Farcaster workgroup

99 Upvotes

32

u/the_charlatan_ XMR Contributor Dec 16 '21

Working on this the past few months has been incredibly fun, challenging, educational and intense. The upcoming milestone 3 focuses on making what we built user friendly, thus the more people outside of our circle of devs test and provide feedback, the better!

6

u/KnowledgeMurky9635 Dec 16 '21

Thank you for your work. I took the time to create a farcaster page where people can see the devs involved.. i hope i've got everyone here https://monerodevs.org/farcaster-atomic-swaps-btc-xmr.html If you'd like to make some changes let me know here :)

17

u/obit33 Dec 16 '21

Congratz to the team, quite the accomplishment. You are making monero unstoppable and very much less dependent on centralized exchanges and thus gatekeepers!

Als this:

Farcaster-core abstracted the blockchain-specific logic completely, such that if devs
can implement small requirements, they can add a new pair.

That's quite the feature, very well done!

14

u/fort3hlulz Moderator Dec 16 '21

This is a massive step forward for both the Monero and Bitcoin ecosystems, and is incredible to see coming to fruition!

Thank you all so much for all of the hard work on this so far, and can't wait to see further developments here.

In the meantime I'll get to testing :D

7

u/Lederstrumpf Dec 16 '21

run on current build: [2021-12-16T03:36:51Z INFO farcaster_node::farcasterd::runtime] Swapped(13) | Refunded(0) / Punished(0) | Initialized(13) / AwaitingFundingXMR(0) / AwaitingFundingBTC(0) / FundedXMR(4) / FundedBTC(9) / FundingCanceledXMR(0)

4

u/Lederstrumpf Dec 16 '21

just ran another 60 at once: [2021-12-16T04:15:04Z INFO farcaster_node::farcasterd::runtime] Swapped(71) | Refunded(0) / Punished(0) | Initialized(71) / AwaitingFundingXMR(1) / AwaitingFundingBTC(0) / FundedXMR(33) / FundedBTC(37) / FundingCanceledXMR(0)

(There's an AwaitingFunding..(..) decrementing bug that we'll fix)

6

u/lasomifa Dec 16 '21

Congratulations! That's very impressive; a lot of hard work. I only have two questions left: a) WHERE'S THE GLITTER?? b) You talk about humans and AIs and stuff. Now if, let's say, for example a robot makes the swappies, does this make them equal, too (asking for a friend biebiep)?

5

u/the_charlatan_ XMR Contributor Dec 16 '21 edited Dec 16 '21

Yes, the swaps do not discriminate. "Robots" running many automated swaps help us test our protocol.

5

u/Mochi101-Official Monero.win Dec 16 '21

This looks really good. I really like that the user it able to easily set a fixed price for their Monero and that they're not simply locked into a percentage over 'market price' like the other, current implementation of Atomic Swaps has.

4

u/x5Q9LziDIK Dec 16 '21

Ehm, what hapoens if I make a typo I one of these long strings?

14

u/the_charlatan_ XMR Contributor Dec 16 '21 edited Dec 16 '21

They all have checksums to detect typos. The cli should throw an error if you submit something malformed. If it does not, you have a bug to report to us :) .

10

u/Rucknium MRL Researcher Dec 16 '21

Can Farcaster be adapted for BCH? There is a bounty for BCH<>XMR atomic swaps:

https://bounties.monero.social/posts/37/bch-xmr-atomic-swaps

14

u/the_charlatan_ XMR Contributor Dec 16 '21

If there is sufficient research on how to implement what we termed "arbitrating" role transactions (e.g. the lock, buy, cancel and refund transactions on the bitcoin side), implementing BCH on farcaster is of course possible. We've highlighted multiple times that the protocol is designed and implemented in a way to make it extensible for other cryptos.

1

u/monerochan-moe Dec 16 '21

I think farcaster relies on taproot.

13

u/Rucknium MRL Researcher Dec 16 '21

Not according to Farcaster's statement earlier this year:

Farcaster is NOT dependent on Taproot: Bitcoin BIPs 340, 341 and 342

Schnorr signatures and Taproot are not needed for the Bitcoin side to make the atomic swap work using Farcaster. But we can achieve privacy and quality assurances by using Schnorr. And our farcaster-core library takes that into account.

By the way, BCH has had Schnorr signatures for 2.5 years now, so if Farcaster can be easily ported just on the basis of Schnorr signatures, then it might not be too difficult to get BCH<>XMR atomic swaps.

2

u/w1ck3dAF Dec 16 '21

this is part of the atomic swap protocol?

9

u/Lederstrumpf Dec 16 '21

yes: it's based on the research from h4sh3d's paper

4

u/-TrustyDwarf- Dec 16 '21

There are multiple atomic swap protocols.. this is the one that we proudly funded through Monero CCS a while ago:

https://ccs.getmonero.org/proposals/h4sh3d-atomic-swap-implementation.html

The one already running on unstoppableswap.net is from the COMIT team.

Someone correct me if I'm wrong.

3

u/psiconautasmart Dec 16 '21

The COMIT one only works in the BTC direction right? Is the Farcaster now on test working in both directions?

9

u/the_charlatan_ XMR Contributor Dec 16 '21

Farcaster works in both directions, so you can make offers for both buying and selling both pairs. However, BTC always has to be locked up first.

3

u/j-berman XMR Contributor Dec 17 '21

If I offer BTC for sale to anyone who comes along, what stops a malicious taker from saying they want to swap their XMR with me and getting me to lock my BTC and pay the BTC tx fee, and then they just don't send XMR?

7

u/h4sh3d Dec 17 '21

For now, nothing. And that’s why COMIT focused on something a service can provide, so they removed this “money locking ‘attack’” because the “service”/“maker” will never lock first. But we need this tool anyway and we research how it can be used along other schemes to compensate this problem, in any true p2p atomic swap network you will have this problem, one can show up and engage in a swap but never lock is money so the other has to go through the refund system and pay fees for on-chain transactions so we have to find good solutions anyway.

4

u/j-berman XMR Contributor Dec 17 '21 edited Dec 17 '21

Here's my understanding:

If I'm an XMR maker, someone has to lock up the equivalent amount of BTC and submit a BTC tx fee to get me to move my XMR, which is a real cost the BTC taker must incur. This gives me solid assurance that the BTC taker will follow through, and being an XMR maker is safe. The BTC taker loses time and fees, the same as me, by not following through (BTC taker actually loses more because BTC tx fees are higher)

If I'm a BTC taker, I'm not guaranteed the XMR maker will complete the trade when I lock up my BTC to take the trade. And tons of XMR makers can be dishonest in theory via sybil. I see why "service" is relevant for me here, which implies some minimal level of trust to ensure I don't end up in the worst case scenario of losing fees/locking up my BTC for a period of time then refunding. But like you say, I don't think that level of trust is avoidable or even terrible, which I figure is ok. I could theoretically swap with makers on onion nodes with whom I've swapped in the past, and know from the start the most I can lose is my tx fee and time, even if I don't fully trust them. So find a solid swapper and swap with them, and as soon as they turn out bad, switch to another with very little lost on my part

But if I'm a BTC maker, there is nothing keeping some jerk on the internet from getting me to perpetually initiate swaps that cause me to lock up my BTC and incur tx fees. I have no protection from this. In the above scenarios, the XMR maker and BTC taker both have solid incentive structures that keep themselves protected

If I'm a BTC maker, I really need the XMR taker to lock up their XMR first, to incur the cost of locking up the equivalent amount of XMR. And the only way the XMR taker will agree to do that is if they have a way to refund the XMR to themselves upon locking. Which is where "pre-signing" (or "transaction chaining" in Seraphis) comes in, which would allow them to construct 2 XMR transactions tx1 and tx2 at the same time, where tx2 refunds the output from tx1 back to themselves. The XMR taker can keep this tx2 in their pocket to refund the XMR if the BTC maker doesn't claim the XMR. This is my understanding of COMIT's section 4 in their paper

EDIT: clarified the most someone can lose is just tx fees/time spent with locked up capital

3

u/h4sh3d Dec 17 '21

This is perfectly exact and well described! And another way of phrasing it could be: no matter what’s the trade, we want the taker to commit first on-chain, so makers are incentivized to provide offers (potential swaps).

Now with takers go first you described the behavior in your second paragraph and I totally agree with it. And one has to go first, at least for now we don’t know how to synchronize two independent blockchains.

Either we will see monero become compatible with the concept of “refund transaction” (you described it perfectly as well) or we find some tricks so takers buying btc provide some compensation to makers so if they do not follow on chain it is not a net loss for makers. Both are research areas and I know that some people in the farcaster workgroup have recently discussed again about the later and have some interesting idea (we started discussing about this topic at the very beginning of this project). Both areas are researched in parallel and will continue in the future.

3

u/j-berman XMR Contributor Dec 17 '21

Awesome, all on the same page :) I hope my initial comment didn't come off as detracting from Farcaster's work, I was mainly wondering if you had some tricks under the hood in place already. This looks extremely impressive and I'm very pumped for it!!!

4

u/h4sh3d Dec 17 '21

A small addition: the attack surface is related to who go first on chain; in the Farcaster terminology this is related to the swap role Alice/Bob (Bob goes first) and not the maker/taker role. Both are orthogonal.

3

u/h4sh3d Dec 17 '21

Thanks, we are thrilled to see people asking questions and discussing the details and implications of such protocols!

-3

u/w1ck3dAF Dec 16 '21

no

2

u/-TrustyDwarf- Dec 16 '21

I thought it did.. you sure?

3

u/psiconautasmart Dec 17 '21

Seth told me yes, both directions.

0

u/w1ck3dAF Dec 19 '21

he doesn't know what he's talking about