반응형

웹3 및 NFT에서 자주 사용되는 용어 정리

중앙화 거래소(CEX)와 탈중앙화 거래소(DEX)

CEX (Centralized Exchange)

  • 대표 예시: 바이낸스, 업비트
  • 특징: 오더북 기반으로 거래를 처리하며, 장부 정리를 한꺼번에 수행합니다.

DEX (Decentralized Exchange)

  • 대표 예시: 유니스왑, 쥬피터
  • 특징: 스마트 컨트랙트를 활용하여 거래를 처리하며, 자산 보호를 제공하지 않음. 탈중앙화 특성상 보안에 주의가 필요합니다.

Contract Address (CA)

  • 토큰 주소를 의미하며, 특정 토큰의 고유 식별자 역할을 합니다.

상장 관련 용어

TGE (Token Generate Event)

  • 토큰이 발행되는 시점을 의미합니다.

Vesting

  • 토큰의 잠금 기간을 의미하며, 예를 들어 "TGE 60%, 1년 vesting 40%"는 상장 당시 60% 지급 후, 나머지 40%는 1년에 걸쳐 지급됨을 뜻합니다.

에어드랍 관련 용어

Airdrop

  • 특정 요건을 충족한 사용자에게 무료로 신규 코인을 배포하는 행위입니다.

WhiteList (WL)

  • 프로젝트에서 제공하는 우선 청약권을 의미합니다.

Snapshot

  • 특정 시점을 기준으로 조건에 맞는 사용자를 분리하는 행위를 뜻합니다.

Reveal

  • 선판매된 NFT를 고유 특성을 가진 NFT로 변환시키는 작업입니다.

토큰 관련 용어

SWAP

  • DEX에서 토큰 간 교환을 의미합니다.

MCAP (Market Capitalization)

  • 유통 중인 토큰의 시가총액입니다.

TVL (Total Value Locked)

  • 담보 또는 유동성 풀에 잠겨 있는 금액입니다.

FDV (Fully Diluted Valuation)

  • 전체 발행 가능한 토큰의 총 가치입니다.

런치패드, 런치풀, APR

런치패드

  • 신규 코인을 판매하는 방법으로, 공모주 청약과 유사한 방식입니다.

런치풀

  • 예치된 코인에 대해 상장 예정 코인을 이자로 받는 개념입니다.
  • 스테이킹: 기간이 끝날 때까지 인출 불가능.
  • 런치풀: 언제든 인출 가능.

APR (Annual Percentage Rate)

  • 연간 이자율을 의미합니다.

NFT 관련 용어

PFP

  • 프로필 사진(Profile Picture)으로 활용되는 NFT입니다.

Minting

  • NFT를 발행하는 과정을 뜻합니다.

브리딩 (Breeding)

  • NFT 프로젝트에서 새로운 프로젝트를 생성하는 행위로, 펏지 펭귄 → 릴 펏지와 같은 사례가 있습니다.

FP (Floor Price)

  • NFT의 최저가를 의미합니다.

플랫폼별 지갑

  1. 이더리움
    • 메타마스크, 래빗월렛
  2. 솔라나
    • 팬텀, 백팩
  3. 비트코인
    • 엑스버스, 유니삿

블록체인 및 거래 관련 필수 용어

MEV (Maximal Extractable Value)

  • 블록체인 거래에서 선순위 요청을 밀어내고 차익을 얻는 행위로, 일종의 새치기입니다.

슬리피지 (Slippage)

  • 주문 가격과 실제 거래 가격의 차이로, 유동성이 낮은 코인에서 자주 발생합니다.

Mintable

  • 무한 발행이 가능한 코인으로, 추가 발행 가능 여부를 항상 확인해야 합니다.

Conviction

  • 특정 코인에 강한 확신을 가지고 대량 매수하는 행위입니다.

Top Blast

  • 가격이 가장 높은 시점에서 매수하는 것을 의미합니다.

Freeze / 허니팟

  • 매도가 불가능하게 만들어 피해를 입히는 스캠 방식입니다.
반응형
반응형

https://learn.microsoft.com/ko-kr/windows/wsl/install

Anchor

솔라나는 Rust 라는 언어로 컨트랙트를 작성해 배포한다. 하지만, 쌩 Rust 로는 너무너무나 어렵고 관리가 힘들기에 Anchor 라는 Rust 프레임 워크를 사용한다. 하지만, Windows 상에서 anchor 설치 및 관리가 꽤 복잡하기에 이렇게 문서로 작성한다.

위의 링크에 따라서 WSL 환경에서 구현하려고 한다.

 

WSL 이란?

간단하게 말해서 윈도우 위에서 돌아가는 작은 컴퓨터다. VM 이 있지 않나요? 하신다면, VM 은 진짜 OS 를 새로 띄워 구동부터 하는 반면, WSL 은 윈도우 운영체제 안에 작은 디스크 조각안에서 가상머신 운영체제 명령어를 이용할 수 있는 기능이다. 윈도우와 파일교환이 가능하다.

1. WSL 설치

Powershell 혹은 cmd 창을 열어 wsl 을 설치한다.

wsl --install

2.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

3.

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

4. 재부팅

5.

Rust & Cargo 설치

Rust를 설치하고 Cargo를 설치한다.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
  • rustup 을 설치해 rust를 설치하고, cargo 를 설치한다.

6.

Node.js, NPM 설치

Anchor CLI와 프로젝트 초기화를 위해 Node.js를 설치해야 한다.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

nvm install 22

7. 솔라나 설치

sh -c "$(curl -sSfL https://release.solana.com/v1.16.5/install)"

8. Anchor 설치

npm i -g @coral-xyz/anchor-cli

9. 솔라나 cli 설치

 solana config set --url localhost

 solana config set --url https://api.devnet.solana.com
Config File: /home/lkbrothers/.config/solana/cli/config.yml
RPC URL: http://localhost:8899
WebSocket URL: ws://localhost:8900/ (computed)
Keypair Path: /home/lkbrothers/.config/solana/id.json
Commitment: confirmed

 

솔라나 키체인 생성

solana-keygen new
----
Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none):

Wrote new keypair to /home/lkbrothers/.config/solana/id.json
=========================================================================
pubkey: "YOUR KEYCHAIN"
=========================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
normal warm mercy fix leader crater cinnamon palm truly nice movie embark
=========================================================================

 

주소확인

solana address

 

앵커 인잇

Anchor 프로젝트가 생성된다.

anchor init my-project

4. 빌드 및 배포

로컬 밸리데이터 실행

로컬에서 실행되는 블록체인 환경이다. 실행하면 블록체인 시스템이 로컬에서 실행된다.

solana-test-validator

빌드

anchor build

배포

anchor deploy

에러 처리

  1. 솔라나 테스트 밸리데이터 오류

솔라나 테스트 밸리데이터 실행시 오류가 나왔다. 처음 ubuntu 실행환경에서는 bzip2 가 깔려있지 않아 깔아줘야한다.

sudo apt update
sudo apt install bzip2

 

2. 앵커 버전4 빌드 오류

 

There is an issue on the anchor repository for this: https://github.com/coral-xyz/anchor/issues/3392#issuecomment-2508412018

 

Fresh project `anchor build` fails with "lock file version 4 requires `-Znext-lockfile-bump`" · Issue #3392 · coral-xyz/anchor

Issue Running anchor build or anchor test in a fresh project initialized with anchor-cli fails with the following: error: failed to parse lock file at: /Users/{user}/{project_dir}/anchor/Cargo.lock...

github.com

 

The suggested solution is to change the lock file version from 4 to 3.

This is acherons answer to the issue which will be solved in Anchor version 2.x

You can fix this simply by changing the version field of Cargo.lock as #3393 (comment) suggested:

- version = 4
+ version = 3
The reason why it happens is because Anchor v0.30 uses Solana v1.18, and Solana v1.18 depends on rustc 1.75, but the new version (4) of Cargo.lock has only been stabilized in rustc 1.78 (as mentioned in rust-lang/cargo#14655 (comment)).

Solana build tools have recently been updated to use rustc 1.79, which is available since Solana v2.1, and it's also what the master branch of Anchor uses (#3339).

Anchor v0.31 (#3259) will support Solana v2, meaning this issue will be resolved automatically. In the meantime, you can just use the fix mentioned at the beginning of this comment.

If you are still having issues afterwards follow the guide from beeman here: https://github.com/coral-xyz/anchor/issues/3392#issuecomment-2565734744

 

Fresh project `anchor build` fails with "lock file version 4 requires `-Znext-lockfile-bump`" · Issue #3392 · coral-xyz/anchor

Issue Running anchor build or anchor test in a fresh project initialized with anchor-cli fails with the following: error: failed to parse lock file at: /Users/{user}/{project_dir}/anchor/Cargo.lock...

github.com

 

⇒ Cargo 최신버전이 4 인데 어째서인지 오류가 난다. 깃헙 이슈에도 해당 이슈가 나와있고, 문제가 있어 3으로 내리라고한다. lock 파일 버전을 변경해주자.

 

3. 빌드오류2

=> 링커 못찾음

 

링커를 찾지못하면 gcc, cc 등 c 기반 프로그램이 깔려있지 않아서다. 아래 방법대로 깔아주자.

 

1. 필수 패키지 설치 (Ubuntu/WSL 기준)

  1. 시스템 패키지 업데이트
  2. sudo apt update sudo apt upgrade
  3. C 컴파일러 및 빌드 도구 설치
    아래 명령어로 필요한 패키지를 설치합니다:
  4. sudo apt install build-essential
  5. 설치 확인
    설치된 gcccc의 버전을 확인합니다:
  6. gcc --version cc --version

2. Rust 및 Cargo 빌드 도구 재설치

Rust 및 Cargo 관련 문제가 있을 경우 재설치해보세요:

  1. Rust 재설치:
  2. rustup self uninstall curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  3. 설치 후 Rust 버전 확인:
  4. rustc --version cargo --version

3. 프로젝트 다시 빌드

필요한 도구를 설치한 후, Rust 프로젝트를 다시 빌드하세요:

cargo clean
cargo build
반응형
반응형

1. Install ehthers zkSync

npm install ethers zkSync

2. zkSync 란?

zkSync 는 EVM 을 확장하기 위한 레이어 2 솔루션. ZKP 를 이용한 빠르고 저렴한 거래처리 가능

ZKP (Zero Knowledge Proof) 는 뭔데?

어떤 정보를 드러내지 않고 특정 주장이나 사실이 참임을 증명하는 기술

블록체인에서는 거래내역을 보여주지 않고 거래내역이 유효함을 증명할 수 있다.

zkSync 를 통해 빠르고 저렴한 거래처리를 적용할 수 있다!

Provider 생성

alice.js, bob.js 를 zkSync 로 연결하기 위해서는 util.js 에서 zkSync Provider를 생성해야한다.

// utils.js

async function getZkSyncProvider(zksync, networkName) {
    let zkSyncProvider;
    try {
        zkSyncProvider = await zksync.getDefaultProvider(networkName);
    } catch (error) {
        console.log('Unable to connect to zkSync.');
        console.error(error);
    }
    return zkSyncProvider;
}

3. zkSync 계정 만들기

zkSync 와 이더리움을 연결하려면 계정과 지갑에 대해 알아야한다. 따라서, zkSync 의 지갑 계정을 생성해 이더리움과 연결해보자.

async function getZkSyncProvider (zksync, networkName) {
  let zkSyncProvider
  try {
    zkSyncProvider = await zksync.getDefaultProvider(networkName)
  } catch (error) {
    console.log('Unable to connect to zkSync.')
    console.log(error)
  }
  return zkSyncProvider
}

async function getEthereumProvider (ethers, networkName) {
  let ethersProvider
  try {
    ethersProvider = new ethers.getDefaultProvider(networkName)
  } catch (error) {
    console.log('Could not connect to Rinkeby')
    console.log(error)
  }
  return ethersProvider
}

async function initAccount (rinkebyWallet, zkSyncProvider, zksync) {
  const zkSyncWallet = await zksync.Wallet.fromEthSigner(rinkebyWallet, zkSyncProvider)
  return zkSyncWallet
}

 

위 코드의 결과로 zkSyncWallet 을 생성할 수 있다.

4. zkSync 인증 확인하기

zkSync 계정을 생성했다면 인증 여부를 확인해야한다. 지갑의 key 가 존재한다면 key 가 singing key에 등록이 되어있는지 확인 후 changePubkey 에 저장한다.

async function registerAccount (wallet) {
  console.log(`Registering the ${wallet.address()} account on zkSync`)
  if(!await wallet.isSigningKeySet()){
    if(await wallet.getAccountId() === undefined){
        throw new Error('Unknown account')
    }
    const changePubkey = await wallet.setSigningKey()
    await changePubkey.awaitReceipt()
  }
}

5. zkSync 에 재화를 넣어보자

Priority Operations

  • 이더리움 네트워크에서 작동되는 작업들

Transactions

  • zkSync 에서 사용되는 활동들

zkSync에서 transaction 이 사용되는 원리

zkSync 에 트랜잭션을 보낼때 Promise 를 사용하게 된다. 트랜잭션의 작업을 믿는다면 따로 블록이 생성될 때까지 기다릴 필요없다.

zkSync 트랜잭션은 SNARK 증명 방식으로 검증하고, 이더리움 스마트 컨트랙트에 등록될 때까지 10분 소요된다.

async function depositToZkSync(zkSyncWallet, token, amountToDeposit, ethers){
    const deposit = await zkSyncWallet.depositToSyncFromEthereum({
        depositTo: zkSyncWallet.address(),
        token: token,
        amount: ethers.utils.parseEther(amountToDeposit)
    })
    try{
        await deposit.awaitReceipt()
    }catch(error){
        console.log('Error while awaiting confirmation from the zkSync operators.')
        console.log(error)
    }
}
  • deposit 객체를 만들기 위해 이더리움 wei 단위로 변경해야한다.
  • awaitReceipt 함수를 이용해 트랜잭션이 정상 작동한지 확인 한다.

6. zkSync 에서 애셋 옮기기

애셋을 옮기기 위해서는 두 가지 과정으로 나눌 수 있다.

  1. syncTransfer 함수를 통해 zkSync 지갑과 수취인의 주소, 애셋 정보 및 fee 를 전달할 수 있다.
  2. awaitReceipt 를 통해 정상 작동했는지 확인할 수 있다.

zkSync에서 전송 작업의 정밀도는 제한되어 있으므로 전송량은 5바이트 길이의 부동 소수점

지불한 수수료는 2바이트 길이의 부동 소수점 표현 으로 패키징해야한다.

async function transfer (from, toAddress, amountToTransfer, transferFee, token, zksync, ethers) {
    const closestPackableAmount = zksync.utils.closestPackableTransactionAmount(ethers.utils.parseEther(amountToTransfer))
    const closestPackableFee = zksync.utils.closestPackableTransactionFee(ethers.utils.parseEther(transferFee))
    const transfer = await from.syncTransfer(
        {
            to:toAddress,
            token: token,
            amount : closestPackableAmount,
            fee:closestPackableFee
        }
    )
    const transferReceipt = await transfer.awaitReceipt()
    console.log('Got transfer receipt.')
    console.log(transferReceipt)
}

7. Transfer Fee

Transfer fee 를 계산하는 방법을 배우자

fee 의 종류

  1. off-chain fee
    • 계산 및 저장 비용을 뜻하며, 불가변성이다.
  2. on-chain fee
    • 이더리움에서 SNARK 를 검증하는데 드는 비용이다. 가스 가격에 따라 달라지기에 가변적이다.
async function getFee(transactionType, address, token, zkSyncProvider, ethers){
    const feeInWei = await zkSyncProvider.getTransactionFee(transactionType, address, token)
    return ethers.utils.formatEther(feeInWei.totalFee.toString())
}
  • getTransactionFee 로 구한 wei 는 매우 길기 때문에 formatEther 함수로 처리해준다.

8. Withdraw to Ethereum

세 가지 과정으로 Withdraw 할 수 있다.

  1. closestPackableAmount 를 계산
  2. wallet.withdrawFromSyncToEthereum 으로 withdraw를 계산
  3. Receipt 검증 완료
async function withdrawToEthereum (wallet, amountToWithdraw, withdrawalFee, token, zksync, ethers) {
    const closestPackableAmount = zksync.utils.closestPackableTransactionAmount(ethers.utils.parseEther(amountToWithdraw))
    const closestPackableFee = zksync.utils.closestPackableTransactionFee(ethers.utils.parseEther(withdrawalFee))
    const withdraw = await wallet.withdrawFromSyncToEthereum({
        ethAddress : wallet.address(),
        token : token,
        amount : closestPackableAmount,
        fee : closestPackableFee
    })
    await withdraw.awaitVerifyReceipt()
  console.log('ZKP verification is complete')
}

9. Account Balances

계정의 Balance 에는 두가지가 존재한다.

  1. commit balance
    1. 거래 내역을 zkSync 의 스마트 컨트랙트에 포함시킨다.
    2. 즉시 사용 가능
    3. 이더리움 메인넷에 기록되지만 검증되지 않았다.
  2. verify balance
    1. 블록을 최종 검증 상태로 확정
    2. SNARK 로 블록을 검증
    3. 최종적으로 보장된 verify 금액
async function displayZkSyncBalance (wallet, ethers){
    const state = await wallet.getAccountState()
    if(state.committed.balances.ETH){
        console.log(`Commited ETH balance for ${wallet.address()}: ${ethers.utils.formatEther(state.committed.balances.ETH)}`)
    }else{
        console.log(`Commited ETH balance for ${wallet.address()}: 0`)
    }
    if(state.verified.balances.ETH){
        console.log(`Verified ETH balance for ${wallet.address()}: ${ethers.utils.formatEther(state.verified.balances.ETH)}`)
    }else{
        console.log(`Verified ETH balance for ${wallet.address()}: 0`)
    }
}

10. 가게주인 밥 - 블록체인과 연결

위에서 만든 utils.js 를 이용해 클라이언트와 연결해보자

(async () => {
  const ethers = require('ethers')
  const zksync = require('zksync')
  const utils = require('./utils')

  // Start here
  const zkSyncProvider = await utils.getZkSyncProvider(zksync, process.env.NETWORK_NAME)
  const ethersProvider = await utils.getEthereumProvider(ethers, process.env.NETWORK_NAME)
})()
  • zkSyncProvider, ethersProvider 을 util.js 에서 불러와야 한다.

11. 가게주인 밥 - 밥의 지갑 주소를 가져오다

const bobRinkebyWallet = new ethers.Wallet(process.env.BOB_PRIVATE_KEY, ethersProvider)
console.log(`Bob's Rinkeby address is: ${bobRinkebyWallet.address}`)
console.log(`Bob's initial balance on Rinkeby is: ${ethers.utils.formatEther(await bobRinkebyWallet.getBalance())}`)
const bobZkSyncWallet = await utils.initAccount(bobRinkebyWallet, zkSyncProvider, zksync) 
  • 밥에게 필요한 지갑주소와 zkSync 지갑 주소를 가져온다.

12. 잔액 업데이트

zkSync 에는 잔액이 업데이트 됐음을 알리는 메커니즘이 없기 때문에 setInterval 을 통해 잔액을 주기적으로 최신화해야한다.

  process.on('SIGINT', () => {
    console.log('Disconnecting')
    // Disconnect
    process.exit()
  })
  setInterval(async () => {
    // Call the `utils.displayZkSyncBalance` function
    await utils.displayZkSyncBalance(bobZkSyncWallet, ethers);
    console.log('---')
  }, SLEEP_INTERVAL)

13. 계좌 등록

상점을 사용할 앨리스의 계좌를 등록해야한다.

앨리스가 상점을 방문한 이후의 시나리오는 다음과 같다.

  1. 앨리스는 zkSync 계좌를 이용해 이더리움을 배포하려고한다.
  2. 퍼블릭 키를 등록해 zkSync 로 거래할 수 있게 하려고 한다.
  3. zkSync 를 이용해 밥과 거래를 할 것 이다.
  4. 이더리움 코인으로 zkSync 에서 이더리움으로 옮겨 남은 금액을 확인해야한다.
(async () => {
  const ethers = require('ethers')
  const zksync = require('zksync')
  const utils = require('./utils')
  const token = 'ETH'
  const amountToDeposit = '0.05'
  const amountToTransfer = '0.02'
  const amountToWithdraw = '0.002'

  const zkSyncProvider = await utils.getZkSyncProvider(zksync, process.env.NETWORK_NAME)
  const ethersProvider = await utils.getEthereumProvider(ethers, process.env.NETWORK_NAME)
  console.log('Creating a new Rinkeby wallet for Alice')
  const aliceRinkebyWallet = new ethers.Wallet(process.env.ALICE_PRIVATE_KEY, ethersProvider) // Account #78
  console.log(`Alice's Rinkeby address is: ${aliceRinkebyWallet.address}`)
  const aliceInitialRinkebyBalance = await aliceRinkebyWallet.getBalance()
  console.log(`Alice's initial balance on Rinkeby is: ${ethers.utils.formatEther(aliceInitialRinkebyBalance)}`)

  console.log('Creating a zkSync wallet for Alice')
  const aliceZkSyncWallet = await utils.initAccount(aliceRinkebyWallet, zkSyncProvider, zksync)

  console.log('Depositing')
  // Start here
    await utils.depositToZkSync(aliceZkSyncWallet, token, amountToDeposit, ethers)
    await utils.displayZkSyncBalance(aliceZkSyncWallet, ethers)
    await utils.registerAccount(aliceZkSyncWallet)
})()

14. zkSync 로 결제해보자

utils.getFee, utils.transfer 함수를 이용해 결제 시나리오를 만들어보자.

const transferFee = await utils.getFee('Transfer', aliceRinkebyWallet.address, token, zkSyncProvider, ethers)
await utils.transfer(aliceZkSyncWallet, process.env.BOB_ADDRESS, amountToTransfer, transferFee,token,zksync,ethers)

15. withdraw

결제와 마찬가지로 withdraw 도 구현할 수 있다.

const withdrawalFee = await utils.getFee('Withdraw', aliceRinkebyWallet.address, token,zkSyncProvider, ethers)
await utils.withdrawToEthereum(aliceZkSyncWallet, amountToWithdraw, withdrawalFee, token,zksync,ethers)
반응형

'BlockChain > Solidity' 카테고리의 다른 글

[DP/NFT] 4. 리액트 세팅  (0) 2022.09.05
[DP/NFT] 3. SaleAnimalToken 작성  (0) 2022.09.05
[DP/NFT] 2. Minting contract 작성  (0) 2022.09.05
[DP/NFT] 1. Install Solidity & Metamask  (0) 2022.08.25
반응형
더보기

 

 

TON (The Open Network)

일명 (분산형 개방형 인터넷 플랫폼)

TON 블록체인


Blockchain of Blockchains

Single Actor

  • Actor 는 스마트 컨트랙트 , Account 와 같이 블록체인 엔티티를 설명하는데 사용되는 말이다.

TON 에서는 address code data balance 같은 속성들이 있다. 이러한 객체들은 storage , behavior 를 가지고 있다. 이러한 behavior 는 다음과 같은 패턴을 보인다.

  1. 무슨일이 발생 (보통은 컨트랙트가 메시지를 가져올때)
  2. TON 버추얼 머신에서 code를 실행한 이벤트에 따라 컨트랙트가 작동한다.
  3. code data 와 같은 속성들을 컨트랙트가 변경한다.
  4. 컨트랙트는 선택적으로 출력 메시지를 발생시킨다.
  5. 컨트랙트는 다음 이벤트가 발생할 때까지 대기한다.

The Lowest Level : Account Chain

트랜잭션의 시퀀스 Tx1 -> Tx2 -> Tx3 -> ...체인 이라고 부른다.

AccountChain 은 트랜잭션의 단일 계정의 체인을 강조하기 위한 말이다.

트랜잭션을 처리하는 노드는 스마트 컨트랙트의 상태를 조정해야 하므로 다음과 같은 순서로 배치된다. [Tx1 -> Tx2] -> [Tx3 -> Tx4 -> Tx5] -> [] -> [Tx6]

이렇게 되는 배칭은 컨트랙트의 시퀀싱에는 영향을 미치지않는다. 각각의 트랜잭션은 오직 하나의 이전 트랜잭션과 최대 하나의 다음 트랜잭션을 가진다. 이러한 시퀀스는 Block 으로 잘리게 된다.

블록이 들어오거나 나가는 메시지를 담는 큐를 포함하는 것도 편리하다. 이러한 경우에는 블록에 블록에서의 스마트 컨트랙트에서 무슨 일이 생기는지에 대해 설명된 정보의 전부가 포함이 될것이다.

Many AccountChains: Shards

몇개의 AccountChains 를 ShardChain 라고 한다. ShardChain 을 또한 ShardBlocks 로 나눌 수 있다. SharBlocks 는 개개인의 AccountBlocks 를 포함하고 있다.

ShardChains 를 동적으로 분리하고 병합

ShardChain 은 구분하기 쉬운 AccountChains 로 구성되어있다. 따라서, 쉽게 분리가 가능하다. 예를 들어 1million 개의 계정에서 일어나는 이벤트를 처리하는 ShardChain 1개가 있고 초당 거래가 너무 많아 하나의 노드에서 처리하고 저장할 수 없다면 ShardChain 을 두 개로 나눌 수 있다.

또한, 일부 Shard 에서 사용되지 않는 부분이 생기면 하나의 더 큰 ShardChain 으로 병합할 수 있다.

각각의 계정은 메시지를 보내서 상호작용할 수 있다. 메시지 발신큐에서 수신큐로 옮기고 이러한 메시지를 broadcast 할 수 있는 특별한 라우팅 메커니즘이 있다.

  1. 모든 메시지는 전달되어진다.
  2. 모든 메시지는 연속적으로 전달된다. (순서가 보장된다.)

BlockChain

모든 계정을 담은 Shard 의 집합이 일련의 규칙을 따르는 것을 블록체인 이라고 한다.

TON 에서는 다양한 규칙이 있으며 많은 블록체인들은 동시에 작동되고, crosschain 들과 메시지를 보내면서 상호작용한다. 같은 방식으로 한 체인안에 계정들도 서로 의사소통할 수 있다.

Workchain : 당신만의 규칙을 가진 블록체인

Shardchain 들의 그룹을 커스텀하고 싶다면 Workchain 을 만들 수 있다. 솔리디티로 구현된 스마트 컨트랙트를 EVM에서 작동하는 것이 그 예이다.

이론적으로, 커뮤니티 안의 모든 구성원은 자신만의 워크체인을 만들 수 있는데 사실 약간 복잡하다. 워크체인을 만들려면 돈도 많이들고 2/3 의 구성원들의 찬성이 필요하기 때문이다.

현재 TON 에는 2개의 워크체인이 있다. (MasterChain, BaseChain)

BaseChain

  • 값이 싸기에 모든 트랜잭션에서 거의 사용된다.

MasterChain

  • TON 의 중요한 함수들을 가지고 있다.

MasterChain : 블록체인들의 블록체인

메시지 라우팅과 트랜잭션 실행에 있어 동기화는 중요하다. 여러 체인들의 상태를 관리하고 고치는데 있어 노드들은 어떠한 방법이 필요하다.

따라서, TON 은 MasterChain 을 만들었다. 마스터 체인의 블록들은 시스템에서 모든 블록들의 정보를 가지고 있다. 그렇기에 observer 은 명확하게 멀티체인 시스템의 상태를 결정할 수 있다.

반응형

+ Recent posts