Giter Site home page Giter Site logo

solana-labs / break Goto Github PK

View Code? Open in Web Editor NEW
284.0 284.0 193.0 21.06 MB

Break Solana Game

Home Page: https://break.solana.com

License: MIT License

JavaScript 0.31% TypeScript 62.02% CSS 4.13% HTML 0.63% Shell 0.06% Rust 0.98% SCSS 31.87% Procfile 0.01%

break's People

Contributors

chaitanyapotti avatar criesofcarrots avatar darrensapalo avatar dependabot[bot] avatar evgenyshvingelsky avatar igorburak-zenio avatar joeaba avatar jstarry avatar memoriesadrift avatar mvines avatar ojshua avatar rmshea avatar ryan-shea avatar wargot-by avatar youjustdontknow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

break's Issues

Track transactions created per day

Problem

We want to track the full impact of the break game on the cluster over time

Proposed Changes

  • Create break program config account
  • Add increment day count instruction
  • Profit

If short on time:

  • Add Redis Heroku addon
  • Track sent transactions in the server and increment a date redis key
  • Periodically broadcast daily transactions

Create square for click during the game

  1. During the game - every click should create a square on the screen.
  2. If the amount of squares is more, than fits the screen - scroll should appear
    a. When new row of squares is created - scrlollable area should scroll for 1 row.
  3. "Total amount of transaction" should increment by 1 after every click

Break.solana INTRO screen

  1. Break solana page should exist on "break.solana.com"

  2. layouts should be based image, attached to this story.

  3. "Read how it works" button should exist on this screen. Clicking on the button - link should be opened in new browser tab. Link: https://solana.com/category/blog/

  4. Solona logo should exist, clickin on the logo - open Solana.com page in new browser tab.

  5. Solana static image should exist on this screen. This image can be animated in terms of future tasks.

  6. "Play the game" button should exsit on this screen. Clicking on the button - Start/break screen should be displayed

Details about transaction popover

  1. Popovers are available "Stats after game" screen
  2. Popover should be displayed hovering transaction
  3. Information on Popover:
    a. Lamports
    b. Signature
    c. Transaction time

Confirmation time calculation is incorrect

Problem

This is not a correct way to calculate transaction confirmation time.

            const t1 = performance.now();
            const response = await this.connection.sendTransaction(transaction, this.keypair);
            const t2 = performance.now();

All this is doing is broadcasting a transaction to the network. Next, the network sends the transaction to the leader node who will then process the transaction and eventually produce a block with the results of this transaction (if it succeeds).

Proposed Solution

Make use of https://solana-labs.github.io/solana-web3.js/function/index.html#static-function-sendAndConfirmRecentTransaction or https://solana-labs.github.io/solana-web3.js/class/src/connection.js~Connection.html#instance-method-confirmTransaction to get the correct transaction confirmation time

Prepare a few hundred break programs

Problem

Break client transactions create program accounts, and those transactions can be easily verified by subscribing to the program using the RPC pub sub API. If all break clients create accounts for the same program, the fan out of program subscription notifications is going to overwhelm the RPC server as well the clients themselves.

Napkin math: 1000 users * 15 tps = 15,000 tps => 15,000 notifications * 1000 users => 15M websocket messages per second. Each user getting 15k messages per second.

Proposed Change

Sharding!

  1. Create a few hundred programs on the cluster ahead of time
  2. Give the same programId to a few clients before rotating to the next programId

Handle RPC server restarts

Problem

When the RPC server restarts, it binds to a new random TPU udp port. The break server is oblivious to that and doesn't realize it's sending transactions into the void when this happens.

Proposed Changes

Detect RPC restarts or periodically query cluster info to make sure tpu info is up to date

Calculate confirmation time

Problem

We want to show users how fast confirmation times are on Solana

Proposed Changes

  • Stream confirmation times and calculate a rolling median

User can enter username

We'll need to store:

Time completed
Username
Email (make a field for this)
Referrer ID (if there was one, from the URL that created the session)

Server crashes if cluster is not accessible

Problem

If apps do not bind to the provided PORT, Heroku will attempt to restart a few times until it marks it as crashed.

Proposed Solution

  • Always bind to the port
  • Add network failure UI state to the client app

The cost of each transaction is too high

Problem

Each transaction creates a rent exempt account but creating rent exempt accounts is not necessary.

Proposed Changes

Only transfer enough rent to cover a single epoch.

Reuse break program account

Problem

Each new deploy of the break app creates a new program with a random pubkey. It would be nice if the program id was a vanity address and was always the same because these program instructions will be inspected on the explorer.

Try game again

  1. When game is finished I can see "Try again" button
  2. Clicking on the button, I want to see /game screen

Stop bloating the account ledger

Problem

Break transactions create a new account for each transaction and these accounts bloat the ledger

Proposed changes

Use BPF instructions!

  • Client subscribes to account that it receives from the server
  • Client encodes an id in program ix data
  • Program modifies account data based on ix data id
  • Client checks account data to determine which ids were processed

Load testing

5k concurrent users
15k in one hour
100k in one day

No Social share button

Otherwise, it's a bit solitaire-like. :)

Also, some kind of rankings by the transaction count would be nice to have. :)

Broadcast active client count from Break Server

Problem

We want to show users that they're not alone when playing Break by showing the number of concurrent players.

Proposed Changes

The break server tracks websocket clients, broadcast the client count periodically

I can see number of TPS, from all collaborators

  1. Number of created transactions from all clients should be collected an send to BE every second.
  2. Backend should sum up all transactions created for 5 seconds.
    a. result should be divided by 5 to get TPS
  3. FE should display TPS number.
    a. TPS number should refreshed every 5 seconds

Break.Solana game screen

  1. Page should exist on break.solana.com/game
  2. Name for Browser tab: "Brake Solana"
  3. Browser tab should have Solana logo as favicon.
  4. Solana logo should exist on the screen
  5. Countdown clock should exist on the screen. It is frozen on 15 seconds, until game is started
  6. "BEGIN" button should exist on the screen. Clickin on it - game begins.

Subscribe to account data instead of program

Problem

Break is creating too many accounts. See more details here: #108

Proposed Changes

This captures the client side of the changes:

  • Change from program subscription to account subscription
  • Inspect account data to determine tx success

Expand the TPS calculation window

Problem

TPS updates are too choppy because they are calculated with a short time window

Proposed Changes

Use a rolling time window for TPS calculation so that TPS updates are smooth

Break solana STATS after the game is finished

Exists on /stats

  1. After the game is finished, stats should be displayed:
    Total amount of transactions
    #% of Solana capability used (Formula: #of transaction/50000)
  2. "Try again" button - display "Start the game screen"
  3. Message after game finished: "Well, perhaps if you invited a fem more friends...
    With transactions in 15 seconds you took up of our blockchain's network capabilities. If you invited couple more people our decentralized database would start to slow down.
    You can review every transaction with stats on confirmation and signatures hovering it."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.