Giter VIP home page Giter VIP logo

amino_rs's Introduction

Tendermint

UPDATE: TendermintCore featureset is frozen for LTS, see issue #9972
This is the latest stable release used by cosmoshub-4, version 0.34.24
The previous main branch (v0.38.xx) can now be found under "main_backup"

banner

Byzantine-Fault Tolerant State Machine Replication. Or Blockchain, for short.

Version API Reference Go version Discord chat License Sourcegraph

Branch Tests Linting
main Tests Lint

Tendermint Core is a Byzantine Fault Tolerant (BFT) middleware that takes a state transition machine - written in any programming language - and securely replicates it on many machines.

For protocol details, refer to the Tendermint Specification.

For detailed analysis of the consensus protocol, including safety and liveness proofs, read our paper, "The latest gossip on BFT consensus".

Documentation

Complete documentation can be found on the website.

Releases

Please do not depend on main as your production branch. Use releases instead.

Tendermint has been in the production of private and public environments, most notably the blockchains of the Cosmos Network. we haven't released v1.0 yet since we are making breaking changes to the protocol and the APIs. See below for more details about versioning.

In any case, if you intend to run Tendermint in production, we're happy to help. You can contact us over email or join the chat.

More on how releases are conducted can be found here.

Security

To report a security vulnerability, see our bug bounty program. For examples of the kinds of bugs we're looking for, see our security policy.

We also maintain a dedicated mailing list for security updates. We will only ever use this mailing list to notify you of vulnerabilities and fixes in Tendermint Core. You can subscribe here.

Minimum requirements

Requirement Notes
Go version Go 1.18 or higher

Install

See the install instructions.

Quick Start

Contributing

Please abide by the Code of Conduct in all interactions.

Before contributing to the project, please take a look at the contributing guidelines and the style guide. You may also find it helpful to read the specifications, and familiarize yourself with our Architectural Decision Records (ADRs) and Request For Comments (RFCs).

Versioning

Semantic Versioning

Tendermint uses Semantic Versioning to determine when and how the version changes. According to SemVer, anything in the public API can change at any time before version 1.0.0

To provide some stability to users of 0.X.X versions of Tendermint, the MINOR version is used to signal breaking changes across Tendermint's API. This API includes all publicly exposed types, functions, and methods in non-internal Go packages as well as the types and methods accessible via the Tendermint RPC interface.

Breaking changes to these public APIs will be documented in the CHANGELOG.

Upgrades

In an effort to avoid accumulating technical debt prior to 1.0.0, we do not guarantee that breaking changes (ie. bumps in the MINOR version) will work with existing Tendermint blockchains. In these cases you will have to start a new blockchain, or write something custom to get the old data into the new chain. However, any bump in the PATCH version should be compatible with existing blockchain histories.

For more information on upgrading, see UPGRADING.md.

Supported Versions

Because we are a small core team, we only ship patch updates, including security updates, to the most recent minor release and the second-most recent minor release. Consequently, we strongly recommend keeping Tendermint up-to-date. Upgrading instructions can be found in UPGRADING.md.

Resources

Libraries

Applications

Research

Join us!

Tendermint Core is maintained by Interchain GmbH. If you'd like to work full-time on Tendermint Core, we're hiring!

Funding for Tendermint Core development comes primarily from the Interchain Foundation, a Swiss non-profit. The Tendermint trademark is owned by Tendermint Inc., the for-profit entity that also maintains tendermint.com.

amino_rs's People

Contributors

adeschamps avatar briansmith avatar danburkert avatar fabricedesre avatar hcpl avatar im-0 avatar kestred avatar liamsi avatar ngg avatar olix0r avatar reidwagner avatar vorner avatar warrenfalk avatar xla avatar yetanotherminion avatar zmanian 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amino_rs's Issues

bug: decoding / skipping after prefix bytes fails

E.g. for SignVoteRequest (see tendermint/tmkms#61)

This happens only if the type is registered. This part is the reason:

fn merge_field<B>(&mut self, buf: &mut B) -> ::std::result::Result<(), _prost::DecodeError>
where B: _bytes::Buf {
#struct_name
if #is_registered {
// skip some bytes: varint(total_len) || prefix_bytes:
let mut tmp_buf = vec![];
// prefix + total_encoded_len:
let len = 4 #(+ #encoded_len3)*;
_prost::encoding::encode_varint(len as u64, &mut tmp_buf);
buf.advance(len + tmp_buf.len());

At this point the var encoded_len doesn't hold the total encoded length but only the prefix bytes length (4). We'd need to skip ahead at an earlier point. In general this needs way more testing, too.

Add travis CI

  • it's easier to discuss failing builds / test (one can link to test output)
  • never miss a failing test etc.
  • more complicated to use circleci & rust
  • no need to wait until someone grants travis access (I've submitted an access request for the whole org, still pending), as we can grant travis access to our forks immediately

See #4 (comment)

Going for circle-ci for now.

Provide amino codec functionality & disambiguation bytes

For registered types this lib currently just skips over the prefix bytes. This assumes the caller knows which types to decode on the other side. In reality the user doesn't necessarily know which implementation of a certain type he needs to decode. This was a little hack to be able to unblock building a MVP-kms. In the kms, we only differentiate between a few types and the logic for this currently lives there: https://github.com/tendermint/kms/blob/0ce1408bd3c99367f6712d6434252a556b712065/src/rpc.rs#L44-L97

This should be handled by this amino library here instead. Similarly to the go-lang implementation:
https://github.com/tendermint/go-amino/blob/master/codec.go

Also, and of lower priority, this library does not deal with disambigaution bytes yet (only with prefix bytes). This should be implemented too.

Bug: If top-level struct is registered, every field will be treated as registered

The macro-generated code always checks the top-level attributes of the wrapping message for is_registered instead of on a per field basis :-/

We haven't noticed that so far because the only place this feature was (successfully) used was for PubKeyMsg which contains only one field which also happen to be registered.

if #is_registered {
// skip some bytes: varint(total_len) || prefix_bytes
// prefix (4) + total_encoded_len:
let _full_len = _prost::encoding::decode_varint(buf)?;
buf.advance(4);
}

let top_level_attrs: Vec<syn::Attribute> = input.attrs;
let amino_name_attrs: Vec<syn::Attribute> = top_level_attrs
.into_iter()
.filter(|a| a.path.segments.first().unwrap().value().ident == "amino_name")
.collect();
if amino_name_attrs.len() > 1 {
bail!("got more than one registered amino_name");
}
let is_registered = amino_name_attrs.len() == 1;

Additionally, this length computation is wrong:

if #is_registered {
// TODO: in go-amino this only get length-prefixed if MarhsalBinary is used
// opposed to MarshalBinaryBare
let len = 4 #(+ #encoded_len2)*;
_prost::encoding::encode_varint(len as u64, buf);

Implement prost! like derive functionality

prost uses a custom derive macro to handle encoding and decoding types, which means that if your existing Rust type is compatible with Protobuf types, you can serialize and deserialize it by adding the appropriate derive and field annotations.

See https://github.com/danburkert/prost#serializing-existing-types

We want the same thing but for amino messages. @zmanian already started working on this here: https://github.com/tendermint/amino_rs/blob/master/amino-derive/src/lib.rs

proc-macro derive panicked

$ rustc --version
rustc 1.41.0 (5e1a79984 2020-01-27)
$ cargo new test-amino
     Created binary (application) `test-amino` package
$ cd test-amino
$ cat > src/main.rs << EOF
#[macro_use]
extern crate prost_amino_derive as prost_derive;
use prost_amino_derive::Message;

#[derive(Clone, PartialEq, Message)]
pub struct OptionalScalar {
    #[prost(int64, optional, tag = "1")]
    pub height: Option<i64>,
    #[prost(string, tag = "2")]
    pub name: String,
}

fn main() {
    println!("Hello, world!");
}
EOF
$ cat >> Cargo.toml << EOF
prost-amino = "0.5"
prost-amino-derive = "0.5"
EOF
$ cargo build
   Compiling test-amino v0.1.0 (/private/tmp/test-amino)
error: proc-macro derive panicked
 --> src/main.rs:6:28
  |
6 | #[derive(Clone, PartialEq, Message)]
  |                            ^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: ErrorMessage { msg: "no type attribute" }

          invalid message field OptionalScalar.height

error: aborting due to previous error

error: could not compile `test-amino`.

To learn more, run the command again with --verbose.

Spurious shift operations when encoding / decoding i32 and i64

Compare

amino_rs/src/encoding.rs

Lines 197 to 202 in 993a4a5

pub fn encode_int32<B>(num:i32, buf:&mut B) where B:BufMut{
buf.put_u32::<BigEndian>((num << 1) as u32);
}
pub fn encode_int64<B>(num:i64, buf:&mut B) where B:BufMut{
buf.put_u64::<BigEndian>((num << 1) as u64);
}

and

amino_rs/src/encoding.rs

Lines 213 to 223 in 993a4a5

pub fn decode_int32<B>(buf: &mut B)-> Result<i32, DecodeError> where B: Buf {
let x = B::get_u32::<BigEndian>(buf);
Ok((x >>1) as i32)
}
pub fn decode_int64<B>(buf: &mut B)-> Result<i64, DecodeError> where B: Buf {
let x = B::get_u64::<BigEndian>(buf);
Ok((x >>1) as i64)
}

with
https://github.com/tendermint/go-amino/blob/c7424fdd930314cc4c344b331e112dac004718ef/encoder.go#L63-L75
and
https://github.com/tendermint/go-amino/blob/c7424fdd930314cc4c344b331e112dac004718ef/decoder.go#L42-L62

Need to remove these shift operations to match with go-amino.

For instance:

package main

import (
	"github.com/tendermint/go-amino"

	"bytes"
	"encoding/hex"
)

func main() {
	b := new(bytes.Buffer)
	amino.EncodeInt32(b, 1)
	println(hex.Dump(b.Bytes()))
}

prints
00000000 00 00 00 01 |....|
while the corresponding rust buffer after calling encode_int32 is
[0, 0, 0, 2]

after changes of this PR it's
[0, 0, 0, 1] ๐ŸŽ‰

(We definitely need to autom. this #5 )

Catch up with latest amino releases

Alternative: replace amino_rs with this prost! fork.

Update: We can close this as soon as #12 is merged!

In particular the changes from 0.9.10 to the latest 0.10.1. An upcoming release is planned will contain a few additional breaking changes that should affect amino_rs (skipping over default values, incl. time structs).

  • do not encode empty structs, unless explicitly enforced via amino:"write_empty"
  • do not encode zero values in EncodeTime
  • removed struct term (missing in changelog?)
  • proto3 compatibility:
    • BigEndian -> LittleEndian
    • [u]int[64/32] is (signed) Varint by default, "fixed32" and "fixed64" to use 4 and 8 byte types
    • Amino:JSON [u]int64 and ints are strings (might be irrelevant for the kms)

related: tendermint/tmkms#32

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.