or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing
xxxxxxxxxx
L2 client spec(chamber spec)
This client spec of OVM. A whole document is here.
Modules
Primitive Types
We have several primitive types for inner representation.
Bytes
Address
Integer
BigNumber
BigNumber = max uint256(L1 dependent)
List
Tuple
Struct
Range
Data Structure
Basic data structure.
Property
Plasma data structure
StateUpdate
Block
Transaction
L2 Clients
Developed in lite client and aggregator.
Common Class
StateManager
Manage StateUpdates which have been verified by Merkle Tree.
Plasma client
Plasma Cash's lite client to send a transaction and recieve a transaction verifying coin history.
Plasma aggregator
Plasma aggregator client collects transactions in BlockManager and constructs their Merkle tree. The aggregator submits Merkle Root to Commitment Contract.
BlockManager
getBlock(blockNumber: Integer): Promise<Block>
HTTP endpoint
/send_tx
Core Database
Developed in
db
.Core Databases are general purpose database such as KeyValueStore or RangeDb. RangeDb is a special form of KVS which can handle record using range(start: u64, end: u64) as a key.
KeyValueStore
put(key: Bytes, value: Bytes): Promise<void>
get(key: Bytes): Promise<Bytes | null>
del(key: Bytes): Promise<void>
iter(bound: Bytes)
: Creates iterator with bound key. Iterator seek greater than equal bound.bucket(name: Bytes)
: Returns bucket instance with bucket name. Bucket just appends a prefix to key but connecting one database.Iterator
RangeDb
put(start: Integer, end: Integer, value: Bytes): Promise<void>
get(start: Integer, end: Integer): Promise<Bytes[]>
bucket(name: Bytes): Bucket
start
andend
must support 256bit integer.Local information Database
The database for local information. local infomation is described in this article.
We call these database WitnessDatabase.
moved WitnessDatabase to here.
We use "hint-data" to query witness database.
The format is "type
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →SignedByDb
A key is address + Hash(message).
TransactionDb
RangeAtBlockDb
Network
Core OVM decider
https://github.com/cryptoeconomicslab/wakkanay/tree/master/src/ovm
OVM decider system check a property is true or false. This system include various deciders and each decider load witness from database to decide.
The list of deciders.
Logical Connective and quantifier
Atomic deciders
Data Structure
Decision
Challenge
It stands for validChallenge of a property.
e.g.) Challenge of
Not(P)
isChallenge
getWitness
getWitnesses
function get witnesses from database by hint string.The format of hint
bucket,type,param
type is KEY, RANGE, ITER or NUMBER.
bucket is db bucket where witnesses are stored.
THe format of param is different by
type
. ForKEY
, param is hex string of key of KVS db. ForRANGE
, param is L1 specific encoded Range data(hex). ForITER
, the format is same asKEY
.For
NUMBER
, param is${s}-${e}
: s and e are hex string of numbers.Wallet
getBalance(): Balance
sign(message)
veryfySignature(message, signature, address)
WalletFactory
createFromPrivateKey(privateKey: Bytes)
Create a wallet instance from private key.
createFromEncryptedJson(json: string, password: string)
Create a wallet instance from encrypted JSON data and a password.
Encrypted JSON should be stored at a user's device such as PC or smartphone.
The password is provided by the user every time the user opens the wallet.
The purpose of this password is for encrypting privatekey. So even if user lost their smartphone, nobody can’t peek(spy?) the password.
getMetaMaskWallet()
Return a wallet instance connecting to Metamask extension.
Contract Wrapper
Contract API. we may use Web3 like library for implementing this.
These are minimal requirement. We need more contract wrapper
contract repo is here
CommitmentContract
submitRoot(root: Bytes32, blockNumber: Integer)
getEventWatcher()
Gets EventWatcher instance connecting to Commitment Contract.
DepositContract
deposit(amount: Integer, initialState: Property)
finalizeCheckpoint(checkpoint: Property)
finalizeExit(exit: Property, depositedRangeId: Integer)
subscribeCheckpointFinalized
subscribeExitFinalized
AdjudicatorContract
claimProperty(property: Property)
decideClaimTrue
subscribePropertyClaimed
Event Watcher
Polling ethereum events. Default polling interval is 10000 seconds, but we can set interval in constructor.
EventWatcher class
Constructor
ContractInterface
is created by ethereum contract abi, and most web3 library has this class. It is used by pasing log bytes.options has only polling interval as
interval
.addHandler(event: string, handler: EventHandler): void
Add handler for a contract event.
removeHandler(event: string): void
Unsubscribe an event and remove all handlers.
initPolling(errorHandler?: ErrorHandler): void
Start polling.
EventHandler function
We should think EventHandler argument shouldbe raw log byte data or parsed log data. If EventHandler pass raw log bytes, contractInterface isn't required in EventWatcher's constructor.
Implementation
Events examples?
Also you can check contracts.