-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat(evmengine): use current finalized block events & remove prev events #514
Draft
jdubpark
wants to merge
6
commits into
release/1.2
Choose a base branch
from
jdub/use-finalized-events
base: release/1.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
493ac12
feat: remove prev events & use finalized block events
jdubpark ddccb9c
fix: optimize loop
jdubpark 5b55016
fix: deprecated proto field
jdubpark f742cc4
test: override filter logs to test current block events
jdubpark 50da4ac
refactor: public fns
jdubpark 466d539
feat: upgrade handler v1.3.0
jdubpark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
//nolint:revive,stylecheck // versioning | ||
package v_1_3_0 | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
|
||
"github.com/piplabs/story/client/app/upgrades" | ||
) | ||
|
||
const ( | ||
UpgradeName = "v1.3.0" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: storetypes.StoreUpgrades{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
//nolint:revive,stylecheck // versioning | ||
package v_1_3_0 | ||
|
||
import ( | ||
"context" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/piplabs/story/client/app/keepers" | ||
"github.com/piplabs/story/lib/errors" | ||
"github.com/piplabs/story/lib/log" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
_ *module.Manager, | ||
_ module.Configurator, | ||
keepers *keepers.Keepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
log.Info(ctx, "Start upgrade v1.3.0") | ||
|
||
// When this handler is triggered at the beginning of block X, we must process the events from block X-1. | ||
// Otherwise, events from block X-1 will be discarded as the upgrade changes the logic to process events of the | ||
// current block once finalized. | ||
|
||
// Get the block hash and events of the previous block. | ||
head, err := keepers.EVMEngKeeper.GetExecutionHead(ctx) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "get execution head") | ||
} | ||
lastBlockHeight := head.GetBlockHeight() | ||
lastBlockHash := common.BytesToHash(head.GetBlockHash()) | ||
|
||
events, err := keepers.EVMEngKeeper.EvmEvents(ctx, lastBlockHash) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "fetch evm event logs") | ||
} | ||
|
||
// Deliver all the payload log events of the block X-1 | ||
if err := keepers.EvmStakingKeeper.ProcessStakingEvents(ctx, lastBlockHeight, events); err != nil { | ||
return nil, errors.Wrap(err, "deliver staking-related event logs") | ||
} | ||
if err := keepers.EVMEngKeeper.ProcessUpgradeEvents(ctx, lastBlockHeight, events); err != nil { | ||
return nil, errors.Wrap(err, "deliver upgrade-related event logs") | ||
} | ||
if err := keepers.EVMEngKeeper.ProcessUbiEvents(ctx, lastBlockHeight, events); err != nil { | ||
return nil, errors.Wrap(err, "deliver ubi-related event logs") | ||
} | ||
|
||
if err := keepers.EVMEngKeeper.UpdateExecutionHeadWithBlock(ctx, lastBlockHeight, lastBlockHash, head.GetBlockTime()); err != nil { | ||
return nil, errors.Wrap(err, "update execution head") | ||
} | ||
|
||
log.Info(ctx, "Upgrade v1.3.0 complete") | ||
|
||
return vm, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark reserve or deprecated, not removing the field for future backward or forward compatibility.
It can cause unexpected issue in deserialization.
https://stackoverflow.com/questions/71782502/what-happened-if-you-delete-a-field-on-protobuf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 5b55016