Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
osmosis
Commits
6f6f9427
Commit
6f6f9427
authored
3 years ago
by
ValarDragon
Browse files
Options
Download
Email Patches
Plain Diff
Add panic guard, bug fix
parent
91e48c5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+8
-0
CHANGELOG.md
osmoutils/cache_ctx.go
+13
-3
osmoutils/cache_ctx.go
x/superfluid/keeper/hooks.go
+1
-1
x/superfluid/keeper/hooks.go
with
22 additions
and
4 deletions
+22
-4
CHANGELOG.md
+
8
-
0
View file @
6f6f9427
...
...
@@ -39,6 +39,14 @@ All notable changes to this project will be documented in this file.
The format is based on
[
Keep a Changelog
](
https://keepachangelog.com/en/1.0.0/
)
,
and this project adheres to
[
Semantic Versioning
](
https://semver.org/spec/v2.0.0.html
)
.
## [v7.0.2 - Carbon](https://github.com/osmosis-labs/osmosis/releases/tag/v7.0.2)
This release fixes an instance of undefined behaviour present in v7.0.0.
Parts of the code use a function called
[
`ApplyFuncIfNoErr`
](
)
whose purpose is to catch errors, and if found undo state updates during its execution.
It is intended to also catch panics and undo the problematic code's execution.
Right now a panic in this code block would halt the node, as it would not know how to proceed.
(But no state change would be committed)
## [v7.0.0 - Carbon](https://github.com/osmosis-labs/osmosis/releases/tag/v7.0.0)
The Osmosis Carbon Release! The changes are primarily
...
...
This diff is collapsed.
Click to expand it.
osmoutils/cache_ctx.go
+
13
-
3
View file @
6f6f9427
package
osmoutils
import
(
"errors"
"fmt"
sdk
"github.com/cosmos/cosmos-sdk/types"
)
// This function lets you run the function f, but if theres an error
// This function lets you run the function f, but if theres an error
or panic
// drop the state machine change and log the error.
// If there is no error, proceeds as normal (but with some slowdown due to SDK store weirdness)
// Try to avoid usage of iterators in f.
func
ApplyFuncIfNoError
(
ctx
sdk
.
Context
,
f
func
(
ctx
sdk
.
Context
)
error
)
error
{
func
ApplyFuncIfNoError
(
ctx
sdk
.
Context
,
f
func
(
ctx
sdk
.
Context
)
error
)
(
err
error
)
{
// Add a panic safeguard
defer
func
()
{
if
recovErr
:=
recover
();
recovErr
!=
nil
{
fmt
.
Println
(
recovErr
)
err
=
errors
.
New
(
"panic occured during execution"
)
}
}()
// makes a new cache context, which all state changes get wrapped inside of.
cacheCtx
,
write
:=
ctx
.
CacheContext
()
err
:
=
f
(
cacheCtx
)
err
=
f
(
cacheCtx
)
if
err
!=
nil
{
ctx
.
Logger
()
.
Error
(
err
.
Error
())
}
else
{
...
...
This diff is collapsed.
Click to expand it.
x/superfluid/keeper/hooks.go
+
1
-
1
View file @
6f6f9427
...
...
@@ -83,7 +83,7 @@ func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress,
func
(
h
Hooks
)
AfterDelegationModified
(
ctx
sdk
.
Context
,
delAddr
sdk
.
AccAddress
,
valAddr
sdk
.
ValAddress
)
{
}
func
(
h
Hooks
)
BeforeValidatorSlashed
(
ctx
sdk
.
Context
,
valAddr
sdk
.
ValAddress
,
infractionHeight
int64
,
slashFactor
sdk
.
Dec
,
effectiveSlashFactor
sdk
.
Dec
)
{
if
slashFactor
==
sdk
.
Zero
Dec
()
{
if
slashFactor
.
Is
Zero
()
{
return
}
h
.
k
.
SlashLockupsForValidatorSlash
(
ctx
,
valAddr
,
infractionHeight
,
slashFactor
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets