Move - blog.pufsecurity.com...•with semantics inspired by linear logic •ordinary program values...

Preview:

Citation preview

Move

What is MoveProgramming language for implementing work in Libra

◦ Issuing cryptocurrencies, tokens, and digital assets

◦ Facilitating smooth and secure blockchain transactions

◦ Secure management of validators

Feature of MoveStatic Type System

◦ Find error in compile, not in execution

First-class Resources

◦ A resource type can only be created or destroyed by the module that defines the type

◦ Prevent some logic error in smart contact

◦ Ex:

module DToken {

// A resource representing the DToken

resource T {

// The value of the coin. May be zero

value: u64,

}

}

Managing Digital Assets on a Blockchain

• An Abstract View of a Blockchain

• Encoding Digital Assets in an Open System

• Existing Blockchain Languages

An Abstract View of a Blockchain

• blockchain is a replicated state machine

• Replicators in the system are known as validators

• Users of the system send transactions to validators

• Each validator understands how to execute a transaction to transition its internal state machine from the current state to a new state

• Following consensus protocol

Encoding Digital Assets in an Open System

• encode the owners of digital assets at a given point in time

• Libra Blockchain is an open system

Scarcity

• The supply of assets in the system should be controlled

• Duplicating existing assets should be prohibited

• creating new assets should be a privileged operation

Access control

• A participant in the system should be able to protect her assets with access control policies.

Existing Blockchain Languages

• Bitcoin Script / Ethereum Virtual Machine bytecode

• Indirect representation of assets

• Scarcity is not extensible

• Access control is not flexible

Move Design Goals

• First-Class Resources

• Flexibility

• Safety

• Verifiability

First-Class Resources

• with semantics inspired by linear logic

• ordinary program values

• to implement safe digital assets

• write correct business logic for wrapping assets and enforcing access control policies

Flexibility

• includes a transaction script that is effectively the main procedure of the transaction

• invoke multiple procedures of modules published in the blockchain

• perform local computation on the results

Safety

• resource safety / type safety / memory safety

• use a high-level programming language with a compiler that checks these properties

• use low-level untyped assembly and perform these safety checks at runtime

Verifiability

• No dynamic dispatch

• Limited mutability

• Modularity

Move 概論

Peer-to-Peer Payment Transaction Script

◆1.發送方從存儲在 0x0.Currency 的module 中,調用名為withdraw_from_sender的 procedure。

◆2.發送者通過將貨幣的資源值移動到 0x0.Currency module 的存款這動作,將資金轉移到收款人。

Can not……

◆1. 將move(coin)改為 copy(coin)來複製貨幣金額,資源值無法複製

◆2. 透過兩次move(coin) 來重新使用貨幣

EX: 0x0.Currency.deposit (copy(some_other_payee),move(coin))

◆3. 透過刪除move(coin) 丟失貨幣

Currency Module & resource: ◆帳戶最多只能包含一個給定類型的資源值,和一個具有給定名稱的模組(在地址 0x0 的帳戶不允許包含其他的類型為 0x0.Currency.Coin 的資源)

◆ 0x0.Currency.Coin 和 0x1.Currency.Coin 算是不能互換使用的不同類型

Declaring the Coin resource

1) Coin 是一種結構類型,其單個字段(field)值類型為 u64(64 位無符號整數)

2) 只有 Currency module(模組)的procedure(程序)才能創建或銷毀 Coin 類型的值

3) 其他module(模組)和 transaction script(交易腳本)只能透過模組公開的 procedure(程序)寫入或引用值的字段

Implementing deposit

1) 銷毀輸入 Coin 並記錄其值。

2) 獲取對存儲在收款人帳戶下的獨一的 Coin 資源的引用。

3) 通過將 Coin 的值傳遞給 procedure(程序),來增加收款人 Coin 的值。

Implementing withdraw_from_sender

1) 獲取對在發件人帳戶下發布的 Coin 類型的唯一資源的引用。2) 透過輸入量來減少引用的 Coin 的值。3) 創建並返回值為金額的新 Coin。

THE MOVE LANGUAGE

CONTENTS

Global State Modules Types ValuesProcedures and

transaction scripts

GLOBAL STATE

MODULES

TYPES

VALUES

PROCEDURES AND TRANSACTION SCRIPTS

BYTECODE OPERATIONS

Bytecode Interpreter

Bytecode Verifier

Linking with global state

BYTECODE INTERPRETER

BYTECODE VERIFIER

LINKING WITH GLOBAL STATE

Virtual MachineExecute a block 𝐵 of transactions from a global state Σ and produce a transaction effect 𝐸 representing modifications to the global state

Virtual Machine(example)

Next for MoveImplementing core Libra Blockchain functionality

New language feature

Improved developer experience

Support third-party Move modules

REFERENCE

• https://developers.libra.org/docs/assets/papers/libra-move-a-language-with-programmable-resources.pdf

聖人大盜觀看心得 何明翰

• 我覺得聖人大盜不單單是一部講述區塊鍊的影片也很多地方可以去探討,我們知道區塊鍊就是為了去中心化,而電影中為了達成這目標必須就是把中心給去除掉,藉由揭露這些表面的聖人把原本掌控著大量財富的體制給破除,或許區塊鍊在這部片只是一個出發點但是我覺得卻也深深帶給我們很多想法,也就是如果真正要做到會遭遇的許多困境。

聖人大盜心得(李睿)看完這部電影以後,我覺得我對區塊鏈有了不一樣的認識,而其中電影裡有句話也讓我印象深刻,「錢是往上流的」,我覺得這句話挺合理的,有錢的人,你可以做許多大額的投資,,因此獲得不斐的利息,而一般人,做的投資都是小額的,利息也相對有限,久而久之一般人與有錢人的差距就會越來越大,這部電影,我覺得整體來說還不錯看,值得推薦

聖人大盜心得(謝明翰)聖人大盜心得這部電影主要以區塊鍊的技術為背景,講述創業家與大資本家的攻防戰。雖然裡面提及區塊鍊的部分,僅限於表面的建議介紹,並沒有更多應用的呈現。但是電影的主軸始終離不開所謂「去中心化」的區塊鍊核心理念。電影想要表現的事區塊鍊發展到最後,人人都可以做自己資本的掌握者,不再受到銀行或是大資本家剝削或是欺騙,內容發人深思。

聖人大盜心得 劉安得

• 電影裡有句台詞:「現在什麼東西冠上區塊鏈都會方便很多」。聖人大盜這部電影也是。如果把電影裡的”區塊鏈”這三個字換成任何一個現在最先進的技術,例如人工智慧、大數據,或者換成任何一家新創公司,我想對整部劇情幾乎完全沒有影響。區塊鏈到底是擊垮資本怪獸的解藥,還是其實只不過是另一個資本家賺錢的手段,值得令人省思。

Recommended