Skip to content

Comments

reduce panic chance by checking CallToMethod return len on all cases#2695

Merged
sukantoraymond merged 7 commits intomainfrom
reduce-panics
Mar 26, 2025
Merged

reduce panic chance by checking CallToMethod return len on all cases#2695
sukantoraymond merged 7 commits intomainfrom
reduce-panics

Conversation

@felipemadero
Copy link
Collaborator

@felipemadero felipemadero commented Mar 21, 2025

Why this should be merged

  • Introduces contract.GetMethodReturn to be used after calling contract.CallToMethod, to always check returned slice is not empty, and also properly check for return type
  • Also removes duplicated function GetRegisteredValidator in favor of GetValidationID

How this works

How this was tested

How is this documented

}

func GetRegisteredValidator(
func GetValidationID(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add description to this function?

// Verifies
/**
* @notice Returns a validation ID registered to the given nodeID
* @param nodeID ID of the node associated with the validation ID
*/

return out, nil
}

func GetMethodReturn[T any](methodName string, out []interface{}) (T, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetSmartContractCallResult?

@github-project-automation github-project-automation bot moved this from Backlog 🗄️ to In Review 👀 in avalanchego Mar 26, 2025
@sukantoraymond sukantoraymond merged commit c4e8fa8 into main Mar 26, 2025
36 checks passed
@sukantoraymond sukantoraymond deleted the reduce-panics branch March 26, 2025 23:37
@github-project-automation github-project-automation bot moved this from In Review 👀 to Done ✅ in avalanchego Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants