Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Rollback will not re-execute the transaction. #17739

Open
1 task done
gofmanaa opened this issue Sep 14, 2023 · 4 comments
Open
1 task done

[Bug]: Rollback will not re-execute the transaction. #17739

gofmanaa opened this issue Sep 14, 2023 · 4 comments
Labels
S:needs more info This bug can't be addressed until more information is provided by the reporter. T:Bug

Comments

@gofmanaa
Copy link

gofmanaa commented Sep 14, 2023

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

Rollback will not re-execute the transaction.

I found a problem with the rollback command.
The documentation about the rollback says that "the transactions in block n will be re-executed against the
application." but this does not happen.
Transactions with non-deterministic data are not re-executed and the blockchain does not produce new blocks.

Maybe I'm doing something wrong, please tell me how it should be, this question is very important to me

I want to know how such a problem can be solved.
What to do if it happens on prod?

Cosmos SDK Version

v0.47.2, v0.47.3

How to reproduce?

Steps to reproduction:
1 versions:
$ ignite version
Ignite CLI version: v0.27.1-dev
Ignite CLI build date: 2023-06-02T20:29:26Z
Ignite CLI source hash: 15cf9a60b8dfbed6d9ddb0cad7e890d2a5b60979
Ignite CLI config version: v1
Cosmos SDK version: v0.47.2
Your OS: linux
Your arch: amd64
Your Node.js version: v18.15.0
Your go version: go version go1.20.7 linux/amd64
Your uname -a: Linux archlinux 6.4.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 24 Aug 2023 00:38:14 +0000 x86_64 GNU/Linux
Your cwd: /home/user
Is on Gitpod: false

2 Scaffold a new blockchain using ignite cli (https://docs.ignite.com/guide/blog/express)
3. Add non-determenistic data to message

func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (*types.MsgCreatePostResponse, error) {
	ctx := sdk.UnwrapSDKContext(goCtx)

	var post = types.Post{
		Creator: msg.Creator,
		Title:   fmt.Sprintf("%d-%s", rand.Int(), msg.Title), #  <--add this random data
		Body:    msg.Body,
	}
  1. Launch a blockchain on 3 nodes ()
    $ blogd testnet start
    acquiring test network lock
    preparing test network with chain-id "blog"
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    ++ THIS MNEMONIC IS FOR TESTING PURPOSES ONLY ++
    ++ DO NOT USE IN PRODUCTION ++
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    starting test network...
    started validator 0
    started validator 1
    started validator 2
    started test network at height: 1
    press the Enter Key to terminate

  2. Broadcast the transaction. The message must contain random data.
    $ blogd tx blog create-post 'Hello, World!' 'This is a blog post' --from node0 --keyring-backend test --keyring-dir ./.testnets/blog/node0/simcli

The non-deterministic transaction stops the generation of new blocks.

  1. Stop the blockchain and execute the rollback command
    $ blogd rollback --hard --home ./.testnets/blog/node0/simd
    $ blogd rollback --hard --home ./.testnets/blog/node1/simd
    $ blogd rollback --hard --home ./.testnets/blog/node2/simd
    Every time the command gives an error:
    Error: failed to rollback to version: no versions found while trying to load 6

  2. Fix the message, removing random from the message.

func (k msgServer) CreatePost(goCtx context.Context, msg *types.MsgCreatePost) (*types.MsgCreatePostResponse, error) {
	ctx := sdk.UnwrapSDKContext(goCtx)

	var post = types.Post{
		Creator: msg.Creator,
		Title:   msg.Title, # <- fix message
		Body:    msg.Body,
	}
  1. Rebuild the blockchain.
    $ ignite c build
  2. Launch a blockchain on 3 nodes
    The blockchain changes the current height to n -1, but the transaction is not re-execute!
@gofmanaa gofmanaa added the T:Bug label Sep 14, 2023
@facundomedica
Copy link
Member

facundomedica commented Sep 14, 2023

EDIT: replied without seeing that we re-implement this command in the SDK and that it's not only from Comet

@alexanderbez
Copy link
Contributor

Error: failed to rollback to version: no versions found while trying to load 6 This seems problematic, no?

@gofmanaa
Copy link
Author

Thanks, without a flag --hard, the node started working and new blocks started to be produced.

Description from CometBFT:

A state rollback is performed to recover from an incorrect application state transition,
when CometBFT has persisted an incorrect app hash and is thus unable to make
progress. Rollback overwrites a state at height n with the state at height n - 1.
The application should also roll back to height n - 1. If the --hard flag is not used, 
no blocks will be removed so upon restarting CometBFT the transactions in block n will be 
re-executed against the application. Using --hard will also remove block n. This can
be done multiple times.

Please tell me in what cases it is possible to use the "--hard" flag ?

@github-project-automation github-project-automation bot moved this to 👀 To Do in Cosmos-SDK Nov 16, 2023
@tac0turtle
Copy link
Member

the error means that it could be that the node has pruned the older versions, can you share the pruning settings?

@tac0turtle tac0turtle added the S:needs more info This bug can't be addressed until more information is provided by the reporter. label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:needs more info This bug can't be addressed until more information is provided by the reporter. T:Bug
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants