Skip to content

Commit a7ee110

Browse files
authored
Merge branch 'master' into native/connect-with-otp
2 parents 477f3ee + 8b340c0 commit a7ee110

File tree

86 files changed

+342
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+342
-174
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/canisters/airdrop_bot/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [unreleased]
88

9+
### Changed
10+
11+
- Expose `liquid_cycles_balance` in metrics ([#8350](https://github.com/open-chat-labs/open-chat/pull/8350))
12+
- Add delay before retrying c2c call under certain error conditions ([#8355](https://github.com/open-chat-labs/open-chat/pull/8355))
13+
914
## [[2.0.1811](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1811-airdrop_bot)] - 2025-07-01
1015

1116
### Changed

backend/canisters/airdrop_bot/impl/src/actions.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use tracing::{error, info, trace};
1010
use types::icrc1::{self, Account};
1111
use types::{
1212
BotMessage, CanisterId, ChannelId, CommunityId, CompletedCryptoTransaction, CryptoContent, CryptoTransaction,
13-
MessageContentInitial, UserId,
13+
MessageContentInitial, Milliseconds, UserId,
1414
};
15-
use utils::canister::should_retry_failed_c2c_call;
15+
use utils::canister::delay_if_should_retry_failed_c2c_call;
1616
use utils::time::{MONTHS, MonthKey};
1717

1818
impl TimerJobItem for Action {
19-
async fn process(&self) -> Result<(), bool> {
19+
async fn process(&self) -> Result<(), Option<Milliseconds>> {
2020
match self.clone() {
2121
Action::JoinChannel(community_id, channel_id) => join_channel(community_id, channel_id).await,
2222
Action::SendMessage(a) if matches!(a.airdrop_type, AirdropType::Lottery(_)) => {
@@ -66,7 +66,7 @@ pub struct LotteryAirdrop {
6666
pub position: usize,
6767
}
6868

69-
async fn join_channel(community_id: CommunityId, channel_id: ChannelId) -> Result<(), bool> {
69+
async fn join_channel(community_id: CommunityId, channel_id: ChannelId) -> Result<(), Option<Milliseconds>> {
7070
info!(?community_id, ?channel_id, "Join channel");
7171

7272
let local_user_index_canister_id = match community_canister_c2c_client::local_user_index(
@@ -77,8 +77,8 @@ async fn join_channel(community_id: CommunityId, channel_id: ChannelId) -> Resul
7777
{
7878
Ok(community_canister::local_user_index::Response::Success(canister_id)) => canister_id,
7979
Err(error) => {
80-
let retry = should_retry_failed_c2c_call(error.reject_code(), error.message());
81-
return Err(retry);
80+
let delay_if_should_retry = delay_if_should_retry_failed_c2c_call(error.reject_code(), error.message());
81+
return Err(delay_if_should_retry);
8282
}
8383
};
8484

@@ -99,15 +99,15 @@ async fn join_channel(community_id: CommunityId, channel_id: ChannelId) -> Resul
9999
| Ok(local_user_index_canister::join_channel::Response::SuccessJoinedCommunity(_)) => (),
100100
Ok(local_user_index_canister::join_channel::Response::InternalError(err)) => {
101101
error!("Failed to join_channel {err:?}");
102-
return Err(true);
102+
return Err(Some(0));
103103
}
104104
Ok(resp) => {
105105
error!("Failed to join_channel {resp:?}");
106-
return Err(false);
106+
return Err(None);
107107
}
108108
Err(err) => {
109109
error!("Failed to join_channel {err:?}");
110-
return Err(true);
110+
return Err(Some(0));
111111
}
112112
}
113113

@@ -118,7 +118,7 @@ async fn join_channel(community_id: CommunityId, channel_id: ChannelId) -> Resul
118118
Ok(())
119119
}
120120

121-
async fn handle_transfer_action(action: AirdropTransfer) -> Result<(), bool> {
121+
async fn handle_transfer_action(action: AirdropTransfer) -> Result<(), Option<Milliseconds>> {
122122
let amount = action.amount.into();
123123

124124
trace!(?amount, "CHAT Transfer");
@@ -187,14 +187,14 @@ async fn handle_transfer_action(action: AirdropTransfer) -> Result<(), bool> {
187187
}
188188
Err(error) => {
189189
error!(?args, ?error, "Failed to transfer CHAT, retrying");
190-
return Err(true);
190+
return Err(Some(0));
191191
}
192192
}
193193

194194
Ok(())
195195
}
196196

197-
async fn handle_main_message_action(action: AirdropMessage) -> Result<(), bool> {
197+
async fn handle_main_message_action(action: AirdropMessage) -> Result<(), Option<Milliseconds>> {
198198
trace!("Send DM");
199199

200200
let AirdropType::Main(MainAirdrop { chit, shares }) = action.airdrop_type else {
@@ -231,21 +231,21 @@ async fn handle_main_message_action(action: AirdropMessage) -> Result<(), bool>
231231
Ok(user_canister::c2c_handle_bot_messages::Response::Success) => Ok(()),
232232
Ok(resp) => {
233233
error!(?args, ?resp, "Failed to send DM");
234-
Err(false)
234+
Err(None)
235235
}
236236
Err(error) => {
237-
let retry = should_retry_failed_c2c_call(error.reject_code(), error.message());
237+
let delay_if_should_retry = delay_if_should_retry_failed_c2c_call(error.reject_code(), error.message());
238238
error!(?args, ?error, "Failed to send DM");
239-
Err(retry)
239+
Err(delay_if_should_retry)
240240
}
241241
}
242242
}
243243

244-
async fn handle_lottery_message_action(action: AirdropMessage) -> Result<(), bool> {
244+
async fn handle_lottery_message_action(action: AirdropMessage) -> Result<(), Option<Milliseconds>> {
245245
info!("Send lottery winners message");
246246

247247
let AirdropType::Lottery(LotteryAirdrop { position }): AirdropType = action.airdrop_type else {
248-
return Err(false);
248+
return Err(None);
249249
};
250250

251251
let Some((community_id, channel_id, message_id)) = mutate_state(|state| {
@@ -255,7 +255,7 @@ async fn handle_lottery_message_action(action: AirdropMessage) -> Result<(), boo
255255
.current(state.env.now())
256256
.map(|c| (c.community_id, c.channel_id, state.env.rng().r#gen()))
257257
}) else {
258-
return Err(false);
258+
return Err(None);
259259
};
260260

261261
let position = match position {
@@ -295,12 +295,12 @@ async fn handle_lottery_message_action(action: AirdropMessage) -> Result<(), boo
295295
Ok(community_canister::send_message::Response::Success(_)) => Ok(()),
296296
Ok(resp) => {
297297
error!(?args, ?resp, "Failed to send lottery message");
298-
Err(false)
298+
Err(None)
299299
}
300300
Err(error) => {
301301
error!(?args, ?error, "Failed to send lottery message");
302-
let retry = should_retry_failed_c2c_call(error.reject_code(), error.message());
303-
Err(retry)
302+
let delay_if_should_retry = delay_if_should_retry_failed_c2c_call(error.reject_code(), error.message());
303+
Err(delay_if_should_retry)
304304
}
305305
}
306306
}

backend/canisters/airdrop_bot/impl/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl RuntimeState {
5454
stable_memory_used: utils::memory::stable(),
5555
now: self.env.now(),
5656
cycles_balance: self.env.cycles_balance(),
57+
liquid_cycles_balance: self.env.liquid_cycles_balance(),
5758
wasm_version: WASM_VERSION.with_borrow(|v| **v),
5859
git_commit_id: utils::git::git_commit_id().to_string(),
5960
airdrops: self.data.airdrops.metrics(),
@@ -120,6 +121,7 @@ pub struct Metrics {
120121
pub heap_memory_used: u64,
121122
pub stable_memory_used: u64,
122123
pub cycles_balance: Cycles,
124+
pub liquid_cycles_balance: Cycles,
123125
pub wasm_version: BuildVersion,
124126
pub git_commit_id: String,
125127
pub canister_ids: CanisterIds,

backend/canisters/community/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99
### Changed
1010

1111
- When a bot invites a user also send an invitation ([#8320](https://github.com/open-chat-labs/open-chat/pull/8320))
12+
- Expose `liquid_cycles_balance` in metrics ([#8350](https://github.com/open-chat-labs/open-chat/pull/8350))
13+
- Add delay before retrying c2c call under certain error conditions ([#8355](https://github.com/open-chat-labs/open-chat/pull/8355))
14+
- Allow members to read community summary/membership ([#8357](https://github.com/open-chat-labs/open-chat/pull/8357))
1215

1316
### Fixed
1417

backend/canisters/community/impl/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ impl RuntimeState {
350350
stable_memory_used: utils::memory::stable(),
351351
now: self.env.now(),
352352
cycles_balance: self.env.cycles_balance(),
353+
liquid_cycles_balance: self.env.liquid_cycles_balance(),
353354
wasm_version: WASM_VERSION.with_borrow(|v| **v),
354355
git_commit_id: utils::git::git_commit_id().to_string(),
355356
public: self.data.is_public.value,
@@ -1182,6 +1183,7 @@ pub struct Metrics {
11821183
pub stable_memory_used: u64,
11831184
pub now: TimestampMillis,
11841185
pub cycles_balance: Cycles,
1186+
pub liquid_cycles_balance: Cycles,
11851187
pub wasm_version: BuildVersion,
11861188
pub git_commit_id: String,
11871189
pub public: bool,

backend/canisters/community/impl/src/model/local_user_index_event_batch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{can_borrow_state, run_regular_jobs};
22
use local_user_index_canister::CommunityEvent;
33
use timer_job_queues::{TimerJobItem, timer_job_batch};
4-
use types::{CanisterId, IdempotentEnvelope};
5-
use utils::canister::should_retry_failed_c2c_call;
4+
use types::{CanisterId, IdempotentEnvelope, Milliseconds};
5+
use utils::canister::delay_if_should_retry_failed_c2c_call;
66

77
timer_job_batch!(LocalUserIndexEventBatch, CanisterId, IdempotentEnvelope<CommunityEvent>, 10);
88

99
impl TimerJobItem for LocalUserIndexEventBatch {
10-
async fn process(&self) -> Result<(), bool> {
10+
async fn process(&self) -> Result<(), Option<Milliseconds>> {
1111
if can_borrow_state() {
1212
run_regular_jobs();
1313
}
@@ -23,8 +23,8 @@ impl TimerJobItem for LocalUserIndexEventBatch {
2323
match response {
2424
Ok(local_user_index_canister::c2c_community_canister::Response::Success) => Ok(()),
2525
Err(error) => {
26-
let retry = should_retry_failed_c2c_call(error.reject_code(), error.message());
27-
Err(retry)
26+
let delay_if_should_retry = delay_if_should_retry_failed_c2c_call(error.reject_code(), error.message());
27+
Err(delay_if_should_retry)
2828
}
2929
}
3030
}

backend/canisters/community/impl/src/model/user_event_batch.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{can_borrow_state, run_regular_jobs};
22
use timer_job_queues::{TimerJobItem, grouped_timer_job_batch};
3-
use types::{IdempotentEnvelope, UserId};
3+
use types::{IdempotentEnvelope, Milliseconds, UserId};
44
use user_canister::CommunityCanisterEvent;
5-
use utils::canister::should_retry_failed_c2c_call;
5+
use utils::canister::delay_if_should_retry_failed_c2c_call;
66

77
grouped_timer_job_batch!(UserEventBatch, UserId, IdempotentEnvelope<CommunityCanisterEvent>, 1000);
88

99
impl TimerJobItem for UserEventBatch {
10-
async fn process(&self) -> Result<(), bool> {
10+
async fn process(&self) -> Result<(), Option<Milliseconds>> {
1111
if can_borrow_state() {
1212
run_regular_jobs();
1313
}
@@ -23,8 +23,8 @@ impl TimerJobItem for UserEventBatch {
2323
match response {
2424
Ok(user_canister::c2c_community_canister::Response::Success) => Ok(()),
2525
Err(error) => {
26-
let retry = should_retry_failed_c2c_call(error.reject_code(), error.message());
27-
Err(retry)
26+
let delay_if_should_retry = delay_if_should_retry_failed_c2c_call(error.reject_code(), error.message());
27+
Err(delay_if_should_retry)
2828
}
2929
}
3030
}

backend/canisters/cycles_dispenser/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [unreleased]
88

9+
### Changed
10+
11+
- Expose `liquid_cycles_balance` in metrics ([#8350](https://github.com/open-chat-labs/open-chat/pull/8350))
12+
913
## [[2.0.1826](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1826-cycles_dispenser)] - 2025-07-09
1014

1115
### Changed

backend/canisters/cycles_dispenser/impl/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl State {
4747
stable_memory_used: utils::memory::stable(),
4848
now: self.env.now(),
4949
cycles_balance: self.env.cycles_balance(),
50+
liquid_cycles_balance: self.env.liquid_cycles_balance(),
5051
wasm_version: WASM_VERSION.with_borrow(|v| **v),
5152
git_commit_id: utils::git::git_commit_id().to_string(),
5253
governance_principals: self.data.governance_principals.iter().copied().collect(),
@@ -123,6 +124,7 @@ pub struct Metrics {
123124
pub heap_memory_used: u64,
124125
pub stable_memory_used: u64,
125126
pub cycles_balance: Cycles,
127+
pub liquid_cycles_balance: Cycles,
126128
pub wasm_version: BuildVersion,
127129
pub git_commit_id: String,
128130
pub governance_principals: Vec<Principal>,

0 commit comments

Comments
 (0)