-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(submit loop): add more logging around skew calculation (#1000)
- Loading branch information
Showing
17 changed files
with
129 additions
and
43 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package atomic | ||
|
||
import ( | ||
"sync/atomic" | ||
) | ||
|
||
/* | ||
TODO: move to sdk-utils | ||
*/ | ||
|
||
// Uint64Sub does x := x-y and returns the new value of x | ||
func Uint64Sub(x *atomic.Uint64, y uint64) uint64 { | ||
// Uses math | ||
return x.Add(^(y - 1)) | ||
} |
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,35 @@ | ||
package atomic | ||
|
||
import ( | ||
"flag" | ||
"sync/atomic" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"pgregory.net/rapid" | ||
) | ||
|
||
func TestUint64Sub(t *testing.T) { | ||
_ = flag.Set("rapid.checks", "50") | ||
_ = flag.Set("rapid.steps", "50") | ||
|
||
rapid.Check(t, func(r *rapid.T) { | ||
exp := uint64(0) | ||
got := atomic.Uint64{} | ||
r.Repeat(map[string]func(r *rapid.T){ | ||
"": func(r *rapid.T) { | ||
require.Equal(t, exp, got.Load()) | ||
}, | ||
"add": func(r *rapid.T) { | ||
d := rapid.Uint64().Draw(r, "d") | ||
exp += d | ||
got.Add(d) | ||
}, | ||
"sub": func(r *rapid.T) { | ||
d := rapid.Uint64().Draw(r, "d") | ||
exp -= d | ||
Uint64Sub(&got, d) | ||
}, | ||
}) | ||
}) | ||
} |
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,24 @@ | ||
package errors | ||
|
||
import ( | ||
"github.com/dymensionxyz/dymint/types" | ||
"golang.org/x/sync/errgroup" | ||
) | ||
|
||
/* | ||
TODO: move to sdk-utils | ||
*/ | ||
|
||
// ErrGroupGoLog calls eg.Go on the errgroup but it will log the error immediately when it occurs | ||
// instead of waiting for all goroutines in the group to finish first. This has the advantage of making sure all | ||
// errors are logged, not just the first one, and it is more immediate. Also, it is guaranteed, in case that | ||
// of the goroutines is not properly context aware. | ||
func ErrGroupGoLog(eg *errgroup.Group, logger types.Logger, fn func() error) { | ||
eg.Go(func() error { | ||
err := fn() | ||
if err != nil { | ||
logger.Error("ErrGroup goroutine.", "err", err) | ||
} | ||
return err | ||
}) | ||
} |