free web page hit counter
NEAR's Submission to Reddit's Scaling Bake-off

NEAR's Submission to Reddit's Scaling Bake-off

Etherum Reddit

More / Etherum Reddit 22 Views

NEAR's Submission to Reddit's Scaling Bake-off

Hi Reddit & community,

This is submission to The Great Reddit Scaling Bake-off by Digital Mob and NEAR teams.

Checkout the live demo here: https://near-reddit.digitalmob.ro/

NEAR Reddit demo

It also has links to videos of each activity to quickly check out how it works.

About NEAR

NEAR has been designed to improve developer and user experience. One of the code issues recently with user experience is constantly climbing fees, and NEAR addresses this issue by linearly scaling as demand increases via sharding.

To attract developers, NEAR provides SDKs for common and loved languages like AssemblyScript (compilable TypeScript) and Rust with integrated testing tooling.

Novel account model provides new ways of user’s interacting with blockchain that are hard or impossible to build on other chains. As an example, NEAR Wallet showcases some of the most common use cases.

Scaling

Currently running with a single shard on MainNet and TestNet, we are getting ~200 mint/burn transactions per second for this contract. As more shards will get added and by sharding this contract, expect to linearly grow this number.

Sharding is also the only way that will provide the same level of composability as a single chain while keeping fees at the same level across the network.

Because of focusing on making the node running more accessible, performance of the single shard is naturally capped (most nodes are running on 2 vCPU machines). NEAR’s design is geared toward removing the need in the future for developers to think how to scale their application where a “single” machine mode will become not enough for the whole world to use.

Decentralization

Sharding and lower requirements for validators are designed to drive more decentralization on the overall network, both for consensus and data replication. Even hobbyists can run both validating and non validating nodes (we have 200+ nodes in one of our test networks mostly by hobbyists).

Specifically Reddit demo has Backend, which provides approval for the user to cover their transaction fees and can be used to create token minting requests and other service functions. This doesn’t affect the user’s ability to operate their accounts, withdraw and transfer funds. In production this will be operated by reddit.com and linked to the sign up and upvote flows on the website / app.

Usability

NEAR has been focused on usability from the start and provides a variety of tools to developers to improve UX for their users.

There are three ways that users can interact with the network:

  • Using a self custody wallet and paying own fees.
  • Using a self custody wallet and letting a third-party to pay fees. In this case the operator must whitelist this user (by allowing their keys to sign transactions on their behalf).
  • Operator custodies the user's account but can transfer custody to the user on demand.

In the case of Reddit, the 2nd option fits best. As a user creates Vault in the Reddit app, backend can whitelist such users to cover it’s fees within a specific allowance.

NEAR has a unique account structure, where an account is named with a human readable name like “illia.near” and can have multiple keys accessing it with different permissions. This opens up a lot of functionality, but the main benefit in this case is that a user can easily add other wallets / devices to their account to the same account.

Fast, 1 second, block time with immediate confirmation and usually one or two blocks on top for finality provide experience that is matching non-blockchain systems.

Additionally, we have built a self custody web wallet that supports email and phone based account recovery and 2FA. This is the first time that users can custody crypto without installing anything and without worrying of losing their device with keys on it.

NEAR Wallet is launching on MainNet soon - https://wallet.near.org, but can play already on TestNet - https://wallet.testnet.near.org

There are plenty of other things to improve user experience. For example users can send tokens to their friends via a link, removing the requirement for their friend to know / install / create a wallet ahead of time. Read more in the NEAR Drop blog post.

Interoperability

Based on our knowledge, NEAR is the first Layer-1 that has a working trustless bridge to Ethereum (e.g. not operated by multisig but fully verifying chains on both sides). This allows developers to compose NEAR and Ethereum in various ways.

Simplest and applicable in the current challenge is transferring tokens from NEAR to Ethereum to interact with a broader ecosystem. Here are details of how ERC-20 <> NEAR Fungible token transfers would work: https://github.com/near/rainbow-bridge/blob/master/docs/workflows/eth2near-fun-transfer.md

Additionally, NEAR is an open platform with its own ecosystem support: contracts, wallets, etc.

You can find details on how to build new contracts, integrate with various off-chain solutions and more in the documentation: https://docs.near.org

To check out examples of apps and contracts written in Rust (most loved language based on SO) and AssemblyScript (language based on TypeScript that compiles to WASM) - see examples page.

Security

NEAR itself is an independent layer-1 protocol that is secured by stake of the validators.

As described in the Usability section, users have self custody of their assets and only they can transfer their tokens.

In this Demo, the Backend provides a process of registering new users but after that users can interact directly with the chain while they have an allowance. This means that even if Reddit’s Backend is completely gone, users can still access their funds.

Because in NEAR, users can always add or change access keys to their account, even if the Reddit application gets attacked and exposes all the keys of all the users - if they set up another wallet or recovery keys, the user can prevent funds from being stolen.

There are easy mechanics to setup 2FA and multisig and contract already available here - https://github.com/near/initial-contracts/tree/master/multisig. Checkout https://github.com/near/near-wallet how this is used in production.

NEAR is available on Ledger now in development mode and soon should be released in general availability.

Code

Backend - using NodeJs for the service and AssemblyScript for smart contract.

Repo structure:

  • Main app is located in src/main
  • Near smart contract src/assembly written in AssemblyScript
  • Routes in src/api
  • Benchmark in src/benchmark

https://github.com/DigitalMOB2/NearRedditBackend/

Frontend - created using Create React App - TypeScript.

Repo structure:

  • Main app is located in src/components/App
  • Home page layout in src/components/Pages
  • Routes in src/components/Routes
  • All helper components are located in src/components/shared

https://github.com/DigitalMOB2/near-reddit-frontend

More how to build on NEAR you can learn in the developer documentation: https://docs.near.org

Status

NEAR launched MainNet POA earlier this year. Currently, ironing out last bits and pieces of the infrastructure before transitioning to a fully decentralized validator set. More details can be found in this post: https://near.org/blog/near-mainnet-genesis/

Contracts were deployed and benchmarked on decentralized TestNet that has similar set of validators to the ones that will run MainNet soon: https://explorer.testnet.near.org/accounts/reddit-token-contract-1596110508661

Conclusion

NEAR provides an infrastructure to build an active developer community on top of Reddit’s incentivization and link it to Ethereum’s, without requiring the developer community of Reddit to learn new languages or learn about specifics of the infrastructure.

If you want to check out more NEAR apps, look at examples or explore other apps that are open source.

Great thanks to the DigitalMob team for development of this demo!

submitted by /u/ilblackdragon
[link] [comments]

Comments