Giter Site home page Giter Site logo

olsf / libra Goto Github PK

View Code? Open in Web Editor NEW
251.0 25.0 118.0 324.51 MB

License: Apache License 2.0

Rust 73.94% Shell 0.48% Dockerfile 0.10% Python 0.10% Makefile 0.31% HTML 0.01% Awk 0.01% JavaScript 2.24% C++ 0.01% Go 0.01% Java 0.02% Svelte 0.19% TypeScript 0.64% Smarty 0.01% Mustache 0.03% C# 0.02% Move 20.64% CSS 0.56% Swift 0.01% HCL 0.68%

libra's Introduction

0L

A reference implementation of a neutral replicated state machine. Forked from the Libra/Diem technologies.

TL;DR

Join a network with a validator node, to secure the state machine and earn transaction fees.

Welcome

We live 24/7 on Discord join us there.

Weekly community meetings on Discord video channel.

  • WED 15:00 GMT / 8:00 US PT / Weds 11:00 US ET / 17:00 CET / 23:00 CST / 1:00 AEST (THURS)

Documentation

Read our documentation here.

Skip straight to troubleshooting onboarding a node to network.

Contribute to issues.

0L's Tech Stack

What we are doing

0L's technology strategy is to stay as close as possible to the Libra/Diem code base.

This is because fragmenting the technology products on offer will lead to confusion, and eventually to lack of maintenance and stagnation. This is best for the wider open source ecosystem these tools extend and depend upon. It's also much more efficient on resources. Libra/Diem is a massive project, and simply keeping up to date with the code updates requires a dedicated team, let alone making additions. Separate from Libra/Diem, The 0L project on its own has contributed tens of thousands of lines of new code.

So the forking strategy is simple in concept: take the unmodified Diem code, and import it into the 0L project, and add layers of features. Though it's not that simple in execution because of the nature of the code base. We have to insert many changes in strategic places of the diem-core code, in order for the 0L layers and side-cars to work. In short, it's not a simple code merge, it takes about two weeks from start to finish to incorporate a new upstream Diem release into 0L.

What we inherited

The Libra/Diem platform is a spaceship on all accounts. There are engineering breakthroughs throughout the project. The architecture is sensibly designed, and expertly assembled. This is the merit of the Facebook engineering team (who, as individuals, appear to be true believers in the power of these technologies, and one should make no assumptions of their views on corporate strategy).

This is a non-exhaustive summary of the key features of the Diem architecture that are worth paying attention to. We'll take it from the top of the stack to the bottom.

The Move Language

The smart-contract language of the platform is called Move. It is the most unique breakthrough of the team. This is a language that is designed to be extremely safe in adversarial environments, and for hurried, less experienced developers. It's a very ergonomic language; it's easy to approach if you have even entry-level coding experience. In terms of safety it incorporates much from the Rust language concepts of "borrowing" memory. The compiler is pretty obnoxious, which is something you want when designing autonomous financial systems. One standout feature of the Move language is built-in Formal Verification. Adjacent to the code you can write specs for invariants which your code must preserve (i.e. this function should never be called by this type of account), and it can be checked during the development and build process. This is unique and powerful.

Programming model

The execution of the smart contract and scripts has some subtle but important safety features. By design what are referred to in other platforms as smart-contracts are in fact "modules" here. Users can publish modules, which any other module or transaction can import. This is important. The transactions are scripts. So compared to Ethereum, much of what happens in a smart contract can actually be split into long-lived code in a module, and transaction-scripts which can import from the module (and other modules). This decoupling allows for powerful composability and reliability. The developer can evolve the application without necessarily needing to upgrade modules every time a new transaction use-case emerges.

Modules can have "resources" bound to them. A resource can be thought of as an object in memory, but with restrictions: they can only be modified by the module that instantiated them, and are restricted in how they get created and transferred. Writing a non-fungible token is basically just instantiating one such structure, and something like a fungible token can be done in a handful of lines of code.

Standard Library

This is a minor and easily overlooked architectural decision that is quite powerful. There are many modules that are provided standard by the chain, published to the 0x1 address. This standard library can be imported into user-defined modules and transaction scripts.

Importantly, much of the logic tangential to consensus (e.g. validator inclusion in validator set) which would ordinarily be done in the protocol layer (i.e in Rust) is actually written in Move and is stored in the application layer. That is, much of the system policies are just state in the chain database. This makes upgrades to many aspects of system management trivial. Notably, in Diem's case, this is done by a centralized party (see below how we had to modify this).

The Move VM

This is a purpose-built bytecode execution environment which isolates the Move Language from the state transition core. The unique feature of the Move VM is that it is easily extensible. It's very easy to include a new instruction to the virtual machine, a "native function". The native functions are written in Rust (which is the language of the entire code-base). Below we reference some of the changes we had to make for real-world use cases.

Executor

This is another place where the Libra/Diem architecture shines, and still has opportunity to evolve over the long term. The most important feature of the Execution layer is "decoupled execution". This is an important breakthrough. Typically in blockchains all transactions are handled sequentially, there can be no parallelization. With decoupled execution, on the other hand, the executor service checks if a transaction can successfully be processed in parallel to other operations in the mempool. That is, if the transaction could be executed in isolation, and the state changes are atomic.

This places Libra/Diem in a rarified company, the transaction throughput is massively scaled because of this architectural choice, and skillful engineering. It also lays the groundwork for further optimizations possible and likely coming down the path, including the Narwhal DAG mempool management paper Facebook released recently.

Mempool

The mempool management is different from typical blockchains where transactions within the mempool are propagated (e.g. with gossip protocol) without guarantees of inclusion by other parties. In Libra, a Validator node receiving a transaction has the task of making sure the transaction is included in all other validators' mempools. This change allows voting on proposals to happen faster, and more orderly than other methods.

Consensus

There's a lot to be said about how consensus happens on blockchains, and we won't attempt to go into any depth here. The LibraBFT consensus is a variation on Hotstuff, itself a variation of classical consensus algorithm pBFT. LibraBFT borrows much from HotStuff leveraging consensus linearity wherein an agreement on a message is reached in a single round. Pipelining of blocks in HotStuff guarantees the finality of the proposed block by the third block following the proposed block. Effectively, block production is only gated by the network speed, which is the speed in which blocks can be propagated to other nodes.

Storage

The database that stores the transactions is based on a Sparse Merkle Tree design called Jellyfish. This is an architecture shared by a number of blockchains. It has the benefit of being fast to search, and occupies less storage space (hashes) than a traditional merkle tree. The storage is backed by a RocksDB key-value store. This is a sensible design. There isn't much to remark here, except that there are still opportunities that can be leveraged from this storage architecture to allow for faster syncing of the blockchain.

What had to Change

The technology we are inheriting is a spaceship. It is also purely infrastructural. There's very little in the way of tooling or smart contracts that are usable in the real world. We assume much of the remainder of the software stack is closed-sourced at Facebook.

But most importantly, the architecture is designed as a private, consortium chain.

For system administration, there is an omnipresent Diem Association account. Yes, a private key that controls many functions including: Freezing accounts (!), selecting validators for inclusion, paying transaction fees to validators, upgrading the system code. This is obviously a non-starter. So, a lot of work had to go into making system policies execute in a permissionless environment.

We also had to add Sybil resistance mechanisms. Typically communities have been choosing Proof-of-Stake as the Sybil resistance method for BFT networks. This is not the route we chose given community growth considerations (as well as regulatory). Elsewhere we've talked in detail about our Delay Towers complement to consensus.

Also, there were a number of instructions we wanted to add to the MoveVM so that people could write the types of contract they wanted.

Lastly, there was nothing in Libra/Diem about economics. Meaning, there's nothing in the way of game theory about how the network is supposed to perform in a permissionless environment. For example, the transactions are metered in USD stablecoins in Libra/Diem architecture, and paid out by the administrator, and there's no word anywhere about subsidies that may be needed in the absence of meaningful transaction fees. As such there's no consideration to the performance of the validator nodes, all nodes are assumed to be monitored external to the protocol. So we had to rethink a number of things given some of the technical features of the network. The network has novel features, so economic mechanisms we see in other chains would not be drop-in replacements. This was a significant amount of research.

Our Contributions

This is not an exhaustive summary of the changes. 0L contributed about 40k new lines of code to the codebase, not including changes and code removal. It's a summary of what we think makes 0L a compelling network.

Removing the Root Account

This is an obvious decision. But the task propagated into many subprojects. The Root Account is pervasive in the codebase. So, we had two things to accomplish: (1) replace all its functions with a system 0x0 account, and (2) neuter the Root Account where impossible to remove (e.g., in much of the genesis logic). Decentralized Genesis Beginning with Genesis, the Libra/Diem architecture provides good tooling on creating genesis blocks, mainly for testing. For an actual network genesis, the tools assume that there is an administrator that is picking the participants and then setting a layout file.

In our changes we made it such that an online Github repo acted as a gathering place for anyone who wished to "register" to be part of a genesis. The owner of the repo would have a policy in the genesis ceremony to accept all pull requests or people adding their genesis validator configurations. In our genesis, all candidates had to submit a Delay Tower "proof zero," an initial proof of work. All registrants are expected to provide their own layout file. This means that several genesis blocks (and hence networks) are possible with the initial genesis. After a few attempts and some social consensus a canonical chain will emerge. This may appear unpredictable, but it has the benefit of being a maximally decentralized genesis ceremony.

Delay Towers

We've written about this extensively in ol/documentation/delay_towers/. We needed a way to choose what validators were allowed to operate in a validator set. We did this without Proof of Stake. In short, Delay Towers prove sequential proofs of elapsed time. This can be considered a "heavy" identity, enough for the BFT requirements of there being a durable identity, which is not cheap. This was a significant amount of research and experimentation.

See the long form paper here: https://siasky.net/IAA8rbRgFQLQVnGVWLf5RP0j2MLV7KsxcThqeOlp1pn2_Q

Hot Upgrades

While there's a long discussion possible on how network upgrades should be selected (governance), there was no starting place for that conversation, when the system could only be updated by the root account (that we removed). Read more about the Hot Upgrade procedure here:

We invented an upgrade mechanism for BFT, which does not require hard forks, nor operator intervention at the time of upgrade.

Since all system rules are encoded in the application layer in Diem, the code is quite compact, and a proposed new binary could also be stored in the application layer. Since that's possible it also opens up the binary to be voted on chain, and the code of the upgrade itself, stored on-chain, such that the upgrade can happen without operator intervention. New binaries for the system can be proposed and voted upon by the validators, and if there are โ…” of validators choosing the binary (effectively what would be needed for a hard fork), the changes would be synchronously written by all validator nodes at a coordinated time in the blockchain.

Validator Stats

We had to have on-chain information on the performance of validators. This is critical to designing any economic games around transaction fees and other rewards.

Fortunately in the upstream code, the block prologue is executed in the Move virtual machine, and allows us to add transaction metadata directly into the state machine on every block. So, the 0x0 system address contains information on what validators have voted on a given block, and who the proposer was. We can use this for some naive metering within the state machine. It's a sufficient amount to identify which validator nodes are not performing and apply certain sanctions.

There is a performance penalty for this, but optimizations are possible. Since Move does not offer higher-order data structures (hash tables), the data is stored in tables, which are not ideal for traversing.

Onboarding of accounts

In the upstream LibraDiem code, accounts are not created permissionlessly. It starts with a Diem Association Account, which later adds Virtual Asset Service Providers (such as an exchange), which later create user accounts. So all of this had to be replaced (the code remains in our code base for reference, but is deactivated). Instead, there are only two types of accounts on 0L: end-user accounts (the typical account), and Validator Accounts (who own and operate nodes).

End user accounts can be created by anyone that already has an account, as is typical with any account-based blockchain. Like in Ethereum, you can create keys for an account offline, but the account does not exist until someone already on-chain sends you at least one coin.

Similarly for Validator accounts, an account needs to be created by another pre-existing Validator account. There are some game theoretical considerations here which are discussed in the Rulebook. In short, unlike industry practice where the group of validators have to vote on admission of a new member, in 0L any validator can onboard another, but they are rate-limited from onboarding too many. One validator can onboard another every 14 epochs (days).

Tangentially, but relevant. Any account can optionally create different policies on them called Slow Wallets or Community Wallets. This is described in the Rulebook.

MoveVM changes

We've made some additions to the MoveVM that were necessary for us to implement Delay towers and so that users could write useful financial apps.

  • Decimal - we needed a number type that could be used for financial math that could lead into polynomial curves etc. So we added the Rust Decimal library and some initial APIs and their corresponding native instructions.

  • VDF verification - to verify the Delay Towers proofs we added the ChiaVDF verifier to the VM. The prover is not needed in the VM. The VDF verifier can accept a number of parameters (not hardcoded for 0L's use-case). So application builders could leverage it in their own games.

Auto Pay

The ability to create payments in the future, and regular payments as a percent of account balance or of new income. This was a feature requested early by the community. It powers a number of use-cases important at the start of a network. Namely it is useful for anyone that wants to run a community program. In this case an entity or a person is seeking to accomplish a goal or a project, and is asking for donations. Autopay allows for set-it-and-forget-it donations to programs. Most people in 0L use this to send a portion of their mining rewards to programs automatically.

Autopay can be programmed for:

  • Sending a single payment in the future.
  • Sending recurring flat fee payments every epoch (day).
  • Sending a percent of the balance every epoch.
  • Sending a percent of NEW balance every epoch (e.g. mining rewards).

Future types of autopay are possible. Autopay has a simple First In First Out Queue, to handle planned payments that go above the current balance or above current transfer restrictions. CLI Lots of tooling had to be written to successfully manage nodes and interact with accounts. Much of the tooling is in early stages given the ground that had to be covered given the complexity of the system.

Web Monitor

A web interface for a Node's Operator to see reports on the node. Basic chain info: Epoch number, Waypoint. Includes Node Health, and account info Performance reports on all validators in the set. JSON endpoints to query data, like the node's account profile, epoch. Not to be confused with a fullnode json-rpc

Terminal Explorer

Explorer - a terminal block explorer. This one is mostly for fun. This is a terminal interface for a block explorer to check some vitals of your fullnode or validator node.

TXS

We needed a library for sending different types of transactions. So that it could be imported in other tools. TXS also includes a CLI utility to send commands from terminal.

Onboard

This is a library and CLI tool for creating packaging all of the necessary files for a new fullnode or validator account to join the network. Because 0L changed the account creation permissions and logic, there had to be purpose built tooling for it.

Restore

Diem has one significant limitation which is a slower sync time. A fullnode joining an already mature network will take a long period of time to catch up to consensus. So we had to create tools and a bit of infrastructure to leverage some of Diem's existing backup and restore tools. At every new epoch there is a snapshot taken of the chain, and submitted to a Github repository. Multiple such repositories can exist. When a new validator is joining the network they must begin as fullnodes. The OL Restore tool will fetch a snapshot from repository, check it, and deploy it so that the fullnode can begin syncing from an advanced epoch (i.e. waypoint).

Carpe

Last but not least. We wanted all users to be able to participate meaningfully, and on equal footing with a protocol. Since there is a subsidy for creating heavy identities on the chain (Delay Tower), we needed to make this accessible to a diverse audience. The Carpe app combines a Wallet with a Light Miner, which allows anyone with a desktop whether Windows, Ubuntu, or Mac, to "mine" coins for themselves.

libra's People

Contributors

0o-de-lally avatar ankushagarwal avatar bmwill avatar bothra90 avatar davidiw avatar dependabot-preview[bot] avatar dependabot[bot] avatar emmazzz avatar gregnazario avatar huitseeker avatar joshlind avatar junkil-park avatar lightmark avatar ma2bd avatar metajack avatar mimoo avatar msmouse avatar phlip9 avatar rexhoffman avatar runtian-zhou avatar sausagee avatar sblackshear avatar simsekgokhan avatar soaresa avatar sunshowers avatar tnowacki avatar vgao1996 avatar wrwg avatar xli avatar zekun000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libra's Issues

Reimplement Transaction Fee Distribution.

TLDR;
Libra has two conflicting models of transaction fee distribution. In the stdlib folder it seems the fees are burnt,

In the prover test suite, it is instead transferred to validators. This is the model OL needs to implement.

As implemented in /move-prover/ tests (how OL should do this).

https://github.com/OLSF/libra/blob/02acecbacb3ba40e55d3dd20f26ce78d8b4e8c86/language/move-prover/tests/sources/stdlib/modules/transaction_fee.move

-- This code is likely correct, but we need the distribution of fees to be set to Node Weight, and not equal.

How it appears in /stdlib/:
https://github.com/OLSF/libra/blob/02acecbacb3ba40e55d3dd20f26ce78d8b4e8c86/language/stdlib/modules/TransactionFee.move

[Bug] LibraBlock's BlockMetadata passing empty previous_block_votes

๐Ÿ› Bug

In language/stdlib/modules/LibraBlock.move, the function block_prologue is called each time a new block is committed. This function is passed in previous_block_votes, a vector of addresses who have voted on the previous block. Currently, tests suggest that this is being passed as empty.

Update the VDF security parameters based on the Dobson, Galbraightm Smith paper.

This paper proposes for 128 bit security level the security parameter for class groups should 6656 bits. I haven't read the paper in enough detail to estimate the security of a 4096 bit discriminant.

Paper: https://eprint.iacr.org/2020/196 h/t Eli Ben Sasson

The author's estimate the impact of Sutherland's algorithm for finding the order of a class group on security.

Some thoughts.

My initial assessment that for our narrow use case, these finding are of low impact. They would be higher impact if also expected the VDF to be a random oracle but we don't need the assumption.

if we update this, we need to remember to

  • Update the tests and mock results
  • Update the miner and verifier to take the larger proofs.
  • Repeat benchmarks to estimate a larger delay.

VDF module: Gracefully handle invalid VDF proofs

Invalid VDFs submitted to the VDF module, are not returning a false because we get a panic instead of Err for VDFs that have invalid parameters.

thread 'run_test::OL/vdf/vdf_verify_invalid_proof.move' panicked at 'assertion failed: &self.discriminant + four_ac == &self.b * &self.b', /Users/lucas/.cargo/git/checkouts/vdf-144e42bc351cca28/c740ef3/classgroup/src/gmp_classgroup/mod.rs:192:13

This line is what generates the panic:
https://github.com/OLSF/libra/blob/90a6edb2d7fa5df161a8e341cb9358768e98a56f/language/move-vm/natives/src/vdf.rs#L45

How do we handle this gracefully?

Steps to reproduce:
There are a couple of tests for this.
vdf_verify_invalid_challenge.move
vdf_verify_invalid_proof.move

You can see when you run the test suite:
libra/language/ir-testsuite> cargo test vdf_verify_invalid_proof.move

Any sender should be able to create a new Validator with VDF proof.

For OL: Validator accounts are the default. In libra core, the validators can only be initialized by association.
We would like the accounts to be initiated with the presentation of a VDF proof.

Related to issue: #75

The Challenge of the first VDF proof needs to be parsed, and the first 32 bytes sliced (is the account public key). A new account needs to be generated with                 Value::address(account),
    // let first_32 = _node_configs.challenge[..32]
    // AuthenticationKey::ed25519(&account_key);
    // let account = auth_key.derived_address();
    // let address = Value::address(account);

    // 4. begin_redeem will check the proof, but also add the miner to ValidatorUniverse, which Libra's flow above doesn't ordinarily do. (DONE)
    // 5. begin_redeem now also creates a new validator account on submission of the first proof. (TODO)

Possibly a one-line change here to enable account creation by non-system address.
https://github.com/OLSF/libra/blob/97a31252f6af4ecf4daa88790c7b1204e1a82718/language/stdlib/modules/LibraAccount.move#L1004

Reconfiguration module

TODO

Implement reconfiguration module - calls Node weight and bulk update to validator set.
At end of epoch, the reconfiguration is triggered using block prologue.
NOTE: Ensure that GAS left in transaction pot is carried forward to not waste minted funds.

[Bug] replace LBR everywhere

LBR is hard coded in multiple places. E.g. in e2e-tests/src/account.rs

from_currency_code_string(LBR_NAME).unwrap()

We want to make sure all tests pass including functional, E2E, prover tests.

Test that VDF verify returns a GAS cost.

TODO: add a test to VDF tests.
A test confirms that the native function VDF is being metered by the GAS calcs.
Should test that GAS price is returned in the result.

I made a change here to make it fail (the test case more obvious when we run tests).
5dd6056

VDF Native Function Gas Unit cost

Costs are zero for native functions. This means that VDF verifications are free. This number must be updated

This is currently set in genesis in ./language/tools/vm-genesis/src/genesis_gas_schedule.rs , but it loops through all the native functions and sets to zero. Each function will need a mapping to cost.

Combine system addresses 0xA550C1A8, 0xF1A95, and remove unnecessary ones: 0xB1E55ED

Accounts and capabilities are generated in Genesis.move

  • Wherever possible replace Association (0xA550C1A8), and Config (0xF1A95) operations with VM credentials (0x0)
  • 0xF1A95 doesn't seem to be different in function than xA550C1A8. Let's deprecate Association in favor of 0xF1A95
  • 0xB1E55ED account is only used for tx fee burning, which is deprecated in 0L. I think these special accounts have been superseded capability resources.

Do we need synchronous response in client_proxy.rs / send_proof?

@ping#2401 @zmanian#3977
I've patched redeem-OLv3 so that the client isn't failing with incorrect proofs. 06884cf

I removed a check for is_blocking, which seems to be in other client commands. This was making the client fail. Seems to me that blocking is just for the shell usage, and to prevent the user from submitting other operations from happening until there is a response. So it seems like the Err() response in VDF.rs maybe malformed for those cases. Anyhow, I've removed it in my commit.

I've also added hex decoding to client_proxy.

BlockMetadata in Move: Get validator voters through new_block_events event handler

BlockMetadata resource struct was changed to have a new field 'voters'. However the data we need already is in a field new_block_events, but it is of a type Event Handler which is unclear how to access.

Ideally at this line there would just be an assigment of BlockMetadata.new_block_events.previous_block_votes
https://github.com/OLSF/libra/blob/e81f6af9b41beefa36d7e8a130cf75265a217d20/language/stdlib/modules/LibraBlock.move#L108

@liangping maybe you know how to do this?

Ol-miner submits tx to network, needs keys.

The miner should send transactions on its own to the network. We can test with the local libra-swarm.

It seem we need

  • Generate keys from Miner
  • Ol miner to sign Txs and submit to libra client
  • proof needs to be hex-encoded for Redeem contract.
  • [optional] Multisig keygen

One think that should be looked at now is Multisig Keygen in this step.

zm
my reccomendation is just make libra-wallet from mnemonic when the miner starts up and then call https://github.com/OLSF/libra/blob/OLv3/testsuite/cli/libra-wallet/src/wallet_library.rs#L162-L178

ping
https://github.com/OLSF/libra/blob/b8d061a4d8f9c65be2fc80cc3131deff3f535d90/testsuite/cli/src/client_proxy.rs#L177
This is how libra client did.

zm
you call this
https://github.com/OLSF/libra/blob/OLv3/testsuite/cli/libra-wallet/src/wallet_library.rs#L51-L60 to make a new wallet

[Feature Request] Global Config Constants

Motivation

For the case of testing, new epoch is triggered every 4 blocks or so.
But in real time, this is gonna be around 10k blocks.
Changing this param in block_prologue everytime doesnot seem like an ideal solution.

Pitch

Ideally, we need to have Global Config constants file which is set based on environment (testing/prod)
One possible solution: @zmanian suggested there is a way to inject this into the genesis blob creation.

Additional context

In current system, I am developing being mindful of testing suite - should be updated later.

Better structure of the commit history.

I don't think current master is good a starting point for the codebase.

  1. We should preserve history of the libra codebase. I think deleting the history looks bad.

  2. We are going to rebase/refactor the OL Standard Library until Libra code freeze.

Post Libra code freeze, we are most likely want to be a fork of Libra where we review upstream changes and decide what to bring over.

It's most likely suboptimal to have a mix of Libra code and OL changes mixed in the base commit.

Error Code Semantics

Hello Everyone!

I think we should define error code with some pattern.

Use cases:

Transaction::assert(blob_redeemed == false, 10000);
Transaction::assert(valid == true, 10001);

Maybe 3 digits long
101 :( 1=module code, 01=error code)

Here are what I found from stdlib

// Error codes:
// 7000 -> INSUFFICIENT_PRIVILEGES
// 7001 -> INVALID_ROOT_VASP_ACCOUNT
// 7002 -> INVALID_CHILD_VASP_ACCOUNT
// 7003 -> CHILD_ACCOUNT_STILL_PARENT
// 7004 -> INVALID_PUBLIC_KEY
// Error codes:
// 1100 -> OPERATOR_ACCOUNT_DOES_NOT_EXIST
// 1101 -> INVALID_TRANSACTION_SENDER
// 1102 -> VALIDATOR_NOT_CERTIFIED
// 1103 -> VALIDATOR_OPERATOR_NOT_CERTIFIED
// 1104 -> VALIDATOR_CONFIG_IS_NOT_SET
// 1105 -> VALIDATOR_OPERATOR_IS_NOT_SET
// 1106 -> VALIDATOR_RESOURCE_DOES_NOT_EXIST
// 1107 -> INVALID_NET

[Bug] [ERROR] Failed to get balances: No account exists at xxxx

Using local testnet, with libra swarm. Trying to retrieve balances.

Steps to reproduce:
start a local testnet
$ cd ~/libra
$ cargo run -p libra-swarm -- -s

in the libra shell:
libra% account create
libra% query balance 0
[ERROR] Failed to get balances: No account exists at 41e1fec06892166ed30fe4dafe916d2e

another command gets a similar error:
libra% transfer 0 1 10 LBR

Transferring
[ERROR] Failed to perform transaction: Transaction submission failed with error: JsonRpcError { code: -32001, message: "Server error: VM Validation error: VMStatus { major_status: SENDING_ACCOUNT_DOES_NOT_EXIST, sub_status: None, message: Some("sender address: 3f5125eb3571e88dc7d292351b7f89a5") }", data: Some(Object({"major_status": Number(7), "message": String("sender address: 3f5125eb3571e88dc7d292351b7f89a5"), "sub_status": Null})) }

Simplify Libra.move (or replace)

We can radically simplify Libra.move

Since there are changes to stdlib/Libra.move, perhaps we should fork that file, and call it something like Coins.move, and place in /OL/. That way we could keep the original Libra.move, and pull in FB's changes to follow what is changing. (Although eventually think we need to not include it in genesis).

Some changes to Libra.move

  • mint/burn/preburn/register/etc. capabilites in Libra.move. I think all of these are not useful, especially if we have only one address (Subsidy) that can mint and burn GAS.
  • Preburning is not a workflow for us. There is just burning. Can remove all references including preburn marketcap.
  • lbr_exchange_rate in Libra.move, Ratios/exchange rate to LBR is not a meaningful field for us, can remove from all types.
  • isSynthetic is not meaningful to us. Can also remove.
  • update_minting_ability in Libra.move. Can be commented out, perhaps keep as a reference.
  • approx_lbr_for_value. not useful
  • approx_lbr_for_coin. not useful
  • Reserve in GasCoin.move is odd, I think it's not necessary if we will always have one address that can mint or burn the coins. Seems like a dangerous capability to maintain if we don't need it.

Modify Debug so we can see strings.

Debug::print(&b"test"), prints a vec. The native function for Debug should be changed so we can tell it to parse as string. Perhaps add a bool argument for parse string. Debug::print(&b"test", true)

e2e tests failing with out of gas, or over max gas bounds

e2e/gascosts.rs TXN_RESERVED: u64 = 2_000_000;

https://github.com/OLSF/libra/blob/244548b633c813d6c739f38c83f377e5ed0791fd/language/e2e-tests/src/gas_costs.rs#L18

Raising this amount to 1_000_000 to make Redeem e2e test pass. However raising it to 2_000_000 causes librablock e2e test to fail unexpectedly. With:

VMStatus { major_status: MAX_GAS_UNITS_EXCEEDS_MAX_GAS_UNITS_BOUND, sub_status: None, message: Some("max gas units: 2000000, gas units submitted: 6000000") }

Many other libra core tests are failing. May be unrelated.

Async startup of experimental net

We need to include proof and preimage in the genesis transaction. This is to verify the work done and the address/auth key of the miner, before creating an account.

// PSEUDOCODE...
// 1. The miner who participates in genesis ceremony, will add the first vdf proof block to the node.config.toml file.
// TODO: This file will be parsed as usual, but the NodeConfig object needs to be modified and the data be vailable here.
// 2. The Challenge of the first VDF proof needs to be parsed, and the first 32 bytes sliced (is the account public key). A new account needs to be generated with                 Value::address(account),
// let first_32 = _node_configs.challenge[..32]
// AuthenticationKey::ed25519(&account_key);
// let account = auth_key.derived_address();
// let address = Value::address(account);

// 3. this function initialize_miners() will directly call the Redeem::begin_redeem() with context.exec here. Note the miners get initialized as usual in the above initialize_validators() (Done)

// context.set_sender(account_config::association_address());
// context.exec(
//     "Redeem",
//     "begin_redeem",
//     vec![],
//     vec![miner, vdf_proof_blob],
// );

// 4. begin_redeem will check the proof, but also add the miner to ValidatorUniverse, which Libra's flow above doesn't ordinarily do. (DONE)
// 5. begin_redeem now also creates a new validator account on submission of the first proof. (TODO) However in the case of Genesis, this will be a no-op. Should fail gracefully on attempting to create the same accounts

OL Stdlib Integrations

  • Epoch Change triggers #70

  • Voting power updated by Node Weight: #65

  • Redeem stores and returns the Tower Height #58 (Do this one last, lower priority)

[Bug] Withdraw_from_sender doesnt work for collecting transaction fees

๐Ÿ› Bug

Withdraw_from_sender doesnt work for collecting transaction fees from accounts other than association

To reproduce

Try creating transactions using sender as any other account apart from "association". A check for account signer to be "association" will discard the transaction.

Expected Behavior

Need to disable withdraw_from_sender from outside the method wherever it is used in LibraAccount. Also, we need to check if withdraw_from_sender is a public method and disable that from being accessed external to the account.

OLIP-0058: Node Weight to include the Tower height count of VDFs successfully submitted.

Two modifications to Node Weight.

  1. The node weight should check if any VDFs have been submitted during the last epoch by the validator. If none, remove.
  2. How many vdf proofs and address has successfully verified during its entire history. This chain of proofs is called a Tower. And we can call this the Tower Height.

Implementation:
Node Weight can query via the Redeem.move module. Perhaps with some API changes there.

Genesis.move should check econ constants

Script that can check consistency of the the econ values in Genesis.move.

Max gas bound per transaction
Transaction minimum
Subsidy Ceiling
Gas Table Defaults
VDF gas units

Testing Move modules is a pain, need to remember to wipe binaries. Better way?

Running tests on move modules is prone to error. If one pulls a change from a repo, or otherwise edits a move file, the VM will still be using the old binary. It's especially easy to forget when merging changes from another branch.

What do we do today:
git reset --hard - which will help you lose work fast :)
cd ./language/stdlib/ && cargo run --release - will help you lose your day, takes forever to rebuild everything.

Depending on your IDE you may be able to automate this (but we all use different ones).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.