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

refactor(settlement): settlement layer redundent abstraction layer #873

Merged
Merged
6 changes: 3 additions & 3 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Manager struct {
Pubsub *pubsub.Server
p2pClient *p2p.Client
DAClient da.DataAvailabilityLayerClient
SLClient settlement.LayerI
SLClient settlement.ClientI

/*
Production
Expand Down Expand Up @@ -86,7 +86,7 @@ func NewManager(
mempool mempool.Mempool,
proxyApp proxy.AppConns,
dalc da.DataAvailabilityLayerClient,
settlementClient settlement.LayerI,
settlementClient settlement.ClientI,
eventBus *tmtypes.EventBus,
pubsub *pubsub.Server,
p2pClient *p2p.Client,
Expand Down Expand Up @@ -192,7 +192,7 @@ func (m *Manager) NextHeightToSubmit() uint64 {

// syncBlockManager enforces the node to be synced on initial run.
func (m *Manager) syncBlockManager() error {
res, err := m.SLClient.RetrieveBatch()
res, err := m.SLClient.GetLatestBatch()
if errors.Is(err, gerr.ErrNotFound) {
// The SL hasn't got any batches for this chain yet.
m.logger.Info("No batches for chain found in SL.")
Expand Down
2 changes: 1 addition & 1 deletion block/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (m *Manager) syncToTargetHeight(targetHeight uint64) error {
return fmt.Errorf("query state index: %w", err)
}

settlementBatch, err := m.SLClient.RetrieveBatch(stateIndex)
settlementBatch, err := m.SLClient.GetBatchAtIndex(stateIndex)
if err != nil {
return fmt.Errorf("retrieve batch: %w", err)
}
Expand Down
18 changes: 9 additions & 9 deletions block/submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/libp2p/go-libp2p/core/crypto"

"github.com/dymensionxyz/dymint/config"
mocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement"
slmocks "github.com/dymensionxyz/dymint/mocks/github.com/dymensionxyz/dymint/settlement"
"github.com/dymensionxyz/dymint/testutil"
"github.com/dymensionxyz/dymint/types"
)
Expand Down Expand Up @@ -74,13 +74,13 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) {
PublicKey: cosmosPrivKey.PubKey(),
}

// Create a new mock LayerI
mockLayerI := &mocks.MockLayerI{}
mockLayerI.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
mockLayerI.On("Start").Return(nil)
mockLayerI.On("GetProposer").Return(proposer)
// Create a new mock ClientI
slmock := &slmocks.MockClientI{}
slmock.On("Init", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
slmock.On("Start").Return(nil)
slmock.On("GetProposer").Return(proposer)

manager, err := testutil.GetManagerWithProposerKey(testutil.GetManagerConfig(), lib2pPrivKey, mockLayerI, nil, 1, 1, 0, proxyApp, nil)
manager, err := testutil.GetManagerWithProposerKey(testutil.GetManagerConfig(), lib2pPrivKey, slmock, nil, 1, 1, 0, proxyApp, nil)
require.NoError(err)

// Check initial assertions
Expand All @@ -95,11 +95,11 @@ func TestBatchSubmissionFailedSubmission(t *testing.T) {
assert.Zero(t, manager.LastSubmittedHeight.Load())

// try to submit, we expect failure
mockLayerI.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("submit batch")).Once()
slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(fmt.Errorf("submit batch")).Once()
assert.Error(t, manager.HandleSubmissionTrigger())

// try to submit again, we expect success
mockLayerI.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
slmock.On("SubmitBatch", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
manager.HandleSubmissionTrigger()
assert.EqualValues(t, manager.State.Height(), manager.LastSubmittedHeight.Load())
}
Expand Down
Loading
Loading