Ethereum: A Comprehensive Guide to Sequence Verification and Relative Time Blocking
The Ethereum platform is built on a new consensus algorithm called Proof of Work (PoW), which requires nodes to solve complex mathematical equations to validate transactions and create new blocks. In addition, the network uses a mechanism called Sequence Verification to ensure the integrity of the blockchain.
Sequence Verification: A Brief Overview
Sequence Verification is a Level 2 scaling solution that aims to improve Ethereum performance by reducing the amount of gas used in each transaction. It works by creating a “sequence” of transactions that are executed sequentially, one after the other.
Here’s how it works:
- A user creates a sequence of transactions by calling the
createTransaction()
function on an Ethereum account.
- Each transaction is represented as a JSON object with a
data
field containing the transaction data.
- The sequence of transactions is broadcast on the Ethereum network, where nodes verify its validity using a combination of mathematical algorithms and the user’s account balance.
How nSequence Works
The nSequence
project implements a custom implementation of sequence verification that is designed for high-performance scaling. Here’s how it works:
- A user creates an
nSequence
contract on the Ethereum network.
- The contract creates a new sequence of transactions by calling the
createSequence()
function.
- Each transaction in the sequence has a unique ID, which is used to identify each transaction.
- The contract uses a new algorithm called
hash chaining
to verify the validity of the sequence.
- When a node receives a message containing the sequence, it verifies the transactions by hashing each with the corresponding ID.
Relative Timelock (RTT): A Practical Example
Relative timelock is a feature that allows Ethereum nodes to process multiple transactions in parallel without blocking or waiting for confirmation. RTT relies on an off-chain wallet and a custom implementation of sequence verification.
Here is a step-by-step example:
- A user creates a sequence of transactions using the
nSequence
contract.
- The user generates an off-chain wallet with enough funds to cover the transaction fees.
- The user locks the off-chain wallet by calling the
lockWallet()
function, which authenticates their account and unlocks it for processing.
- When a node receives a message containing the sequence, it uses RTT to process multiple transactions in parallel.
Practical Example: Example Transactions
Let’s consider two example transactions:
Transaction 1: tx1
{
"data": {
"amount": 100,
"to": "0x1234567890abcdef"
}
}
Transaction 2: tx2
{
"data": {
"amount": 200,
"from": "0x567890abcdef"
}
}
Sequence Verification
To verify the validity of the sequence, we need to create a hash for each transaction and connect them together. This is done using the createSequence()
function in the nSequence
contract.
{
"sequenceId": "tx1 tx2",
"transactions": [
{
"txid": "tx1",
"hash": "0x..."
},
{
"txid": "tx2",
"hash": "..."
}
]
}
RTT
To process transactions in parallel, we need to use RTT. We can do this by generating an off-chain wallet and locking it using the lockWallet()
function.
{
"walletId": "0x1234567890abcdef",
"lockedDuration": 10 // seconds
}
When a node receives a message containing the sequence, it uses RTT to process multiple transactions in parallel. The sequence is verified by hashing each transaction with its corresponding ID and connecting them together.
Deixe um comentário