OpenTron is an implementation of the Tron blockchain written in Rust

. This project is under active development and is not ready for general use.

  • Rationale
  • Roadmap
    • TODOs
  • Quickstart
  • License
    • Contribution

Rationale

  1. Decentralised

    The Tron network currently has one and only implementation. This has lead to some criticism of Tron being too centralized. We want to change that by providing an alternative implementation and independent development team.

  2. High performance

    API calls to java-tron nodes often results in CPU timeouts and other "out of resource" related errors. This is partly due to java-tron being written in Java, a garbage collected language that runs on a virtual machine. OpenTron is written in Rust, a modern compiled language that is increasingly adopted for blockchain and systems development due to its high performance, safety and modern design.

  3. Modern codebase

    Java-tron was forked a few years ago from a Java Ethereum implementation. It has accumulated a lot of technical debt over the years and has a lot of inconsistent or missing documentation. We believe that a greenfield implementation will enable us to produce a cleaner code base that is easier to understand, improve and extend. In addition, since Rust has first class support for WebAssembly, it will be possible to re-use its code for creating web based clients, wallets, explorers, etc.

Roadmap

  • Block data sync, only blocks (raw transactions), without transaction info and any other state data. Handle chain fork and block Merkle tree verification.
  • Simple transaction broadcast, without much verification, just broadcast transactions to the network as quickly as possible(an airdrop tool can be made from it)
  • Handle transaction verification. all state data will be available. (difficult, EVM engine, resource consumption mode, witness/vote/proposal, chain parameter are all handled at this stage, to make the state data identical as java-tron )
  • Build a query API layer upon state data. json-rpc.
  • Build a event API layer upon state data.
  • block mining logic (difficult, DPoS mining, need resource to become an SR)

TODOs

  • Full Tron Protocol implementation
    • proto2: refactor the protobuf
    • primitives
      • use primitive-types
      • keys: Address, PublicKey, PrivateKey, Signature
    • config file
      • genesis block parsing
      • toml config file parsing
      • reorganize chain parameters
    • chain-db
      • Block / Transaction
    • state-db
    • discover protocol
    • channel protocol
      • demo works
      • sync
      • TODO: minor bug fix, timeout error
      • integrate with state-db
    • mempool - block producing
    • governance
      • witness schedule
      • voting
      • proposal
      • block reward - still has minor bug
    • executor/actuator
      • account
      • trx/trc10 assets
      • witness and voting
      • proposal
      • resource freeze/unfreeze
      • exchange
      • smart contract
      • market (4.1)
    • EVM / TVM
      • 3.7 TVM https://github.com/opentron/evm and tvm crate
      • 4.0 TVM with zksnark: ztron crate
        • shielded trc20 transaction - ztron
        • integration
      • 4.1 TVM
        • CREATE2
      • massive tests against resource usage, exit_reason
    • RPC API replacement
      • will not support gRPC
      • might have json-rpc support
      • GraphQL API for chain query and state query
      • GraphQL API to broadcast transaction

Quickstart

See INSTALL.md for more detailed information.

> # Install rust-nightly
> curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
> rustup component add rustfmt

> # Install protoc
> brew install protobuf  # macOS
> sudo pacman -S protobuf  # ArchLinux
> sudo apt install protobuf-compiler libprotobuf-dev # Ubuntu / Debian

> # Get code
> git clone https://github.com/opentron/opentron.git

> # Compile opentron
> cd ./opentron/
> cargo build

> cargo run -- --config etc/conf.nile.toml

Local Testnet

./target/release/opentron --config ./etc/conf.local-test.toml

Then open http://localhost:3000 and play with the GraphQL APIs.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Issues

Collection of the latest Issues

andelf

andelf

java-tron-upgrade
3
  • TIP 250: merkle tree root of transaction result
    • This might be a dangerous decision. since there're only 2 fields in transaction result are used.
  • Vote for tron power upgrade?
andelf

andelf

enhancement
8

This issue will be used to trace the dev process of mempool & block producer.

The goal is to run the very first testnet of opentron.🚀

Update 2021/03/01

Since the producer is the most complex part, the milestone is divided into:

  • executor for all type of transactions
  • a state-db implementation: use cargo run -- dev to test against it
  • refactor channel protocol to handle transaction broadcast
  • impl Manager::produceBlock (in manager crate)
  • impl consensus base(code in base/*.java)
    • most of the code logic is implemented by manager crate
  • impl DPoS mining (logic in dpos/*.java files)
    • DposSlot - merge logic into Manager
    • IncentiveManager
    • MaintenanceManager
    • StateManager
    • DposService
    • DposTask - rewrite using producer_service crate

Update 2021/03/15

  • refactor channel protocol to handle incoming and outgoing broadcasts
  • add a PeerContext to manage connected peers
andelf

andelf

java-tron-upgrade
0

2 new proposal.

  • TRANSACTION_FEE_POOL, proposal 48

  • Blackhole will not receive transaction fees, proposal 49

  • Transaction fee pool - proposal 48

  • black hole - proposal 49

andelf

andelf

enhancement
1

NOTE: The official Tron foundation's big picture is in reverse! -- Adding more system contracts.😩

The question is, how many system contracts (builtin transaction type) can be implemented using smart contracts?

Easy to conclude that:

Can be implemented in plain smart contract:

  • TRC10 related, Assets
  • Exchange & Market related (Exchange is deprecated, Market is introduced in 4.1)

Requires a central registry contract

Or a powerful event query API.

  • AccountName, AccountId
  • TRC10 Issue, to implement "list asset" API

Requires a "System" contract

  • Resource model
  • Witness, proposal, voting
  • ... others
andelf

andelf

mainnet
0

transaction-info is changed.

txn: e2be4dadd9c71e0b98716ec7b99f20ea2c657229df6688ed0f2e30af86c3c7b0

In a DB downloaded from the official site, it says: validateForSmartContract failure

While sync from genesis, it says:

Some commit has changed the error message.

This should NOT happen. A blockchain should be consistent without a proposal or forks.

andelf

andelf

announcement
11

Update 2020/10/27

Stopped at 4152605.

Problem: balance mismatch

Update 2020/10/29

The balance mismatch located.

Account: TLw48YQsUcKTkuPnn9nHjieacvntHADQaw

block #4137160 0xa33ca08a8cffff532fa43771527e145a63a37fca50dd1468632acc146e8e2d7a

An ExchangeTransaction

in opentron:

exchange sell #1000161:29218, buy #0:13516579895

while in javatron:

buy #0:13516579896

See-also: https://stackoverflow.com/questions/64586096/math-pow-in-java8-and-java13-returns-different-result

Update 2020/10/30

Recorded as #36. Fixed.

andelf

andelf

enhancement
1
  • rm usage of .unwrap()
  • Use meaningful error types instead of BoxError or String

Information - Updated Jun 21, 2022

Stars: 55
Forks: 17
Issues: 17

Repositories & Extras

Solana blockchain repo and docs

Please make sure you are always using the latest stable rust version as this is a crypto library and require safe code

Solana blockchain repo and docs

Wagyu Etherum blockchain ledger and wallet in Rust

Cross platform ether wallet generator that makes automated creation of crypto wallets easy

Wagyu Etherum blockchain ledger and wallet in Rust

Blockchain Commons torgap-sig

torgap-sig is a fork of spdx:BSD-2-Clause Plus Patent License

Blockchain Commons torgap-sig

Blockchain Commons torgap-sig-cli-rust

torgap-sig-cli-rust is a fork of Minisign, with support for

Blockchain Commons torgap-sig-cli-rust

Phala Blockchain

pRuntime (Phala Network Secure Enclave Runtime) is a runtime to execute confidential smart contracts, based on confidential computing

Phala Blockchain

A Blockchain implementation in Rust

MIT (c) Doublify Technologies

A Blockchain implementation in Rust

Simple Blockchain

cargo run para ejecutar la app, cargo build para crear un ejecutable

Simple Blockchain

A Blockchain implementation in pure Rust

Below find an example usage of the library:

A Blockchain implementation in pure Rust

rusted-blockchain

Wanted a better understanding of blockchain, and practice more rust

rusted-blockchain
Facebook Instagram Twitter GitHub Dribbble
Privacy