neo icon indicating copy to clipboard operation
neo copied to clipboard

getWhitelistFeeContracts asymmetry

Open roman-khimov opened this issue 4 months ago • 3 comments

Describe the bug https://github.com/neo-project/neo/pull/4201 has added a set of policy contract methods:

setWhitelistFeeContract(hash, method, argCount, fee)
removeWhitelistFeeContract(hash, method, argCount)
getWhitelistFeeContracts()

and a WhitelistFeeChanged(contract, method, argCount, fee) event. Originally getWhitelistFeeContracts() returned an iterator over keys that are "hash + argCount + method". Then https://github.com/neo-project/neo/pull/4359 has changed the storage scheme to more effective one, but it made getWhitelistFeeContracts() return an iterator over keys that are "hash + offset".

Now we have an obvious asymmetry in the interface, we operate with method/argCount pairs for set/remove methods, but getWhitelistFeeContracts() returns something completely alien.

To Reproduce Call setWhitelistFeeContract(hash, method, argCount, fee), then call getWhitelistFeeContracts(), then try to figure out what the result means.

Expected behavior getWhitelistFeeContracts() returning an iterator over values that are (hash, method, argCount, fee). This can be easily done by storing a structure with this data by the same offset-based key and then using ValuesOnly | DeserializeValues for iterator. This also easily solves the problem mentioned in https://github.com/neo-project/neo/pull/4359/files#r2582191161.

(Optional) Additional context https://github.com/neo-project/neo/pull/4201 https://github.com/neo-project/neo/pull/4359 https://github.com/nspcc-dev/neo-go/pull/4052

roman-khimov avatar Dec 11 '25 07:12 roman-khimov

We can store the struct instead just the value

shargon avatar Dec 12 '25 11:12 shargon

This is good to be done before 3.9.0

vncoelho avatar Dec 14 '25 23:12 vncoelho

I will do it today or tomorrow

This is good to be done before 3.9.0

shargon avatar Dec 15 '25 11:12 shargon