ContractName::try_from()
allows invalid ContractName
to be created
#4727
Milestone
ContractName::try_from()
allows invalid ContractName
to be created
#4727
Description
The
ContractName
struct is implemented using a macro, like this:MAX_STRING_LEN
is 128, so it's possible to construct aContractName
with up to 128 characters. However, when we implementStacksMessageCodec
forContractName
:CONTRACT_MAX_NAME_LENGTH
is 40, much smaller thanMAX_STRING_LEN
. This means thatContractName::try_from()
allows us to create structs that can't be serializedProposed solutions
CONTRACT_MAX_NAME_LENGTH
instead ofMAX_STRING_LEN
. This won't actually fix the problem, and will likely expose more invalidContractName
s that were never being serialized, but it will make invalidContractName
s easy to find and fix. Where it fails, we can replaceContractName::try_from()
withContractName::from_truncated()
orContractName::try_from_truncated()
CONTRACT_MAX_NAME_LENGTH
to matchMAX_STRING_LEN
. Probably not what we want to do, but would fix the issue immediatelyRelated issues
The text was updated successfully, but these errors were encountered: