Repository navigation
feat: exec api #1997
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
feat: exec api #1997
Changes from 1 commit
584b187
d06c288
3fce7ae
fb1e4ec
12f7e65
d3df482
1704717
75872c2
13cc399
503c98b
0fb08e1
00ad30d
b7d5ec0
a2c4b28
975a289
0abc30d
590b8a6
a8529b5
6468fc5
5bb907a
efa6ad2
5a9cb2d
f6b391d
c93989b
fa42d1a
ca9bcfe
5d72b03
843ff3d
4b06c4a
03d091d
dbd5e85
11b9bd2
5bfd758
e0a0812
148144f
ee6612d
7e475c8
2ee60f9
f7bf1bd
f31cd14
ec4c6eb
44507f0
6840bec
dc7f85f
382454f
3c577bf
bc62d28
6e6d303
1ab5efb
e56e821
cd60d76
438bf45
4e71351
f52b14b
11ec5fb
7ab7387
4e1628d
7cab9e5
7745a79
98072d7
726e153
d01c738
a0819f9
ede2690
90096e7
d719600
551a40f
5fa72f2
3b97a57
31007ea
ec9add9
2d99233
2e53815
08746a5
01f5412
9892f0e
7f57d49
b2fca53
1feddf3
dfd8f01
48aaf04
2af5c65
75efbc8
7e1b2b9
6319f6e
a9f3391
f8591ac
0f5c6a3
bc5999a
255e604
74a2dc8
e107d48
d119af4
3734edc
2262207
e74563f
104787b
1ea4930
75e8333
6976cc4
e9e0a1b
8374715
97e8b1d
6d38cb3
f418236
027e75c
664a35a
bced847
8aa1cf9
56d9c8b
35dc9f8
f488b8d
c7ee8f6
94e358e
1c3fd54
a7d8cbc
6285377
224f89a
a312168
a8c67e2
7025bf9
317d7aa
4591957
9185d0e
ea4a66c
e9d9cc2
ea82341
1ed8707
c1eb6dc
c4cfcf0
a8df966
ead4dec
20fb173
550bb03
b151c8b
501dbb2
70f70b7
bb1d7c8
a634e2c
5b66ea7
1fcf5f5
2fb2529
ef20348
1116acf
8d637bb
8e7a7af
571291c
21f7406
019de5e
c553e20
0018222
a45bb29
845a307
de183ff
49b86f7
e320b1e
4fed1e6
4df8705
5035cd2
0d3b03a
440e370
6b8fd4f
e823326
6b5a666
a8c6e53
455e945
30343a3
18960df
27d0737
1541dd2
6eefc3f
fec350b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| package node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "testing" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "time" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "github.com/stretchr/testify/require" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func TestBasicExecutionFlow(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require := require.New(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Setup node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node, cleanup := setupTestNodeWithCleanup(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defer cleanup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //startNodeWithCleanup(t, node) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ctx := context.Background() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Give node time to initialize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| time.Sleep(100 * time.Millisecond) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Test InitChain - we don't need to call this explicitly as it's done during node start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| executor := node.blockManager.GetExecutor() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NotNil(executor) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Test GetTxs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| txs, err := executor.GetTxs(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lastState, err := node.Store.GetState(ctx) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Test ExecuteTxs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newStateRoot, newMaxBytes, err := executor.ExecuteTxs(ctx, txs, 1, time.Now(), lastState.LastResultsHash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Greater(newMaxBytes, uint64(0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Logf("newStateRoot: %s %d", newStateRoot, newMaxBytes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NotEmpty(newStateRoot) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Test SetFinal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err = executor.SetFinal(ctx, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func TestExecutionWithDASync(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Run("basic DA sync", func(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require := require.New(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Setup node with mock DA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| node, cleanup := setupTestNodeWithCleanup(t) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defer cleanup() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Start node | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err := node.Start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defer func() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err := node.Stop() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+109
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Potential race condition in error handling The error channel has a buffer size of 1, but there's no guarantee it won't fill up if multiple errors occur. Consider using a context with cancel or a done channel to signal test failure immediately: - errCh := make(chan error, 1)
+ errCh := make(chan error)
wg.Add(1)
go func() {
defer wg.Done()
err := node.Run(ctx)
- select {
- case errCh <- err:
- default:
- t.Logf("Error channel full, discarding error: %v", err)
- }
+ if err != nil && !errors.Is(err, context.Canceled) {
+ errCh <- err
+ }
}()
+
+ // Use a separate goroutine to monitor for errors
+ go func() {
+ select {
+ case err := <-errCh:
+ t.Errorf("Node stopped unexpectedly: %v", err)
+ cancel() // Stop the test
+ case <-ctx.Done():
+ // Test is ending normally
+ }
+ }()📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Give node time to initialize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| time.Sleep(100 * time.Millisecond) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Verify DA client is working | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NotNil(node.dalc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Wait for first block to be produced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err = waitForFirstBlock(node, Header) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+143
to
+144
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined function and variable The - err = waitForFirstBlock(node, Header)
+ err = waitForFirstBlock(node)You need to either:
📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Get height and verify it's greater than 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height, err := getNodeHeight(node, Header) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.NoError(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+147
to
+148
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined function and variable Similar to the previous issue, - height, err := getNodeHeight(node, Header)
+ height, err := getNodeHeight(node)📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require.Greater(height, uint64(0)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Reference to undefined test setup function
The
setupTestNodeWithCleanupfunction is called but not defined in this file. This might be confusing for new developers.Check if this function is defined in another test file, and consider either adding a comment pointing to its location or moving the function definition to this file.
🏁 Script executed:
Length of output: 133
Action: Clarify the External Test Helper Location
The function
setupTestNodeWithCleanup(t)is indeed defined—innode/helpers_test.go. However, its external location might still confuse new contributors. To address this:node/execution_test.go(lines 20-21) where the function is called, add a brief comment noting that its definition lives innode/helpers_test.go.