Skip to content

Repository files navigation

crude

How to create basic CRUD module

1. Install Ignite CLI

curl -L https://get.ignite.com/cli! | bash

2. Create New Chain

ignite scaffold chain crude
cd crude

3. Add CRUD Module

ignite scaffold module resource --dep bank
ignite scaffold list resource title content --module resource

4. Build

ignite chain build

5. Start Chain

ignite chain serve

6. Create Resource

cruded tx resource create-resource "First Post" "Hello Cosmos" --from alice

7. CRUD Resource

# list all
./cruded q resource list-resource

# list with condition
./cruded q resource list-resource --title "Post1"

# get details of resource by id
./cruded q resource show-resource 1

# update resource details
./cruded tx resource update-resource 1 "Updated Post" "Updated content" --from alice

# delete resource
./cruded tx resource delete-resource 1 --from alice

![create resource](./pics/create resource.png)

![delete resource](./pics/delete resource.png)

![list & search resource](./pics/list & search resource.png)

![update resource](./pics/update resource.png)

How to create a git branch with a consensus-breaking change

1. What is Consensus-Breaking?

In the context of blockchain, consensus-breaking refers to a situation where the state of the blockchain becomes inconsistent across different nodes (validators) in the network. This inconsistency causes some nodes to disagree about the current state of the blockchain and may lead to forking or data divergence.

For example, in a blockchain network, if two nodes have conflicting versions of the blockchain’s state or different transaction histories, the consensus protocol must resolve this conflict. If the system can’t resolve the differences, the blockchain state is considered “broken.”

2. How to make a consensus-breaking change

Change field of Resource in file resource.proto, and correspondingly make change to the related reference in msg_server_resource.go.

message Resource {
  uint64 id = 1;
  string title = 2; 
  
---  string content = 3;
+++  string updated_content = 3;
  
  string creator = 4;
}

3. Why Would Changing a Field in Resource Lead to Consensus-Breaking?

The reason modifying a field in a blockchain’s data model (like changing the field content = 3 to updated_content = 3 in the Resource proto) may lead to consensus-breaking is that blockchains rely on a shared data structure and protocol that ensures all nodes on the network understand the data in the same way.

When you modify a field in the Resource message (e.g., renaming content to updated_content), the definition of the Resource structure changes. If different nodes have different versions of this structure, they won’t be able to correctly interpret or validate transactions or blocks involving Resource objects.

Old nodes will expect content, while new nodes will expect updated_content. This can cause validation errors because nodes with mismatched data structures won’t be able to correctly interpret the transactions, causing them to diverge.

![create updated resource](./pics/create updated resource.png)

![field name error log](./pics/field name error log.png)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages