Skip to content

Commit

Permalink
feat(fraud): extend fraud information upon detection (dymensionxyz#1237)
Browse files Browse the repository at this point in the history
Co-authored-by: Faulty Tolly <@faulttolerance.net>
Co-authored-by: unknown unknown <unknown@unknown>
Co-authored-by: Sergi Rene <[email protected]>
Co-authored-by: Sergi Rene <[email protected]>
Co-authored-by: keruch <[email protected]>
Co-authored-by: Daniel T <[email protected]>
Co-authored-by: keruch <[email protected]>
  • Loading branch information
7 people authored Nov 19, 2024
1 parent a5453ad commit 377dc7c
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 74 deletions.
1 change: 0 additions & 1 deletion block/fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func TestShouldStopNode(t *testing.T) {
}

func TestCheckForkUpdate(t *testing.T) {

tests := []struct {
name string
setupMocks func(*settlement.MockClientI, *store.MockStore, *types.State)
Expand Down
2 changes: 2 additions & 0 deletions block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/types"
"github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp"
"github.com/dymensionxyz/dymint/version"

abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/crypto/ed25519"
Expand All @@ -45,6 +46,7 @@ import (
// TODO: test sequencer after L2 handover but before last state update submitted
// TODO: test halt scenario
func TestInitialState(t *testing.T) {
version.DRS = "0"
var err error
assert := assert.New(t)
genesis := testutil.GenerateGenesis(123)
Expand Down
4 changes: 4 additions & 0 deletions block/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import (
"github.com/dymensionxyz/dymint/types"
uchannel "github.com/dymensionxyz/dymint/utils/channel"
uevent "github.com/dymensionxyz/dymint/utils/event"
"github.com/dymensionxyz/dymint/version"
)

// TODO: test producing lastBlock
// TODO: test using already produced lastBlock
func TestCreateEmptyBlocksEnableDisable(t *testing.T) {
version.DRS = "0"
const blockTime = 200 * time.Millisecond
const MaxIdleTime = blockTime * 10
const runTime = 10 * time.Second
Expand Down Expand Up @@ -292,6 +294,7 @@ func TestUpdateInitialSequencerSet(t *testing.T) {
require := require.New(t)
app := testutil.GetAppMock(testutil.EndBlock)
ctx := context.Background()
version.DRS = "0"
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{
RollappParamUpdates: &abci.RollappParams{
Da: "mock",
Expand Down Expand Up @@ -398,6 +401,7 @@ func TestUpdateExistingSequencerSet(t *testing.T) {
require := require.New(t)
app := testutil.GetAppMock(testutil.EndBlock)
ctx := context.Background()
version.DRS = "0"
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{
RollappParamUpdates: &abci.RollappParams{
Da: "mock",
Expand Down
5 changes: 1 addition & 4 deletions block/slvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ func (v *SettlementValidator) ValidateDaBlocks(slBatch *settlement.ResultRetriev
}

if !bytes.Equal(expectedNextSeqHash[:], lastDABlock.Header.NextSequencersHash[:]) {
return types.NewErrInvalidNextSequencersHashFraud(
expectedNextSeqHash,
lastDABlock.Header.NextSequencersHash,
)
return types.NewErrInvalidNextSequencersHashFraud(expectedNextSeqHash, lastDABlock.Header)
}

v.logger.Debug("DA blocks validated successfully", "start height", daBlocks[0].Header.Height, "end height", daBlocks[len(daBlocks)-1].Header.Height)
Expand Down
2 changes: 2 additions & 0 deletions block/slvalidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/types"
"github.com/dymensionxyz/dymint/types/pb/dymensionxyz/dymension/rollapp"
"github.com/dymensionxyz/dymint/version"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand All @@ -29,6 +30,7 @@ import (
)

func TestStateUpdateValidator_ValidateStateUpdate(t *testing.T) {
version.DRS = "0"
// Init app
app := testutil.GetAppMock(testutil.EndBlock)
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{
Expand Down
7 changes: 7 additions & 0 deletions block/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
slmocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/types"
"github.com/dymensionxyz/dymint/version"
)

// TestBatchOverhead tests the scenario where we have a single block that is very large, and occupies the entire batch size.
Expand All @@ -34,6 +35,7 @@ import (
// 1. single block with single large tx
// 2. single block with multiple small tx
func TestBatchOverhead(t *testing.T) {
version.DRS = "0"
manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, 1, 1, 0, nil, nil)
require.NoError(t, err)
require.NotNil(t, manager)
Expand Down Expand Up @@ -105,6 +107,8 @@ func TestBatchSubmissionHappyFlow(t *testing.T) {
app := testutil.GetAppMock(testutil.EndBlock)
ctx := context.Background()

version.DRS = "0"

// Create proxy app
clientCreator := proxy.NewLocalClientCreator(app)
proxyApp := proxy.NewAppConns(clientCreator)
Expand Down Expand Up @@ -149,6 +153,8 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) {
app := testutil.GetAppMock(testutil.EndBlock)
ctx := context.Background()

version.DRS = "0"

app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{
RollappParamUpdates: &abci.RollappParams{
Da: "mock",
Expand Down Expand Up @@ -222,6 +228,7 @@ func TestSubmissionByTime(t *testing.T) {
submitTimeout = 1 * time.Second
blockTime = 200 * time.Millisecond
)
version.DRS = "0"

require := require.New(t)
app := testutil.GetAppMock(testutil.EndBlock)
Expand Down
2 changes: 2 additions & 0 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/dymensionxyz/dymint/node"
"github.com/dymensionxyz/dymint/settlement"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/version"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"
Expand All @@ -31,6 +32,7 @@ import (
// simply check that node is starting and stopping without panicking
func TestStartup(t *testing.T) {

version.DRS = "0"
assert := assert.New(t)
require := require.New(t)

Expand Down
2 changes: 2 additions & 0 deletions p2p/block_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (

"github.com/dymensionxyz/dymint/p2p"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/version"
"github.com/ipfs/go-datastore"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
)

func TestBlockSync(t *testing.T) {
version.DRS = "0"
logger := log.TestingLogger()
ctx := context.Background()

Expand Down
2 changes: 2 additions & 0 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/dymensionxyz/dymint/settlement"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/types"
"github.com/dymensionxyz/dymint/version"
)

var expectedInfo = abci.ResponseInfo{
Expand Down Expand Up @@ -986,6 +987,7 @@ func getRPCAndNodeSequencer(t *testing.T) (*tmmocks.MockApplication, *client.Cli
// getRPC returns a mock application and a new RPC client (non-sequencer mode)
func getRPCInternal(t *testing.T, sequencer bool) (*tmmocks.MockApplication, *client.Client, *node.Node) {
t.Helper()
version.DRS = "0"
require := require.New(t)
app := &tmmocks.MockApplication{}
app.On("Info", mock.Anything).Return(expectedInfo)
Expand Down
2 changes: 2 additions & 0 deletions rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (

"github.com/dymensionxyz/dymint/node/events"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/version"
)

func TestNodeHealthRPCPropagation(t *testing.T) {
var err error
version.DRS = "0"
server, listener := testutil.CreateLocalServer(t)
defer func() {
err = server.Stop()
Expand Down
Loading

0 comments on commit 377dc7c

Please sign in to comment.