0xMiden / 0xMiden/takeoff

Deploying larger compiled packages can fail during base64 encoding

Đang mở Phù hợp với người mới
#8 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
2
Fork
2
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Summary

Deploying a compiled contract can fail before `useDeploy()` is called when the compiled package is large enough.

`ContractList` converts `contract.packageBytes` to base64 with:

```ts
btoa(String.fromCharCode(...contract.packageBytes))
```

Spreading a large `Uint8Array` into `String.fromCharCode()` is limited by the JavaScript engine's maximum argument count. Once the compiled package crosses that threshold, the click handler throws synchronously with `RangeError: Maximum call stack size exceeded` and the deploy flow never starts.

## Repro

This is the same conversion pattern used by the deploy button:

```sh
node -e "const b=new Uint8Array(200000); String.fromCharCode(...b)"
```

It fails with:

```text
RangeError: Maximum call stack size exceeded
```

## Impact

A contract can compile successfully and still be impossible to deploy from the UI solely because its `.masp` package is too large for the spread call. The deploy hook already accepts base64, so this is only an encoding issue in the UI boundary.

## Suggested fix

Encode the `Uint8Array` in chunks, or move a safe `uint8ArrayToBase64()` helper into a shared utility and use it from `ContractList`.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Xem xét thành phần ContractList nơi contract.packageBytes được chuyển đổi sang base64. Vấn đề nằm ở việc sử dụng String.fromCharCode(...contract.packageBytes). Tìm hoặc tạo một hàm tiện ích để mã hóa base64 an toàn cho các Uint8Array lớn, có thể trong một tệp utils dùng chung. Kiểm tra bản sửa lỗi bằng cách mô phỏng việc triển khai một gói lớn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
cli, frontend
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
75/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.