@@ -22,7 +22,7 @@ import {
22
22
VanillaRuntimeModules ,
23
23
UInt64 ,
24
24
} from "@proto-kit/library" ;
25
- import { log } from "@proto-kit/common" ;
25
+ import { log , mapSequential , range } from "@proto-kit/common" ;
26
26
import {
27
27
BatchProducerModule ,
28
28
InMemoryDatabase ,
@@ -35,6 +35,7 @@ import {
35
35
BlockProducerModule ,
36
36
VanillaTaskWorkerModules ,
37
37
SequencerStartupModule ,
38
+ TimedBlockTrigger ,
38
39
} from "@proto-kit/sequencer" ;
39
40
import {
40
41
BatchStorageResolver ,
@@ -45,6 +46,7 @@ import {
45
46
NodeStatusResolver ,
46
47
QueryGraphqlModule ,
47
48
BlockResolver ,
49
+ OpenTelemetryServer ,
48
50
} from "@proto-kit/api" ;
49
51
import { container } from "tsyringe" ;
50
52
@@ -103,16 +105,19 @@ export async function startServer() {
103
105
modules : {
104
106
Database : InMemoryDatabase ,
105
107
// Database: PrismaRedisDatabase,
108
+ OpenTelemetryServer,
106
109
107
110
Mempool : PrivateMempool ,
108
111
GraphqlServer,
109
112
LocalTaskWorkerModule : LocalTaskWorkerModule . from (
110
113
VanillaTaskWorkerModules . withoutSettlement ( )
111
114
) ,
115
+
112
116
BaseLayer : NoopBaseLayer ,
113
117
BatchProducerModule,
114
118
BlockProducerModule,
115
- BlockTrigger : ManualBlockTrigger ,
119
+ // BlockTrigger: ManualBlockTrigger,
120
+ BlockTrigger : TimedBlockTrigger ,
116
121
TaskQueue : LocalTaskQueue ,
117
122
// SettlementModule: SettlementModule,
118
123
@@ -135,6 +140,7 @@ export async function startServer() {
135
140
BlockResolver : { } ,
136
141
} ,
137
142
} ) ,
143
+
138
144
SequencerStartupModule,
139
145
} ,
140
146
} ) ,
@@ -189,6 +195,8 @@ export async function startServer() {
189
195
MerkleWitnessResolver : { } ,
190
196
} ,
191
197
198
+ OpenTelemetryServer : { } ,
199
+
192
200
Database : {
193
201
// redis: {
194
202
// host: "localhost",
@@ -218,7 +226,10 @@ export async function startServer() {
218
226
allowEmptyBlock : true ,
219
227
} ,
220
228
221
- BlockTrigger : { } ,
229
+ BlockTrigger : {
230
+ blockInterval : 10000 ,
231
+ settlementInterval : 20000 ,
232
+ } ,
222
233
} ,
223
234
224
235
TransactionSender : { } ,
@@ -246,30 +257,31 @@ export async function startServer() {
246
257
const as = await appChain . query . protocol . AccountState . accountState . get (
247
258
priv . toPublicKey ( )
248
259
) ;
249
- const nonce = Number ( as ?. nonce . toString ( ) ?? "0" ) ;
250
-
251
- const tx = await appChain . transaction (
252
- priv . toPublicKey ( ) ,
253
- async ( ) => {
254
- await balances . addBalance ( tokenId , priv . toPublicKey ( ) , UInt64 . from ( 1000 ) ) ;
255
- } ,
256
- {
257
- nonce,
258
- }
259
- ) ;
260
- appChain . resolve ( "Signer" ) . config . signer = priv ;
261
- await tx . sign ( ) ;
262
- await tx . send ( ) ;
263
-
264
- const tx2 = await appChain . transaction (
265
- priv . toPublicKey ( ) ,
266
- async ( ) => {
267
- await balances . addBalance ( tokenId , priv . toPublicKey ( ) , UInt64 . from ( 1000 ) ) ;
268
- } ,
269
- { nonce : nonce + 1 }
270
- ) ;
271
- await tx2 . sign ( ) ;
272
- await tx2 . send ( ) ;
260
+ let nonce = Number ( as ?. nonce . toString ( ) ?? "0" ) ;
261
+
262
+ setInterval ( async ( ) => {
263
+ const random = Math . floor ( Math . random ( ) * 5 ) ;
264
+ await mapSequential ( range ( 0 , random ) , async ( ) => {
265
+ const tx = await appChain . transaction (
266
+ priv . toPublicKey ( ) ,
267
+ async ( ) => {
268
+ await balances . addBalance (
269
+ tokenId ,
270
+ priv . toPublicKey ( ) ,
271
+ UInt64 . from ( 1000 )
272
+ ) ;
273
+ } ,
274
+ {
275
+ nonce,
276
+ }
277
+ ) ;
278
+ appChain . resolve ( "Signer" ) . config . signer = priv ;
279
+ await tx . sign ( ) ;
280
+ await tx . send ( ) ;
281
+
282
+ nonce += 1 ;
283
+ } ) ;
284
+ } , 10000 ) ;
273
285
274
286
return appChain ;
275
287
}
0 commit comments