diff --git a/docs/architecture/consensus.md b/docs/architecture/consensus.md deleted file mode 100644 index e2c77992..00000000 --- a/docs/architecture/consensus.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -sidebar_position: 3 ---- -# Consensus Mechanism - -Ten combines Ethereum's L1 security, rollup efficiency, Secure Enclave privacy, and the POBI mechanism for a unique consensus approach. - -## POBI (Proof Of Block Inclusion) - -- **Unique to Ten**: Ensures a single version of truth by validating rollups only if they're included in a block. -- **Chain Selection**: The chain with the latest block inclusion is deemed the canonical chain. - -## Rollup-Based Consensus - -- **Aggregators**: These are L2 nodes that collect, aggregate, and submit batches of transactions to Ethereum L1. They play a crucial role in the consensus mechanism. - -- **Sequential Processing**: Transactions are processed in the order they are received, ensuring a consistent state across all nodes. - -- **Finality**: Once a rollup is accepted on Ethereum L1, it is considered final. This provides the same level of security as Ethereum itself. - -## Attestation - -- **Secure Enclave Attestation**: Before an L2 node can participate in the network, it must prove its legitimacy through a process called attestation. This ensures that the node operates within a genuine Secure Enclave. - -- **Continuous Attestation**: Nodes must continuously attest to their validity to remain active in the network. - -## Economic Incentives - -- **Staking**: L2 nodes are required to stake a certain amount of tokens as collateral. This ensures they act honestly, as malicious actions can lead to the loss of their stake. - -- **Rewards**: Honest nodes are rewarded for their services, such as aggregating transactions or producing rollups. - -- **Penalties**: Malicious nodes or those that fail to meet the network's standards can be penalized, which includes the loss of their staked tokens. - -## Sybil Attack Prevention - -Ten's consensus mechanism is designed to resist Sybil attacks. The combination of Secure Enclave attestation and economic incentives ensures that creating multiple fake nodes is not only challenging but also economically unviable. \ No newline at end of file diff --git a/docs/architecture/design.md b/docs/architecture/design.md deleted file mode 100644 index ed0ee07e..00000000 --- a/docs/architecture/design.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -sidebar_position: 1 ---- -# Design - -Ten is architected as an L2 protocol, leveraging the rollup pattern to store transaction data on the L1 chain. While most rollup implementations aim for scalability, Ten's primary objective is confidentiality. The rollups encapsulate the entire encrypted transaction data. - -![L1-L2 Interaction](../assets/l1-l2-interaction.png) - -## L1 Network - -- **Management Contracts**: On the L1 network, there are several standard Ethereum contracts, often referred to as Management Contracts. These contracts play a pivotal role in the functioning and management of the Ten network. - - - **Network Management**: This contract acts as the gatekeeper for the protocol. It manages the Secure Enclave / TEE attestation requirements, verifies attestation reports, and oversees the stake of the Aggregators. - - - **Rollup Management**: This module accepts rollups submitted by L2 nodes and collaborates with the bridge to process user withdrawal requests. - - - **Ten Bridge**: A crucial contract ensuring the security of the liquidity deposited by Ethereum end-users, mirrored in the confidential Ten ledger. - -## L2 Network - -The L2 design aims to establish a decentralized network of nodes with valid Secure Enclave / TEEs, ensuring transaction confidentiality even amidst potential Secure Enclave / TEE breaches. - -- **L2 Nodes**: There are two primary categories of nodes within the Ten network: - - - **Aggregator Nodes**: These nodes, equipped with Secure Enclave / TEEs and the shared secret, can submit rollups to the L1. They process user transactions, roll them up, and submit them for inclusion in Ethereum blocks. - - - **Verifier Nodes**: These nodes, also equipped with Secure Enclave / TEEs and the shared secret, play a significant role in consensus security. They monitor the L1 network, calculating the state based on the submitted rollups. - -## Rollup Data Structure - -The Management Contract implements a blockchain-like structure to store the rollups. Each rollup references a parent rollup, and multiple competing sibling rollups can exist simultaneously. It's the responsibility of individual L2 nodes to determine the validity of these siblings. diff --git a/docs/architecture/governance.md b/docs/architecture/governance.md deleted file mode 100644 index 7ecd6472..00000000 --- a/docs/architecture/governance.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -sidebar_position: 5 ---- -# Governance - -Ten's governance is explicit, transparent, and draws inspiration from the experiences of Bitcoin and Ethereum. In a decentralized system, control can be: - -- **Explicit**: Exercised by a group through direct signing or voting. -- **Implicit Immutable**: Implemented in an unchangeable protocol. -- **Implicit Mutable**: Implemented in a protocol represented by an open-source, changeable codebase. - -## Ten Controls - -### 1. TEE Attestation Constraints - -The Attestation Constraints control which software can run inside the Secure Enclave, processing user transactions and creating rollups. Independent security auditors analyze and approve the code. The constraints contain the keys of these auditors, determining which software is permitted. - -### 2. Administration Of Ethereum Management Contracts - -Ethereum management contracts in Ten may have upgradeable components to address bugs and introduce new features. Upgradeable components imply administrative control over: - -- Bridge logic -- Rollup logic -- Attestation logic - -### 3. Creating Rollups - -Ten Aggregators, running attested software and hardware with a stake, have the power to append to the L2 ledger. However, they cannot choose competing software or create forks. - -### 4. Canonical Rollup Chain - -The canonical chain in Ten is determined by the rules implemented in the attested software run by Aggregators. A valid Secure Enclave will not sign a rollup built on a non-canonical chain, ensuring ledger integrity. - -### 5. Slashing The Stake Of Misbehaving Parties - -Aggregators attempting to compromise the ledger's integrity face penalties. Misbehaviors are detected by the protocol, and culprits are penalized through stake slashing. - -### 6. Expected Monthly Operational Cost For Nodes - -Ten's fee structure aims for predictable income for node operators and fees for users. A set value representing the monthly operational cost for each node is crucial for determining fees and balancing decentralization with user costs. \ No newline at end of file diff --git a/docs/architecture/interaction-with-ethereum.md b/docs/architecture/interaction-with-ethereum.md deleted file mode 100644 index bf0fb3de..00000000 --- a/docs/architecture/interaction-with-ethereum.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -sidebar_position: 4 ---- -# Interaction with Ethereum - -Ten serves as a confidential extension to Ethereum, enabling assets to move seamlessly between the two networks. While many sidechains and L2 solutions have developed bridges to address mismatches between different network models, Ten's approach is distinct, ensuring a decentralized and secure interaction. - -## Deposits - -- **Process**: Users deposit supported ERC tokens into the Bridge contract's address. Once the transaction is confirmed on Ethereum L1, the Ten-enabled wallet automatically creates an L2 transaction, crediting the user's Ten account with wrapped tokens. - -- **Finality Consideration**: Due to Ethereum's probabilistic finality, Ten introduces a dependency mechanism between L2 rollups and L1 blocks to ensure accurate crediting of L2 accounts. - -## Withdrawals - -- **Requirement**: To move assets back to Ethereum, Ten provides a secure withdrawal function. - -- **Decentralized Approach**: Ten employs economic incentives on top of the POBI protocol to ensure a decentralized withdrawal process, avoiding reliance on multi-signature technology or long waiting periods. - -## Rollup Finality - -- **Standard Delay**: Typically, a rollup is considered final if a standard number of Ethereum blocks (equivalent to a 1-day period) have passed since its publication on Ethereum L1. - -- **Competing Forks**: If multiple forks are detected, finality is suspended on all forks, and withdrawals are halted. The protocol has mechanisms to address such scenarios and ensure user satisfaction. - -## Ten Public Events - -- **Use Cases**: Ethereum applications can utilize Ten for tasks like organizing fair lotteries or publishing poker game results, which require data originating in L2 to be final. - -- **Public Events**: Applications within Ten can emit special "Public Events". Once these events reach finality, they are exposed to external contracts on Ethereum L1. \ No newline at end of file diff --git a/docs/architecture/overall_design.md b/docs/architecture/overall_design.md new file mode 100644 index 00000000..33c1c7a3 --- /dev/null +++ b/docs/architecture/overall_design.md @@ -0,0 +1,137 @@ +--- +sidebar_position: 1 +--- + +# Ten Node Architecture + +This is an advanced document that describes the technical architecture of a Ten deployment. + +While Ten has similarities with other Ethereum L2s, the setup is more complex, as shown in the following diagram +that depicts the main components and their responsibilities. + +![architecture diagram](../assets/ten_node_arch.png) + +*Note: The Ethereum node components are developed and maintained by third-parties. E.g.: Infura* + +## Trusted Computing Base (TCB) + +Ten makes use of Intel SGX to protect the execution of transactions and the state from node operators. +For development, we use the EGo SDK from Edgeless, and EdgelessDB. + +The Ten TCB has two components: the Ten Enclave, and the encrypted database. + +### The Ten Enclave + +From a high level, the Ten Enclave (TE) is a process that exposes an RPC server (currently gRPC). + +The TE is a process that loads the SGX enclave built from the source code. The EGo SDK handles the low level I/O +interactions +and communication. + +The TE has two interfaces points: + +1. The RPC server +2. The Storage + +The next section will cover the main logical components of the TE. + +### 1. The RPC server + +The Ten Enclave processes various types of information, including: + +* Ethereum Transactions: These are transactions submitted to the management contracts and the message bus. +* User Transactions: Encrypted Ten transactions submitted by users, either through the Gateway or directly to the RPC + server. +* Sequencer Batches and Rollups: Ten batches and rollups submitted by the sequencer. +* Data Requests: Users can query transaction receipts or any of the `eth_` requests. +* For each of these operations, there are corresponding RPC endpoints, along with additional functionalities. +* + +### 2. Transaction Execution Engine + +The latest iteration of Ten utilizes the EVM execution engine sourced from go-ethereum. A wrapper has been developed to +facilitate necessary pre and post-processing operations while maintaining the core execution intact. + +Additionally, the key/value storage system originally employed by the go-ethereum EVM engine has been substituted. + +### 3. The Storage + +The TE is a stateful component that needs access to both the EVM state and the Ten chain information. + +The TE initiates a mutually authenticated TLS connection to another enclave housing a SQL engine. Over this encrypted +channel, +SQL read and write statements are transmitted securely. + +### Error Handling + +The enclave has the capability to return two types of errors: + +1. System Errors: These errors stem from unexpected malfunctions, like disk space exhaustion. +2. User Errors: These errors arise due to unprocessable user requests. + +For User Errors, the TE encrypts the error message with the user's viewing key to ensure that only the corresponding +user can decipher it. System Errors are returned in plain text to facilitate straightforward handling. + +### EdglessDB + +EdgelessDB is an open-source database designed for confidential computing environments, offering security features and +high performance. Running entirely within Intel SGX enclaves, EdgelessDB ensures that all data, both in memory and on +disk, remains encrypted at all times. Leveraging a manifest system akin to smart contracts, EdgelessDB provides a +framework for defining database states and access controls. + +- Always Encrypted: Data is encrypted both on disk and in memory. +- Manifest: A JSON-based contract system defining the initial database state and access controls. +- Remote Attestation: Proves the secure execution of EdgelessDB within an enclave, enforcing the manifest's parameters. + +EdglessDB is architecturally based on MariaDB and utilises an enhanced version of RocksDB as its storage engine. + +## The Host + +The Host component is the external layer of our architecture, operating outside the Trusted Computing Base (TCB). It +offers extensive functionality while providing two crucial advantages: + +- Minimizing TCB Complexity: By moving certain functionalities outside the TCB, the Host component reduces the size and + complexity of the Trusted Computing Base. +- Reducing TCB Churn: By handling non-essential operations, the Host component decreases the frequency of + re-attestations required for the TCB. + +The Host and the enclave function as separate OS processes, rather than threads within a single process. This +architectural decision aligns with our initial target Trusted Execution Environment (TEE), Intel SGX, which mandates +separate process execution. + +Communication between the Host and the enclave occurs via Remote Procedure Call (RPC), facilitated by the gRPC library. + +gRPC was chosen for its open-source nature (Apache 2.0 license) and widespread adoption. + +For simplicity, the transport layer lacks authentication (e.g., TLS or credentials). However, to mitigate potential +security risks, the enclave maintains full control over rollup rewards allocation. This design prevents unauthorized +access and misuse by parasitic aggregators seeking to economize on operational costs. + +To enhance system modularity and resilience, the enclave process is supervised and managed independently of the Host +process. + +## Host design + +The Host component carries out a multitude of responsibilities, including: + +- Serving requests for data and transaction submissions. +- Supplying data to the enclave to ensure synchronization with the L1 and L2 networks. +- Publishing secret requests/responses and rollups (for the sequencer) to the L1 network. +- Exchanging Ten data (e.g., batches and mempool transactions) with peer nodes. +- Handling failover and recovery procedures for the enclave to maintain high availability (HA) nodes. + +The Host architecture is structured around a diverse set of services, each tasked with managing specific +responsibilities within the system. + +The following diagram shows a high-level view of the main services involved: + +![host services diagram](../assets/host_arch.png) + +## The Ten Gateway + +The Ten Gateway serves as a bridge between a Ten node and external tools like MetaMask, facilitating secure +communication due to data encryption within the Ten node. Adhering to the Ethereum JSON-RPC specification the Ten +Gateway ensures seamless integration. + +The onboarding process is streamlined, requiring just a few clicks on a website hosting the Ten Gateway to add the +network to their wallet, connect, and sign over an EIP-712 formatted message, including an encryption token. \ No newline at end of file diff --git a/docs/architecture/system-components.md b/docs/architecture/system-components.md deleted file mode 100644 index 705be4fb..00000000 --- a/docs/architecture/system-components.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -sidebar_position: 2 ---- -# System Components - -## Cryptography - -- **Master Seed**: Every Secure Enclave is provisioned with one or multiple keys, known as the Enclave Key (EK). The first enclave, termed the Genesis Enclave, generates a random byte array called the Master Seed. This seed is encrypted using the EK and stored in the Management Contract. - -- **Sharing the Master Seed**: After attestation, subsequent nodes receive the Master Seed encrypted with their key. Before obtaining this shared secret, the L2 nodes must attest their validity. - -- **Generating Keys**: Secure Enclaves use the shared secret to generate further keys. These keys are used for various purposes, including network identity and encrypting transactions. - -- **Transaction Encryption**: Ten aims to balance user privacy with application functionality. Transactions are encrypted differently based on predefined revealing options, ensuring that they can be decrypted independently after a set time delay. - -- **Revelation Mechanism**: Ten uses L1 blocks as a reliable measure of average time. After a set number of blocks, any user can request the encryption key from any Ten node's Secure Enclave. - -- **Cryptographic Algorithms**: Ten uses the same cryptographic algorithms as Ethereum for hashing and signing. Communication encryption algorithms are still under consideration. - -## State - -Ten's state management is similar to Ethereum's L1 blockchain. It's an account-based L2 decentralized ledger system. The state is stored as a Patricia Trie in each rollup, and each node processes all prior transactions to establish the current state. - -## Smart Contracts and the Ten VM - -- **Smart Contract Types**: Ten supports two types of smart contracts: Public contracts (similar to Ethereum smart contracts) and Private contracts (where the source code isn't publicly available). - -- **State Confidentiality between Smart Contracts**: Ten aims to protect user data while allowing contract composition. Developers need to be cautious about data access and potential data leaks when their contracts interact with others. - -- **Wallets and Transaction Submission**: User wallets create transactions encrypted with the Ten public key. These transactions can only be decrypted, executed, and viewed by valid Secure Enclaves. \ No newline at end of file diff --git a/docs/assets/host_arch.png b/docs/assets/host_arch.png new file mode 100644 index 00000000..374287de Binary files /dev/null and b/docs/assets/host_arch.png differ diff --git a/docs/assets/node_arch.png b/docs/assets/node_arch.png new file mode 100644 index 00000000..9e91da15 Binary files /dev/null and b/docs/assets/node_arch.png differ diff --git a/docs/assets/obscuro_arch.jpeg b/docs/assets/obscuro_arch.jpeg new file mode 100644 index 00000000..2f142b83 Binary files /dev/null and b/docs/assets/obscuro_arch.jpeg differ diff --git a/docs/assets/ten_node_arch.png b/docs/assets/ten_node_arch.png new file mode 100644 index 00000000..d45d2a79 Binary files /dev/null and b/docs/assets/ten_node_arch.png differ diff --git a/docs/getting-started/for-developers/develop-deploy-dapp.md b/docs/getting-started/for-developers/develop-deploy-dapp.md index d0a4918c..3945043e 100644 --- a/docs/getting-started/for-developers/develop-deploy-dapp.md +++ b/docs/getting-started/for-developers/develop-deploy-dapp.md @@ -1,20 +1,35 @@ --- sidebar_position: 3 --- + # Develop & Deploy dApp ## 1. Develop Smart Contracts -Smart contracts are the backbone of your dApp, defining its rules and operations. Begin your development in Solidity based on the instructions [here](/docs/getting-started/for-developers/explore-contracts-in-ten). + +Smart contracts are the backbone of your dApp, defining its rules and operations. Begin your development in Solidity +based on the instructions [here](/docs/getting-started/for-developers/explore-contracts-in-ten). ## 2. Develop the Frontend -Use common web tools like HTML, CSS, and JavaScript. You can consider ReactJs, VueJs to enhance development. To connect your frontend to Ethereum, choose a library such as Web3.js or Ether.js. See supported libraries [here](#). + +Use common web tools like HTML, CSS, and JavaScript. You can consider ReactJs, VueJs to enhance development. To connect +your frontend to Ethereum, choose a library such as Web3.js or Ether.js. See supported libraries [here](#). ## 3. Integrating Ten Gateway + Users need to configure their wallets to connect with Ten the first time they access your dApp. - - **Gateway**: During the initial user onboarding, prompt users to visit the [Ten Gateway](https://testnet.ten.xyz/). By clicking "Connect to Ten Testnet" and following the on-screen instructions, they can easily configure their wallets. Learn more about the Hosted Ten Gateway [here](/docs/tools-infrastructure/hosted-gateway). + +- **Gateway**: During the initial user onboarding, prompt users to visit the [Ten Gateway](https://testnet.ten.xyz/). By + clicking "Connect to Ten Testnet" and following the on-screen instructions, they can easily configure their wallets. + Learn more about the Hosted Ten Gateway [here](/docs/tools-infrastructure/hosted-gateway). ## 4. Test & Deploy the Dapp -Before the final deployment, test your dApp in a controlled environment. This ensures that it interacts correctly with the blockchain and provides the desired user experience. Once satisfied with your dApp's functionality and performance, deploy it for public access. + +Before the final deployment, test your dApp in a controlled environment. This ensures that it interacts correctly with +the blockchain and provides the desired user experience. Once satisfied with your dApp's functionality and performance, +deploy it for public access. ## 5. Verify & Track the Deployment -Post-Deployment it's essential to monitor your dApps performance and user interactions. Use the TenScan block explorer to verify and inspect the details of your deployed contract. This tool provides insights into transactions, contract interactions, and more. Learn how to use the block explorer [here](/docs/tools-infrastructure/obscuroscan). + +Post-Deployment it's essential to monitor your dApps performance and user interactions. Use the TenScan block explorer +to verify and inspect the details of your deployed contract. This tool provides insights into transactions, contract +interactions, and more. Learn how to use the block explorer [here](/docs/tools-infrastructure/obscuroscan). diff --git a/docs/getting-started/for-developers/explore-contracts-in-ten.md b/docs/getting-started/for-developers/explore-contracts-in-ten.md index 99dc4602..78478623 100644 --- a/docs/getting-started/for-developers/explore-contracts-in-ten.md +++ b/docs/getting-started/for-developers/explore-contracts-in-ten.md @@ -1,55 +1,67 @@ --- sidebar_position: 1 --- + # Explore Contracts in Ten -Ten offers a distinct environment for smart contract development so you'll need to consider how to design your dApps slightly differently from how you would a transparent dApp. This guide explains these differences: +Ten offers a distinct environment for smart contract development so you'll need to consider how to design your dApps +slightly differently from how you would a transparent dApp. This guide explains these differences: ## 1. Accessing Storage Values -While both Ethereum and Ten allow easy access to public variables, their handling of private variables differs significantly, highlighting Ethereum's transparency challenges and Ten's privacy solutions. +While both Ethereum and Ten allow easy access to public variables, their handling of private variables differs +significantly, highlighting Ethereum's transparency challenges and Ten's privacy solutions. ### Ethereum's Transparency Challenge -In Ethereum, private variables are intended to be accessed solely through functions. However, due to Ethereum's transparent nature, a workaround exists using the `getStorageAt` function. This method can bypass the designated functions, making true private data storage unattainable. +In Ethereum, private variables are intended to be accessed solely through functions. However, due to Ethereum's +transparent nature, a workaround exists using the `getStorageAt` function. This method can bypass the designated +functions, making true private data storage unattainable. **Example**: Accessing a private variable in Ethereum: + ```solidity uint256 value = eth.getStorageAt(contractAddress, position); ``` ### Ten's Privacy Solution -To provide privacy on Ethereum, Ten has disabled the `getStorageAt` function. This ensures that private variables can only be accessed via their associated functions, providing genuine programmable privacy. +To provide privacy on Ethereum, Ten has disabled the `getStorageAt` function. This ensures that private variables can +only be accessed via their associated functions, providing genuine programmable privacy. **Example**: Accessing a private variable in Ten: + ```solidity private uint256 privateVariable; function getPrivateVariable() public view returns (uint256) { - return privateVariable; +return privateVariable; } ``` -In summary, while Ethereum's transparency poses challenges for true data privacy, Ten offers a robust solution by ensuring that private data remains genuinely private. +In summary, while Ethereum's transparency poses challenges for true data privacy, Ten offers a robust solution by +ensuring that private data remains genuinely private. ## 2. Access Control for Functions -In smart contract development, it's essential to ensure that only authorized entities can access certain functions. This is achieved using access control mechanisms. +In smart contract development, it's essential to ensure that only authorized entities can access certain functions. This +is achieved using access control mechanisms. ### Access Control Using `require` -The `require` statement in Solidity is a straightforward way to enforce access control. It checks a condition, and if the condition is not met, the function execution stops, and an optional error message is thrown. +The `require` statement in Solidity is a straightforward way to enforce access control. It checks a condition, and if +the condition is not met, the function execution stops, and an optional error message is thrown. **Example**: + ```solidity address owner = msg.sender; function restrictedFunction() public { - require(msg.sender == owner, "Only the owner can call this function."); - // Rest of the function logic +require(msg.sender == owner, "Only the owner can call this function."); +// Rest of the function logic } ``` @@ -63,6 +75,7 @@ Ten has specific event visibility rules: - Events with an address parameter related to an account are private. **Example**: + ```solidity // Public event on Ten event LifecycleEvent(uint256 indexed value); @@ -73,7 +86,8 @@ event AccountEvent(address indexed account, uint256 value); ## 4. Secure Random Number Generation in Ten -Random number generation on blockchains is challenging due to timing, delay, complexity, and fees. Ten offers a unique, immediate, and secure solution. +Random number generation on blockchains is challenging due to timing, delay, complexity, and fees. Ten offers a unique, +immediate, and secure solution. ### Challenges with On-Chain Randomness @@ -81,7 +95,7 @@ Random number generation on blockchains is challenging due to timing, delay, com 2. **Delay**: Many solutions introduce a delay, affecting user experience. 3. **Complexity & Fees**: Solutions like oracles add overhead and costs. -### Ten's Solution +### Ten's Solution Ten nodes run on secure enclave's, ensuring: @@ -90,15 +104,20 @@ Ten nodes run on secure enclave's, ensuring: - **Simplicity & No Extra Fees**: Every transaction gets its random seed. **Example**: + ```solidity function getRandomNumber() public view returns (uint256) { - // Ten network injects a secure and unique seed to the prevrandao property, note: on other EVM chains this code would be exploitable by MEV bots - return uint256(block.prevrandao); + // Ten network injects a secure and unique seed to the prevrandao property, note: on other EVM chains this code would be exploitable by MEV bots. + // At the EVM level, difficulty will return the prevrandao property generated by Ten + return uint256(block.difficulty); } ``` -Ten's approach ensures secure and straightforward random number generation. For more information on using randomness in Ten, take a look at the [Random Numbers page](/docs/standards-primitives/random-numbers.md). +Ten's approach ensures secure and straightforward random number generation. For more information on using randomness in +Ten, take a look at the [Random Numbers page](/docs/standards-primitives/random-numbers.md). ## 5. Gas Consumption -Gas consumption is a vital consideration in smart contract development. On Ten, it's essential to optimize your contract functions to ensure efficient gas usage. Always test your contracts in a simulated environment before deploying to gauge gas consumption. +Gas consumption is a vital consideration in smart contract development. On Ten, it's essential to optimize your contract +functions to ensure efficient gas usage. Always test your contracts in a simulated environment before deploying to gauge +gas consumption. diff --git a/docs/getting-started/for-developers/setup-dev-env.md b/docs/getting-started/for-developers/setup-dev-env.md index 795ca3b1..ef3e856a 100644 --- a/docs/getting-started/for-developers/setup-dev-env.md +++ b/docs/getting-started/for-developers/setup-dev-env.md @@ -1,6 +1,7 @@ --- sidebar_position: 2 --- + # Set Up Dev Environment ## 1. Wallet Setup & Configuration @@ -9,14 +10,17 @@ To start building on Ten, you first need to set up and configure your wallet wit 1. **Install MetaMask**: [Install](https://metamask.io/download/) MetaMask either as a browser extension or mobile app. 2. **Configure MetaMask for Ten**: - - Visit the [Ten Gateway](https://testnet.ten.xyz/) for wallet setup. - - Click on 'Connect to Ten Testnet' and follow the on-screen instructions. - - Learn more about the [Ten Gateway](/docs/tools-infrastructure/hosted-gateway). -3. **Acquire Testnet ETH Tokens**: To perform transactions, you'll need testnet ETH tokens. Refer to our [Getting tokens](/docs/getting-started/for-users/get-tokens). + - Visit the [Ten Gateway](https://testnet.ten.xyz/) for wallet setup. + - Click on 'Connect to Ten Testnet' and follow the on-screen instructions. + - Learn more about the [Ten Gateway](/docs/tools-infrastructure/hosted-gateway). +3. **Acquire Testnet ETH Tokens**: To perform transactions, you'll need testnet ETH tokens. Refer to + our [Getting tokens](/docs/getting-started/for-users/get-tokens). ## 2. Setting Up the Environment Once your wallet is ready, you can proceed with the development and deployment of your smart contracts. -1. **Choose an IDE**: Use your preferred development environment or Integrated Development Environment (IDE) like Truffle, Remix, Hardhat, or Foundry. Check out IDE compatibility and its features [here](/docs/tools-infrastructure/compatible-tools). +1. **Choose an IDE**: Use your preferred development environment or Integrated Development Environment (IDE) like + Truffle, Remix, Hardhat, or Foundry. Check out IDE compatibility and its + features [here](/docs/tools-infrastructure/compatible-tools). 2. **Connect IDE to MetaMask**: Ensure your chosen IDE is connected to your MetaMask wallet. diff --git a/docs/getting-started/for-users/get-tokens.md b/docs/getting-started/for-users/get-tokens.md index 3c71d770..a4308094 100644 --- a/docs/getting-started/for-users/get-tokens.md +++ b/docs/getting-started/for-users/get-tokens.md @@ -6,7 +6,8 @@ sidebar_position: 2 ## Use Ten Discord Faucet -To obtain Ten ETH directly on the Ten testnet, utilize the Discord faucet. Remember, ENS names won't work; use your actual address. Follow these steps: +To obtain Ten ETH directly on the Ten testnet, utilize the Discord faucet. Remember, ENS names won't work; use your +actual address. Follow these steps: 1. Join the Ten [Discord server](https://discord.gg/HSPwgH89YK). 2. Go to the `#faucet-requests` channel under the `TESTNET INFO` category. @@ -14,4 +15,5 @@ To obtain Ten ETH directly on the Ten testnet, utilize the Discord faucet. Remem 4. Input your wallet address and hit enter. 5. Your wallet should receive ETH shortly. -If your wallet balance remains unchanged, double-check your wallet configuration or refer to the [set up your wallet](/docs/getting-started/for-users/setup-you-wallet) page. +If your wallet balance remains unchanged, double-check your wallet configuration or refer to +the [set up your wallet](/docs/getting-started/for-users/setup-you-wallet) page. diff --git a/docs/getting-started/for-users/setup-you-wallet.md b/docs/getting-started/for-users/setup-you-wallet.md index aacce8ca..3ee131c3 100644 --- a/docs/getting-started/for-users/setup-you-wallet.md +++ b/docs/getting-started/for-users/setup-you-wallet.md @@ -4,17 +4,25 @@ sidebar_position: 1 # Set up your wallet -Ten is fully compatible with Ethereum and seamlessly integrates with MetaMask. If you're unfamiliar with MetaMask or wallets, start here. +Ten is fully compatible with Ethereum and seamlessly integrates with MetaMask. If you're unfamiliar with MetaMask or +wallets, start here. To engage with Ten: 1. [Install](https://metamask.io/download/) MetaMask as a browser extension or mobile app. -2. To use Ten network, you have to configure the wallet using the Ten Gateway. Go to the [Ten Gateway](https://testnet.ten.xyz/) for wallet setup, click 'Connect to Ten Testnet', and follow the setup steps. Know more about the Ten Gateway [here](/docs/tools-infrastructure/hosted-gateway). +2. To use Ten network, you have to configure the wallet using the Ten Gateway. Go to + the [Ten Gateway](https://testnet.ten.xyz/) for wallet setup, click 'Connect to Ten Testnet', and follow the setup + steps. Know more about the Ten Gateway [here](/docs/tools-infrastructure/hosted-gateway). -No matter your activity on Ten, you'll probably need tokens to make transactions. See our following section: [Getting tokens.](/docs/getting-started/for-users/get-tokens) +No matter your activity on Ten, you'll probably need tokens to make transactions. See our following +section: [Getting tokens.](/docs/getting-started/for-users/get-tokens) ## Facing a problem with configuring MetaMask? -When using a dApp on Ten, start by checking its documentation and resources. If that doesn't help, consult the Ten docs' [troubleshooting](/docs/category/troubleshooting) section or seek assistance on the Ten [Discord](http://discord.gg/yQfmKeNzNd). If the issue appears to be with MetaMask, head to MetaMask's [Help Center](https://support.metamask.io/hc/en-us) to browse their forums or engage with their Support team. + +When using a dApp on Ten, start by checking its documentation and resources. If that doesn't help, consult the Ten +docs' [troubleshooting](/docs/category/troubleshooting) section or seek assistance on the +Ten [Discord](http://discord.gg/yQfmKeNzNd). If the issue appears to be with MetaMask, head to +MetaMask's [Help Center](https://support.metamask.io/hc/en-us) to browse their forums or engage with their Support team. ## Other wallets diff --git a/docs/introduction/developer-quickstart.md b/docs/introduction/developer-quickstart.md index 89fba36f..2bd4a165 100644 --- a/docs/introduction/developer-quickstart.md +++ b/docs/introduction/developer-quickstart.md @@ -3,6 +3,7 @@ sidebar_position: 4 --- # Migrate your dApp to Ten + Migrating to Ten is a straight-forward process that immediately unlocks private state. There are three main types of changes you need to make: @@ -22,7 +23,8 @@ To integrate the Ten Network into your Hardhat project, install the ten-hardhat- npm install ten-hardhat-plugin ``` -You can extend the functionality of Hardhat by installing plugins. Install them using npm or Yarn & configure it in the next step. +You can extend the functionality of Hardhat by installing plugins. Install them using npm or Yarn & configure it in the +next step. ### 1.2 Configuring `hardhat.config.js` @@ -34,36 +36,42 @@ import "@nomiclabs/hardhat-waffle"; import 'ten-hardhat-plugin' module.exports = { - solidity: "0.8.10", - networks: { - hardhat: { - // Configuration for the Hardhat Network - }, - ten: { - url: "https://testnet.ten.xyz/v1/", - chainId: 443, - accounts: ["your-private-key"], + solidity: "0.8.10", + networks: { + hardhat: { + // Configuration for the Hardhat Network + }, + ten: { + url: "https://testnet.ten.xyz/v1/", + chainId: 443, + accounts: ["your-private-key"], + }, }, - }, }; export default config; ``` + Now, start writing the smart contracts for your project. # 2. Writing Smart Contracts -Ten performs bytecode execution in the EVM identically to Ethereum, allowing developers to leverage their existing codebase and tools. +Ten performs bytecode execution in the EVM identically to Ethereum, allowing developers to leverage their existing +codebase and tools. -The main difference and advantage of Ten is that on Ten, during execution, private variables and the internal state of the contract are hidden from everyone, including node operators and the sequencer. +The main difference and advantage of Ten is that on Ten, during execution, private variables and the internal state of +the contract are hidden from everyone, including node operators and the sequencer. :::info In Ten, the internal node database is encrypted, and the execution itself is also encrypted inside the TEE. ::: -The calls to [getStorageAt](https://docs.alchemy.com/reference/eth-getstorageat) are disabled, so all data access will be performed through view functions which are under the control of the smart contract developer. Public variables are accessible to everyone because Solidity automatically generates a getter function for them. +The calls to [getStorageAt](https://docs.alchemy.com/reference/eth-getstorageat) are disabled, so all data access will +be performed through view functions which are under the control of the smart contract developer. Public variables are +accessible to everyone because Solidity automatically generates a getter function for them. -We'll illustrate how this works by creating a simple data storage example. In this dApp, users can store a number and retrieve it later. +We'll illustrate how this works by creating a simple data storage example. In this dApp, users can store a number and +retrieve it later. ## Step 1: Declaring a Public Variable @@ -84,7 +92,9 @@ contract StorageExample { ### Explanation: -In this step, we've declared a public variable `storedValues`. Solidity automatically generates a public getter view function for it, so on both Ethereum and Ten, you can call this view function without any restrictions. We also created a function that allows users to store a value against their address. +In this step, we've declared a public variable `storedValues`. Solidity automatically generates a public getter view +function for it, so on both Ethereum and Ten, you can call this view function without any restrictions. We also created +a function that allows users to store a value against their address. ## Step 2: Transitioning to a Private Variable with a Getter Function @@ -97,7 +107,7 @@ contract StorageExample { function storeValue(uint256 value) public { _storedValues[tx.origin] = value; } - + function getValue(address account) public view returns (uint256) { return _storedValues[account]; } @@ -106,15 +116,18 @@ contract StorageExample { ### Explanation: -We've now made our data variable private, meaning it can't be accessed directly from outside the contract. To fetch its value, we've provided a custom public view function `getValue` where the user provides the address. On both Ethereum and Ten, if you call this function you will retrieve the number stored by that address. +We've now made our data variable private, meaning it can't be accessed directly from outside the contract. To fetch its +value, we've provided a custom public view function `getValue` where the user provides the address. On both Ethereum and +Ten, if you call this function you will retrieve the number stored by that address. :::caution In Ethereum, the `_storedValues` variable can also be accessed directly using the `getStorageAt` method, but not in Ten. ::: -## Step 3: Implementing Data Access Control +## Step 3: Implementing Data Access Control -In this step, our aim is to restrict users to only access their own value. This feature can only be implemented in Ten because as mentioned above, `_storedValues` is not hidden in Ethereum. +In this step, our aim is to restrict users to only access their own value. This feature can only be implemented in Ten +because as mentioned above, `_storedValues` is not hidden in Ethereum. ### Code: @@ -135,17 +148,23 @@ contract StorageExample { ### Explanation: -Since `getValue` is the only function which exposes the values, we can add a check like this: `require(tx.origin == account, "Not authorized!");` If anyone, other than the original account, asks for the value, they will get an error. +Since `getValue` is the only function which exposes the values, we can add a check like +this: `require(tx.origin == account, "Not authorized!");` If anyone, other than the original account, asks for the +value, they will get an error. :::info -In Ethereum, since all data is accessible anyway, there is no need to sign calls to view functions, so `tx.origin` can be spoofed. +In Ethereum, since all data is accessible anyway, there is no need to sign calls to view functions, so `tx.origin` can +be spoofed. ::: -In Ten, the platform ensures that calls to view functions are authenticated. Which means that behind the scenes, there is a signature of the `tx.origin` address. +In Ten, the platform ensures that calls to view functions are authenticated. Which means that behind the scenes, there +is a signature of the `tx.origin` address. ## Step 4: Emitting Events -Events in Ethereum are crucial for UIs to react to smart contract state changes. In this step, we'll emit an event when a user stores a value. We'll also gauge the popularity of our contract by emitting an event when certain milestones are reached. +Events in Ethereum are crucial for UIs to react to smart contract state changes. In this step, we'll emit an event when +a user stores a value. We'll also gauge the popularity of our contract by emitting an event when certain milestones are +reached. ### Code: @@ -175,14 +194,17 @@ contract StorageExample { ### Explanation: -On Ethereum, events are visible to anyone. For example, you can subscribe to the `DataChanged` event and receive notifications in real-time about the data of everyone else. In Ten, we wanted to do better than that. +On Ethereum, events are visible to anyone. For example, you can subscribe to the `DataChanged` event and receive +notifications in real-time about the data of everyone else. In Ten, we wanted to do better than that. - The `DataChanged` event is specific to an account, so it should only be received by that user. - `MilestoneReached`, on the other hand, is intended for everyone, as we want to show how popular our contract is. -The behavior you desire is to restrict the visibility of `DataChanged`, but not that of `MilestoneReached`. **This is exactly how it works by default!** +The behavior you desire is to restrict the visibility of `DataChanged`, but not that of `MilestoneReached`. **This is +exactly how it works by default!** How it works: + - `DataChanged` - has an address as a topic (an indexed field), which makes it relevant to that address. - `MilestoneReached` - has no address topic, so it is visible to everyone. diff --git a/docs/introduction/features.md b/docs/introduction/features.md index b488318c..c20727b4 100644 --- a/docs/introduction/features.md +++ b/docs/introduction/features.md @@ -1,25 +1,41 @@ --- sidebar_position: 2 --- + # Features ### 1. **Encryption: Data Confidentiality and Computational Privacy** -Ten leverages hardware-based [Trusted Execution Environments (TEE)](https://whitepaper.ten.xyz/obscuro-whitepaper/technical-background.html#trusted-execution-environment) to achieve data confidentiality and computational privacy. - + +Ten leverages +hardware-based [Trusted Execution Environments (TEE)](https://whitepaper.ten.xyz/obscuro-whitepaper/technical-background.html#trusted-execution-environment) +to achieve data confidentiality and computational privacy. + ### 2. **Scaling: Ethereum Layer 2 Rollup** + Designed as a decentralized Ethereum L2 Rollup protocol, Ten enhances the scalability of the Ethereum network. ### 3. **MEV-free: Prevention of Maximal Extractable Value** -Ten is designed to prevent [Maximal Extractable Value (MEV)](https://ethereum.org/en/developers/docs/mev/), ensuring fairness in transaction ordering. + +Ten is designed to prevent [Maximal Extractable Value (MEV)](https://ethereum.org/en/developers/docs/mev/), ensuring +fairness in transaction ordering. ### 4. **RNG: Generate Random Number Securely** -Ten can generate secure random numbers without using any additional libraries or external applications. Generated random numbers are completely secure and no validator or user can peek into the generated numbers. + +Ten can generate secure random numbers without using any additional libraries or external applications. Generated random +numbers are completely secure and no validator or user can access the generated numbers, ensuring confidentiality and +integrity. ### 5. **Great UX: Privacy Preservation** -Ten prioritizes privacy while maintaining a seamless user experience, allowing users to access their preferred dApps and services without additional applications or extensions. + +Ten prioritizes privacy while maintaining a seamless user experience, allowing users to access their preferred dApps and +services without additional applications or extensions. ### 6. **Great Developer Experience: Efficiency and Simplicity** -Ten fills the gap between L2 rollups like Optimistic and ZK rollups. Leveraging confidential computing and economic incentives, it mirrors the efficiency and simplicity of Optimistic rollups. Developers can build on Ten using just Solidity, without needing new SDKs, frameworks or languages. + +Ten fills the gap between L2 rollups like Optimistic and ZK rollups. Leveraging confidential computing and economic +incentives, it mirrors the efficiency and simplicity of Optimistic rollups. Developers can build on Ten using just +Solidity, without needing new SDKs, frameworks or languages. ### 7. **High Performance: Fast Bridge** + Ten's design allows faster bridging of assets between Ethereum and Ten when compared to Optimistic rollups. diff --git a/docs/introduction/overview.md b/docs/introduction/overview.md index 9f0e9bfb..11e19592 100644 --- a/docs/introduction/overview.md +++ b/docs/introduction/overview.md @@ -5,10 +5,19 @@ sidebar_position: 1 ![Ten in Web3](../assets/overview-banner.png) -_The full Litepaper is available to view [here](https://ten.xyz/litepaper)._ +_The Litepaper is available to view [here](https://obscu.ro/litepaper)._ -Ten is revolutionizing Ethereum with encrypted layer 2 solution. Just as HTTPS transformed Web 2.0, ushering in a new era of secure applications and enhanced user trust, Ten is set to redefine the Ethereum ecosystem. By introducing an encrypted Ethereum Layer 2, Ten not only amplifies transaction speed and efficiency but also fortifies it with the robust security and consensus mechanisms inherent to Ethereum. +Ten is revolutionizing Ethereum by adding an encrypted layer 2 solution. -Serving as a cutting-edge Layer 2 blockchain solution, Ten significantly reduces transaction costs while seamlessly inheriting Ethereum's unparalleled security features. What sets Ten apart is its commitment to privacy and encryption. Every transaction input, the intricate state of smart contracts, and the entire execution process remain encrypted, ensuring utmost confidentiality. This encryption in blockchain ensures users and developers enjoy a familiar Web2 experience without compromising on privacy or functionality. +Just as HTTPS transformed Web 2.0, ushering in a new era of secure applications and enhanced user trust, Ten is set to +redefine the Ethereum ecosystem. -With Ten, the possibilities for Web3 applications are boundless. From next-gen gaming platforms and advanced DeFi 2.0 systems to dark pool trading, sealed-bid auctions, confidential agreements, secure identity management, and beyond, Ten is at the forefront of a private and efficient decentralized future. \ No newline at end of file +Serving as a cutting-edge Layer 2 blockchain solution, Ten significantly reduces transaction costs while seamlessly +inheriting Ethereum's unparalleled security features. What sets Ten apart is its commitment to privacy and encryption. +Every transaction input, the intricate state of smart contracts, and the entire execution process remain encrypted, +ensuring utmost confidentiality. This encryption in blockchain ensures users and developers enjoy a familiar Web2 +experience without compromising on privacy or functionality. + +With Ten, the possibilities for Web3 applications are boundless. From next-gen gaming platforms and advanced DeFi 2.0 +systems to dark pool trading, sealed-bid auctions, confidential agreements, secure identity management, and beyond, +Ten is at the forefront of a private and efficient decentralized future. \ No newline at end of file diff --git a/docs/introduction/technology.md b/docs/introduction/technology.md index ee0138b6..cdabd73b 100644 --- a/docs/introduction/technology.md +++ b/docs/introduction/technology.md @@ -1,8 +1,15 @@ --- sidebar_position: 3 --- -# Technology -At the heart of Ten's innovative approach to blockchain encryption lies the pragmatic use of Trusted Execution Environments (TEEs). These TEEs are not just about encryption; they ensure unparalleled confidentiality while providing absolute certainty about the code in execution. This technology empowers Ten to deliver a unique blend of smart contracts, decentralization, scalability, and encryption, setting a new benchmark in the blockchain realm. +# Technology -By integrating encryption directly into the Ethereum Mainnet, Ten harnesses the Mainnet's inherent liveness and availability, ensuring impeccable ledger integrity. But what truly sets Ten apart is its proprietary Proof of Block Inclusion (POBI) protocol. This groundbreaking protocol guarantees that Ten's confidential roll-ups achieve consensus within a decentralized Ten network, ensuring both security and transparency. \ No newline at end of file +At the heart of Ten's innovative approach to blockchain encryption lies the pragmatic use of Trusted Execution +Environments (TEEs). These TEEs are not just about encryption; they ensure unparalleled confidentiality while providing +absolute certainty about the code in execution. This technology empowers Ten to deliver a unique blend of smart +contracts, decentralization, scalability, and encryption, setting a new benchmark in the blockchain realm. + +By integrating encryption directly into the Ethereum Mainnet, Ten harnesses the Mainnet's inherent liveness and +availability, ensuring impeccable ledger integrity. But what truly sets Ten apart is its proprietary Proof of Block +Inclusion (POBI) protocol. This groundbreaking protocol guarantees that Ten's confidential roll-ups achieve consensus +within a decentralized Ten network, ensuring both security and transparency. \ No newline at end of file