Skip to content

Commit 3bf1e49

Browse files
committed
chore: reduced TTL, replace [] == with list.is_empty.
1 parent d490ce2 commit 3bf1e49

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

cardano/gateway/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OGMIOS_ENDPOINT=http://127.0.0.1:1337
1212
CARDANO_CHAIN_HOST=127.0.0.1
1313
CARDANO_CHAIN_PORT=3001
1414
CARDANO_NETWORK_MAGIC=42
15-
CARDANO_EPOCH_NONCE_GENESIS="4c6b67f8bfd7964851d0a027a68ce66bc88c8fe32f720e6ae6cf2a343b1a9c29"
15+
CARDANO_EPOCH_NONCE_GENESIS="1ded2ae250301711769f64e867307cc034a3f2c4b1f134cc71e53cb35c0f44b5"
1616

1717
HANDLER_JSON_PATH=/usr/src/app/cardano/offchain/deployments/handler.json
1818

cardano/gateway/src/tx/channel.service.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class ChannelService {
8282
channelOpenInitOperator,
8383
constructedAddress,
8484
);
85-
const validToTime = Date.now() + 3 * 1e5;
85+
const validToTime = Date.now() + 2e4;
8686
const validToSlot = unixTimeToSlot(this.lucidService.lucid.config().network, Number(validToTime));
8787
const currentSlot = this.lucidService.lucid.currentSlot();
8888
if (currentSlot > validToSlot) {
@@ -126,7 +126,8 @@ export class ChannelService {
126126
channelOpenTryOperator,
127127
constructedAddress,
128128
);
129-
const unsignedChannelOpenTryTxValidTo: TxBuilder = unsignedChannelOpenTryTx.validTo(Date.now() + 300 * 1e3);
129+
const validToTime = Date.now() + 2e4;
130+
const unsignedChannelOpenTryTxValidTo: TxBuilder = unsignedChannelOpenTryTx.validTo(validToTime);
130131
// TODO: signing should be done by the relayer in the future
131132
const signedChannelOpenTryTxCompleted = await (await unsignedChannelOpenTryTxValidTo.complete()).sign
132133
.withWallet()
@@ -159,7 +160,7 @@ export class ChannelService {
159160
channelOpenAckOperator,
160161
constructedAddress,
161162
);
162-
const validToTime = Date.now() + 3 * 1e5;
163+
const validToTime = Date.now() + 2e4;
163164
const validToSlot = unixTimeToSlot(this.lucidService.lucid.config().network, Number(validToTime));
164165
const currentSlot = this.lucidService.lucid.currentSlot();
165166
if (currentSlot > validToSlot) {
@@ -200,9 +201,8 @@ export class ChannelService {
200201
channelOpenConfirmOperator,
201202
constructedAddress,
202203
);
203-
const unsignedChannelConfirmInitTxValidTo: TxBuilder = unsignedChannelConfirmInitTx.validTo(
204-
Date.now() + 600 * 1e3,
205-
);
204+
const validToTime = Date.now() + 2e4;
205+
const unsignedChannelConfirmInitTxValidTo: TxBuilder = unsignedChannelConfirmInitTx.validTo(validToTime);
206206

207207
// TODO: signing should be done by the relayer in the future
208208
const signedChannelConfirmInitTxCompleted = await (await unsignedChannelConfirmInitTxValidTo.complete()).sign
@@ -243,7 +243,8 @@ export class ChannelService {
243243
channelCloseInitOperator,
244244
constructedAddress,
245245
);
246-
const unsignedChannelCloseInitTxValidTo: TxBuilder = unsignedChannelCloseInitTx.validTo(Date.now() + 300 * 1e3);
246+
const validToTime = Date.now() + 2e4;
247+
const unsignedChannelCloseInitTxValidTo: TxBuilder = unsignedChannelCloseInitTx.validTo(validToTime);
247248

248249
// TODO: signing should be done by the relayer in the future
249250
const signedChannelCloseInitTxCompleted = await (await unsignedChannelCloseInitTxValidTo.complete()).sign

cardano/gateway/src/tx/client.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ export class ClientService {
121121

122122
const unsignedUpdateClientTx: TxBuilder =
123123
await this.buildUnsignedUpdateOnMisbehaviour(updateOnMisbehaviourOperator);
124+
const validToTime = Date.now() + 2e4;
124125
const unSignedTxValidTo: TxBuilder = unsignedUpdateClientTx
125126
.validFrom(new Date().valueOf())
126-
.validTo(new Date().valueOf());
127+
.validTo(validToTime);
127128
// Todo: signing should be done by the relayer in the future
128129
const signedUpdateClientTxCompleted = await (await unSignedTxValidTo.complete()).sign.withWallet().complete();
129130

@@ -145,7 +146,7 @@ export class ClientService {
145146
BigInt(currentClientDatum.state.clientState.maxClockDrift || 0)) /
146147
10n ** 6n +
147148
100n * 10n ** 3n;
148-
const validToTime = new Date().valueOf() + 100 * 1e3;
149+
const validToTime = Date.now() + 2e4;
149150
const updateClientHeaderOperator: UpdateClientOperatorDto = {
150151
clientId,
151152
header,

cardano/gateway/src/tx/connection.service.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ export class ConnectionService {
6868
connectionOpenInitOperator,
6969
constructedAddress,
7070
);
71-
const unsignedConnectionOpenInitTxValidTo: TxBuilder = unsignedConnectionOpenInitTx.validTo(
72-
Date.now() + 100 * 1e3,
73-
);
71+
const validToTime = Date.now() + 2e4;
72+
const unsignedConnectionOpenInitTxValidTo: TxBuilder = unsignedConnectionOpenInitTx.validTo(validToTime);
7473

7574
// Todo: signing should be done by the relayer in the future
7675
const signedConnectionOpenInitTxCompleted = await (await unsignedConnectionOpenInitTxValidTo.complete()).sign
@@ -108,7 +107,8 @@ export class ConnectionService {
108107
connectionOpenTryOperator,
109108
constructedAddress,
110109
);
111-
const unsignedConnectionOpenTryTxValidTo: TxBuilder = unsignedConnectionOpenTryTx.validTo(Date.now() + 100 * 1e3);
110+
const validToTime = Date.now() + 2e4;
111+
const unsignedConnectionOpenTryTxValidTo: TxBuilder = unsignedConnectionOpenTryTx.validTo(validToTime);
112112

113113
// Todo: signing should be done by the relayer in the future
114114
const signedConnectionOpenTryTxCompleted = await (await unsignedConnectionOpenTryTxValidTo.complete()).sign
@@ -146,7 +146,8 @@ export class ConnectionService {
146146
connectionOpenAckOperator,
147147
constructedAddress,
148148
);
149-
const unsignedConnectionOpenAckTxValidTo: TxBuilder = unsignedConnectionOpenAckTx.validTo(Date.now() + 100 * 1e3);
149+
const validToTime = Date.now() + 2e4;
150+
const unsignedConnectionOpenAckTxValidTo: TxBuilder = unsignedConnectionOpenAckTx.validTo(validToTime);
150151
// Todo: signing should be done by the relayer in the future
151152
const signedConnectionOpenAckTxCompleted = await (await unsignedConnectionOpenAckTxValidTo.complete()).sign
152153
.withWallet()
@@ -187,9 +188,8 @@ export class ConnectionService {
187188
connectionOpenConfirmOperator,
188189
constructedAddress,
189190
);
190-
const unsignedConnectionOpenConfirmTxValidTo: TxBuilder = unsignedConnectionOpenConfirmTx.validTo(
191-
Date.now() + 150 * 1e3,
192-
);
191+
const validToTime = Date.now() + 2e4;
192+
const unsignedConnectionOpenConfirmTxValidTo: TxBuilder = unsignedConnectionOpenConfirmTx.validTo(validToTime);
193193

194194
// Todo: signing should be done by the relayer in the future
195195
const signedConnectionOpenConfirmTxCompleted = await (

cardano/gateway/src/tx/packet.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class PacketService {
133133
constructedAddress,
134134
);
135135

136-
const validToTime = Date.now() + 3 * 1e5;
136+
const validToTime = Date.now() + 2e4;
137137
const validToSlot = this.lucidService.lucid.unixTimeToSlot(Number(validToTime));
138138
const currentSlot = this.lucidService.lucid.currentSlot();
139139
if (currentSlot > validToSlot) {
@@ -181,7 +181,7 @@ export class PacketService {
181181
const sendPacketOperator = validateAndFormatSendPacketParams(data);
182182

183183
const unsignedSendPacketTx: TxBuilder = await this.buildUnsignedSendPacketTx(sendPacketOperator);
184-
const validToTime = Date.now() + 3 * 1e5;
184+
const validToTime = Date.now() + 2e4;
185185
const validToSlot = this.lucidService.lucid.unixTimeToSlot(Number(validToTime));
186186
const currentSlot = this.lucidService.lucid.currentSlot();
187187
if (currentSlot > validToSlot) {
@@ -227,7 +227,8 @@ export class PacketService {
227227
timeoutPacketOperator,
228228
constructedAddress,
229229
);
230-
const unsignedSendPacketTxValidTo: TxBuilder = unsignedSendPacketTx.validTo(Date.now() + 3 * 1e5);
230+
const validToTime = Date.now() + 2e4;
231+
const unsignedSendPacketTxValidTo: TxBuilder = unsignedSendPacketTx.validTo(validToTime);
231232

232233
// Todo: signing should be done in the relayer in the future
233234
const signedSendPacketTxCompleted = await (await unsignedSendPacketTxValidTo.complete()).sign
@@ -280,7 +281,7 @@ export class PacketService {
280281
timeoutRefreshOperator,
281282
constructedAddress,
282283
);
283-
const validToTime = Date.now() + 3 * 1e5;
284+
const validToTime = Date.now() + 2e4;
284285
const validToSlot = this.lucidService.lucid.unixTimeToSlot(Number(validToTime));
285286

286287
const currentSlot = this.lucidService.lucid.currentSlot();
@@ -329,7 +330,8 @@ export class PacketService {
329330
ackPacketOperator,
330331
constructedAddress,
331332
);
332-
const unsignedAckPacketTxValidTo: TxBuilder = unsignedAckPacketTx.validTo(Date.now() + 300 * 1e3);
333+
const validToTime = Date.now() + 2e4;
334+
const unsignedAckPacketTxValidTo: TxBuilder = unsignedAckPacketTx.validTo(validToTime);
333335

334336
// Todo: signing should be done in the relayer in the future
335337
const signedAckPacketCompleted = await (await unsignedAckPacketTxValidTo.complete()).sign.withWallet().complete();

cardano/onchain/validators/spending_channel.ak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn find_updated_output(address: Address, outputs: List<Output>) -> Output {
130130
}
131131

132132
fn no_output_for_address(address: Address, outputs: List<Output>) -> Bool {
133-
[] == list.filter(outputs, fn(output) { output.address == address })
133+
list.is_empty(list.filter(outputs, fn(output) { output.address == address }))
134134
}
135135

136136
fn extract_output_datum(output: Output) -> ChannelDatum {

0 commit comments

Comments
 (0)