A Ledger For The Earth

The first post in a series exploring Regen Ledger and the core modules that make up Regen Ledger, starting with an update on Regen Mainnet and the development of Regen Ledger.

Ryan Christoffersen
Regen Network
9 min readJul 19, 2021

--

Regen Ledger is the underlying blockchain application supporting Regen Mainnet.

Getting Up To Speed

The Regen Network blockchain is live on mainnet — it’s been live for three months! On April 15, 2021, we launched Regen Mainnet during a virtual launch party. The launch of the first public blockchain dedicated to planetary regeneration could not have gone smoother. Within a matter of seconds, validators were up and running, proposing, verifying and adding new blocks to the blockchain. We owe much gratitude to our well-prepared validators who participated in multiple testnets over the last two years leading up to the launch of Regen Mainnet.

Since the launch, the Regen Network community has proposed, voted upon, and passed two on-chain governance proposals. The first proposal was to enable token transfers and the second proposal was to enable token transfers using Inter-Blockchain Communication (IBC). This means the REGEN token can now be transferred between accounts on Regen Mainnet and between blockchains within the Cosmos ecosystem. We were thrilled to see these two proposals pass and to see community governance in action.

Well, what next? It’s time for an upgrade! If the Regen Network community supports the initiative, Regen Mainnet will upgrade to a new version of Regen Ledger mid-August 2021. Regen Mainnet has been operating on Regen Ledger v1.0 since launch and will soon have the option to upgrade to Regen Ledger v2.0. This post provides an overview of the features currently implemented in v1.0, what new features to expect in v2.0, and what the upgrade process looks like. Let’s start with a quick review of Regen Ledger, Cosmos SDK, and the role Regen Network plays in building the internet of blockchains.

Building in the Cosmos

Regen Ledger is a modular Proof-of-Stake (PoS) blockchain application built with Cosmos SDK. Cosmos SDK is an open-source framework for building blockchain applications that includes a standard set of modules that can be easily implemented in any application, allowing application developers to focus on building custom modules specific to their needs. The ability to pick and choose modules, creating a customizable blockchain on top of existing infrastructure, is one of the main reasons the Regen Network team chose to build Regen Ledger with Cosmos SDK. To learn more about this decision, check out How to Choose a Blockchain.

Regen Ledger is built on top of Cosmos SDK — a framework for building blockchain applications.

It takes a village to build a blockchain! Cosmos SDK is a community project with a number of teams within the Cosmos ecosystem actively contributing to it. In April 2020, the Regen Network team became the official lead maintainers for Cosmos SDK. This has been a huge honor and ever since we have been working hard alongside the community to help bring the vision of the internet of blockchains to fruition and to improve the overall user experience of interacting with and building blockchains that leverage the power of Cosmos SDK. As the lead maintainers, the Regen Network team is responsible for managing and coordinating Cosmos SDK releases. This year has already been a big year for releases, starting with the Stargate release (v0.40 — v0.42) in January followed by the latest v0.43 release, which will be officially released in a matter of days!

The Stargate release was a pivotal moment for the Cosmos ecosystem, completing the original roadmap laid out in the Cosmos Whitepaper. The Stargate release includes the implementation of Inter-Blockchain Communication (IBC), improved state sync for blockchains built on top of Tendermint Core, an upgrade module that enables the on-chain upgrade process, full-featured light clients, and the transition from Amino to Protocol Buffers that allows for wider language support. For the Stargate release, the Regen Network team led the implementation of the upgrade module and the refactoring of existing modules using Protocol Buffers.

Following the Stargate release, v0.43 focused on improving the developer experience around building blockchain applications with Cosmos SDK and the user experience around interacting with those applications. For the v0.43 release, the Regen Network team led the implementation of two new modules and improved the chain upgrade process by adding support for in-place store migrations. The two new modules are the feegrant module and the authz (“authorization”) module, both of which will be included in Regen Ledger v2.0. Also, Regen Ledger v2.0 will be configured to run in-place store migrations.

Regen Ledger v1.0

What does a minimum-viable community-governed blockchain look like? You’re looking at it. The goal of Regen Ledger v1.0 was to provide the foundation for the first blockchain dedicated to planetary regeneration governed and operated by the Regen Network community. Regen Mainnet is currently operating with a set of standard modules implemented in Regen Ledger v1.0 that enables token and account management, incentivized staking, and on-chain governance.

The standard modules currently available to application developers building with Cosmos SDK.

This standard set of modules is available to any application developer building with Cosmos SDK. The modules are imported from Cosmos SDK and registered in the root of the Regen Ledger application. To highlight a few, the bank module is responsible for keeping track of the token balances for each account and handling transfers between accounts, the staking module is responsible for keeping track of validators, delegators, and delegations, and the governance module is responsible for on-chain governance proposals with support for deposits and token-weighted voting.

Regen Ledger v1.0 provides the necessary infrastructure for Regen Mainnet to be governed by a community of REGEN token holders. The Regen Network community governs the blockchain by staking their REGEN tokens and voting on governance proposals. At the beginning of this post, we mentioned two governance proposals, one to enable transfers between accounts and the other to enable transfers between blockchains in the Cosmos ecosystem. These two proposals were parameter change proposals, meaning they did not require a chain upgrade, only the updating of existing parameters associated with the bank module and the ibc-transfer module respectively. The parameters were initially set in the genesis file and then stored in on-chain state when Regen Mainnet first started.

In order to upgrade Regen Mainnet from Regen Ledger v1.0 to v2.0, a software upgrade proposal will need to be proposed, voted upon, and passed. A software upgrade proposal runs migrations that alter the structure of on-chain state, which is required when updating modules or adding new modules. Regen Ledger v1.0 includes the upgrade module required to submit the software upgrade proposal and Regen Ledger v2.0 will include the functionality required to run in-place store migrations.

Regen Ledger v2.0

The v2.0 release of Regen Ledger includes an update to Cosmos SDK v0.43 and the addition of three new modules — the ecocredit (“ecological credit”) module, the feegrant module, and the authz (“authorization”) module. The ecocredit module is a custom module built within Regen Ledger, whereas the feegrant and the authz modules are the two new standard modules mentioned above that were added to Cosmos SDK in the v0.43 release.

A code snippet from the ecocredit module being built within Regen Ledger.

The ecocredit module is the most exciting addition to Regen Ledger v2.0. The ecocredit module will enable the ability to define and manage the issuance of new classes of credits for ecosystem services that represent positive ecological health (i.e. soil health credits, carbon credits, biodiversity credits, etc). Each ecocredit asset is represented as a fungible credit that can be issued, traded and retired and each credit is part of a credit class designed and issued by a credit issuer. The Regen Network team will start by creating an on-chain credit class for CarbonPlus Grasslands, the credit class we designed and have used for our first issuances of carbon credits last year, and then officially issuing those credits on-chain on Regen Mainnet. We’ll dive into more details on this module and how credit classes work in a follow up post.

The feegrant module and the authorization module are part of a larger initiative for improved key management. The barrier to entry for users of any blockchain application has historically been a challenge and these modules are designed to help solve that problem. The feegrant module will enable the ability for a granter to grant an allowance to a grantee where the allowance is used to cover fees for sending transactions. The allowance can either be a periodic allowance that automatically resets after a set time or a one-time allowance that has a one-time spending limit. The authz module will enable a granter to grant an authorization to a grantee that allows them to execute messages on behalf of the granter.

Upgrading Blockchains

Now that we have an idea of what’s included in Regen Ledger v1.0 and v2.0, let’s take a look at the upgrade process. We’ll be using the in-place store migrations feature that was added to the upgrade module and made available in v0.43 and recommending node operators use a process manager developed and maintained by the Regen Network team called Cosmovisor.

Chain upgrades were previously done as “genesis migrations”, which required exporting the state of the blockchain to a JSON file, modifying that JSON file (i.e. running migrations), and then starting a new chain with the JSON file as the new genesis file. This upgrade process was essentially a hard fork and exporting the entire blockchain state would take a lot of time when performing upgrades with blockchain applications that had a significant amount of data stored (accounts, validators, proposals, etc.). We are thrilled to introduce in-place store migrations in the latest v0.43 release of Cosmos SDK. No more hard forks!

With “in-place store migrations’’, migrations are handled in-place as opposed to requiring JSON to be exported and reimported. This feature requires each module to adopt a consensus version that needs to be updated each time a module introduces a state breaking change. In Cosmos SDK, the first version of each module is the version implemented in the Stargate release. Each module includes migration scripts that need to be run to migrate the state of the module. The migrations are run using an upgrade handler that is implemented in the main application file. In addition to running migrations, the upgrade handler also manages the adding of new stores for new modules. For the upgrade to Regen Ledger to v2.0, the upgrade handler will add stores for the feegrant module and the authz module.

We will also be recommending validators use Cosmovisor, which is a process manager for application binaries. With the use of Cosmovisor, node operators can prepare the upgrade binary in advance or optionally enable the automatic downloading of upgrade binaries if the governance proposal includes a mapping of download URLs for upgrade binaries within the upgrade plan. In order to provide strong security guarantees, Cosmovisor will also verify the checksum before downloading the upgrade binaries. Cosmovisor also provides the option to automatically restart the node with the new upgrade binary once the chain halts at the upgrade height. With the combination of Cosmovisor and in-place store migrations, the upgrade process can be automated and chain upgrades will take significantly less time to perform.

The Road Ahead

If you have been following along with the development of Regen Ledger, you might be asking yourself — what about the data module and group module? These two modules were not quite ready for Regen Ledger v2.0 but rest assured these modules are well under development and we expect to include them in the next release following v2.0.

With Regen Ledger v2.0 just around the corner, we are moving closer to fulfilling our mission to align economics with ecology to drive regenerative land management. It’s time to develop a deeper understanding of the core features that make up Regen Ledger. In subsequent posts, we’ll dive into more details on the core modules and how to interact with them. Stay tuned.

. . .

I recently joined Regen Network Development (RND) as Developer Relations Engineer. I’m here to support developers building with the Regen Ledger and Cosmos SDK. Feel free to reach out if you have any questions! Discord: https://discord.gg/BDcBJu3

--

--

Regen Network
Regen Network

Published in Regen Network

Regen Network aligns economics with ecology to drive regenerative land management. Learn more: https://regen.network. This blog is published by RND PBC, the development company building Regen Network

Ryan Christoffersen
Ryan Christoffersen

Written by Ryan Christoffersen

Software research and development at Chora Studio (chora.studio). Former Technical Product Manager at Regen Network (regen.network).

No responses yet