Application: Cosmic.vote

Summary:

Cosmic.vote implements the first building blocks for decentralized organizations on Stellar: majority judgment and passive contracts. Majority judgment is a robust voting system that is suitable for achieving both community and automated consensus. A passive contract is a mechanism that achieves trustless Turing-complete computations under specific conditions. Cosmic.vote provides an open-source implementation of those, as well as three real-world use cases: polls, contests w/ decentralized prize pools, & oracles.

Category:

Applications, Tool & Infrastructure

Goals:

  • [X] Implement majority judgment.
  • [X] Implement passive contracts.
  • [  ] Implement operated contracts.
  • [X] Use those building-blocks to run a decentralized voting system.
  • [  ] Use those building-blocks to run a decentralized prize distribution for an SCF-like contest.
  • [  ] Use those building-blocks to run a decentralized oracle system.
  • [  ] Provide open-source libraries & toolkit.
  • [X] Provide integration with third-party websites.

Let's Give It A Try :)

  1. Browse to Cosmic.vote.
  2. Select a grade for each candidate.
  3. Click on Cast Your Vote!.
  4. Within the SideFrame, select Test Account under Step 2: Signing Method.
  5. (Give it a second, it's creating & funding your test account...)
  6. Click on Sign with Test Account.
  7. Enjoy!

Description:

Cosmic.vote is about running votes, prize distributions, and oracles without having to rely on a third-party. This quality, referred to as "trustless", is fundamental to cryptocurrencies. What has achieved Bitcoin? The first digital currency that doesn't require a trusted third-party to exists. What has achieved Ethereum? Contracts that don't require a trusted third-party to execute. What about DeFi? Same principles.

In cryptocurrency-related development, trustlessness is more than a nice quality to have: it is a requirement. While Stellar can't execute arbitrary code as Ethereum does, in some cases, it is possible to achieve similar results using alternative mechanisms.

Cosmic.vote introduces some of those mechanisms as the firsts building blocks for decentralized organizations on Stellar. It shows how those can be combined together to build trustless systems that would normally require Turing-complete smart contracts.

Majority Judgment is a voting system first described in 2007 by R. Laraki & M. Balinski as the least bad solution to Arrows's impossibility theorem

This theorem, pivotal in social choice theory, states that it is impossible to create a voting system that is fully resistant to aberrant results. In his work, Kenneth Arrow went over the many ways voting systems can be (and are) abused. The research that leads to majority judgment capitalized on that work to figure out a system that would, at least, mitigate those issues as much as possible.

What is beautiful about majority judgment is that, despite being the most robust voting system known to that day, it is simple enough to be understood & put in practice by everyone. Thus, it is a suitable alternative to traditional voting systems, be it a simple online poll or national elections.

Passive Contracts are a way to build contracts that makes it possible to run complex programs such as voting systems without having to rely on a third-party. The principle is to store the contract parameters on the ledger and to have the clients perform the computations. For a particular family of programs, which is referred to as "fully functional", this facility provably achieves trustless layer 2 contracts.

The limit here is that passive contracts cannot mutate the ledger. In simple words, they can do pretty much everything except sending money.

Operated Contracts are an extension of passive contracts, that are already being used in many systems, but those have the limitation of requiring third-party for settlement. That's why, while possible on Stellar, this family of contracts is often left aside as unsuitable. However, under certain conditions, they can be leveraged to achieve a near-optimal level of robustness.

Links:

Application: Cosmic.vote
Code Repository: GitHub

Some Polls:
(Stellar Public) Unhealthy Meals Ranking
(Stellar Test) Coins Fundamentals −> Check the embedded Version
(Stellar Test) Browse Polls

Organization: Cosmic.plus
Social: Keybase | Telegram | Reddit | Twitter | Medium

Articles

  • Cosmic.vote #1: Introducing Majority JudgmentThe ambition of Cosmic.vote is to bring decentralized organizations to Stellar. No wonder that Majority Judgment has been chosen for its first contract: when it comes to decentralized governance, having a well-designed, robust voting system is an absolute game-changer. Let’s see why Majority Judgement is superior in this matter.

Going Further

Pedagogic Content:

Scientific Content: (Publications of M. Balinski & R. Liraki)

About Majority Judgment Inventors:

Michel Louis Balinski was emeritus director of research of the CNRS at the Ecole Polytechnique (Paris). He was the Founding Editor of Mathematical Programming and a former President of the Mathematical Optimization Society. In 2013 he was awarded the John von Neumann Theory Prize by INFORMS for “fundamental, sustained contributions to theory in operations research and the management sciences.” [More...]

Rida Liraki is director of research CNRS in computer science at LAMSADE (University of Paris Dauphine) since 2013 (and researcher at the CNRS since 2001). From 2006 to 2017, he was professor at the École Polytechnique and since september 2017, he is professor at the University of Liverpool (computer science department, part-time). [More...]

Tags:

poll, vote, oracle, trustless, contract, decentralized, organization, 100% open-source

Mood Box

I hope I forgot nothing... It's quite late already!

For now, the released web app supports only a subset of the planned features. There's still a couple of challenges on the way toward prize distribution & oracles. Anyway, I believe I can deliver at least a PoC of those during this SCF cycle.

At that time, public & custom nets contracts are fully supported, but I decided to release on testnet first. You can vote & create your own polls by selecting the "Stellar Authenticator" signing method & using the "Guest Mode" to obtain a testnet account right away. Stellar Laboratory works too.

More soon. Stay tuned!

    MisterTicot

    MisterTicot At that time, public & custom nets contracts are fully supported, but I decided to release on testnet first. You can vote & create your own polls by selecting the "Stellar Authenticator" signing method & using the "Guest Mode" to obtain a testnet account right away. Stellar Laboratory works too.

    The interesting thing is, did I understand correctly that the test mode already allows you to create your own questions when choosing a guest mode subscription, and I will get full access to the supported features?

      WalterBeen The interesting thing is, did I understand correctly that the test mode already allows you to create your own questions when choosing a guest mode subscription, and I will get full access to the supported features?

      Yes, currently it gives you access to all features, but on the testnet. When we'll do prize distribution, it will be on the public net & will require a normal Stellar account. (e.g: Keybase)

      Release 1.0.0-beta.2

      Mobile interface & UI polishing.

      Added

      • UI: Tell when the contract is being loaded.
      • UI: Keep results in sync with the ledger.
      • UI: Redirect to results once the vote has been validated.
      • UI: Display contract time-related parameters.

      Fixed

      • Meta: Ensure stellar.toml is being served.
      • Style: Fix unwanted "bumping" effect on buttons.
      • Style: Fix mobile tab selector arrow & width.
      • Style: Fix buttons vertical-align.
      • Style: Fix mobile display of results.
      • UI: Fix syncing after posting a new poll.

      Judging by the number of voting projects in this round of SCF, the company's request for fair voting services is greatly aggravated. Today it is really important. Therefore, I wish you to realize a truly working and applicable service!

        4 days later

        Release 1.0.0-beta.3

        Polls browsing.

        Added

        • UI: Add custom poll listing address.
        • UI: Add browse tab.

        Changed

        • Style: Polish header style.

        Fixed

        • Style: Normalize iOs/macOs form elements.
        • UI: Fix typos.
        • UI: Fix poll confirmation canceling.

        Commentary

        It is now possible to browse the polls list. For now, it only browses list*cosmic.vote although adding lists is an easy matter.

        This browsing thing opens several questions:

        • Should we have public contracts listings & how to deal with spam? (by burning XLM?)
        • Should I extend this feature to list the user's polls and/or polls in which they participated? In this case, I need to obtain voters pubkey, which was not needed so far.
        • Should I design a filter contract that'd enforce fair listing requirements such as "burning ${x} XLM", "being authorized for asset ${y}" or "being a signer of account ${z}"?

        A composable filter contract would prove useful to filter poll voters as well. Chaining a filter contract with a poll contract would result in the smallest possible DAO. (Something like $votes > filter@1.0{...} | poll@1.0{...})

        Figuring out a way to compose contracts is a big deal, as this is the most demanding requirement to achieve DAOs on Stellar. Before I get there, I need more instances of contracts & more use cases from which I can generalize. Hence Cosmic.vote.

        [Subscribe to weekly updates]

        Release 1.0.0-beta.4~5

        Improved Testing Flow

        Added

        • Meta: Setup favicons & social preview.
        • UI: Add explanations for 'New' & 'Browse' tabs.

        Changed

        • UI: Switch to Cosmic.link v2. It is now possible to select 'Test Account' directly in the Cosmic.link signing methods list.
        • Logic: Temporarily disable polls list auto-update. Running multiple streams leads to poor network performance.

        Fixed

        • UI: Fix a couple of sentences.

        Commentary

        It's now possible to get a testnet account directly from the Cosmic.link interface, which makes testing easier:

        1. Browse to Cosmic.vote.
        2. Select a grade for each candidate.
        3. Click on Cast Your Vote!.
        4. Within the SideFrame, select Test Account under Step 2: Signing Method.
        5. (Give it a second, it's creating & funding your test account...)
        6. Click on Sign with Test Account.
        7. Enjoy!

        I experimented a bit with your voting app. A few notes:

        • Poll creation wizard - Members section is not clear. Does it mean "answer options" or "poll participant addresses"?
        • It would be nice to add more advanced description regarding parameters, like what the "listing address" actually means.
        • I can't customize answer options. Also it seems like there is no way to create a single-choice questions. For example, "Your nationality". And there is not way to customize answer options.
        • There are "Open since NaN days" and "Never expire" labels in the voting interface. It looks like your engine supports time bounds settings, but there is no way to set them in the interface.
        • What is the overall length limit for the title and options? Looks like it is determined by the maximum manage_data op you can pack into the transaction (100-2=98 data entries). Am I right?

        The way you store the data on the ledger is quite ingenious. However, there is one thing I thought about for a while. If someone could come up with an idea that allows usage of voting results in the smart contracts, it would be a giant step towards the oracles and DAOs on Stellar. Something like voting by creating a trustline to a specific predefined asset, or sending specially minted voting tokens to one of the accounts that represent voting options. A pre-signed smart contract transaction might use this to execute conditional actions allowing elaborate chained smart contracts schemes.

        What do you think? Is there a way to use your voting contracts for this case?

          OrbitLens

          Thanks for the feedback, that's very helpful :)

          Poll creation wizard - Members section is not clear. Does it mean "answer options" or "poll participant addresses"?

          This is "answer options" The next release will be more specific about that.

          I can't customize answer options. Also it seems like there is no way to create a single-choice questions. For example, "Your nationality". And there is not way to customize answer options.

          Maybe there's some confusion around the term "poll". This system is for voting (e.g.: elections), not to build custom forms. In a future release, I'll add an option to have custom grades, though.

          Btw, the set of grades Cosmic.vote is using has been researched & designed after the principles of majority judgment creators. That is, distinct & meaningful enough so you won't hesitate between two - but as restricted as possible. Except for specific cases, you'd be better with those defaults.

          There are "Open since NaN days" and "Never expire" labels in the voting interface. It looks like your engine supports time bounds settings, but there is no way to set them in the interface.

          The time bounds feature is being worked on, I'll release it within the next couple of weeks. If you get the NaN error again, could you please share the page link with me?

          What is the overall length limit for the title and options? Looks like it is determined by the maximum manage_data op you can pack into the transaction (100-2=98 data entries). Am I right?

          Yes, and I should probably set a sane limit here. ;)

          Something like voting by creating a trustline to a specific predefined asset, or sending specially minted voting tokens to one of the accounts that represent voting options. A pre-signed smart contract transaction might use this to execute conditional actions allowing elaborate chained smart contracts schemes.

          What do you think? Is there a way to use your voting contracts for this case?

          The system you're proposing is worth digging, although this is not what I'm trying to do here.

          What you're proposing is using "conventional" Stellar smart-contract capabilities to implement voting & maybe money distribution. This is possible to some extent, but to really shine this solution would need a special type of transaction that doesn't increment the sequence number on failure. This way, we could any operation as conditions similar to minTime/maxTime/sequence. Then, it'll be possible to set conditions on the amount of asset, trustlines & so on.

          What I'm doing instead is saying "Ok, there's a ton of things we can't build within this paradigm. Let's see what can be taken to layer 2 without losing the properties of the underlying consensus (trustlessness)". That's how I came with passive & operated contracts, which are layer 2 contracts - btw those mechanisms are not new, but the way I'm working with them is.

          This is a different path with different trade-offs, but long story short, I'm indeed working on chaining those things as I mentioned earlier.

          If someone could come up with an idea that allows usage of voting results in the smart contracts, it would be a giant step towards the oracles and DAOs on Stellar.

          Well then... ;)

            MisterTicot

            Maybe there's some confusion around the term "poll". This system is for voting (e.g.: elections), not to build custom forms.

            Ah, that wasn't clear to me. Now it makes a lot more sense. I thinks it worth mentioning in both the SFC entry description and the poll creation wizard which kinds of polls it is suited for. I wonder if the system you employed can be adopted for the governance decisions like "Do we need the on-chain anonymous transactions? Yes/No".

            This is a different path with different trade-offs, but long story short, I'm indeed working on chaining those things as I mentioned earlier.

            Cool, will be keeping an eye on your further announcements. Definitely, a super interesting topic.

              OrbitLens I wonder if the system you employed can be adopted for the governance decisions like "Do we need the on-chain anonymous transactions? Yes/No".

              "Yes/No" is possible because it is still a grade set, with two options. "Yes/Undecided/No" is possible too and is probably a better option. It is a few commits away as the engine is ready for it, but I still have to figure out the UX.

              To achieve some sort of governance, we'll also need a trustless way to filters voters - that is, something that lives on the ledger. That's the missing component right now. Hopefully, on-chain PHOTON will be rebooted & fill that gap. We really need that thing if we want to bootstrap community-scale DAOs.

              Release 1.0.0-beta.6

              Embeddable Widgets & Public Network Support

              I've finally implemented something I've been working on since a while:
              embeddable micro-frontends. From now on, you can obtain widgets by iframing any Cosmic.vote page. You can see what it looks like here.

              Cosmic.vote is meant to be an additional tool in the Stellar community toolbox. Embeddable micro-frontends means that you can bring features the application offers into your own websites. This time, I intend to push the concept as far as making every and each feature accessible this way.

              Other than that, Cosmic.vote is now available on public network, and you'll find the first third-party-less poll to ever happen on Stellar right here. Make sure to be part of it. 😉

              Added

              • Meta: Provide embeddable micro-frontends. Any Cosmic.vote view can now be
                embedded into third-party websites by using an iframe pointing to its address.
                When embedded, Cosmic.vote only displays the desired tab content, not the full interface. (Example)
              • UI: Add public network support (All).

              Changed

              • Meta: Ensure URL<->content consistency (All).
              • UI: Make "Listing" setting a yes/no question (New Poll). − Thanks @OrbitLens
              • UI: Improve hints (New Poll). − Thanks @OrbitLens
              • UI: Rename the "Indifferent" grade into "Undecided". (All)

              Fixed

              • Logic: Fix votes streaming on contract switching (Results).
              • Logic: Create accounts using the minimum required balance (New Poll).
              • UI: Fix polls list auto-update (Browse).
              • UI: Fix table scrolling on mobile (Browse).
              • UI: Fix inconsistent consensus confirmation (Vote).

                OrbitLens

                Unfortunately, that's a bug related to the version update - it happens only once but I can't do anything about it − the link is right.

                5 days later
                bkolobara changed the title to Cosmic.vote ~ Working Toward Decentralized Organizations .

                Release 1.0.0-beta.7

                Timebound contracts & UX polishing

                Each page can now easily be shared across social media or as embeds. Embeds now offers a minimal interface that is similar to most polling system for the web. (Demo here)

                Besides bugfixes, UX polishing & small improvements, this week's release comes with timebound contracts, which let you define a closing time for Majority Judgment polls. This is one of the requirements for running contests.

                Finally, the app will now keep track of your votes (locally) to help you review & edit them. Unfortunately, I couldn't finish the interface in time for this release, but we're a couple of bugfixes away. 🙂

                Added

                • Documentation: Add an image to exemplify vote counting. (Results)
                • Style: Outline majority grade (Results).
                • UI: Add timebound contracts (New, Results).
                • UI: Enforce form requirements (New).
                • UI: Add a share button (All).

                Changed

                • UI: Don't display <aside> explanations in embeds. (All)
                • UI: Improve "Open since X" time precision. Now supports seconds/minutes/hours/days/months/years. (Results)
                • UI: Hide advanced settings (New).
                • UI: Make title mandatory (New).

                Fixed

                • Meta: Fix missing favicon.
                • UI: Fix "Open since NaN" bug (Results). This happened after creating a new poll.
                • UI: Make sure last candidate is not skipped by error (New).
                • UI: Fix view poll inbox link (Browse). (Regression introduced with 1.0.0-beta.6)
                6 days later

                Release 1.0.0-beta.8~9

                Social preview, vote editing & voters filtering

                I wrote a lightest contract reader that can run within Cloudflare workers, to generate ricklink previews for social media:

                I wrote the interface for vote editing - which was already possible, but now you'll have the app remembering your pubkey & figuring out which one was your ballot - letting you edit it if needed.

                I also added voters filtering based on held asset, amount & duration. This makes it possible to build a voters' list by creating trustlines, and to shape subgroups by playing on asset amounts. Sometimes, a little feature can go a long way, and soon enough the smell of a DAOs starts floating around 🙂

                Finally, I posted a poll that showcases these new features, on the public net:
                Which Strategy to Send Stellar to the Moon. That's the first decentralized community poll to ever happen on Stellar, so make sure that you leave your footprint in there 🙂

                Added

                • API: Add support for custom pollsInbox.
                • Documentation: Link the article about Majority Judgment. (available here)
                • Meta: Add support for richlink preview.
                • UI: Add vote editing.
                • UI: Display the poll conditions (Vote).
                • UI: Add "no vote editing" option (New, Vote).
                • UI: Add filtering voters by a held asset.

                Changed

                • API: Set the title max length to 56 characters.
                • Meta: Keep images in the browser cache. This optimizes the loading delay.
                • Style: Polish form hints (New).
                • Style: Improve readability on mobile.
                • UI: Tell that closing time is in local time (New).
                • UI: Display since how long a poll is closed (Results).
                • UI: Automatically close side-frame (Vote, New). This detects when the transaction has been submitted from another device using QRcode, and trigger the next UX step accordingly.
                • UI: Set default polls inbox to list*cosmic.vote (Browse). So far, the app was using the equivalent pubkey since federated addresses were not supported.
                • UI: Set 'Stellar Public' as the default network.
                • UI: Show expiration instead of the number of votes (Browse).

                Fixed

                • API: Fix wrong network when updating from first releases. (Thanks @OrbitLens)
                • Style: Fix "Advanced Settings" chevron (New).
                • Style: Fix the display of long candidate names.
                • UI: Hide the voting button until the contract is loaded (Vote).
                • UI: Prevent AdBlock blocking of the share button.
                • UI: Prevent polls that have a past maxTime (New).
                • UI: Prevent votes once the poll is closed (Vote). Note: Votes posted after contract maxTime don't count anyway, this is simply a convenience UX feature.