Skip to content

Commit caa7fba

Browse files
committed
chore: disable feature again. Code cleanup
1 parent 91e83e5 commit caa7fba

5 files changed

Lines changed: 106 additions & 104 deletions

File tree

apps/evm/cmd/post_tx_cmd.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import (
2121
)
2222

2323
const (
24-
flagNamespace = "namespace"
25-
flagGasPrice = "gas-price"
26-
flagSubmitOpts = "submit-options"
24+
flagNamespace = "namespace"
25+
flagGasPrice = "gas-price"
2726
)
2827

2928
// PostTxCmd returns a command to post a signed Ethereum transaction to the DA layer
@@ -61,7 +60,6 @@ Examples:
6160
// Add command-specific flags
6261
cobraCmd.Flags().String(flagNamespace, "", "DA namespace ID (if not provided, uses config namespace)")
6362
cobraCmd.Flags().Float64(flagGasPrice, -1, "Gas price for DA submission (if not provided, uses config gas price)")
64-
cobraCmd.Flags().String(flagSubmitOpts, "", "Additional DA submit options (if not provided, uses config submit options)")
6563

6664
return cobraCmd
6765
}
@@ -104,6 +102,11 @@ func postTxRunE(cmd *cobra.Command, args []string) error {
104102
if namespace == "" {
105103
namespace = nodeConfig.DA.GetForcedInclusionNamespace()
106104
}
105+
106+
if namespace == "" {
107+
return fmt.Errorf("forced inclusionnamespace cannot be empty")
108+
}
109+
107110
namespaceBz := da.NamespaceFromString(namespace).Bytes()
108111

109112
// Get gas price (use flag if provided, otherwise use config)
@@ -112,16 +115,6 @@ func postTxRunE(cmd *cobra.Command, args []string) error {
112115
return fmt.Errorf("failed to get gas-price flag: %w", err)
113116
}
114117

115-
// Get submit options (use flag if provided, otherwise use config)
116-
submitOpts, err := cmd.Flags().GetString(flagSubmitOpts)
117-
if err != nil {
118-
return fmt.Errorf("failed to get submit-options flag: %w", err)
119-
}
120-
121-
if submitOpts == "" {
122-
submitOpts = nodeConfig.DA.SubmitOptions
123-
}
124-
125118
logger.Info().Str("namespace", namespace).Float64("gas_price", gasPrice).Int("tx_size", len(txData)).Msg("posting transaction to DA layer")
126119

127120
daClient, err := jsonrpc.NewClient(
@@ -139,7 +132,7 @@ func postTxRunE(cmd *cobra.Command, args []string) error {
139132
logger.Info().Msg("submitting transaction to DA layer...")
140133

141134
blobs := [][]byte{txData}
142-
options := []byte(submitOpts)
135+
options := []byte(nodeConfig.DA.SubmitOptions)
143136

144137
dac := evblock.NewDAClient(&daClient.DA, nodeConfig, logger)
145138
result := dac.Submit(cmd.Context(), blobs, gasPrice, namespaceBz, options)
@@ -156,7 +149,7 @@ func postTxRunE(cmd *cobra.Command, args []string) error {
156149
genesisPath := filepath.Join(filepath.Dir(nodeConfig.ConfigPath()), "genesis.json")
157150
genesis, err := genesispkg.LoadGenesis(genesisPath)
158151
if err != nil {
159-
return fmt.Errorf("failed to load genesis: %w", err)
152+
return fmt.Errorf("failed to load genesis for calculating inclusion time estimate: %w", err)
160153
}
161154

162155
_, epochEnd, _ := types.CalculateEpochBoundaries(result.Height, genesis.DAStartHeight, genesis.DAEpochForcedInclusion)
@@ -205,7 +198,7 @@ func decodeTxFromJSON(input string) ([]byte, error) {
205198
input = strings.TrimSpace(input)
206199

207200
// Try to decode as JSON with "raw" field
208-
var txJSON map[string]interface{}
201+
var txJSON map[string]any
209202
if err := json.Unmarshal([]byte(input), &txJSON); err == nil {
210203
if rawTx, ok := txJSON["raw"].(string); ok {
211204
return decodeHexTx(rawTx)

core/execution/context_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package execution_test
2+
3+
import (
4+
"context"
5+
"slices"
6+
"testing"
7+
8+
"github.com/evstack/ev-node/core/execution"
9+
)
10+
11+
// TestWithForceIncludedMask_ContextRoundtrip verifies that the mask
12+
// can be stored in and retrieved from context correctly
13+
func TestWithForceIncludedMask_ContextRoundtrip(t *testing.T) {
14+
t.Parallel()
15+
16+
tests := []struct {
17+
name string
18+
mask []bool
19+
}{
20+
{
21+
name: "nil mask",
22+
mask: nil,
23+
},
24+
{
25+
name: "empty mask",
26+
mask: []bool{},
27+
},
28+
{
29+
name: "single element",
30+
mask: []bool{true},
31+
},
32+
{
33+
name: "multiple elements",
34+
mask: []bool{true, false, true, false, false},
35+
},
36+
{
37+
name: "all true",
38+
mask: []bool{true, true, true},
39+
},
40+
{
41+
name: "all false",
42+
mask: []bool{false, false, false},
43+
},
44+
}
45+
46+
for _, tt := range tests {
47+
t.Run(tt.name, func(t *testing.T) {
48+
t.Parallel()
49+
50+
ctx := context.Background()
51+
52+
// Add mask to context
53+
ctxWithMask := execution.WithForceIncludedMask(ctx, tt.mask)
54+
55+
// Retrieve mask from context
56+
retrieved := execution.GetForceIncludedMask(ctxWithMask)
57+
58+
// Verify it matches
59+
if !slices.Equal(tt.mask, retrieved) {
60+
t.Errorf("expected mask %v, got %v", tt.mask, retrieved)
61+
}
62+
})
63+
}
64+
}
65+
66+
// TestGetForceIncludedMask_NoMask verifies that getting a mask from
67+
// a context without one returns nil
68+
func TestGetForceIncludedMask_NoMask(t *testing.T) {
69+
t.Parallel()
70+
71+
ctx := context.Background()
72+
mask := execution.GetForceIncludedMask(ctx)
73+
if mask != nil {
74+
t.Errorf("expected nil mask from context without mask, got %v", mask)
75+
}
76+
}
77+
78+
// TestGetForceIncludedMask_WrongType verifies that wrong types in context
79+
// are handled gracefully
80+
func TestGetForceIncludedMask_WrongType(t *testing.T) {
81+
t.Parallel()
82+
83+
// Create context with wrong type
84+
ctx := context.WithValue(context.Background(), "force_included_mask", "wrong type")
85+
86+
mask := execution.GetForceIncludedMask(ctx)
87+
if mask != nil {
88+
t.Errorf("expected nil mask when context has wrong type, got %v", mask)
89+
}
90+
}

execution/evm/execution.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,6 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
257257
validTxs := make([]string, 0, len(txs))
258258
for i, tx := range txs {
259259
if len(tx) == 0 {
260-
c.logger.Debug().
261-
Int("tx_index", i).
262-
Uint64("block_height", blockHeight).
263-
Msg("skipping empty transaction")
264260
continue
265261
}
266262

@@ -274,7 +270,7 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
274270
// Validate that the transaction can be parsed as an Ethereum transaction
275271
var ethTx types.Transaction
276272
if err := ethTx.UnmarshalBinary(tx); err != nil {
277-
c.logger.Warn().
273+
c.logger.Debug().
278274
Int("tx_index", i).
279275
Uint64("block_height", blockHeight).
280276
Err(err).
@@ -287,7 +283,7 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
287283
}
288284

289285
if len(validTxs) < len(txs) {
290-
c.logger.Info().
286+
c.logger.Debug().
291287
Int("total_txs", len(txs)).
292288
Int("valid_txs", len(validTxs)).
293289
Int("filtered_txs", len(txs)-len(validTxs)).

execution/evm/force_included_test.go

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -160,80 +160,3 @@ func TestExecuteTxs_ForceIncludedMask(t *testing.T) {
160160
})
161161
}
162162
}
163-
164-
// TestWithForceIncludedMask_ContextRoundtrip verifies that the mask
165-
// can be stored in and retrieved from context correctly
166-
func TestWithForceIncludedMask_ContextRoundtrip(t *testing.T) {
167-
t.Parallel()
168-
169-
tests := []struct {
170-
name string
171-
mask []bool
172-
}{
173-
{
174-
name: "nil mask",
175-
mask: nil,
176-
},
177-
{
178-
name: "empty mask",
179-
mask: []bool{},
180-
},
181-
{
182-
name: "single element",
183-
mask: []bool{true},
184-
},
185-
{
186-
name: "multiple elements",
187-
mask: []bool{true, false, true, false, false},
188-
},
189-
{
190-
name: "all true",
191-
mask: []bool{true, true, true},
192-
},
193-
{
194-
name: "all false",
195-
mask: []bool{false, false, false},
196-
},
197-
}
198-
199-
for _, tt := range tests {
200-
t.Run(tt.name, func(t *testing.T) {
201-
t.Parallel()
202-
203-
ctx := context.Background()
204-
205-
// Add mask to context
206-
ctxWithMask := coreexecution.WithForceIncludedMask(ctx, tt.mask)
207-
208-
// Retrieve mask from context
209-
retrieved := coreexecution.GetForceIncludedMask(ctxWithMask)
210-
211-
// Verify it matches
212-
assert.Equal(t, tt.mask, retrieved)
213-
})
214-
}
215-
}
216-
217-
// TestGetForceIncludedMask_NoMask verifies that getting a mask from
218-
// a context without one returns nil
219-
func TestGetForceIncludedMask_NoMask(t *testing.T) {
220-
t.Parallel()
221-
222-
ctx := context.Background()
223-
mask := coreexecution.GetForceIncludedMask(ctx)
224-
225-
assert.Nil(t, mask, "expected nil mask from context without mask")
226-
}
227-
228-
// TestGetForceIncludedMask_WrongType verifies that wrong types in context
229-
// are handled gracefully
230-
func TestGetForceIncludedMask_WrongType(t *testing.T) {
231-
t.Parallel()
232-
233-
// Create context with wrong type
234-
ctx := context.WithValue(context.Background(), "force_included_mask", "wrong type")
235-
236-
mask := coreexecution.GetForceIncludedMask(ctx)
237-
238-
assert.Nil(t, mask, "expected nil mask when context has wrong type")
239-
}

pkg/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ func (c *Config) Validate() error {
268268
}
269269

270270
if len(c.DA.GetForcedInclusionNamespace()) > 0 {
271-
if err := validateNamespace(c.DA.GetForcedInclusionNamespace()); err != nil {
272-
return fmt.Errorf("could not validate forced inclusion namespace (%s): %w", c.DA.GetForcedInclusionNamespace(), err)
273-
}
274-
// return fmt.Errorf("forced inclusion is not yet live")
271+
// if err := validateNamespace(c.DA.GetForcedInclusionNamespace()); err != nil {
272+
// return fmt.Errorf("could not validate forced inclusion namespace (%s): %w", c.DA.GetForcedInclusionNamespace(), err)
273+
// }
274+
return fmt.Errorf("forced inclusion is not yet live")
275275

276276
}
277277

0 commit comments

Comments
 (0)