-
Notifications
You must be signed in to change notification settings - Fork 179
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
MAT-170 - Wiggle for heimdall tx #87
Conversation
@@ -85,6 +87,32 @@ func isProposer(cliCtx cliContext.CLIContext) bool { | |||
return false | |||
} | |||
|
|||
// IsStateSyncer returns if current user is state syncer or not | |||
func IsStateSyncer(cliCtx cliContext.CLIContext) bool { |
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.
func IsStateSyncer(cliCtx cliContext.CLIContext) bool { | |
func IsStateSyncer(cliCtx cliContext.CLIContext) (isStateSyncer bool) { |
// IsStateSyncer returns if current user is state syncer or not | ||
func IsStateSyncer(cliCtx cliContext.CLIContext) bool { | ||
var stateSyncerList []types.Validator | ||
isStateSyncer := false |
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.
We can remove this, because we are anyway implicitly returning false
and true
isStateSyncer = true | ||
break |
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.
Directly return true
here?
|
||
// fetch state syncer list | ||
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s/%s", clerkTypes.QuerierRoute, clerkTypes.QueryStateSyncer), nil) | ||
|
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.
remove blank line
for _, record := range data.EventRecords { | ||
keeper.SetEventRecord(ctx, *record) | ||
} | ||
} | ||
|
||
keeper.SetStateSyncEventCount(ctx, uint64(eventCount)) |
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.
It might be the case where keeper.SetEventRecord(ctx, *record)
will return an error but eventCount will not reflect that. Let's handle that error and/or ensure EventCount
is always equal to actual events stored.
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.
Event Count is always equal to actual events stored.
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.
oh yes, it has to be, but in this case in one case it might not be. The case where SetStateSyncEventCount
throws an error.
|
||
// convert state sync event to bytes | ||
eventCountInBytes := []byte(strconv.FormatUint(eventCount, 10)) | ||
|
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.
remove line
expectedValIDs []types.ValidatorID | ||
} | ||
|
||
dataItems := []TestDataItem{ |
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.
Table tests!!! 🎉
for i := 0; i < syncerCount; { | ||
valIndex := eventCount % uint64(validatorCount) | ||
validator, _ := stakingKeeper.GetValidatorFromValID(ctx, types.ValidatorID(valIndex+1)) | ||
if stakingKeeper.IsCurrentValidatorByAddress(ctx, validator.Signer.Bytes()) { |
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.
Can't we get validators from current validator set instead of getting all validators and filter by validator status?
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.
Yeah. we can do that.
We should sort the current validator set by valID and do a binary search of validator Index.
Sorting is extra time complexity.
Considering CurrentValSet count is less, sorting should be fine i think.
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.
@mankenavenkatesh Validators in CurrentValSet will be already sorted as signer as far as I know. Can you check?
var stateSyncerList []types.Validator | ||
isStateSyncer := false | ||
|
||
result, err := FetchFromAPI(cliCtx, GetHeimdallServerEndpoint(fmt.Sprintf(StateSyncerURL))) |
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.
What if all three validators are offline?
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.
That would be the case if we go with backup model also.
Ideally, Instead of 3 validators We should increase the number to 1/3rd of currentvalidatorset count. It results in more number of transactions per sync.
Let me know if there is any better idea.
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.
Yeah 1/3rd of current validator set would be better here and in bor as backup.
@mankenavenkatesh Please resolve comments |
Wiggle for heimdall tx.
Approach- https://hackmd.io/055mjdcEQUa0uzAqMPLdNg