Skip to content
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

Reflect Marshaler #1592

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Reflect Marshaler #1592

wants to merge 8 commits into from

Conversation

containerman17
Copy link
Collaborator

@containerman17 containerman17 commented Sep 27, 2024

A single CLI binary to manage all the HyperSDK VMs sounds great. However, the current ABI implementation requires regenerating structs with data types for each VM. This PR changes that by generating structs dynamically using reflection.

This package should NOT be used within VMs, only in CLI applications. I'm happy to rename it if you have better ideas.

P.S. I've also added 0x to addresses to follow the recent changes.
P.S. Please take some extra time during the code review or suggest additional test cases. The code is short but does quite a bit. It is well-tested using the existing abi package specs, but I wouldn’t call myself an expert with Go’s reflect package.

abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
// Find the type in the ABI
abiType := findABIType(inputAbi, abiTypeName)
if abiType == nil {
// If not found, fallback to interface{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? Please elaborate in the comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It makes much more sense to return errors here instead of just an empty value, I agree. Yeah, that was a dumb thing to do.

abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Show resolved Hide resolved
abi/dynamic/reflect_marshal.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants