Tendermint: what is a good architecture to implement application with tendermint?

396 views Asked by At

What is a good architecture to implement application on Tendermint? I concerns about these 3 parts.

  1. to implement business logic like smart contact, we could implement on any language.
  2. interface between smart contact and tendermint core. 2.1 To submit transactions to Tendermint, do we always call "broadcast_tx_commit"? If we use this interface, how can we submit data in JSON format? 2.2 To query data, which one is better between querying via api abci_query or querying from database directly.
  3. Database parts- for tendermints, they have 2 databases that are clevel storing blocks and badger storing data (smartcontact stage). if I like to replace badger with other database like MongoDB, or mysql, is it a good design or will we have any suitable database?
1

There are 1 answers

0
melekes On

to implement business logic like smart contact, we could implement on any language.

If you're looking to implement smart contracts with Tendermint, check out https://www.cosmwasm.com/, https://github.com/datachainlab/hypermint and https://github.com/ndidplatform/smart-contract. All of them use WASM https://en.wikipedia.org/wiki/WebAssembly.

To submit transactions to Tendermint, do we always call "broadcast_tx_commit"? If we use this interface, how can we submit data in JSON format? 2.2 To query data, which one is better between querying via api abci_query or querying from database directly.

/broadcast_tx_commit shall be used during testing. In production, use /broadcast_tx_sync or /broadcast_tx_async https://docs.tendermint.com/master/rpc/#/Tx/broadcast_tx_sync.

To query the data, use /abci_query which will proxy the call to your ABCI application https://docs.tendermint.com/master/spec/abci/abci.html#query.

As for the JSON, Tendermint is agnostic to transaction's content and treats it as raw bytes, so you can use any format you want. If that's JSON, a client can encode the transaction using any JSON marshaller (e.g. https://golang.org/pkg/encoding/json/). In your ABCI application CheckTx/DeliverTx methods you'll need to decode the transaction.

Database parts- for tendermints, they have 2 databases that are clevel storing blocks and badger storing data (smartcontact stage). if I like to replace badger with other database like MongoDB, or mysql, is it a good design or will we have any suitable database?

Where to store application state is up to you. It depends on the desired DB properties (embedded or not, ACID, fault tolerance, schemaless or not, etc.).