/protocol

Primary LanguageGoOtherNOASSERTION

Blockchain logic for P2PCloud

Badge

What is p2pcloud

p2pcloud.io is a protocol and utility set for booking and securing trustless virtual machines over the blockchain.

Development

Agreements

  • All implementations should be in the implementations folder in a separate subfolder;
  • All implementations should comply with BlockchainIface;
  • Good test coverage with edge cases;
  • Deliver changes through pull reqeusts.

How to

Compile contracts

go run ./cmd/compile/

Test:

go test ./...

Current state of things

Undertested and a bit messy

Business logic

Actors

There are 3 actors - miner, user and community. User books and pays for VM. Miner runs VMs. Community gets comission from every VM booking.

Contracts

  1. Broker contract. Facilitates deals between miners and users.
  2. Community contract. Some contract used to vote on SDK and protocol updates. Also accepts and distributes fees. Not implemented yet.
  3. Satblecoin contract. Some external stablecoin, probably USDC. May be replaced.

Workflow

  1. Miner creates offer setting type and price of VM per second
    • Functions: getMinersOffers, updateOffer, addOffer
  2. User sends a stablecoin to the Broker. All stablecoin is split between free and locked states.
  3. User gets list of offers
    • Functions: getAvailableOffers
  4. User books VM. His stablecoin gets locked.
  5. User aborts booking because of miners misbehaviour. Unused stablecoin gets unlocked. Miner gets paid 1/2 of the price. The rest 1/2 goes into the community. Booking gets deleted.
  6. User aborts booking, but no problems with miner. Unused stablecoin gets unlocked. Miner gets paid 95% of the price. The rest 5% goes into the community. Booking gets deleted.
  7. User extends booking. More stablecoin gets locked. New PPS is used. No checks for slot availability.
  8. User does nothing and booking expires.
  9. Miner claims expired booking. Miner gets paid 95% of the price. The rest 5% goes into the community. Booking gets deleted.

Events are used to calculate miner's reputation.

Service functions

  1. Stablecoin address. Set is callable only by community contract/wallet.
  2. Community wallet/contract address. Set is callable only by community contract/wallet. Just a regular wallet for now.
  3. Community fee. 5% for now.