@layerzerolabs/layerzero-v2-ton 3.0.27 → 3.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/ActionsSerde.test.compiled.json +1 -0
- package/build/AllStorages.compiled.json +1 -1
- package/build/AllStorages.test.compiled.json +1 -1
- package/build/BaseContract.test.compiled.json +1 -1
- package/build/Channel.compiled.json +1 -1
- package/build/Channel.permissions.test.compiled.json +1 -1
- package/build/ChannelBurn.test.compiled.json +1 -1
- package/build/ChannelCommitPacket.test.compiled.json +1 -1
- package/build/ChannelConfig.test.compiled.json +1 -1
- package/build/ChannelInitialize.test.compiled.json +1 -1
- package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
- package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
- package/build/ChannelNilify.test.compiled.json +1 -1
- package/build/ChannelReceive.test.compiled.json +1 -1
- package/build/ChannelReceiveCallback.test.compiled.json +1 -1
- package/build/ChannelReceiveView.test.compiled.json +1 -1
- package/build/ChannelSend.test.compiled.json +1 -1
- package/build/ChannelSerde.test.compiled.json +1 -0
- package/build/Classlib.test.compiled.json +1 -1
- package/build/ComputeDataSizeGas.test.compiled.json +1 -1
- package/build/Connection.compiled.json +1 -1
- package/build/Controller.assertions.test.compiled.json +1 -1
- package/build/Controller.compiled.json +1 -1
- package/build/Controller.permissions.test.compiled.json +1 -1
- package/build/Controller.test.compiled.json +1 -1
- package/build/Counter.compiled.json +1 -1
- package/build/Counter.permissions.test.compiled.json +1 -1
- package/build/Counter.setters.test.compiled.json +1 -1
- package/build/Counter.test.compiled.json +1 -1
- package/build/Dvn.compiled.json +1 -1
- package/build/Dvn.test.compiled.json +1 -1
- package/build/DvnFeeLib.compiled.json +1 -1
- package/build/DvnFeeLibSerde.test.compiled.json +1 -0
- package/build/DvnPermissions.test.compiled.json +1 -1
- package/build/DvnSerde.test.compiled.json +1 -0
- package/build/Endpoint.compiled.json +1 -1
- package/build/Endpoint.permissions.test.compiled.json +1 -1
- package/build/Endpoint.test.compiled.json +1 -1
- package/build/EndpointSerde.test.compiled.json +1 -0
- package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
- package/build/Executor.compiled.json +1 -1
- package/build/Executor.test.compiled.json +1 -1
- package/build/ExecutorFeeLib.compiled.json +1 -1
- package/build/ExecutorFeeLibSerde.test.compiled.json +1 -0
- package/build/ExecutorPermissions.test.compiled.json +1 -1
- package/build/ExecutorSerde.test.compiled.json +1 -0
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzClassesSerde.test.compiled.json +1 -0
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsgDataSerde.test.compiled.json +1 -0
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrderSerde.test.compiled.json +1 -0
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.permissions.compiled.json +1 -1
- package/build/PriceFeedCacheSerde.test.compiled.json +1 -0
- package/build/PriceFeedFeeLibSerde.test.compiled.json +1 -0
- package/build/Proxy.compiled.json +1 -1
- package/build/Proxy.permissions.test.compiled.json +1 -1
- package/build/Proxy.test.compiled.json +1 -1
- package/build/SmlConnection.compiled.json +1 -1
- package/build/SmlConnection.permissions.test.compiled.json +1 -1
- package/build/SmlConnection.test.compiled.json +1 -1
- package/build/SmlManager.compiled.json +1 -1
- package/build/SmlManager.permissions.test.compiled.json +1 -1
- package/build/SmlManager.test.compiled.json +1 -1
- package/build/Uln.compiled.json +1 -1
- package/build/Uln.test.compiled.json +1 -1
- package/build/UlnConnection.compiled.json +1 -1
- package/build/UlnConnection.test.compiled.json +1 -1
- package/build/UlnConnectionPermissions.test.compiled.json +1 -1
- package/build/UlnConnectionSerde.test.compiled.json +1 -0
- package/build/UlnManagement.test.compiled.json +1 -1
- package/build/UlnManager.compiled.json +1 -1
- package/build/UlnManager.test.compiled.json +1 -1
- package/build/UlnManagerPermissions.test.compiled.json +1 -1
- package/build/UlnManagerUtil.test.compiled.json +1 -1
- package/build/UlnMsgDataSerde.test.compiled.json +1 -0
- package/build/UlnPermissions.test.compiled.json +1 -1
- package/build/UlnReceiveConfig.test.compiled.json +1 -1
- package/build/UlnSend.test.compiled.json +1 -1
- package/build/UlnSendConfig.test.compiled.json +1 -1
- package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
- package/build/UlnSerde.test.compiled.json +1 -0
- package/build/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- package/build/WorkerCoreMsgDataSerde.test.compiled.json +1 -0
- package/build/WorkerCoreSerde.test.compiled.json +1 -0
- package/build/badFeeLib1.test.compiled.json +1 -1
- package/build/badFeeLib10.test.compiled.json +1 -1
- package/build/badFeeLib11.test.compiled.json +1 -1
- package/build/badFeeLib12.test.compiled.json +1 -1
- package/build/badFeeLib2.test.compiled.json +1 -1
- package/build/badFeeLib3.test.compiled.json +1 -1
- package/build/badFeeLib4.test.compiled.json +1 -1
- package/build/badFeeLib5.test.compiled.json +1 -1
- package/build/badFeeLib6.test.compiled.json +1 -1
- package/build/badFeeLib7.test.compiled.json +1 -1
- package/build/badFeeLib8.test.compiled.json +1 -1
- package/build/badFeeLib9.test.compiled.json +1 -1
- package/package.json +1 -1
- package/src/classes/lz/EpConfig.fc +90 -23
- package/src/classes/lz/MsglibInfo.fc +32 -5
- package/src/classes/lz/Packet.fc +109 -48
- package/src/classes/lz/Path.fc +55 -4
- package/src/classes/lz/ReceiveEpConfig.fc +36 -5
- package/src/classes/lz/SendEpConfig.fc +55 -5
- package/src/classes/msgdata/AddMsglib.fc +11 -0
- package/src/classes/msgdata/ChannelNonceInfo.fc +20 -0
- package/src/classes/msgdata/CoinsAmount.fc +8 -0
- package/src/classes/msgdata/Deploy.fc +19 -0
- package/src/classes/msgdata/ExtendedMd.fc +52 -1
- package/src/classes/msgdata/LzReceivePrepare.fc +21 -1
- package/src/classes/msgdata/LzReceiveStatus.fc +72 -1
- package/src/classes/msgdata/LzSend.fc +143 -24
- package/src/classes/msgdata/MdAddress.fc +42 -0
- package/src/classes/msgdata/MdEid.fc +8 -0
- package/src/classes/msgdata/MdObj.fc +32 -0
- package/src/classes/msgdata/MessagingReceipt.fc +34 -1
- package/src/classes/msgdata/MsglibSendCallback.fc +82 -0
- package/src/classes/msgdata/Nonce.fc +30 -0
- package/src/classes/msgdata/OptionsV1.fc +21 -1
- package/src/classes/msgdata/OptionsV2.fc +27 -0
- package/src/classes/msgdata/PacketId.fc +24 -0
- package/src/classes/msgdata/PacketSent.fc +35 -1
- package/src/classes/msgdata/SetAddress.fc +7 -0
- package/src/classes/msgdata/SetEpConfig.fc +17 -0
- package/src/funC++/actions/event.fc +17 -2
- package/src/funC++/actions/utils.fc +2 -2
- package/src/funC++/classlib.fc +33 -43
- package/src/funC++/constants.fc +28 -28
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +75 -59
- package/src/funC++/stdlib.fc +26 -11
- package/src/funC++/testutils.fc +2 -2
- package/src/funC++/txnContext.fc +14 -14
- package/src/funC++/utils.fc +97 -1
- package/src/protocol/channel/handler.fc +247 -189
- package/src/protocol/channel/storage.fc +206 -1
- package/src/protocol/controller/handler.fc +35 -17
- package/src/protocol/controller/main.fc +1 -1
- package/src/protocol/core/abstract/protocolHandler.fc +11 -21
- package/src/protocol/core/baseStorage.fc +24 -0
- package/src/protocol/endpoint/handler.fc +99 -57
- package/src/protocol/endpoint/storage.fc +69 -5
- package/src/protocol/msglibs/BytesEncoder.fc +11 -10
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +1 -4
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +7 -8
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +20 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +114 -28
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +1 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +6 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +51 -1
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +15 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +84 -107
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +77 -1
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +92 -66
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +113 -6
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +6 -91
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +55 -31
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +13 -9
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +63 -27
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +19 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +55 -6
- package/src/workers/core/abstract/workerHandler.fc +20 -19
- package/src/workers/core/interface.fc +2 -1
- package/src/workers/core/workerCoreStorage.fc +16 -1
- package/src/workers/dvn/handler.fc +67 -26
- package/src/workers/dvn/storage.fc +15 -2
- package/src/workers/executor/handler.fc +18 -6
- package/src/workers/executor/interface.fc +1 -0
- package/src/workers/executor/storage.fc +8 -1
- package/src/workers/msgdata/DropEvent.fc +18 -0
- package/src/workers/msgdata/ExecuteParams.fc +66 -3
- package/src/workers/msgdata/NativeDrop.fc +4 -0
- package/src/workers/msgdata/SetDict.fc +6 -4
- package/src/workers/msgdata/SetQuorum.fc +4 -2
- package/src/workers/msgdata/SignedRequest.fc +8 -0
- package/src/workers/priceFeedCache/handler.fc +21 -27
- package/src/workers/priceFeedCache/storage.fc +16 -1
- package/src/workers/proxy/handler.fc +2 -1
- package/src/workers/proxy/storage.fc +1 -1
- package/tests/baseContractTest.fc +2 -6
- package/tests/testMain.fc +2 -2
- package/src/classes/msgdata/Amount.fc +0 -16
- package/src/funC++/actions/destroy.fc +0 -27
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "../../BytesEncoder.fc";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
#include "../feeLibInterface.fc";
|
|
4
5
|
#include "../feeLibUtils.fc";
|
|
5
6
|
|
|
@@ -64,14 +65,12 @@ int _getEventSink() impure {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
() assertConnection(cell $ulnSendMd) impure inline {
|
|
67
|
-
cell connectionCode = getContractStorage().
|
|
68
|
+
cell connectionCode = getContractStorage().Uln::getConnectionCode();
|
|
68
69
|
|
|
69
|
-
cell $connectionInitialStorage = $ulnSendMd
|
|
70
|
-
.cl::get<objRef>(md::UlnSend::connectionInitialStorage);
|
|
70
|
+
cell $connectionInitialStorage = $ulnSendMd.md::UlnSend::getConnectionInitialStorage();
|
|
71
71
|
|
|
72
|
-
int providedUlnManagerAddress =
|
|
73
|
-
.
|
|
74
|
-
.cl::get<address>(BaseStorage::owner);
|
|
72
|
+
int providedUlnManagerAddress =
|
|
73
|
+
UlnConnection::getBaseStorage($connectionInitialStorage).BaseStorage::getOwner();
|
|
75
74
|
|
|
76
75
|
;; By construction, if the bytecode is valid and the uln manager address is correct,
|
|
77
76
|
;; then the uln address cannot be incorrect (assuming no bug in the ULN connection bytecode).
|
|
@@ -99,11 +98,12 @@ cell _failedMsglibSendCallback(cell $lzSend) impure inline {
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
cell _quote(cell $ulnSendMd, cell $storage) impure inline {
|
|
102
|
-
|
|
101
|
+
(
|
|
102
|
+
cell $lzSend,
|
|
103
|
+
cell $customUlnSendConfig
|
|
104
|
+
) = $ulnSendMd.md::UlnSend::getLzSendAndCustomUlnSendConfig();
|
|
103
105
|
|
|
104
|
-
|
|
105
|
-
.cl::get<objRef>(BASE_STORAGE_INDEX)
|
|
106
|
-
.cl::get<address>(BaseStorage::owner);
|
|
106
|
+
cell $defaultUlnSendConfig = $storage.Uln::getDefaultUlnSendConfig();
|
|
107
107
|
|
|
108
108
|
(
|
|
109
109
|
int quoteGasLimit,
|
|
@@ -114,18 +114,21 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
|
|
|
114
114
|
int confirmations,
|
|
115
115
|
int isValid
|
|
116
116
|
) = lz::UlnSendConfig::resolveUlnSendConfig(
|
|
117
|
-
$
|
|
118
|
-
$
|
|
117
|
+
$customUlnSendConfig,
|
|
118
|
+
$defaultUlnSendConfig
|
|
119
119
|
);
|
|
120
120
|
|
|
121
121
|
ifnot (isValid) {
|
|
122
|
-
return
|
|
123
|
-
_failedMsglibSendCallback($lzSend),
|
|
124
|
-
ownerAddress
|
|
125
|
-
);
|
|
122
|
+
return _failedMsglibSendCallback($lzSend);
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
|
|
125
|
+
(
|
|
126
|
+
cell $packet,
|
|
127
|
+
cell $extraOptions,
|
|
128
|
+
cell $enforcedOptions
|
|
129
|
+
) = $lzSend.md::LzSend::getQuoteInformation();
|
|
130
|
+
|
|
131
|
+
int messageBytes = lz::Packet::_messageBytes($packet);
|
|
129
132
|
|
|
130
133
|
tuple returnStack = unsafeTuple([null()]);
|
|
131
134
|
|
|
@@ -139,8 +142,8 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
|
|
|
139
142
|
optionalDVNs,
|
|
140
143
|
confirmations,
|
|
141
144
|
messageBytes,
|
|
142
|
-
$
|
|
143
|
-
$
|
|
145
|
+
$extraOptions,
|
|
146
|
+
$enforcedOptions
|
|
144
147
|
]),
|
|
145
148
|
_quoteWorkersMethodId,
|
|
146
149
|
1,
|
|
@@ -151,16 +154,10 @@ cell _quote(cell $ulnSendMd, cell $storage) impure inline {
|
|
|
151
154
|
|
|
152
155
|
cell $msglibSendCallback = returnStack.cell_at(0);
|
|
153
156
|
ifnot ($msglibSendCallback.is_cell()) {
|
|
154
|
-
return
|
|
155
|
-
_failedMsglibSendCallback($lzSend),
|
|
156
|
-
ownerAddress
|
|
157
|
-
);
|
|
157
|
+
return _failedMsglibSendCallback($lzSend);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
return
|
|
161
|
-
$msglibSendCallback,
|
|
162
|
-
ownerAddress
|
|
163
|
-
);
|
|
160
|
+
return $msglibSendCallback;
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
;; caller is responsible for asserting the worker exists
|
|
@@ -183,23 +180,22 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
|
|
|
183
180
|
cell $extraOptions,
|
|
184
181
|
cell $enforcedOptions
|
|
185
182
|
) impure inline_ref method_id {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
);
|
|
183
|
+
cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
|
|
184
|
+
|
|
185
|
+
(cell $workerInfo, int workerExists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
|
|
190
186
|
ifnot (workerExists) {
|
|
191
187
|
return (-1, null());
|
|
192
188
|
}
|
|
193
189
|
|
|
190
|
+
( int friendWorkerAddress,
|
|
191
|
+
cell $workerFeelibStorage,
|
|
192
|
+
cell workerFeelibBytecode
|
|
193
|
+
) = $workerInfo.UlnWorkerFeelibInfo::getQuoteWorkerInformation();
|
|
194
|
+
|
|
194
195
|
(cell $friendInfo, int friendExists) = ($workerInfo, true);
|
|
195
|
-
int friendWorkerAddress = $workerInfo
|
|
196
|
-
.cl::get<address>(UlnWorkerFeelibInfo::friendWorkerAddress);
|
|
197
196
|
|
|
198
197
|
ifnot (friendWorkerAddress == NULLADDRESS) {
|
|
199
|
-
($friendInfo, friendExists) = $
|
|
200
|
-
Uln::workerFeelibInfos,
|
|
201
|
-
friendWorkerAddress
|
|
202
|
-
);
|
|
198
|
+
($friendInfo, friendExists) = $workerFeelibInfos.cl::dict256::get<cellRef>(friendWorkerAddress);
|
|
203
199
|
}
|
|
204
200
|
ifnot (friendExists) {
|
|
205
201
|
return (-1, null());
|
|
@@ -208,7 +204,7 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
|
|
|
208
204
|
tuple returnStack = safePackedInputsRunVm(
|
|
209
205
|
unsafeTuple(
|
|
210
206
|
[
|
|
211
|
-
$
|
|
207
|
+
$workerFeelibStorage,
|
|
212
208
|
$friendInfo,
|
|
213
209
|
$path,
|
|
214
210
|
confirmations,
|
|
@@ -219,7 +215,7 @@ cell _removeWorker(cell $storage, cell $workerFeelibInfo) impure inline {
|
|
|
219
215
|
),
|
|
220
216
|
UlnWorkerInterface::quote,
|
|
221
217
|
1,
|
|
222
|
-
|
|
218
|
+
workerFeelibBytecode.begin_parse(),
|
|
223
219
|
MAX_U32 ;; gas limit doesn't matter for the inner call
|
|
224
220
|
);
|
|
225
221
|
|
|
@@ -267,8 +263,8 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
|
|
|
267
263
|
slice requiredDVNs = requiredDVNsCell.begin_parse();
|
|
268
264
|
slice optionalDVNs = optionalDVNsCell.begin_parse();
|
|
269
265
|
|
|
270
|
-
cell $packet = $lzSend.
|
|
271
|
-
cell $path = $packet.
|
|
266
|
+
cell $packet = $lzSend.md::LzSend::getPacket();
|
|
267
|
+
cell $path = $packet.lz::Packet::getPath();
|
|
272
268
|
|
|
273
269
|
tuple payeesInfo = empty_tuple();
|
|
274
270
|
tuple workerEvents = UlnWorkerFeelibEventsBuilder::create();
|
|
@@ -319,7 +315,7 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
|
|
|
319
315
|
}
|
|
320
316
|
|
|
321
317
|
;; create the dvnPaidEvent
|
|
322
|
-
cell $dvnsFeesPaidEvent = DvnFeesPaidEvent::
|
|
318
|
+
cell $dvnsFeesPaidEvent = DvnFeesPaidEvent::build(
|
|
323
319
|
requiredDVNsCell,
|
|
324
320
|
optionalDVNsCell,
|
|
325
321
|
serializePayees(payeesInfo)
|
|
@@ -348,18 +344,16 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
|
|
|
348
344
|
.UlnWorkerFeelibEventsBuilder::push(executor, eventBody);
|
|
349
345
|
|
|
350
346
|
;; create the executorPaidEvent
|
|
351
|
-
cell $executorFeePaidEvent = ExecutorFeePaidEvent::
|
|
347
|
+
cell $executorFeePaidEvent = ExecutorFeePaidEvent::build(executor, executorFee);
|
|
352
348
|
|
|
353
349
|
;; Handle treasury fee
|
|
354
|
-
int
|
|
350
|
+
(int owner, int treasuryFeeBps) = $storage.Uln::getQuoteWorkersInformation();
|
|
351
|
+
int treasuryFee = totalNativeFee * treasuryFeeBps / 10000;
|
|
355
352
|
payeesInfo = payeesInfo.tpush(
|
|
356
|
-
unsafeTuple([
|
|
357
|
-
$storage.cl::get<objRef>(BASE_STORAGE_INDEX).cl::get<address>(BaseStorage::owner),
|
|
358
|
-
treasuryFee
|
|
359
|
-
])
|
|
353
|
+
unsafeTuple([owner, treasuryFee])
|
|
360
354
|
);
|
|
361
355
|
|
|
362
|
-
cell ret = md::MsglibSendCallback::
|
|
356
|
+
cell ret = md::MsglibSendCallback::build(
|
|
363
357
|
totalNativeFee + treasuryFee,
|
|
364
358
|
0,
|
|
365
359
|
$lzSend,
|
|
@@ -369,7 +363,7 @@ cell _quoteWorkers(tuple args) impure inline method_id(23432) {
|
|
|
369
363
|
PacketV1::nonceBytes,
|
|
370
364
|
PacketV1::guidOffsetBytes,
|
|
371
365
|
PacketV1::guidBytes,
|
|
372
|
-
UlnEvents::
|
|
366
|
+
UlnEvents::build(
|
|
373
367
|
UlnWorkerFeelibEvents::FromBuilder(workerEvents),
|
|
374
368
|
$dvnsFeesPaidEvent,
|
|
375
369
|
$executorFeePaidEvent
|
|
@@ -418,7 +412,7 @@ tuple ulnQuote(cell $ulnSendMd) impure inline method_id {
|
|
|
418
412
|
(cell $storage, tuple actions) = preamble();
|
|
419
413
|
|
|
420
414
|
actions~pushAction<call>(
|
|
421
|
-
$ulnSendMd.
|
|
415
|
+
$ulnSendMd.md::UlnSend::getForwardingAddress(),
|
|
422
416
|
Msglib::OP::RETURN_QUOTE,
|
|
423
417
|
_quote($ulnSendMd, $storage)
|
|
424
418
|
);
|
|
@@ -430,7 +424,7 @@ tuple ulnSend(cell $ulnSendMd) impure inline method_id {
|
|
|
430
424
|
(cell $storage, tuple actions) = preamble();
|
|
431
425
|
|
|
432
426
|
actions~pushAction<call>(
|
|
433
|
-
$ulnSendMd.
|
|
427
|
+
$ulnSendMd.md::UlnSend::getForwardingAddress(),
|
|
434
428
|
Channel::OP::MSGLIB_SEND_CALLBACK,
|
|
435
429
|
_quote($ulnSendMd, $storage)
|
|
436
430
|
);
|
|
@@ -446,12 +440,14 @@ tuple ulnSend(cell $ulnSendMd) impure inline method_id {
|
|
|
446
440
|
tuple ulnCommitPacket(cell $mdAddress) impure inline method_id {
|
|
447
441
|
(cell $storage, tuple actions) = preamble();
|
|
448
442
|
|
|
443
|
+
(cell $packet, int ulnConnectionAddress) = $mdAddress.md::MdAddress::deserialize();
|
|
444
|
+
|
|
449
445
|
actions~pushAction<call>(
|
|
450
|
-
|
|
446
|
+
ulnConnectionAddress,
|
|
451
447
|
UlnConnection::OP::ULN_CONNECTION_COMMIT_PACKET,
|
|
452
|
-
md::MdObj::
|
|
453
|
-
$
|
|
454
|
-
$storage.
|
|
448
|
+
md::MdObj::build(
|
|
449
|
+
$packet,
|
|
450
|
+
$storage.Uln::getDefaultUlnReceiveConfig()
|
|
455
451
|
)
|
|
456
452
|
);
|
|
457
453
|
|
|
@@ -468,12 +464,14 @@ tuple ulnCommitPacket(cell $mdAddress) impure inline method_id {
|
|
|
468
464
|
tuple ulnVerify(cell $mdAddress) impure inline method_id {
|
|
469
465
|
(cell $storage, tuple actions) = preamble();
|
|
470
466
|
|
|
467
|
+
(cell $md, int ulnConnectionAddress) = md::MdAddress::deserialize($mdAddress);
|
|
468
|
+
|
|
471
469
|
actions~pushAction<call>(
|
|
472
|
-
|
|
470
|
+
ulnConnectionAddress,
|
|
473
471
|
UlnConnection::OP::ULN_CONNECTION_VERIFY,
|
|
474
|
-
md::ExtendedMd::
|
|
475
|
-
$
|
|
476
|
-
$storage.
|
|
472
|
+
md::ExtendedMd::build(
|
|
473
|
+
$md,
|
|
474
|
+
$storage.Uln::getDefaultUlnReceiveConfig(),
|
|
477
475
|
getCaller()
|
|
478
476
|
)
|
|
479
477
|
);
|
|
@@ -481,28 +479,26 @@ tuple ulnVerify(cell $mdAddress) impure inline method_id {
|
|
|
481
479
|
return actions;
|
|
482
480
|
}
|
|
483
481
|
|
|
484
|
-
() _setWorkerInfo(cell $
|
|
482
|
+
() _setWorkerInfo(cell $workerFeelibInfos, cell $workerInfo) impure inline_ref {
|
|
485
483
|
cell $storage = getContractStorage();
|
|
486
|
-
int workerAddress = $
|
|
484
|
+
int workerAddress = $workerInfo.UlnWorkerFeelibInfo::getWorkerAddress();
|
|
487
485
|
|
|
488
486
|
;; Restrict the size of the new storage to prevent DoS of our contract storage.
|
|
489
487
|
;; The total worker bytecode size is capped by UlnManager::CONST::MAX_CUMULATIVE_BYTECODE_CELLS
|
|
490
488
|
;; and enforced by the UlnManager, so here the only thing we need to check is the storage size
|
|
491
489
|
;; of the workers, excluding their bytecode
|
|
492
490
|
(_, _, _, int success) = compute_data_size?(
|
|
493
|
-
$
|
|
491
|
+
$workerInfo.UlnWorkerFeelibInfo::setWorkerFeeLibBytecode(empty_cell()),
|
|
494
492
|
Uln::WorkerFeelibInfo::MaxCells
|
|
495
493
|
);
|
|
496
494
|
|
|
497
495
|
throw_unless(Uln::ERROR::invalidWorkerStorage, success);
|
|
498
496
|
|
|
499
497
|
setContractStorage(
|
|
500
|
-
$storage
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
$workerFeelibInfo
|
|
505
|
-
)
|
|
498
|
+
$storage.Uln::updateWorkerFeelibInfos(
|
|
499
|
+
workerAddress,
|
|
500
|
+
$workerInfo
|
|
501
|
+
)
|
|
506
502
|
);
|
|
507
503
|
}
|
|
508
504
|
|
|
@@ -510,11 +506,9 @@ tuple updateWorkerFeelib(cell $UlnWorkerFeelibInfo) impure inline method_id {
|
|
|
510
506
|
(cell $storage, tuple actions) = preamble();
|
|
511
507
|
int workerAddress = $UlnWorkerFeelibInfo.cl::get<address>(UlnWorkerFeelibInfo::workerAddress);
|
|
512
508
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
workerAddress
|
|
517
|
-
);
|
|
509
|
+
cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
|
|
510
|
+
|
|
511
|
+
(cell $existingWorkerFeelibInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
|
|
518
512
|
|
|
519
513
|
ifnot (exists) {
|
|
520
514
|
int isAdmin = $UlnWorkerFeelibInfo.cl::get<bool>(UlnWorkerFeelibInfo::isAdmin);
|
|
@@ -564,7 +558,7 @@ tuple updateWorkerFeelib(cell $UlnWorkerFeelibInfo) impure inline method_id {
|
|
|
564
558
|
);
|
|
565
559
|
}
|
|
566
560
|
|
|
567
|
-
_setWorkerInfo($UlnWorkerFeelibInfo);
|
|
561
|
+
_setWorkerInfo($workerFeelibInfos, $UlnWorkerFeelibInfo);
|
|
568
562
|
|
|
569
563
|
actions~pushAction<event>(
|
|
570
564
|
Uln::event::ULN_WORKER_REGISTERED,
|
|
@@ -601,31 +595,17 @@ tuple deregisterWorkerFeelib(cell $empty) impure inline method_id {
|
|
|
601
595
|
tuple setWorkerFeelibStorage(cell $newStorage) impure inline method_id {
|
|
602
596
|
(cell $storage, tuple actions) = preamble();
|
|
603
597
|
|
|
604
|
-
|
|
598
|
+
cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
|
|
605
599
|
|
|
606
|
-
|
|
607
|
-
Uln::workerFeelibInfos,
|
|
608
|
-
workerAddress
|
|
609
|
-
);
|
|
600
|
+
int workerAddress = getCaller();
|
|
610
601
|
|
|
602
|
+
(cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
|
|
611
603
|
throw_unless(Uln::ERROR::nonexistentWorker, exists);
|
|
612
604
|
|
|
613
|
-
cell $updatedWorkerInfo = $workerInfo
|
|
614
|
-
UlnWorkerFeelibInfo::
|
|
615
|
-
$newStorage
|
|
616
|
-
);
|
|
605
|
+
cell $updatedWorkerInfo = $workerInfo
|
|
606
|
+
.UlnWorkerFeelibInfo::setWorkerFeeLibStorage($newStorage);
|
|
617
607
|
|
|
618
|
-
|
|
619
|
-
_setWorkerInfo($updatedWorkerInfo);
|
|
620
|
-
|
|
621
|
-
setContractStorage(
|
|
622
|
-
$storage
|
|
623
|
-
.cl::nestedDict256::setRef(
|
|
624
|
-
Uln::workerFeelibInfos,
|
|
625
|
-
workerAddress,
|
|
626
|
-
$updatedWorkerInfo
|
|
627
|
-
)
|
|
628
|
-
);
|
|
608
|
+
_setWorkerInfo($workerFeelibInfos, $updatedWorkerInfo);
|
|
629
609
|
|
|
630
610
|
actions~pushAction<event>(
|
|
631
611
|
Uln::event::ULN_WORKER_STORAGE_SET,
|
|
@@ -644,19 +624,18 @@ tuple setWorkerFeelibStorage(cell $newStorage) impure inline method_id {
|
|
|
644
624
|
tuple refillWorkerRent(cell $rentRefill) {
|
|
645
625
|
(cell $storage, tuple actions) = preamble();
|
|
646
626
|
|
|
627
|
+
cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
|
|
628
|
+
|
|
647
629
|
int workerAddress = $rentRefill.cl::get<address>(md::RentRefill::address);
|
|
648
630
|
int amount = $rentRefill.cl::get<coins>(md::RentRefill::amount);
|
|
649
|
-
(cell $workerInfo, int exists) = cl::
|
|
650
|
-
$storage,
|
|
651
|
-
Uln::workerFeelibInfos,
|
|
652
|
-
workerAddress
|
|
653
|
-
);
|
|
631
|
+
(cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(workerAddress);
|
|
654
632
|
|
|
655
633
|
throw_unless(Uln::ERROR::nonexistentWorker, exists);
|
|
656
634
|
|
|
657
635
|
int currentRentBalance = $workerInfo.cl::get<coins>(UlnWorkerFeelibInfo::rentBalance);
|
|
658
636
|
|
|
659
637
|
_setWorkerInfo(
|
|
638
|
+
$workerFeelibInfos,
|
|
660
639
|
$workerInfo.cl::set(UlnWorkerFeelibInfo::rentBalance, currentRentBalance + amount)
|
|
661
640
|
);
|
|
662
641
|
|
|
@@ -677,9 +656,9 @@ tuple refillWorkerRent(cell $rentRefill) {
|
|
|
677
656
|
tuple collectWorkerRent(cell $setAddress) impure inline method_id {
|
|
678
657
|
(cell $storage, tuple actions) = preamble();
|
|
679
658
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
659
|
+
cell $workerFeelibInfos = $storage.Uln::getWorkerFeelibInfos();
|
|
660
|
+
|
|
661
|
+
(cell $workerInfo, int exists) = $workerFeelibInfos.cl::dict256::get<cellRef>(
|
|
683
662
|
$setAddress.cl::get<address>(md::SetAddress::address)
|
|
684
663
|
);
|
|
685
664
|
|
|
@@ -704,7 +683,7 @@ tuple collectWorkerRent(cell $setAddress) impure inline method_id {
|
|
|
704
683
|
.cl::set(UlnWorkerFeelibInfo::lastRentTimestamp, currentTimestamp);
|
|
705
684
|
|
|
706
685
|
;; update workerInfo in storage
|
|
707
|
-
_setWorkerInfo($workerInfo);
|
|
686
|
+
_setWorkerInfo($workerFeelibInfos, $workerInfo);
|
|
708
687
|
|
|
709
688
|
actions~pushAction<event>(
|
|
710
689
|
Uln::event::ULN_COLLECT_WORKER_RENT,
|
|
@@ -795,7 +774,7 @@ tuple garbageCollectInvalidAttestations(cell $mdAddress) impure inline method_id
|
|
|
795
774
|
actions~pushAction<call>(
|
|
796
775
|
$mdAddress.cl::get<address>(md::MdAddress::address),
|
|
797
776
|
UlnConnection::OP::GARBAGE_COLLECT_INVALID_ATTESTATIONS,
|
|
798
|
-
md::MdObj::
|
|
777
|
+
md::MdObj::build(
|
|
799
778
|
$mdAddress.cl::get<objRef>(md::MdAddress::md),
|
|
800
779
|
$storage.cl::get<objRef>(Uln::defaultUlnReceiveConfig)
|
|
801
780
|
)
|
|
@@ -804,8 +783,6 @@ tuple garbageCollectInvalidAttestations(cell $mdAddress) impure inline method_id
|
|
|
804
783
|
return actions;
|
|
805
784
|
}
|
|
806
785
|
|
|
807
|
-
;; todo-thomas: I'm not sure if we can read tensors (or tuples for that matter)
|
|
808
|
-
;; from the view functions using the RPC call, maybe it should be one integer?
|
|
809
786
|
(int, int, int) version() impure method_id {
|
|
810
787
|
return (3, 0, 2);
|
|
811
788
|
}
|
|
@@ -40,4 +40,80 @@ cell Uln::New(int owner, int eid, int dstEid) method_id {
|
|
|
40
40
|
[cl::t::uint16, 0] ;; Uln::remainingAdminWorkerSlots
|
|
41
41
|
])
|
|
42
42
|
);
|
|
43
|
-
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
;; ============================== Object Getters ==============================
|
|
46
|
+
|
|
47
|
+
const int Uln::_eidOffset = _HEADER_WIDTH;
|
|
48
|
+
const int Uln::_dstEidOffset = Uln::_eidOffset + 32;
|
|
49
|
+
const int Uln::_treasuryFeeBpsOffset = Uln::_dstEidOffset + 32;
|
|
50
|
+
const int Uln::_remainingWorkerSlotsOffset = Uln::_treasuryFeeBpsOffset + 16;
|
|
51
|
+
const int Uln::_remainingAdminWorkerSlotsOffset = Uln::_remainingWorkerSlotsOffset + 16;
|
|
52
|
+
const int Uln::_sliceBits = Uln::_remainingAdminWorkerSlotsOffset + 16;
|
|
53
|
+
|
|
54
|
+
cell Uln::getDefaultUlnReceiveConfig(cell $self) impure inline {
|
|
55
|
+
return $self.cellPreloadRefAt(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
cell Uln::getConnectionCode(cell $self) impure inline {
|
|
59
|
+
return $self.cellPreloadRefAt(2).cellPreloadRefAt(1);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
cell Uln::getWorkerFeelibInfos(cell $self) impure inline {
|
|
63
|
+
return $self.cellPreloadRefAt(2).cellPreloadRefAt(2);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
;; ============================== Object Multi-Getters ==============================
|
|
67
|
+
|
|
68
|
+
;; (owner, defaultUlnSendConfig)
|
|
69
|
+
cell Uln::getDefaultUlnSendConfig(cell $self) impure inline {
|
|
70
|
+
slice selfSlice = $self.begin_parse();
|
|
71
|
+
return selfSlice.preloadRefAt(2).cellPreloadRefAt(0); ;; defaultUlnSendConfig
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
;; (treasuryFeeBps, owner)
|
|
75
|
+
(int, int) Uln::getQuoteWorkersInformation(cell $self) impure inline {
|
|
76
|
+
slice selfSlice = $self.begin_parse();
|
|
77
|
+
return (
|
|
78
|
+
selfSlice.preloadRefAt(0).BaseStorage::getOwner(), ;; baseStorage.Owner
|
|
79
|
+
selfSlice.preloadUint16At(Uln::_treasuryFeeBpsOffset) ;; treasuryFeeBps
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
;; ============================== Object Setters ==============================
|
|
84
|
+
|
|
85
|
+
cell Uln::setWorkerFeelibInfos(cell $self, cell $workerFeelibInfos) impure inline {
|
|
86
|
+
slice selfSlice = $self.begin_parse();
|
|
87
|
+
|
|
88
|
+
slice ref2_slice = selfSlice.preloadRefSliceAt(2);
|
|
89
|
+
cell new_ref2 = begin_cell()
|
|
90
|
+
.store_slice(ref2_slice.scutfirst(0, 2))
|
|
91
|
+
.store_ref($workerFeelibInfos)
|
|
92
|
+
.end_cell();
|
|
93
|
+
|
|
94
|
+
return begin_cell()
|
|
95
|
+
.store_slice(selfSlice.scutfirst(Uln::_sliceBits, 2))
|
|
96
|
+
.store_ref(new_ref2)
|
|
97
|
+
.end_cell();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
;; updates the worker feelib info for the given [worker address, new worker feelib info]
|
|
101
|
+
;; and returns the new storage
|
|
102
|
+
cell Uln::updateWorkerFeelibInfos(cell $self, int workerAddress, cell $workerFeelibInfo) impure inline {
|
|
103
|
+
slice selfSlice = $self.begin_parse();
|
|
104
|
+
|
|
105
|
+
slice ref2_slice = selfSlice.preloadRefSliceAt(2);
|
|
106
|
+
cell $workerFeelibInfos = ref2_slice
|
|
107
|
+
.preloadRefAt(2)
|
|
108
|
+
.cl::dict256::setRef(workerAddress, $workerFeelibInfo);
|
|
109
|
+
|
|
110
|
+
cell new_ref2 = begin_cell()
|
|
111
|
+
.store_slice(ref2_slice.scutfirst(0, 2))
|
|
112
|
+
.store_ref($workerFeelibInfos)
|
|
113
|
+
.end_cell();
|
|
114
|
+
|
|
115
|
+
return begin_cell()
|
|
116
|
+
.store_slice(selfSlice.scutfirst(Uln::_sliceBits, 2))
|
|
117
|
+
.store_ref(new_ref2)
|
|
118
|
+
.end_cell();
|
|
119
|
+
}
|