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

patch to mtsitrin/324: remove validate batch #830

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 2 additions & 41 deletions block/production_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/dymensionxyz/dymint/mempool"
mempoolv1 "github.com/dymensionxyz/dymint/mempool/v1"
"github.com/dymensionxyz/dymint/node/events"
"github.com/dymensionxyz/dymint/types"
uevent "github.com/dymensionxyz/dymint/utils/event"
tmcfg "github.com/tendermint/tendermint/config"

Expand Down Expand Up @@ -61,8 +60,8 @@ func TestCreateEmptyBlocksEnableDisable(t *testing.T) {
go manager.ProduceBlockLoop(mCtx)
go managerWithEmptyBlocks.ProduceBlockLoop(mCtx)

buf1 := make(chan struct{}, 100) //dummy to avoid unhealthy event
buf2 := make(chan struct{}, 100) //dummy to avoid unhealthy event
buf1 := make(chan struct{}, 100) // dummy to avoid unhealthy event
buf2 := make(chan struct{}, 100) // dummy to avoid unhealthy event
go manager.AccumulatedDataLoop(mCtx, buf1)
go managerWithEmptyBlocks.AccumulatedDataLoop(mCtx, buf2)
<-mCtx.Done()
Expand Down Expand Up @@ -176,44 +175,6 @@ func TestCreateEmptyBlocksNew(t *testing.T) {
assert.True(foundTx)
}

func TestInvalidBatch(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

manager, err := testutil.GetManager(testutil.GetManagerConfig(), nil, nil, 1, 1, 0, nil, nil)
require.NoError(err)

batchSize := uint64(5)
syncTarget := uint64(10)

// Create cases
cases := []struct {
startHeight uint64
endHeight uint64
shouldError bool
}{
{startHeight: syncTarget + 1, endHeight: syncTarget + batchSize, shouldError: false},
// batch with endHight < startHeight
{startHeight: syncTarget + 1, endHeight: syncTarget, shouldError: true},
// batch with startHeight != previousEndHeight + 1
{startHeight: syncTarget, endHeight: syncTarget + batchSize + batchSize, shouldError: true},
}
for _, c := range cases {
batch := &types.Batch{
StartHeight: c.startHeight,
EndHeight: c.endHeight,
}

manager.UpdateSyncParams(syncTarget)
err := manager.ValidateBatch(batch)
if c.shouldError {
assert.Error(err)
} else {
assert.NoError(err)
}
}
}

// TestStopBlockProduction tests the block production stops when submitter is full
// and resumes when submitter is ready to accept more batches
func TestStopBlockProduction(t *testing.T) {
Expand Down
15 changes: 0 additions & 15 deletions block/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ func (m *Manager) HandleSubmissionTrigger() error {
return fmt.Errorf("create next batch to submit: %w", err)
}

if err := m.ValidateBatch(nextBatch); err != nil {
return fmt.Errorf("validate batch: %w", err)
}

resultSubmitToDA, err := m.submitNextBatchToDA(nextBatch)
if err != nil {
return fmt.Errorf("submit next batch to da: %w", err)
Expand Down Expand Up @@ -169,17 +165,6 @@ func (m *Manager) submitNextBatchToSL(batch *types.Batch, daResult *da.ResultSub
return actualEndHeight, nil
}

func (m *Manager) ValidateBatch(batch *types.Batch) error {
syncTarget := m.SyncTarget.Load()
if batch.StartHeight != syncTarget+1 {
return fmt.Errorf("batch start height != syncTarget + 1. StartHeight %d, m.SyncTarget %d", batch.StartHeight, syncTarget)
}
if batch.EndHeight < batch.StartHeight {
return fmt.Errorf("batch end height must be greater than start height. EndHeight %d, StartHeight %d", batch.EndHeight, batch.StartHeight)
}
return nil
}

func (m *Manager) CreateNextBatchToSubmit(startHeight uint64, endHeightInclusive uint64) (*types.Batch, error) {
var height uint64
// Create the batch
Expand Down
Loading