Closed jeff-aion closed 5 years ago
Note that our internal helper will handle the null
as NullPointerException
but the AVM specification requires that API argument problems be handled as a IllegalArgumentException
without any message so that is what will be visible to the user code.
These changes currently apply only to the topics. No size constraints are currently applied to the data component of the log and this will be investigated under issue #359.
Typo in the closing commit: b5c951d0dea65aab69733057e21e760dd256e84a
Issue #326 changed our handling of logging topics to be hashed with
sha256
in order to force the topics to be 32 bytes long. This is relevant since the rest of the system expects these quantities to be 32 bytes and Solidity quantities are naturally this size so we wanted to coerce the arbitrarily-sized AVM log topics into this shape.sha256
was chosen, seemingly just because it was available and had the size properties we wanted. This, however, is a very slow way to truncate/pad a sequence of bytes (since that is ultimately all we want), which also has the consequence of requiring the user tosha256
any topic they wish to query. Further, this adds extra complexity to work being done under #354 where we would like to remove hashing/crypto functionality from the core of the AVM and this creates yet another place where this is required.Instead, I propose that we define a simple topic sizing specification:
null
is invalid and results inNullPointerException
byte[]
longer then 32 bytes is truncated to 32 by removing bytes at the end (higher indices removed while indices0
to31
remain untouched)byte[]
shorter than 32 bytes is zero-extended by adding bytes at the end (forbyte[]
of lengthn
given, adding0
bytes from indexn
to31
while leaving indices0
ton-1
untouched)