diff --git a/eth_abi/decoding.py b/eth_abi/decoding.py index bc7a827b1e..8205efe875 100644 --- a/eth_abi/decoding.py +++ b/eth_abi/decoding.py @@ -386,10 +386,17 @@ def read_data_from_stream(self, stream): data = stream.read(self.data_byte_size) if len(data) != self.data_byte_size: - raise InsufficientDataBytes( - f"Tried to read {self.data_byte_size} bytes, " - f"only got {len(data)} bytes." - ) + if self.strict: + raise InsufficientDataBytes( + f"Tried to read {self.data_byte_size} bytes, " + f"only got {len(data)} bytes." + ) + + # Pad the value. + data_stripped = data.lstrip(b"\x00") + num_zeroes = max(0, 32 - len(data_stripped)) + zeroes = b"\x00" * num_zeroes + data = zeroes + data_stripped return data diff --git a/eth_abi/registry.py b/eth_abi/registry.py index a145c1f44a..d88ee55a3b 100644 --- a/eth_abi/registry.py +++ b/eth_abi/registry.py @@ -474,13 +474,7 @@ def has_encoder(self, type_str: abi.TypeStr) -> bool: def _get_decoder_uncached(self, type_str, strict=True): decoder = self._get_registration(self._decoders, type_str) - - if hasattr(decoder, "is_dynamic") and decoder.is_dynamic: - # Set a transient flag each time a call is made to ``get_decoder()``. - # Only dynamic decoders should be allowed these looser constraints. All - # other decoders should keep the default value of ``True``. - decoder.strict = strict - + decoder.strict = strict return decoder def copy(self):