• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

razor-network / oracle-node / 11380926803

17 Oct 2024 08:09AM UTC coverage: 80.35% (-0.02%) from 80.365%
11380926803

push

github

web-flow
feat: added commitment verification layer for data during reveal after removing waitForBlockCompletion check for voting transactions (#1254)

* refactor: added verification layer on commit data from memory

* refactor: removed waitForBlockCompletion from propose and reveal

* fix: returned err instead of nil in GetConfirmedBlock

* reafctor: fixed tests

* refactor: fixed lint errors

* fix: returned supported struct type and added a condition to attempt confirmBlock when node just started voting

* refactor: fixed tests after rebasing

* refactor: removed commented unwanted tests

* refactor: Fetched selected commit data first and than applied commitment verification

* feat: saved commitment in the memory/file along with commit data and reused it in reveal

135 of 152 new or added lines in 6 files covered. (88.82%)

7 existing lines in 1 file now uncovered.

6559 of 8163 relevant lines covered (80.35%)

477.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.44
/utils/struct-utils.go
1
package utils
2

3
import (
4
        "context"
5
        "crypto/ecdsa"
6
        "encoding/json"
7
        "errors"
8
        "io"
9
        "io/fs"
10
        "math/big"
11
        "os"
12
        "razor/client"
13
        "razor/core"
14
        coretypes "razor/core/types"
15
        "razor/path"
16
        "razor/pkg/bindings"
17
        "reflect"
18
        "time"
19

20
        "github.com/avast/retry-go"
21
        "github.com/ethereum/go-ethereum"
22
        "github.com/ethereum/go-ethereum/accounts/abi"
23
        "github.com/ethereum/go-ethereum/accounts/abi/bind"
24
        "github.com/ethereum/go-ethereum/common"
25
        "github.com/ethereum/go-ethereum/core/types"
26
        "github.com/ethereum/go-ethereum/ethclient"
27
        "github.com/spf13/pflag"
28
)
29

30
var RPCTimeout int64
31

32
func StartRazor(optionsPackageStruct OptionsPackageStruct) Utils {
238✔
33
        UtilsInterface = optionsPackageStruct.UtilsInterface
238✔
34
        EthClient = optionsPackageStruct.EthClient
238✔
35
        ClientInterface = optionsPackageStruct.ClientInterface
238✔
36
        Time = optionsPackageStruct.Time
238✔
37
        OS = optionsPackageStruct.OS
238✔
38
        CoinInterface = optionsPackageStruct.CoinInterface
238✔
39
        IOInterface = optionsPackageStruct.IOInterface
238✔
40
        ABIInterface = optionsPackageStruct.ABIInterface
238✔
41
        PathInterface = optionsPackageStruct.PathInterface
238✔
42
        BindInterface = optionsPackageStruct.BindInterface
238✔
43
        BlockManagerInterface = optionsPackageStruct.BlockManagerInterface
238✔
44
        StakeManagerInterface = optionsPackageStruct.StakeManagerInterface
238✔
45
        AssetManagerInterface = optionsPackageStruct.AssetManagerInterface
238✔
46
        VoteManagerInterface = optionsPackageStruct.VoteManagerInterface
238✔
47
        BindingsInterface = optionsPackageStruct.BindingsInterface
238✔
48
        JsonInterface = optionsPackageStruct.JsonInterface
238✔
49
        StakedTokenInterface = optionsPackageStruct.StakedTokenInterface
238✔
50
        RetryInterface = optionsPackageStruct.RetryInterface
238✔
51
        MerkleInterface = optionsPackageStruct.MerkleInterface
238✔
52
        FlagSetInterface = optionsPackageStruct.FlagSetInterface
238✔
53
        FileInterface = optionsPackageStruct.FileInterface
238✔
54
        GasInterface = optionsPackageStruct.GasInterface
238✔
55
        return &UtilsStruct{}
238✔
56
}
238✔
57

58
func InvokeFunctionWithTimeout(interfaceName interface{}, methodName string, args ...interface{}) []reflect.Value {
×
59
        var functionCall []reflect.Value
×
60
        var gotFunction = make(chan bool)
×
61
        ctx, cancel := context.WithTimeout(context.Background(), time.Duration(RPCTimeout)*time.Second)
×
62
        defer cancel()
×
63

×
64
        go func() {
×
65
                inputs := make([]reflect.Value, len(args))
×
66
                for i := range args {
×
67
                        inputs[i] = reflect.ValueOf(args[i])
×
68
                }
×
69
                log.Debug("Blockchain function: ", methodName)
×
70
                functionCall = reflect.ValueOf(interfaceName).MethodByName(methodName).Call(inputs)
×
71
                gotFunction <- true
×
72
        }()
73
        for {
×
74
                select {
×
75
                case <-ctx.Done():
×
76
                        log.Errorf("%s function timeout!", methodName)
×
77
                        log.Debug("Kindly check your connection")
×
78
                        return nil
×
79

80
                case <-gotFunction:
×
81
                        return functionCall
×
82
                }
83
        }
84
}
85

86
func CheckIfAnyError(result []reflect.Value) error {
87✔
87
        if result == nil {
87✔
88
                return errors.New("RPC timeout error")
×
89
        }
×
90

91
        errorDataType := reflect.TypeOf((*error)(nil)).Elem()
87✔
92
        errorIndexInReturnedValues := -1
87✔
93

87✔
94
        for i := range result {
260✔
95
                returnedValue := result[i]
173✔
96
                returnedValueDataType := reflect.TypeOf(returnedValue.Interface())
173✔
97
                if returnedValueDataType != nil {
302✔
98
                        if returnedValueDataType.Implements(errorDataType) {
172✔
99
                                errorIndexInReturnedValues = i
43✔
100
                        }
43✔
101
                }
102
        }
103
        if errorIndexInReturnedValues == -1 {
131✔
104
                return nil
44✔
105
        }
44✔
106
        returnedError := result[errorIndexInReturnedValues].Interface()
43✔
107
        if returnedError != nil {
86✔
108
                return returnedError.(error)
43✔
109
        }
43✔
110
        return nil
×
111
}
112

113
func InvokeFunctionWithRetryAttempts(ctx context.Context, interfaceName interface{}, methodName string, args ...interface{}) ([]reflect.Value, error) {
88✔
114
        var returnedValues []reflect.Value
88✔
115
        var err error
88✔
116
        var contextError bool
88✔
117
        inputs := make([]reflect.Value, len(args))
88✔
118
        for i := range args {
268✔
119
                inputs[i] = reflect.ValueOf(args[i])
180✔
120
        }
180✔
121
        alternateProvider := client.GetAlternateProvider()
88✔
122
        switchToAlternateClient := client.GetSwitchToAlternateClientStatus()
88✔
123
        if switchToAlternateClient && alternateProvider != "" {
88✔
124
                // Changing client argument to alternate client
×
125
                log.Debug("Making this RPC call using alternate RPC provider!")
×
126
                inputs = client.ReplaceClientWithAlternateClient(inputs)
×
127
        }
×
128
        err = retry.Do(
88✔
129
                func() error {
176✔
130
                        // Check if the context has been cancelled or timed out
88✔
131
                        select {
88✔
132
                        case <-ctx.Done():
1✔
133
                                // If context is done, return the context error timeout
1✔
134
                                log.Debugf("Context timed out for method: %s", methodName)
1✔
135
                                contextError = true
1✔
136
                                return retry.Unrecoverable(ctx.Err())
1✔
137
                        default:
87✔
138
                                // Proceed with the RPC call
87✔
139
                                returnedValues = reflect.ValueOf(interfaceName).MethodByName(methodName).Call(inputs)
87✔
140
                                err = CheckIfAnyError(returnedValues)
87✔
141
                                if err != nil {
130✔
142
                                        log.Debug("Function to retry: ", methodName)
43✔
143
                                        log.Errorf("Error in %v....Retrying", methodName)
43✔
144
                                        return err
43✔
145
                                }
43✔
146
                                return nil
44✔
147
                        }
148
                }, RetryInterface.RetryAttempts(core.MaxRetries), retry.Delay(time.Second*time.Duration(core.RetryDelayDuration)), retry.DelayType(retry.FixedDelay))
149
        if err != nil {
132✔
150
                if contextError {
45✔
151
                        // Skip the alternate client switch when the error is context-related
1✔
152
                        log.Warnf("Skipping alternate client switch due to context error: %v", err)
1✔
153
                        return returnedValues, err
1✔
154
                }
1✔
155
                if !switchToAlternateClient && alternateProvider != "" {
43✔
156
                        log.Errorf("%v error after retries: %v", methodName, err)
×
157
                        log.Info("Switching RPC to alternate RPC")
×
158
                        client.SetSwitchToAlternateClientStatus(true)
×
159
                        go client.StartTimerForAlternateClient(core.SwitchClientDuration)
×
160
                }
×
161
        }
162
        return returnedValues, err
87✔
163
}
164

165
func (b BlockManagerStruct) GetBlockIndexToBeConfirmed(client *ethclient.Client) (int8, error) {
×
166
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
167
        returnedValues := InvokeFunctionWithTimeout(blockManager, "BlockIndexToBeConfirmed", &opts)
×
168
        returnedError := CheckIfAnyError(returnedValues)
×
169
        if returnedError != nil {
×
170
                return -1, returnedError
×
171
        }
×
172
        return returnedValues[0].Interface().(int8), nil
×
173
}
174

175
func (s StakeManagerStruct) WithdrawInitiationPeriod(client *ethclient.Client) (uint16, error) {
×
176
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
177
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "WithdrawInitiationPeriod", &opts)
×
178
        returnedError := CheckIfAnyError(returnedValues)
×
179
        if returnedError != nil {
×
180
                return 0, returnedError
×
181
        }
×
182
        return returnedValues[0].Interface().(uint16), nil
×
183
}
184

185
func (a AssetManagerStruct) GetNumJobs(client *ethclient.Client) (uint16, error) {
×
186
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
187
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetNumJobs", &opts)
×
188
        returnedError := CheckIfAnyError(returnedValues)
×
189
        if returnedError != nil {
×
190
                return 0, returnedError
×
191
        }
×
192
        return returnedValues[0].Interface().(uint16), nil
×
193
}
194

195
func (a AssetManagerStruct) GetCollection(client *ethclient.Client, id uint16) (bindings.StructsCollection, error) {
×
196
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
197
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetCollection", &opts, id)
×
198
        returnedError := CheckIfAnyError(returnedValues)
×
199
        if returnedError != nil {
×
200
                return bindings.StructsCollection{}, returnedError
×
201
        }
×
202
        return returnedValues[0].Interface().(bindings.StructsCollection), nil
×
203
}
204

205
func (a AssetManagerStruct) GetJob(client *ethclient.Client, id uint16) (bindings.StructsJob, error) {
×
206
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
207
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetJob", &opts, id)
×
208
        returnedError := CheckIfAnyError(returnedValues)
×
209
        if returnedError != nil {
×
210
                return bindings.StructsJob{}, returnedError
×
211
        }
×
212
        return returnedValues[0].Interface().(bindings.StructsJob), nil
×
213
}
214

215
func (a AssetManagerStruct) GetCollectionIdFromIndex(client *ethclient.Client, index uint16) (uint16, error) {
×
216
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
217
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "LeafIdToCollectionIdRegistry", &opts, index)
×
218
        returnedError := CheckIfAnyError(returnedValues)
×
219
        if returnedError != nil {
×
220
                return 0, returnedError
×
221
        }
×
222
        return returnedValues[0].Interface().(uint16), nil
×
223
}
224

225
func (a AssetManagerStruct) GetCollectionIdFromLeafId(client *ethclient.Client, leafId uint16) (uint16, error) {
×
226
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
227
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetCollectionIdFromLeafId", &opts, leafId)
×
228
        returnedError := CheckIfAnyError(returnedValues)
×
229
        if returnedError != nil {
×
230
                return 0, returnedError
×
231
        }
×
232
        return returnedValues[0].Interface().(uint16), nil
×
233
}
234

235
func (a AssetManagerStruct) GetLeafIdOfACollection(client *ethclient.Client, collectionId uint16) (uint16, error) {
×
236
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
237
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetLeafIdOfCollection", &opts, collectionId)
×
238
        returnedError := CheckIfAnyError(returnedValues)
×
239
        if returnedError != nil {
×
240
                return 0, returnedError
×
241
        }
×
242
        return returnedValues[0].Interface().(uint16), nil
×
243
}
244

245
func (v VoteManagerStruct) ToAssign(client *ethclient.Client) (uint16, error) {
×
246
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
247
        returnedValues := InvokeFunctionWithTimeout(voteManager, "ToAssign", &opts)
×
248
        returnedError := CheckIfAnyError(returnedValues)
×
249
        if returnedError != nil {
×
250
                return 0, returnedError
×
251
        }
×
252
        return returnedValues[0].Interface().(uint16), nil
×
253
}
254

255
func (v VoteManagerStruct) GetSaltFromBlockchain(client *ethclient.Client) ([32]byte, error) {
×
256
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
257
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetSalt", &opts)
×
258
        returnedError := CheckIfAnyError(returnedValues)
×
259
        if returnedError != nil {
×
260
                return [32]byte{}, returnedError
×
261
        }
×
262
        return returnedValues[0].Interface().([32]byte), nil
×
263
}
264

265
func (b BlockManagerStruct) GetNumProposedBlocks(client *ethclient.Client, epoch uint32) (uint8, error) {
×
266
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
267
        returnedValues := InvokeFunctionWithTimeout(blockManager, "GetNumProposedBlocks", &opts, epoch)
×
268
        returnedError := CheckIfAnyError(returnedValues)
×
269
        if returnedError != nil {
×
270
                return 0, returnedError
×
271
        }
×
272
        return returnedValues[0].Interface().(uint8), nil
×
273
}
274

275
func (b BlockManagerStruct) GetProposedBlock(client *ethclient.Client, epoch uint32, proposedBlock uint32) (bindings.StructsBlock, error) {
×
276
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
277
        returnedValues := InvokeFunctionWithTimeout(blockManager, "GetProposedBlock", &opts, epoch, proposedBlock)
×
278
        returnedError := CheckIfAnyError(returnedValues)
×
279
        if returnedError != nil {
×
280
                return bindings.StructsBlock{}, returnedError
×
281
        }
×
282
        return returnedValues[0].Interface().(bindings.StructsBlock), nil
×
283
}
284

285
func (b BlockManagerStruct) GetBlock(client *ethclient.Client, epoch uint32) (bindings.StructsBlock, error) {
×
286
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
287
        returnedValues := InvokeFunctionWithTimeout(blockManager, "GetBlock", &opts, epoch)
×
288
        returnedError := CheckIfAnyError(returnedValues)
×
289
        if returnedError != nil {
×
290
                return bindings.StructsBlock{}, returnedError
×
291
        }
×
292
        return returnedValues[0].Interface().(bindings.StructsBlock), nil
×
293
}
294

295
func (b BlockManagerStruct) MinStake(client *ethclient.Client) (*big.Int, error) {
×
296
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
297
        returnedValues := InvokeFunctionWithTimeout(blockManager, "MinStake", &opts)
×
298
        returnedError := CheckIfAnyError(returnedValues)
×
299
        if returnedError != nil {
×
300
                return nil, returnedError
×
301
        }
×
302
        return returnedValues[0].Interface().(*big.Int), nil
×
303
}
304

305
func (b BlockManagerStruct) StateBuffer(client *ethclient.Client) (uint8, error) {
×
306
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
307
        returnedValues := InvokeFunctionWithTimeout(blockManager, "Buffer", &opts)
×
308
        returnedError := CheckIfAnyError(returnedValues)
×
309
        if returnedError != nil {
×
310
                return 0, returnedError
×
311
        }
×
312
        return returnedValues[0].Interface().(uint8), nil
×
313
}
314

315
func (b BlockManagerStruct) MaxAltBlocks(client *ethclient.Client) (uint8, error) {
×
316
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
317
        returnedValues := InvokeFunctionWithTimeout(blockManager, "MaxAltBlocks", &opts)
×
318
        returnedError := CheckIfAnyError(returnedValues)
×
319
        if returnedError != nil {
×
320
                return 0, returnedError
×
321
        }
×
322
        return returnedValues[0].Interface().(uint8), nil
×
323
}
324

325
func (b BlockManagerStruct) SortedProposedBlockIds(client *ethclient.Client, arg0 uint32, arg1 *big.Int) (uint32, error) {
×
326
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
327
        returnedValues := InvokeFunctionWithTimeout(blockManager, "SortedProposedBlockIds", &opts, arg0, arg1)
×
328
        returnedError := CheckIfAnyError(returnedValues)
×
329
        if returnedError != nil {
×
330
                return 0, returnedError
×
331
        }
×
332
        return returnedValues[0].Interface().(uint32), nil
×
333
}
334

335
func (b BlockManagerStruct) GetEpochLastProposed(client *ethclient.Client, stakerId uint32) (uint32, error) {
×
336
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
337
        returnedValues := InvokeFunctionWithTimeout(blockManager, "EpochLastProposed", &opts, stakerId)
×
338
        returnedError := CheckIfAnyError(returnedValues)
×
339
        if returnedError != nil {
×
340
                return 0, returnedError
×
341
        }
×
342
        return returnedValues[0].Interface().(uint32), nil
×
343
}
344

NEW
345
func (b BlockManagerStruct) GetConfirmedBlocks(client *ethclient.Client, epoch uint32) (coretypes.ConfirmedBlock, error) {
×
NEW
346
        blockManager, opts := UtilsInterface.GetBlockManagerWithOpts(client)
×
NEW
347
        returnedValues := InvokeFunctionWithTimeout(blockManager, "Blocks", &opts, epoch)
×
NEW
348
        returnedError := CheckIfAnyError(returnedValues)
×
NEW
349
        if returnedError != nil {
×
NEW
350
                return coretypes.ConfirmedBlock{}, returnedError
×
NEW
351
        }
×
NEW
352
        return returnedValues[0].Interface().(struct {
×
NEW
353
                Valid        bool
×
NEW
354
                ProposerId   uint32
×
NEW
355
                Iteration    *big.Int
×
NEW
356
                BiggestStake *big.Int
×
NEW
357
        }), nil
×
358
}
359

360
func (s StakeManagerStruct) GetStakerId(client *ethclient.Client, address common.Address) (uint32, error) {
×
361
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
362
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "GetStakerId", &opts, address)
×
363
        returnedError := CheckIfAnyError(returnedValues)
×
364
        if returnedError != nil {
×
365
                return 0, returnedError
×
366
        }
×
367
        return returnedValues[0].Interface().(uint32), nil
×
368
}
369

370
func (s StakeManagerStruct) GetNumStakers(client *ethclient.Client) (uint32, error) {
×
371
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
372
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "GetNumStakers", &opts)
×
373
        returnedError := CheckIfAnyError(returnedValues)
×
374
        if returnedError != nil {
×
375
                return 0, returnedError
×
376
        }
×
377
        return returnedValues[0].Interface().(uint32), nil
×
378
}
379

380
func (s StakeManagerStruct) MinSafeRazor(client *ethclient.Client) (*big.Int, error) {
×
381
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
382
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "MinSafeRazor", &opts)
×
383
        returnedError := CheckIfAnyError(returnedValues)
×
384
        if returnedError != nil {
×
385
                return nil, returnedError
×
386
        }
×
387
        return returnedValues[0].Interface().(*big.Int), nil
×
388
}
389

390
func (s StakeManagerStruct) Locks(client *ethclient.Client, address common.Address, address1 common.Address, lockType uint8) (coretypes.Locks, error) {
×
391
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
392
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "Locks", &opts, address, address1, lockType)
×
393
        returnedError := CheckIfAnyError(returnedValues)
×
394
        if returnedError != nil {
×
395
                return coretypes.Locks{}, returnedError
×
396
        }
×
397
        locks := returnedValues[0].Interface().(struct {
×
398
                Amount      *big.Int
×
399
                UnlockAfter *big.Int
×
400
        })
×
401
        return locks, nil
×
402
}
403

404
func (s StakeManagerStruct) MaxCommission(client *ethclient.Client) (uint8, error) {
×
405
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
406
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "MaxCommission", &opts)
×
407
        returnedError := CheckIfAnyError(returnedValues)
×
408
        if returnedError != nil {
×
409
                return 0, returnedError
×
410
        }
×
411
        return returnedValues[0].Interface().(uint8), nil
×
412
}
413

414
func (s StakeManagerStruct) EpochLimitForUpdateCommission(client *ethclient.Client) (uint16, error) {
×
415
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
416
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "EpochLimitForUpdateCommission", &opts)
×
417
        returnedError := CheckIfAnyError(returnedValues)
×
418
        if returnedError != nil {
×
419
                return 0, returnedError
×
420
        }
×
421
        return returnedValues[0].Interface().(uint16), nil
×
422
}
423

424
func (s StakeManagerStruct) GetStaker(client *ethclient.Client, stakerId uint32) (bindings.StructsStaker, error) {
×
425
        stakeManager, opts := UtilsInterface.GetStakeManagerWithOpts(client)
×
426
        returnedValues := InvokeFunctionWithTimeout(stakeManager, "GetStaker", &opts, stakerId)
×
427
        returnedError := CheckIfAnyError(returnedValues)
×
428
        if returnedError != nil {
×
429
                return bindings.StructsStaker{}, returnedError
×
430
        }
×
431
        return returnedValues[0].Interface().(bindings.StructsStaker), nil
×
432
}
433

434
func (a AssetManagerStruct) GetNumCollections(client *ethclient.Client) (uint16, error) {
×
435
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
436
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetNumCollections", &opts)
×
437
        returnedError := CheckIfAnyError(returnedValues)
×
438
        if returnedError != nil {
×
439
                return 0, returnedError
×
440
        }
×
441
        return returnedValues[0].Interface().(uint16), nil
×
442
}
443

444
func (a AssetManagerStruct) GetNumActiveCollections(client *ethclient.Client) (uint16, error) {
×
445
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
446
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetNumActiveCollections", &opts)
×
447
        returnedError := CheckIfAnyError(returnedValues)
×
448
        if returnedError != nil {
×
449
                return 0, returnedError
×
450
        }
×
451
        return returnedValues[0].Interface().(uint16), nil
×
452
}
453

454
func (a AssetManagerStruct) GetActiveCollections(client *ethclient.Client) ([]uint16, error) {
×
455
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
456
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "GetActiveCollections", &opts)
×
457
        returnedError := CheckIfAnyError(returnedValues)
×
458
        if returnedError != nil {
×
459
                return nil, returnedError
×
460
        }
×
461
        return returnedValues[0].Interface().([]uint16), nil
×
462
}
463

464
func (a AssetManagerStruct) Jobs(client *ethclient.Client, id uint16) (bindings.StructsJob, error) {
×
465
        collectionManager, opts := UtilsInterface.GetCollectionManagerWithOpts(client)
×
466
        returnedValues := InvokeFunctionWithTimeout(collectionManager, "Jobs", &opts, id)
×
467
        returnedError := CheckIfAnyError(returnedValues)
×
468
        if returnedError != nil {
×
469
                return bindings.StructsJob{}, returnedError
×
470
        }
×
471
        job := returnedValues[0].Interface().(struct {
×
472
                Id           uint16
×
473
                SelectorType uint8
×
474
                Weight       uint8
×
475
                Power        int8
×
476
                Name         string
×
477
                Selector     string
×
478
                Url          string
×
479
        })
×
480
        return job, nil
×
481
}
482

483
func (v VoteManagerStruct) GetCommitment(client *ethclient.Client, stakerId uint32) (coretypes.Commitment, error) {
×
484
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
485
        returnedValues := InvokeFunctionWithTimeout(voteManager, "Commitments", &opts, stakerId)
×
486
        returnedError := CheckIfAnyError(returnedValues)
×
487
        if returnedError != nil {
×
488
                return coretypes.Commitment{}, returnedError
×
489
        }
×
490
        commitment := returnedValues[0].Interface().(struct {
×
491
                Epoch          uint32
×
492
                CommitmentHash [32]byte
×
493
        })
×
494
        return commitment, nil
×
495
}
496

497
func (v VoteManagerStruct) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId uint32, medianIndex uint16) (*big.Int, error) {
×
498
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
499
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetVoteValue", &opts, epoch, stakerId, medianIndex)
×
500
        returnedError := CheckIfAnyError(returnedValues)
×
501
        if returnedError != nil {
×
502
                return nil, returnedError
×
503
        }
×
504
        return returnedValues[0].Interface().(*big.Int), nil
×
505
}
506

507
func (v VoteManagerStruct) GetInfluenceSnapshot(client *ethclient.Client, epoch uint32, stakerId uint32) (*big.Int, error) {
×
508
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
509
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetInfluenceSnapshot", &opts, epoch, stakerId)
×
510
        returnedError := CheckIfAnyError(returnedValues)
×
511
        if returnedError != nil {
×
512
                return nil, returnedError
×
513
        }
×
514
        return returnedValues[0].Interface().(*big.Int), nil
×
515
}
516

517
func (v VoteManagerStruct) GetStakeSnapshot(client *ethclient.Client, epoch uint32, stakerId uint32) (*big.Int, error) {
×
518
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
519
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetStakeSnapshot", &opts, epoch, stakerId)
×
520
        returnedError := CheckIfAnyError(returnedValues)
×
521
        if returnedError != nil {
×
522
                return nil, returnedError
×
523
        }
×
524
        return returnedValues[0].Interface().(*big.Int), nil
×
525
}
526

527
func (v VoteManagerStruct) GetTotalInfluenceRevealed(client *ethclient.Client, epoch uint32, medianIndex uint16) (*big.Int, error) {
×
528
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
529
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetTotalInfluenceRevealed", &opts, epoch, medianIndex)
×
530
        returnedError := CheckIfAnyError(returnedValues)
×
531
        if returnedError != nil {
×
532
                return nil, returnedError
×
533
        }
×
534
        return returnedValues[0].Interface().(*big.Int), nil
×
535
}
536

537
func (v VoteManagerStruct) GetEpochLastCommitted(client *ethclient.Client, stakerId uint32) (uint32, error) {
×
538
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
539
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetEpochLastCommitted", &opts, stakerId)
×
540
        returnedError := CheckIfAnyError(returnedValues)
×
541
        if returnedError != nil {
×
542
                return 0, returnedError
×
543
        }
×
544
        return returnedValues[0].Interface().(uint32), nil
×
545
}
546

547
func (v VoteManagerStruct) GetEpochLastRevealed(client *ethclient.Client, stakerId uint32) (uint32, error) {
×
548
        voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client)
×
549
        returnedValues := InvokeFunctionWithTimeout(voteManager, "GetEpochLastRevealed", &opts, stakerId)
×
550
        returnedError := CheckIfAnyError(returnedValues)
×
551
        if returnedError != nil {
×
552
                return 0, returnedError
×
553
        }
×
554
        return returnedValues[0].Interface().(uint32), nil
×
555
}
556

557
func (s StakedTokenStruct) BalanceOf(client *ethclient.Client, tokenAddress common.Address, address common.Address) (*big.Int, error) {
×
558
        stakedToken, opts := UtilsInterface.GetStakedTokenManagerWithOpts(client, tokenAddress)
×
559
        returnedValues := InvokeFunctionWithTimeout(stakedToken, "BalanceOf", &opts, address)
×
560
        returnedError := CheckIfAnyError(returnedValues)
×
561
        if returnedError != nil {
×
562
                return nil, returnedError
×
563
        }
×
564
        return returnedValues[0].Interface().(*big.Int), nil
×
565
}
566

567
func (b BindingsStruct) NewCollectionManager(address common.Address, client *ethclient.Client) (*bindings.CollectionManager, error) {
×
568
        return bindings.NewCollectionManager(address, client)
×
569
}
×
570

571
func (b BindingsStruct) NewRAZOR(address common.Address, client *ethclient.Client) (*bindings.RAZOR, error) {
×
572
        return bindings.NewRAZOR(address, client)
×
573
}
×
574

575
func (b BindingsStruct) NewStakeManager(address common.Address, client *ethclient.Client) (*bindings.StakeManager, error) {
×
576
        return bindings.NewStakeManager(address, client)
×
577
}
×
578

579
func (b BindingsStruct) NewVoteManager(address common.Address, client *ethclient.Client) (*bindings.VoteManager, error) {
×
580
        return bindings.NewVoteManager(address, client)
×
581
}
×
582

583
func (b BindingsStruct) NewBlockManager(address common.Address, client *ethclient.Client) (*bindings.BlockManager, error) {
×
584
        return bindings.NewBlockManager(address, client)
×
585
}
×
586

587
func (b BindingsStruct) NewStakedToken(address common.Address, client *ethclient.Client) (*bindings.StakedToken, error) {
×
588
        return bindings.NewStakedToken(address, client)
×
589
}
×
590

591
func (j JsonStruct) Unmarshal(data []byte, v interface{}) error {
×
592
        return json.Unmarshal(data, v)
×
593
}
×
594

595
func (j JsonStruct) Marshal(v interface{}) ([]byte, error) {
×
596
        return json.Marshal(v)
×
597
}
×
598

599
func (u UtilsStruct) GetUint32(flagSet *pflag.FlagSet, name string) (uint32, error) {
×
600
        return flagSet.GetUint32(name)
×
601
}
×
602

603
func (e EthClientStruct) Dial(rawurl string) (*ethclient.Client, error) {
×
604
        return ethclient.Dial(rawurl)
×
605
}
×
606

607
func (t TimeStruct) Sleep(duration time.Duration) {
×
608
        time.Sleep(duration)
×
609
}
×
610

611
func (o OSStruct) OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error) {
×
612
        return os.OpenFile(name, flag, perm)
×
613
}
×
614

615
func (o OSStruct) Open(name string) (*os.File, error) {
×
616
        return os.Open(name)
×
617
}
×
618

619
func (o OSStruct) WriteFile(name string, data []byte, perm fs.FileMode) error {
×
620
        return os.WriteFile(name, data, perm)
×
621
}
×
622

623
func (o OSStruct) ReadFile(filename string) ([]byte, error) {
×
624
        return os.ReadFile(filename)
×
625
}
×
626

627
func (i IOStruct) ReadAll(body io.ReadCloser) ([]byte, error) {
×
628
        return io.ReadAll(body)
×
629
}
×
630

631
func (c ClientStruct) TransactionReceipt(client *ethclient.Client, ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
×
632
        returnedValues := InvokeFunctionWithTimeout(client, "TransactionReceipt", ctx, txHash)
×
633
        returnedError := CheckIfAnyError(returnedValues)
×
634
        if returnedError != nil {
×
635
                return &types.Receipt{}, returnedError
×
636
        }
×
637
        return returnedValues[0].Interface().(*types.Receipt), nil
×
638
}
639

640
func (c ClientStruct) BalanceAt(client *ethclient.Client, ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) {
×
641
        returnedValues := InvokeFunctionWithTimeout(client, "BalanceAt", ctx, account, blockNumber)
×
642
        returnedError := CheckIfAnyError(returnedValues)
×
643
        if returnedError != nil {
×
644
                return nil, returnedError
×
645
        }
×
646
        return returnedValues[0].Interface().(*big.Int), nil
×
647
}
648

649
func (c ClientStruct) HeaderByNumber(client *ethclient.Client, ctx context.Context, number *big.Int) (*types.Header, error) {
×
650
        returnedValues := InvokeFunctionWithTimeout(client, "HeaderByNumber", ctx, number)
×
651
        returnedError := CheckIfAnyError(returnedValues)
×
652
        if returnedError != nil {
×
653
                return &types.Header{}, returnedError
×
654
        }
×
655
        return returnedValues[0].Interface().(*types.Header), nil
×
656
}
657

658
func (c ClientStruct) NonceAt(client *ethclient.Client, ctx context.Context, account common.Address) (uint64, error) {
×
659
        var blockNumber *big.Int
×
660
        returnedValues := InvokeFunctionWithTimeout(client, "NonceAt", ctx, account, blockNumber)
×
661
        returnedError := CheckIfAnyError(returnedValues)
×
662
        if returnedError != nil {
×
663
                return 0, returnedError
×
664
        }
×
665
        return returnedValues[0].Interface().(uint64), nil
×
666
}
667

668
func (c ClientStruct) SuggestGasPrice(client *ethclient.Client, ctx context.Context) (*big.Int, error) {
×
669
        returnedValues := InvokeFunctionWithTimeout(client, "SuggestGasPrice", ctx)
×
670
        returnedError := CheckIfAnyError(returnedValues)
×
671
        if returnedError != nil {
×
672
                return nil, returnedError
×
673
        }
×
674
        return returnedValues[0].Interface().(*big.Int), nil
×
675
}
676

677
func (c ClientStruct) EstimateGas(client *ethclient.Client, ctx context.Context, msg ethereum.CallMsg) (uint64, error) {
×
678
        returnedValues := InvokeFunctionWithTimeout(client, "EstimateGas", ctx, msg)
×
679
        returnedError := CheckIfAnyError(returnedValues)
×
680
        if returnedError != nil {
×
681
                return 0, returnedError
×
682
        }
×
683
        return returnedValues[0].Interface().(uint64), nil
×
684
}
685

686
func (c ClientStruct) FilterLogs(client *ethclient.Client, ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) {
×
687
        returnedValues := InvokeFunctionWithTimeout(client, "FilterLogs", ctx, q)
×
688
        returnedError := CheckIfAnyError(returnedValues)
×
689
        if returnedError != nil {
×
690
                return []types.Log{}, returnedError
×
691
        }
×
692
        return returnedValues[0].Interface().([]types.Log), nil
×
693
}
694

695
func (c CoinStruct) BalanceOf(erc20Contract *bindings.RAZOR, opts *bind.CallOpts, account common.Address) (*big.Int, error) {
×
696
        returnedValues := InvokeFunctionWithTimeout(erc20Contract, "BalanceOf", opts, account)
×
697
        returnedError := CheckIfAnyError(returnedValues)
×
698
        if returnedError != nil {
×
699
                return nil, returnedError
×
700
        }
×
701
        return returnedValues[0].Interface().(*big.Int), nil
×
702
}
703

704
func (a ABIStruct) Parse(reader io.Reader) (abi.ABI, error) {
×
705
        return abi.JSON(reader)
×
706
}
×
707

708
func (a ABIStruct) Pack(parsedData abi.ABI, name string, args ...interface{}) ([]byte, error) {
×
709
        return parsedData.Pack(name, args...)
×
710
}
×
711

712
func (p PathStruct) GetDefaultPath() (string, error) {
×
713
        return path.PathUtilsInterface.GetDefaultPath()
×
714
}
×
715

716
func (p PathStruct) GetJobFilePath() (string, error) {
×
717
        return path.PathUtilsInterface.GetJobFilePath()
×
718
}
×
719

720
func (b BindStruct) NewKeyedTransactorWithChainID(key *ecdsa.PrivateKey, chainID *big.Int) (*bind.TransactOpts, error) {
×
721
        return bind.NewKeyedTransactorWithChainID(key, chainID)
×
722
}
×
723

724
func (r RetryStruct) RetryAttempts(numberOfAttempts uint) retry.Option {
×
725
        return retry.Attempts(numberOfAttempts)
×
726
}
×
727

728
func (f FlagSetStruct) GetLogFileName(flagSet *pflag.FlagSet) (string, error) {
×
729
        return flagSet.GetString("logFile")
×
730
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc