Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 0 additions & 6 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ type Manager struct {
// in the DA
daIncludedHeight atomic.Uint64
da coreda.DA
gasPrice float64
gasMultiplier float64

sequencer coresequencer.Sequencer
lastBatchData [][]byte
Expand Down Expand Up @@ -310,8 +308,6 @@ func NewManager(
headerBroadcaster broadcaster[*types.SignedHeader],
dataBroadcaster broadcaster[*types.Data],
seqMetrics *Metrics,
gasPrice float64,
gasMultiplier float64,
managerOpts ManagerOptions,
) (*Manager, error) {
s, err := getInitialState(ctx, genesis, signer, store, exec, logger, managerOpts)
Expand Down Expand Up @@ -402,8 +398,6 @@ func NewManager(
sequencer: sequencer,
exec: exec,
da: da,
gasPrice: gasPrice,
gasMultiplier: gasMultiplier,
txNotifyCh: make(chan struct{}, 1), // Non-blocking channel
signaturePayloadProvider: managerOpts.SignaturePayloadProvider,
validatorHasherProvider: managerOpts.ValidatorHasherProvider,
Expand Down
30 changes: 25 additions & 5 deletions block/submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ func submitToDA[T any](
submittedAll := false
var backoff time.Duration
attempt := 0
initialGasPrice := m.gasPrice

// Get gas price from DA layer
initialGasPrice, err := m.da.GasPrice(ctx)
if err != nil {
m.logger.Warn().Err(err).Msg("failed to get gas price from DA layer, using default")
initialGasPrice = 0.0 // fallback default
Comment thread
tac0turtle marked this conversation as resolved.
Outdated
}
gasPrice := initialGasPrice
remaining := items
numSubmitted := 0
Expand Down Expand Up @@ -138,8 +144,15 @@ func submitToDA[T any](
remaining = notSubmitted
marshaled = notSubmittedMarshaled
backoff = 0
if m.gasMultiplier > 0 && gasPrice != -1 {
gasPrice = gasPrice / m.gasMultiplier

// Get gas multiplier from DA layer and adjust price
gasMultiplier, multErr := m.da.GasMultiplier(ctx)
if multErr != nil {
m.logger.Warn().Err(multErr).Msg("failed to get gas multiplier from DA layer, using default")
gasMultiplier = 1.0 // fallback default
}
Comment thread
tac0turtle marked this conversation as resolved.
Outdated
if gasMultiplier > 0 && gasPrice != -1 {
gasPrice = gasPrice / gasMultiplier
gasPrice = max(gasPrice, initialGasPrice)
}
m.logger.Debug().Dur("backoff", backoff).Float64("gasPrice", gasPrice).Msg("resetting DA layer submission options")
Expand All @@ -148,8 +161,15 @@ func submitToDA[T any](
// Record failed DA submission (will retry)
m.recordDAMetrics("submission", DAModeFail)
backoff = m.config.DA.BlockTime.Duration * time.Duration(m.config.DA.MempoolTTL)
if m.gasMultiplier > 0 && gasPrice != -1 {
gasPrice = gasPrice * m.gasMultiplier

// Get gas multiplier from DA layer and increase price for retry
gasMultiplier, multErr := m.da.GasMultiplier(ctx)
if multErr != nil {
m.logger.Warn().Err(multErr).Msg("failed to get gas multiplier from DA layer, using default")
gasMultiplier = 1.0 // fallback default
}
if gasMultiplier > 0 && gasPrice != -1 {
gasPrice = gasPrice * gasMultiplier
}
m.logger.Info().Dur("backoff", backoff).Float64("gasPrice", gasPrice).Msg("retrying DA layer submission")
case coreda.StatusContextCanceled:
Expand Down
19 changes: 12 additions & 7 deletions block/submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ func newTestManagerWithDA(t *testing.T, da *mocks.MockDA) (m *Manager) {
proposerAddr,
)

// Set up DA mock to return gas parameters
da.On("GasPrice", mock.Anything).Return(1.0, nil).Maybe()
da.On("GasMultiplier", mock.Anything).Return(2.0, nil).Maybe()

return &Manager{
da: da,
logger: logger,
config: nodeConf,
gasPrice: 1.0,
gasMultiplier: 2.0,
headerCache: cache.NewCache[types.SignedHeader](),
dataCache: cache.NewCache[types.Data](),
signer: testSigner,
Expand Down Expand Up @@ -154,10 +156,12 @@ func runSubmitToDAFailureCase[T any](t *testing.T, tc submitToDAFailureCase[T])
assert.Contains(t, err.Error(), tc.errorMsg)

// Validate that gas price increased according to gas multiplier
previousGasPrice := m.gasPrice
assert.Equal(t, gasPriceHistory[0], m.gasPrice) // verify that the first call is done with the right price
expectedInitialGasPrice := 1.0
expectedGasMultiplier := 2.0
assert.Equal(t, gasPriceHistory[0], expectedInitialGasPrice) // verify that the first call is done with the right price
previousGasPrice := expectedInitialGasPrice
for _, gasPrice := range gasPriceHistory[1:] {
assert.Equal(t, gasPrice, previousGasPrice*m.gasMultiplier)
assert.Equal(t, gasPrice, previousGasPrice*expectedGasMultiplier)
previousGasPrice = gasPrice
}
}
Expand Down Expand Up @@ -250,8 +254,9 @@ func runRetryPartialFailuresCase[T any](t *testing.T, tc retryPartialFailuresCas
m.logger = zerolog.Nop()
da := &mocks.MockDA{}
m.da = da
m.gasPrice = 1.0
m.gasMultiplier = 2.0
// Set up DA mock to return gas parameters
da.On("GasPrice", mock.Anything).Return(1.0, nil).Maybe()
da.On("GasMultiplier", mock.Anything).Return(2.0, nil).Maybe()
tc.setupStoreAndDA(m, mockStore, da)
ctx := t.Context()
tc.fillPending(ctx, t, m)
Expand Down
6 changes: 0 additions & 6 deletions node/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog"

"github.com/evstack/ev-node/block"

Check failure on line 20 in node/full.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

could not import github.com/evstack/ev-node/block (-: # github.com/evstack/ev-node/block
coreda "github.com/evstack/ev-node/core/da"
coreexecutor "github.com/evstack/ev-node/core/execution"
coresequencer "github.com/evstack/ev-node/core/sequencer"
Expand Down Expand Up @@ -110,8 +110,6 @@
headerSyncService,
dataSyncService,
seqMetrics,
nodeConfig.DA.GasPrice,
nodeConfig.DA.GasMultiplier,
nodeOpts.ManagerOptions,
)
if err != nil {
Expand Down Expand Up @@ -197,8 +195,6 @@
headerSyncService *evsync.HeaderSyncService,
dataSyncService *evsync.DataSyncService,
seqMetrics *block.Metrics,
gasPrice float64,
gasMultiplier float64,
managerOpts block.ManagerOptions,
) (*block.Manager, error) {
logger.Debug().Bytes("address", genesis.ProposerAddress).Msg("Proposer address")
Expand All @@ -218,8 +214,6 @@
headerSyncService,
dataSyncService,
seqMetrics,
gasPrice,
gasMultiplier,
managerOpts,
)
if err != nil {
Expand Down
Loading