Do not generate conversion code for event parameter those type doesn't match the one provided in the contract config #1137

Open
opened 2025-12-28 17:15:21 +00:00 by sami · 3 comments
Owner

Originally created by @AnnaShaleva on GitHub (May 31, 2023).

See https://github.com/nspcc-dev/neo-go/pull/3008#discussion_r1209546459.

Originally created by @AnnaShaleva on GitHub (May 31, 2023). See https://github.com/nspcc-dev/neo-go/pull/3008#discussion_r1209546459.
Author
Owner

@AnnaShaleva commented on GitHub (May 31, 2023):

Within the scope of this issue we also need to add RealType comparison for the set of emitted events if --guessed-evettypes option is used.

@AnnaShaleva commented on GitHub (May 31, 2023): Within the scope of this issue we also need to add `RealType` comparison for the set of emitted events if `--guessed-evettypes` option is used.
Author
Owner

@AnnaShaleva commented on GitHub (May 31, 2023):

@roman-khimov, I did some digging and I still doubt that we need this issue to be implemented. Initially there was a requirement of enforced type casting for events parameters: https://github.com/nspcc-dev/neo-go/issues/2713. The issue was inspired by ABI match requirement for emitted notifications.

Back to our discussion:

"s", 5 can't be the same as "s", "s"
You'll get binary 5 in the ByteString instead of (likely expected) the string "5"

It's a contraversal statement. IMO, the user that calls runtime.Notify("Name", 5) and writes ByteArray in the contract config would probably expect the unchanged binary representation of 5, not the string.

I'd suggest to consider another solution of this problem: we may stil emit conversion code for such cases and store the real type of the parameter. During events check we can warn a user about events mismatch in some compilation log. If it is done intentionally, then OK, the result will be converted. If not, then the user will fix either the contract config or the code.

@AnnaShaleva commented on GitHub (May 31, 2023): @roman-khimov, I did some digging and I still doubt that we need this issue to be implemented. Initially there was a requirement of enforced type casting for events parameters: https://github.com/nspcc-dev/neo-go/issues/2713. The issue was inspired by ABI match requirement for emitted notifications. Back to our discussion: > "s", 5 can't be the same as "s", "s" > You'll get binary 5 in the ByteString instead of (likely expected) the string "5" It's a contraversal statement. IMO, the user that calls `runtime.Notify("Name", 5)` and writes `ByteArray` in the contract config would probably expect the unchanged binary representation of 5, not the string. I'd suggest to consider another solution of this problem: we may stil emit conversion code for such cases and store the real type of the parameter. During events check we can warn a user about events mismatch in some compilation log. If it is done intentionally, then OK, the result will be converted. If not, then the user will fix either the contract config or the code.
Author
Owner

@AnnaShaleva commented on GitHub (Nov 12, 2025):

Within the scope of this issue we need to deal with this test:
nspcc-dev/neo-go@e22e2a1fbe/cli/smartcontract/generate_test.go (L639-L648)

@AnnaShaleva commented on GitHub (Nov 12, 2025): Within the scope of this issue we need to deal with this test: https://github.com/nspcc-dev/neo-go/blob/e22e2a1fbe81c194ef093d9961fa0fffe5035841/cli/smartcontract/generate_test.go#L639-L648
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#1137
No description provided.