Lysa Testnet
WhitepaperWebsiteLinktree
  • 👋Welcome to Lysa Testnet
  • Proof of Work (v1)
  • Proof of Stake (v2)
    • Connecting a Local Node to a Proof-of-Stake (PoS) Network
    • 🚀 Deploying Smart Contracts Using Truffle with GSMC (Gasless)
Powered by GitBook
On this page

Proof of Work (v1)

Overview

This document explains the Proof of Work (PoW) implementation for the Lysa Testnet (v1). It is intended for developers and stakeholders who wish to participate in the network by running nodes, mining, or interacting with the blockchain using GSMC as the native gas token.

1. Introduction

The Lysa Testnet (v1) is built on a modified version of the Go-Ethereum (Geth) client, supporting a PoW consensus mechanism. This testnet enables decentralized applications and asset tokenization within the Go! SmartChain AI ecosystem while allowing stakeholders to validate transactions and secure the network.

Key Features

  • Custom blockchain with GSMC as the gas fee currency.

  • Proof of Work mining for network security and block validation.

  • Open participation for developers and stakeholders.

  • Externally accessible RPC nodes for interaction with the network.

2. Network Setup

2.1. Node Deployment on GCP VM

Stakeholders can deploy a node on a GCP VM by following these steps:

Provision of a GCP VM

sudo apt update
sudo apt install -y build-essential curl git

Clone and Build the Custom Geth Client

Update the repository URL and check out the specific branch:

git clone [email protected]:TheGo-Project/Go-SmartChainAI.git
cd Go-SmartChainAI
make geth

Initialize the Blockchain

Ensure the genesis.json is properly configured:

./build/bin/geth --datadir=./data init genesis.json

If the genesis.json file does not exist, create it in the directory with the following content:

{
  "config": {
    "chainId": 1064552686,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "ethash": {}
  },
  "difficulty": "0x400",
  "gasLimit": "0x8000000",
  "alloc": {
    "0xA7b5aDeFcfAF726ef46EAA8171F76312da81cb21": {
      "balance": "200000000000000000000"
    },
    "0xB11a867a35e63dB44d5E39885C7F6c8d2A05Dbf8": {
      "balance": "250000000000000000000"
    }
  }
}

Start Local the Node

To start the local Geth node and connect to the network, follow these steps:

1. Start the Local Node

Run the following command to start the local node:

./build/bin/geth --networkid 1064552686 \
    --http \
    --http.addr 0.0.0.0 \
    --http.port 8545 \
    --http.corsdomain "*" \
    --http.api "eth,net,web3,miner,personal,admin" \
    --datadir=./data \
    --port 30303 \
    --maxpeers 50 \
    --verbosity 3 \
    --allow-insecure-unlock

2. Attach to the Geth Node

Once the node is running, attach to it using the following command:

geth attach http://127.0.0.1:8545

3. Add the Remote Node as a Peer

To join the network and establish communication with the remote node, run:

admin.addPeer("enode://b1a934c5a8b2d27180290c101b8df067259cbf1c26e3f091d53486bce3bbe60b6bc2f47f9f09da59636fe78f5ae0b8f5c9e03b771859a028ae1d69a2f2f830bf@34.136.9.43:30303")

4. Check Connected Peers

To verify that the peer was successfully added, run:

admin.peers

You should see details of the connected peer.

5. Check the Current Block Number

To verify the current block number synced by your local node:

eth.blockNumber

This confirms that the node is actively syncing and participating in the network.

Options for Executing Geth

Option 1: Use the Full Path in Commands

./build/bin/geth --networkid 1064552686 ...

Option 2: Run the Command from the Build Directory

cd build/bin
./geth --networkid 1064552686 ...

Option 3: Copy the Binary to an Accessible Location

cp build/bin/geth /usr/local/bin/
geth --networkid 1064552686 ...

3. Mining GSMC on Lysa Testnet

3.1. Mining Setup

Developers and stakeholders can mine GSMC to validate transactions and secure the network.

Start Mining

To start mining on the Lysa Testnet, use the command below. Make sure to replace YOUR_WALLET_ADDRESS with your actual Ethereum wallet address where you will receive mining rewards.

./geth --mine --miner.threads=4 --miner.etherbase="YOUR_WALLET_ADDRESS"

Check Mining Status

To check if your node is mining successfully, you can attach to your Geth node using the following command and check the mining status:

geth attach http://127.0.0.1:8545

Then run:

eth.mining;

This will return true if your node is mining.

3.2. Rewards and Gas Fees

  • Block Reward: Miners receive GSMC tokens as a reward for each successfully mined block.

  • Transaction Fees: Transactions on the network require GSMC as gas. The fees are paid to miners as a reward for processing transactions and securing the network.

  • Difficulty Adjustment: The mining difficulty is adjusted dynamically based on the total network hash rate to ensure that block times remain consistent.

4. Interacting with the Network

4.1. Connecting to the Network

Developers can interact with the Lysa Testnet using the ethers.js library as detailed below. This setup assumes that the necessary environment variables have been defined in a .env file.

Example of ethers.js Script for Transactions

const { ethers } = require("ethers");
const axios = require("axios");
require("dotenv").config(); // Load environment variables from a .env file

const RPC_URL = process.env.RPC_URL || "http://localhost:8545";
const SENDER = process.env.SENDER;
const RECEIVER = process.env.RECEIVER;
const PASSWORD = process.env.PASSWORD;
const AMOUNT = process.env.AMOUNT || "1"; // Default to 1 ETH if not specified
const GAS_PRICE = process.env.GAS_PRICE || "20"; // Default 20 Gwei
const GAS_LIMIT = 21000; // Standard for ETH transfers

const provider = new ethers.providers.JsonRpcProvider(RPC_URL);

async function sendTransaction() {
  console.log("🔓 Unlocking sender account...");
  const signer = provider.getSigner(SENDER);
  await signer.unlock(PASSWORD);

  console.log("💰 Fetching balances before transaction...");
  const balanceSenderBefore = await provider.getBalance(SENDER);
  const balanceReceiverBefore = await provider.getBalance(RECEIVER);

  console.log(
    `📊 Sender Balance Before: ${ethers.utils.formatEther(
      balanceSenderBefore
    )} ETH`
  );
  console.log(
    `📊 Receiver Balance Before: ${ethers.utils.formatEther(
      balanceReceiverBefore
    )} ETH`
  );

  console.log("📦 Creating transaction...");
  const tx = await signer.sendTransaction({
    to: RECEIVER,
    value: ethers.utils.parseEther(AMOUNT),
    gasLimit: ethers.utils.hexlify(GAS_LIMIT),
    gasPrice: ethers.utils.parseUnits(GAS_PRICE, "gwei"),
  });

  console.log(`🚀 Transaction sent! Hash: ${tx.hash}`);
  console.log("⏳ Waiting for the transaction to be mined...");
  await tx.wait();

  console.log("✅ Transaction confirmed!");
}

sendTransaction().catch(console.error);

4.2. Deploying Smart Contracts

Smart contracts can be deployed using tools like Hardhat or Truffle.

Example Deployment with Hardhat

yarn hardhat run scripts/deploy.js --network lysa-testnet

Sending Transactions via Web3.js

web3.eth.sendTransaction({
  from: "0xYourAccount",
  to: "0xRecipient",
  value: web3.utils.toWei("1", "ether"),
  gasLimit: 21000,
  gasPrice: web3.utils.toWei("20", "gwei"),
});

5. Monitoring & Performance Metrics

  • Transaction Throughput (TPS): Measures the number of transactions the network can handle per second.

  • Block Finality Time: Tracks the time it takes for a block to be considered final.

  • Validator Uptime: Monitors the uptime and performance of network validators.

6. Next Steps & Mainnet Readiness

As the testnet stabilizes and matures, preparations will be made for a transition to the mainnet. This includes:

  • Security Enhancements: Implementing additional security measures and audits.

  • Staking Mechanisms: Introducing staking for network validators.

  • Community Participation: Increasing community involvement in network governance and decision-making.

Feedback & Improvement

We encourage stakeholders to report any issues and suggest improvements through GitHub or community forums to help enhance the network's robustness and functionality.

PreviousWelcome to Lysa TestnetNextProof of Stake (v2)

Last updated 3 months ago