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

consider undoing murmur hash of invalid name when reading name from JSON #31

Open
spoonincode opened this issue Jun 25, 2024 · 1 comment
Labels

Comments

@spoonincode
Copy link
Member

When reading a name from JSON,

template <typename S>
void from_json(name& obj, S& stream) {
auto r = stream.get_string();
obj = name(hash_name(r));
}

abieos first checks if it's a valid name and uses it, but if it's not a valid name it makes it a valid name by murmur hashing it,
inline constexpr uint64_t hash_name( std::string_view str ) {
auto r = try_string_to_name_strict(str);
if( r ) return r.value();
return murmur64( str.data(), str.size() );
}

This yields (imo) surprising behavior for someone using abieos to serialize actions from JSON. For example, someone using abieos' JSON->bin serialization may pass abieos

{"from":"bob bob bob","to":"carol","quantity":"2.0000 EOS","memo":"sup"}

what would you expect to happen here? nodeos will disallow serialization in this case because bob bob bob isn't a valid name. but abieos will serialize it, with from being the murmur hash output of bob bob bob. I consider nodeos the canonical abi behavior and abieos should match it.

@heifner
Copy link
Member

heifner commented Jun 25, 2024

💯 agree this should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants