Skip to content

Commit

Permalink
fix string wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Mar 24, 2024
1 parent 00c6c8f commit 10a26ef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vyper/codegen/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
LOAD,
STORE,
IRnode,
add_ofst,
clamp_le,
get_dyn_array_count,
get_element_ptr,
get_type_for_exact_size,
make_setter,
wrap_value_for_external_return,
)
from vyper.codegen.expr import Expr
from vyper.codegen.return_ import make_return_stmt
Expand Down Expand Up @@ -127,23 +127,23 @@ def _assert_reason(self, test_expr, msg):
finally:
self.context.constancy = tmp

bufsz = msg_ir.typ.memory_bytes_required + 64
msg_ir = wrap_value_for_external_return(msg_ir)
bufsz = 64 + msg_ir.typ.memory_bytes_required
buf = self.context.new_internal_variable(get_type_for_exact_size(bufsz))

# offset of bytes in (bytes,)
method_id = util.method_id_int("Error(string)")

# abi encode method_id + bytestring to `buf+32`, then
# write method_id to `buf` and get out of here
payload_buf = buf + 32
bufsz -= 32 # reduce buffer by size of `method_id` slot
encoded_length = abi_encode(
add_ofst(buf, 32), msg_ir, self.context, bufsz, returns_len=True
)
encoded_length = abi_encode(payload_buf, msg_ir, self.context, bufsz, returns_len=True)
with encoded_length.cache_when_complex("encoded_len") as (b1, encoded_length):
revert_seq = [
"seq",
["mstore", buf, method_id],
["revert", add_ofst(buf, 28), ["add", 4 + 32, encoded_length]],
["revert", buf + 28, ["add", 4, encoded_length]],
]
revert_seq = b1.resolve(revert_seq)

Expand Down

0 comments on commit 10a26ef

Please sign in to comment.