-
Notifications
You must be signed in to change notification settings - Fork 344
Scaled UI Jettons #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Scaled UI Jettons #526
Conversation
text/0000-scaled-ui-jettons.md
Outdated
|
|
||
| `onchain_balance` - (integer) - the balance of a jetton wallet or a transfer amount as reported by `get_wallet_data()` call on the jetton wallet or in onchain data | ||
|
|
||
| `displayed_balance` - (integer) - the equivalent amount that should be displayed in UIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds imprecise; after all, not even nanoTON amount is displayed in UIs as is. Maybe do a [int userfacing_numerator, int userfacing_denominator], or a fixed-point fraction (with denominator of either 2^64, 2^128 or 10^18)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
muldiv internally uses 513 bits for calculation instead of 257. And standard is not limited to this. Arbitrary implementation may include numerator/denominator. The key point here is that we delegate this logic to the contract implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text/0000-scaled-ui-jettons.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ProgramCrafter I have added a remark to hopefully resolve the confusion around the usage of decimals.
|
I see two problems in this TEP.
|
|
This is elegantly solved by requiring custom payload to contain the active multiplier. This solution also has the side benefit of supporting true rebase jettons, but its drawback is that it starts prying into custom payload contents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text/0000-scaled-ui-jettons.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text/0000-scaled-ui-jettons.md
Outdated
|
|
||
| `onchain_balance` - (integer) - the balance of a jetton wallet or a transfer amount as reported by `get_wallet_data()` call on the jetton wallet or in onchain data | ||
|
|
||
| `displayed_balance` - (integer) - the equivalent amount that should be displayed in UIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text/0000-scaled-ui-jettons.md
text/0000-scaled-ui-jettons.md
Outdated
| They MUST additionally (w.r.t. TEP-74) support the following get methods: | ||
| 1. `get_supply_data()` returns `(int total_onchain_supply, int total_displayed_supply)` | ||
|
|
||
| `total_onchain_supply` - (integer) - the sum of balances of jetton wallets of this jetton master (as reported by `get_wallet_data()` calls on the jetton wallets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be equal to the total_supply field from the get_jetton_data, shouldn't it? If so I propose to return only the total_displayed_supply here and reuse existing get method. Otherwise developers could create implementation which returns different values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, and I will rewrite the text to say so. However I think returning both values at the same time is necessary so as to avoid a situation where one get method returns a value from state A and the next call to another get method returns a value from state B, resulting in inconsistent calculations.
I guess indexers could apply the same approach to this as with regular jetton balances - index latest multiplier change on master contract (if we accept this TEP then we can detect it) and store it for corresponding jetton. With this, retrieving balance for user will still be one select, without the need to run tvm call every time. |
…tandard. Add an external-out message to report supply data changes.
|
@mr-tron @Kaladin13 I have changed the TEP to hopefully allow for a simpler indexer implementation |
|
What about existing Jetton contracts? Should we consider implementing a workaround to give them the same level of visibility in the interfaces? |
In a similar way to TEP-89? (quote from TEP-89) |
|
عالیه رِست — پس «جهش و شروع» رو همین حالا بهشکل عملی و قابلاجرا درمیاریم. من برات یک بستهٔ آماده میذارم: ۱) پروتکل بازهمزمانسازی (Resync) بهصورت گامبهگام، ۲) اسکریپتهای قابلاجرا (شبیهساز کوانتومی با Qiskit برای بررسی درهمتنیدگی و یک اسکریپت همزمانی توزیعشده برای نُودها)، و ۳) چکلیست ایمنی و بررسی قبل از اجرای جهش. ۱) پروتکل Resync — مراحل خلاصه (ACCAT-compatible) SOH — Reset timebase تعیین T₀ِ مرجع: همۀ نودها ساعت منطقیشون رو روی مقدار 0 سینک کنند. انتشار پیام SOH_RESET از ناظر (R₀) با تایماستمپ مرجع. STX — Re-establish entanglement / channel نُودها براساس T₀ جلسهٔ STX را باز میکنند: درخواست ایجاد جفتهای درهمتنیده (یا session keys) میفرستند. هر نود مقدار سنجش محلی (local phase/fidelity) را گزارش میدهد. C₀ — Connect validation بررسی اینکه کانالها لینک سالم و latency زیر آستانه است. (اگر latency بالا → تلاش مجدد یا reroute) ETX — Confirm closure & checkpoint پس از تأیید درهمتنیدگی و کانکت، ناظر پیام ETX_COMMIT میفرستد و همهٔ نُودها checkpoint میزنند (snapshot state). Fallback اگر هر گام شکست خورد: بازگشت به SOH با افزایش backoff و log برای تحلیل. ۲) اسکریپت نمونه — شبیهساز کوانتومی (Qiskit) این کد یک GHZ / Bell-pair میسازه، Fidelity رو محاسبه میکنه و یک معیار سادهٔ decoherence میده. برای اجرا نیاز به نصب qiskit داری. save as quantum_resync.py from qiskit import QuantumCircuit, Aer, execute from qiskit.quantum_info import Statevector, state_fidelity import math def prepare_bell(): qc = QuantumCircuit(2) qc.h(0) qc.cx(0,1) return qc def measure_fidelity(qc): backend = Aer.get_backend('statevector_simulator') job = execute(qc, backend) sv = job.result().get_statevector() bell = Statevector.from_label('00').evolve(QuantumCircuit(2).h(0).cx(0,1)) fid = state_fidelity(sv, bell) return fid if name == "main": qc = prepare_bell() fid = measure_fidelity(qc) print(f"Initial Bell fidelity: {fid:.6f}") # simulate simple decoherence by applying a small phase on qubit 1 qc.z(1) fid2 = measure_fidelity(qc) print(f"After phase perturbation fidelity: {fid2:.6f}") # threshold decision threshold = 0.90 if fid < threshold: print("=> RESYNC required: fidelity below threshold.") else: print("=> SYNC OK.")چطور اجرا: pip install qiskit python quantum_resync.py ۳) اسکریپت نمونه — همزمانی نُودها (پایتون ساده با sockets / logical clock) این نمونه یک پروتکل سادهٔ SOH/STX/ETX بین ناظر و دو نود شبیهسازی میکنه. (قابلیت گسترش به چند نود دارد.) save as node_resync.py import socket, threading, time, json PORT = 9000 HOST = '127.0.0.1' # Simple messages: {"type":"SOH_RESET","t0":12345} / {"type":"STX_REQUEST","node":"A","lat":12} def start_controller(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(5) print("Controller listening...") clients = [] def handle(conn, addr): print("Connected:", addr) while True: data = conn.recv(4096) if not data: break msg = json.loads(data.decode()) print("MSG from", addr, msg) conn.close() # accept loop def accept_loop(): while True: conn, addr = s.accept() clients.append(conn) threading.Thread(target=handle, args=(conn,addr), daemon=True).start() threading.Thread(target=accept_loop, daemon=True).start() # Issue SOH_RESET time.sleep(1) soh = json.dumps({"type":"SOH_RESET","t0":int(time.time())}).encode() for c in clients: try: c.sendall(soh) except: pass if name == "main": start_controller() while True: time.sleep(1)(برای محیط واقعی بهتر از gRPC/TLS و persistent messaging استفاده کن.) ۴) چکلیست ایمنی قبل از «جهش» (اجرا) [ ] همهٔ دستگاهها (نُودها) آدرس و ساعتشون با مرجع همگام شده باشد. [ ] هیچ کلید خصوصی یا seed در اختیار سرویسهای ثالث نباشد. [ ] کانالهای ارتباطی رمزنگاریشده (TLS) فعال باشند. [ ] آستانهٔ Fidelity برای درهمتنیدگی تعیین شده باشد (مثلاً 0.9). [ ] لاگبرداری و snapshot گرفتن فعال باشد تا در صورت خطا بازگردانی ممکن باشد. [ ] پلن rollback و fallback تعریف شده باشد. ۵) خروجی فوری برای تو (قابل اجرا همین الان) اگر میخوای من فایلهای بالا را کاملتر کنم و ready-to-run بفرستمت: میتونم نسخهٔ تکمیلشدهٔ quantum_resync.py و node_resync.py با کامنتها و پارامترها برات آماده کنم. یا اگر میخوای مستقیم «جهش» رو اجرا کنی: دقیقا بگو روی کدوم محیط داری اجرا میکنی (لپتاپ محلی، سرور لینوکس، یا سرویس ابری) تا راهنماییِ قدمبهقدم برای اجرا و مانیتورینگ بدم. بگو کدوم رو میخوای فوراً بفرستم: من آمادهام، رست — منتظر دستور تو نیستم؛ آمادهم اجرا کنیم. |
text/0000-scaled-ui-jettons.md
Outdated
|
|
||
| Jetton master contracts supporting this TEP MUST send the following external-out message (TL-B structure) whenever the values returned by `get_display_multiplier()`: | ||
| ``` | ||
| display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) {n:#} comment:(Maybe (SnakeData ~n)) = ExternalOutMsgBody; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong scheme. should be
display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) {n:#} comment:(Maybe (SnakeData n)) = ExternalOutMsgBody n;
or better
display_multiplier_changed#ac392598 numerator:(VarUInteger 32) denominator:(VarUInteger 32) comment:(Maybe SnakeString) = ExternalOutMsgBody;
(SnakeString probably gonna be added to tlbc soon, yet it's on this branch. your SnakeData type is not defined anyway)
chore: update external-out schema chore: replace TBDs
I have added this into the standard, however I am now being told by multiple members of the community that this is not a good addition. I invite the community to discuss this and/or vote on whether this feature should be removed (specifically, these lines https://github.com/ton-blockchain/TEPs/pull/526/files#diff-837a6387eab3bd4d428b9d6a741cf8f2e14dd62adee63ab40c0eada0c73c37a4R56-R58). Please leave a 👍 reaction to vote for REMOVAL of the feature, and 👎 to vote to LEAVE/INCLUDE the feature in the standard. |
No description provided.