1
- package archway
1
+ package wasm
2
2
3
3
import (
4
4
"bytes"
@@ -23,10 +23,10 @@ import (
23
23
"golang.org/x/sync/errgroup"
24
24
)
25
25
26
- type ArchwayChainProcessor struct {
26
+ type WasmChainProcessor struct {
27
27
log * zap.Logger
28
28
29
- chainProvider * ArchwayProvider
29
+ chainProvider * WasmProvider
30
30
31
31
pathProcessors processor.PathProcessors
32
32
@@ -64,8 +64,8 @@ type Verifier struct {
64
64
Header * types.LightBlock
65
65
}
66
66
67
- func NewArchwayChainProcessor (log * zap.Logger , provider * ArchwayProvider , metrics * processor.PrometheusMetrics ) * ArchwayChainProcessor {
68
- return & ArchwayChainProcessor {
67
+ func NewWasmChainProcessor (log * zap.Logger , provider * WasmProvider , metrics * processor.PrometheusMetrics ) * WasmChainProcessor {
68
+ return & WasmChainProcessor {
69
69
log : log .With (zap .String ("chain_name" , provider .ChainName ()), zap .String ("chain_id" , provider .ChainId ())),
70
70
chainProvider : provider ,
71
71
latestClientState : make (latestClientState ),
@@ -92,7 +92,7 @@ const (
92
92
// latestClientState is a map of clientID to the latest clientInfo for that client.
93
93
type latestClientState map [string ]provider.ClientState
94
94
95
- func (l latestClientState ) update (ctx context.Context , clientInfo clientInfo , ccp * ArchwayChainProcessor ) {
95
+ func (l latestClientState ) update (ctx context.Context , clientInfo clientInfo , ccp * WasmChainProcessor ) {
96
96
existingClientInfo , ok := l [clientInfo .clientID ]
97
97
var trustingPeriod time.Duration
98
98
if ok {
@@ -122,19 +122,19 @@ func (l latestClientState) update(ctx context.Context, clientInfo clientInfo, cc
122
122
}
123
123
124
124
// Provider returns the ChainProvider, which provides the methods for querying, assembling IBC messages, and sending transactions.
125
- func (ccp * ArchwayChainProcessor ) Provider () provider.ChainProvider {
125
+ func (ccp * WasmChainProcessor ) Provider () provider.ChainProvider {
126
126
return ccp .chainProvider
127
127
}
128
128
129
129
// Set the PathProcessors that this ChainProcessor should publish relevant IBC events to.
130
130
// ChainProcessors need reference to their PathProcessors and vice-versa, handled by EventProcessorBuilder.Build().
131
- func (ccp * ArchwayChainProcessor ) SetPathProcessors (pathProcessors processor.PathProcessors ) {
131
+ func (ccp * WasmChainProcessor ) SetPathProcessors (pathProcessors processor.PathProcessors ) {
132
132
ccp .pathProcessors = pathProcessors
133
133
}
134
134
135
135
// latestHeightWithRetry will query for the latest height, retrying in case of failure.
136
136
// It will delay by latestHeightQueryRetryDelay between attempts, up to latestHeightQueryRetries.
137
- func (ccp * ArchwayChainProcessor ) latestHeightWithRetry (ctx context.Context ) (latestHeight int64 , err error ) {
137
+ func (ccp * WasmChainProcessor ) latestHeightWithRetry (ctx context.Context ) (latestHeight int64 , err error ) {
138
138
return latestHeight , retry .Do (func () error {
139
139
latestHeightQueryCtx , cancelLatestHeightQueryCtx := context .WithTimeout (ctx , queryTimeout )
140
140
defer cancelLatestHeightQueryCtx ()
@@ -153,7 +153,7 @@ func (ccp *ArchwayChainProcessor) latestHeightWithRetry(ctx context.Context) (la
153
153
154
154
// nodeStatusWithRetry will query for the latest node status, retrying in case of failure.
155
155
// It will delay by latestHeightQueryRetryDelay between attempts, up to latestHeightQueryRetries.
156
- func (ccp * ArchwayChainProcessor ) nodeStatusWithRetry (ctx context.Context ) (status * ctypes.ResultStatus , err error ) {
156
+ func (ccp * WasmChainProcessor ) nodeStatusWithRetry (ctx context.Context ) (status * ctypes.ResultStatus , err error ) {
157
157
return status , retry .Do (func () error {
158
158
latestHeightQueryCtx , cancelLatestHeightQueryCtx := context .WithTimeout (ctx , queryTimeout )
159
159
defer cancelLatestHeightQueryCtx ()
@@ -172,7 +172,7 @@ func (ccp *ArchwayChainProcessor) nodeStatusWithRetry(ctx context.Context) (stat
172
172
173
173
// clientState will return the most recent client state if client messages
174
174
// have already been observed for the clientID, otherwise it will query for it.
175
- func (ccp * ArchwayChainProcessor ) clientState (ctx context.Context , clientID string ) (provider.ClientState , error ) {
175
+ func (ccp * WasmChainProcessor ) clientState (ctx context.Context , clientID string ) (provider.ClientState , error ) {
176
176
if state , ok := ccp .latestClientState [clientID ]; ok && state .TrustingPeriod > 0 {
177
177
return state , nil
178
178
}
@@ -198,8 +198,8 @@ type queryCyclePersistence struct {
198
198
balanceUpdateWaitDuration time.Duration
199
199
}
200
200
201
- func (ccp * ArchwayChainProcessor ) StartFromHeight (ctx context.Context ) int {
202
- cfg := ccp .Provider ().ProviderConfig ().(* ArchwayProviderConfig )
201
+ func (ccp * WasmChainProcessor ) StartFromHeight (ctx context.Context ) int {
202
+ cfg := ccp .Provider ().ProviderConfig ().(* WasmProviderConfig )
203
203
if cfg .StartHeight != 0 {
204
204
return int (cfg .StartHeight )
205
205
}
@@ -215,7 +215,7 @@ func (ccp *ArchwayChainProcessor) StartFromHeight(ctx context.Context) int {
215
215
// Run starts the query loop for the chain which will gather applicable ibc messages and push events out to the relevant PathProcessors.
216
216
// The initialBlockHistory parameter determines how many historical blocks should be fetched and processed before continuing with current blocks.
217
217
// ChainProcessors should obey the context and return upon context cancellation.
218
- func (ccp * ArchwayChainProcessor ) Run (ctx context.Context , initialBlockHistory uint64 ) error {
218
+ func (ccp * WasmChainProcessor ) Run (ctx context.Context , initialBlockHistory uint64 ) error {
219
219
// this will be used for persistence across query cycle loop executions
220
220
persistence := queryCyclePersistence {
221
221
minQueryLoopDuration : defaultMinQueryLoopDuration ,
@@ -278,7 +278,7 @@ func (ccp *ArchwayChainProcessor) Run(ctx context.Context, initialBlockHistory u
278
278
return err
279
279
}
280
280
281
- ccp .log .Debug ("Entering Archway main query loop" )
281
+ ccp .log .Debug ("Entering Wasm main query loop" )
282
282
283
283
ticker := time .NewTicker (persistence .minQueryLoopDuration )
284
284
defer ticker .Stop ()
@@ -297,7 +297,7 @@ func (ccp *ArchwayChainProcessor) Run(ctx context.Context, initialBlockHistory u
297
297
}
298
298
299
299
// initializeConnectionState will bootstrap the connectionStateCache with the open connection state.
300
- func (ccp * ArchwayChainProcessor ) initializeConnectionState (ctx context.Context ) error {
300
+ func (ccp * WasmChainProcessor ) initializeConnectionState (ctx context.Context ) error {
301
301
ctx , cancel := context .WithTimeout (ctx , queryTimeout )
302
302
defer cancel ()
303
303
connections , err := ccp .chainProvider .QueryConnections (ctx )
@@ -317,7 +317,7 @@ func (ccp *ArchwayChainProcessor) initializeConnectionState(ctx context.Context)
317
317
}
318
318
319
319
// initializeChannelState will bootstrap the channelStateCache with the open channel state.
320
- func (ccp * ArchwayChainProcessor ) initializeChannelState (ctx context.Context ) error {
320
+ func (ccp * WasmChainProcessor ) initializeChannelState (ctx context.Context ) error {
321
321
ctx , cancel := context .WithTimeout (ctx , queryTimeout )
322
322
defer cancel ()
323
323
channels , err := ccp .chainProvider .QueryChannels (ctx )
@@ -344,11 +344,10 @@ func (ccp *ArchwayChainProcessor) initializeChannelState(ctx context.Context) er
344
344
return nil
345
345
}
346
346
347
- func (ccp * ArchwayChainProcessor ) queryCycle (ctx context.Context , persistence * queryCyclePersistence ) error {
348
- // TODO : review if redundent remove
347
+ func (ccp * WasmChainProcessor ) queryCycle (ctx context.Context , persistence * queryCyclePersistence ) error {
349
348
status , err := ccp .nodeStatusWithRetry (ctx )
350
349
if err != nil {
351
- // don't want to cause ArchwayChainProcessor to quit here, can retry again next cycle.
350
+ // don't want to cause WasmChainProcessor to quit here, can retry again next cycle.
352
351
ccp .log .Error (
353
352
"Failed to query node status after max attempts" ,
354
353
zap .Uint ("attempts" , latestHeightQueryRetries ),
@@ -420,7 +419,7 @@ func (ccp *ArchwayChainProcessor) queryCycle(ctx context.Context, persistence *q
420
419
}
421
420
422
421
if err := ccp .Verify (ctx , lightBlock ); err != nil {
423
- ccp .log .Error ("failed to Verify Archway Header" , zap .Int64 ("Height" , blockRes .Height ))
422
+ ccp .log .Error ("failed to Verify Wasm Header" , zap .Int64 ("Height" , blockRes .Height ))
424
423
return err
425
424
}
426
425
@@ -496,7 +495,7 @@ func (ccp *ArchwayChainProcessor) queryCycle(ctx context.Context, persistence *q
496
495
return nil
497
496
}
498
497
499
- func (ccp * ArchwayChainProcessor ) SnapshotHeight (height int ) {
498
+ func (ccp * WasmChainProcessor ) SnapshotHeight (height int ) {
500
499
501
500
blockInterval := ccp .Provider ().ProviderConfig ().GetBlockInterval ()
502
501
snapshotThreshold := common .ONE_HOUR / int (blockInterval )
@@ -512,7 +511,7 @@ func (ccp *ArchwayChainProcessor) SnapshotHeight(height int) {
512
511
}
513
512
}
514
513
515
- func (ccp * ArchwayChainProcessor ) CollectMetrics (ctx context.Context , persistence * queryCyclePersistence ) {
514
+ func (ccp * WasmChainProcessor ) CollectMetrics (ctx context.Context , persistence * queryCyclePersistence ) {
516
515
ccp .CurrentBlockHeight (ctx , persistence )
517
516
518
517
// Wait a while before updating the balance
@@ -522,11 +521,11 @@ func (ccp *ArchwayChainProcessor) CollectMetrics(ctx context.Context, persistenc
522
521
}
523
522
}
524
523
525
- func (ccp * ArchwayChainProcessor ) CurrentBlockHeight (ctx context.Context , persistence * queryCyclePersistence ) {
524
+ func (ccp * WasmChainProcessor ) CurrentBlockHeight (ctx context.Context , persistence * queryCyclePersistence ) {
526
525
ccp .metrics .SetLatestHeight (ccp .chainProvider .ChainId (), persistence .latestHeight )
527
526
}
528
527
529
- func (ccp * ArchwayChainProcessor ) Verify (ctx context.Context , untrusted * types.LightBlock ) error {
528
+ func (ccp * WasmChainProcessor ) Verify (ctx context.Context , untrusted * types.LightBlock ) error {
530
529
531
530
if untrusted .Height != ccp .verifier .Header .Height + 1 {
532
531
return errors .New ("headers must be adjacent in height" )
@@ -607,7 +606,7 @@ func verifyNewHeaderAndVals(
607
606
return nil
608
607
}
609
608
610
- // func (ccp *ArchwayChainProcessor ) CurrentRelayerBalance(ctx context.Context) {
609
+ // func (ccp *WasmChainProcessor ) CurrentRelayerBalance(ctx context.Context) {
611
610
// // memoize the current gas prices to only show metrics for "interesting" denoms
612
611
// if ccp.parsedGasPrices == nil {
613
612
// gp, err := sdk.ParseDecCoins(ccp.chainProvider.PCfg.GasPrices)
0 commit comments