Skip to content

Commit

Permalink
Merge branch 'master' into lpahlavi/xc-240-add-pagination-to-cketh-da…
Browse files Browse the repository at this point in the history
…shboard
  • Loading branch information
lpahlavi authored Dec 11, 2024
2 parents 1e1ab09 + 00d999c commit 4828410
Show file tree
Hide file tree
Showing 28 changed files with 181 additions and 363 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/anonymization-backend-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
RELEASE_TAG="${{ env.NAME }}-${COMMIT_SHORT}"
fi
if [[ ! "${RELEASE_TAG}" =~ "^${{ env.NAME }}" ]]; then
if [[ ! "${RELEASE_TAG}" =~ ^${{ env.NAME }} ]]; then
echo "ERROR: Required tag prefix: ${{ env.NAME }}"
exit 1
fi
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/rate-limits-backend-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: rate-limits-release

on:
workflow_dispatch:
inputs:
title:
description: 'Title for the release'
required: true
type: string

description:
description: 'Human-readable description of the release'
required: true
type: string

tag:
description: 'Tag for the release (required format `rate-limits-*`)'
required: false
type: string

permissions:
contents: write

env:
NAME: rate-limits
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-and-release:
name: Build and release the rate-limits backend canister

runs-on:
group: zh1
labels: dind-large

container:
image: ghcr.io/dfinity/ic-build@sha256:4fd13b47285e783c3a6f35aadd9559d097c0de162a1cf221ead66ab1598d5d45
options: >-
-e NODE_NAME --privileged --cgroupns host -v /cache:/cache -v /var/sysimage:/var/sysimage -v /var/tmp:/var/tmp -v /ceph-s3-info:/ceph-s3-info
steps:
- uses: actions/checkout@v4

- name: build
shell: bash
run: |
TARGET='//rs/boundary_node/rate_limits:rate_limit_canister'
bazel build --config=ci ${TARGET}
OUTPUT='bazel-bin/rs/boundary_node/rate_limits/rate_limit_canister.wasm.gz'
mv ${OUTPUT} rate_limit_canister.wasm.gz
ARTIFACTS=(
rate_limit_canister.wasm.gz
)
echo "ARTIFACTS=${ARTIFACTS[@]}" >> "${GITHUB_ENV}"
- name: checksums
run: |
CHECKSUMS=$(mktemp)
for ARTIFACT in ${ARTIFACTS[@]}; do
shasum -a256 ${ARTIFACT} >> ${CHECKSUMS}
done
echo "CHECKSUMS=${CHECKSUMS}" >> "${GITHUB_ENV}"
- name: tag
run: |
RELEASE_TAG='${{ inputs.tag }}'
if [[ -z "${RELEASE_TAG}" ]]; then
COMMIT_SHORT=$(git rev-parse --short HEAD)
RELEASE_TAG="${{ env.NAME }}-${COMMIT_SHORT}"
fi
if [[ ! "${RELEASE_TAG}" =~ ^${{ env.NAME }} ]]; then
echo "ERROR: Required tag prefix: ${{ env.NAME }}"
exit 1
fi
git tag ${RELEASE_TAG}
git push origin tag ${RELEASE_TAG}
echo "RELEASE_TAG=${RELEASE_TAG}" >> "${GITHUB_ENV}"
- name: release notes
run: |
NOTES=$(mktemp)
CODE_BLOCK='```'
cat > ${NOTES} <<EOF
${{ inputs.description }}
## Verification
To reproduce the artifacts of this release:
${CODE_BLOCK}
bazel build --config=local //rs/boundary_node/rate_limits:rate_limit_canister
${CODE_BLOCK}
## Checksums
${CODE_BLOCK}
$(cat ${CHECKSUMS})
${CODE_BLOCK}
EOF
echo "NOTES=${NOTES}" >> "${GITHUB_ENV}"
- name: release
run: |
gh release create \
${RELEASE_TAG} ${ARTIFACTS[@]} \
--title '${{ inputs.title }}' \
--verify-tag \
--latest=false \
--notes-file ${NOTES}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ members = [
"rs/nervous_system/runtime",
"rs/nervous_system/string",
"rs/nervous_system/temporary",
"rs/nervous_system/tools/sync-with-released-nevous-system-wasms",
"rs/nervous_system/tools/sync-with-released-nervous-system-wasms",
"rs/nns/constants",
"rs/nns/common",
"rs/nns/common/protobuf_generator",
Expand Down
6 changes: 2 additions & 4 deletions rs/cycles_account_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,18 +1015,16 @@ impl CyclesAccountManager {
canister_id: CanisterId,
cycles_balance: &mut Cycles,
amount_to_mint: Cycles,
) -> Result<Cycles, CyclesAccountManagerError> {
) -> Result<(), CyclesAccountManagerError> {
if canister_id != CYCLES_MINTING_CANISTER_ID {
let error_str = format!(
"ic0.mint_cycles cannot be executed on non Cycles Minting Canister: {} != {}",
canister_id, CYCLES_MINTING_CANISTER_ID
);
Err(CyclesAccountManagerError::ContractViolation(error_str))
} else {
let before_balance = *cycles_balance;
*cycles_balance += amount_to_mint;
// equal to amount_to_mint, except when the addition saturated
Ok(*cycles_balance - before_balance)
Ok(())
}
}

Expand Down
10 changes: 0 additions & 10 deletions rs/embedders/src/wasm_utils/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,6 @@ fn get_valid_system_apis_common(I: ValType) -> HashMap<String, HashMap<String, F
},
)],
),
(
"mint_cycles128",
vec![(
API_VERSION_IC0,
FunctionSignature {
param_types: vec![ValType::I64, ValType::I64, I],
return_type: vec![],
},
)],
),
(
"call_cycles_add128",
vec![(
Expand Down
12 changes: 0 additions & 12 deletions rs/embedders/src/wasmtime_embedder/system_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,18 +1190,6 @@ pub fn syscalls<
})
.unwrap();

linker
.func_wrap("ic0", "mint_cycles128", {
move |mut caller: Caller<'_, StoreData>, amount_high: u64, amount_low: u64, dst: I| {
with_memory_and_system_api(&mut caller, |s, memory| {
let dst: usize = dst.try_into().expect("Failed to convert I to usize");
s.ic0_mint_cycles128(Cycles::from_parts(amount_high, amount_low), dst, memory)
})
.map_err(|e| anyhow::Error::msg(format!("ic0_mint_cycles128 failed: {}", e)))
}
})
.unwrap();

linker
.func_wrap("ic0", "cycles_burn128", {
move |mut caller: Caller<'_, StoreData>, amount_high: u64, amount_low: u64, dst: I| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ set -ue
## | update/ic0_canister_status() | 1.27G | 1.34G | +5% | 3.73s |
## | inspect/ic0_msg_method_name_size() | - | 1.28G | - | 23.92s |

if ! which bazel rg >/dev/null; then
echo "Error checking dependencies: please ensure 'bazel' and 'rg' are installed"
exit 1
fi

## To quickly assess the new changes, run benchmarks just once
QUICK=${QUICK:-}
if [ -n "${QUICK}" ]; then
Expand Down
26 changes: 3 additions & 23 deletions rs/execution_environment/benches/system_api/execute_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ pub fn execute_update_bench(c: &mut Criterion) {
Result::No,
Wasm64::Enabled,
), // 10B max
529004006,
529001006,
),
common::Benchmark(
"wasm32/ic0_debug_print()/1B".into(),
Expand Down Expand Up @@ -736,7 +736,7 @@ pub fn execute_update_bench(c: &mut Criterion) {
Result::No,
Wasm64::Enabled,
),
517004006,
517001006,
),
common::Benchmark(
"wasm32/ic0_msg_cycles_available()".into(),
Expand Down Expand Up @@ -878,26 +878,6 @@ pub fn execute_update_bench(c: &mut Criterion) {
Module::Test.from_ic0("mint_cycles", Param1(1_i64), Result::I64, Wasm64::Enabled),
18000006,
),
common::Benchmark(
"wasm32/ic0_mint_cycles128()".into(),
Module::Test.from_ic0(
"mint_cycles128",
Params3(1_i64, 2_i64, 3_i32),
Result::No,
Wasm64::Disabled,
),
19001006,
),
common::Benchmark(
"wasm64/ic0_mint_cycles128()".into(),
Module::Test.from_ic0(
"mint_cycles128",
Params3(1_i64, 2_i64, 3_i64),
Result::No,
Wasm64::Enabled,
),
19004006,
),
common::Benchmark(
"wasm32/ic0_is_controller()".into(),
Module::Test.from_ic0(
Expand Down Expand Up @@ -942,7 +922,7 @@ pub fn execute_update_bench(c: &mut Criterion) {
"wasm32/ic0_cycles_burn128()".into(),
Module::Test.from_ic0(
"cycles_burn128",
Params3(1_i64, 2_i64, 3_i32),
Params3(1_i64, 2_i64, 3),
Result::No,
Wasm64::Disabled,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,6 @@ fn query_cache_future_proof_test() {
| SystemApiCallId::InReplicatedExecution
| SystemApiCallId::IsController
| SystemApiCallId::MintCycles
| SystemApiCallId::MintCycles128
| SystemApiCallId::MsgArgDataCopy
| SystemApiCallId::MsgArgDataSize
| SystemApiCallId::MsgCallerCopy
Expand Down
66 changes: 0 additions & 66 deletions rs/execution_environment/tests/hypervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2280,72 +2280,6 @@ fn ic0_mint_cycles_succeeds_on_cmc() {
);
}

// helper for mint_cycles128 tests
fn verify_error_and_no_effect(mut test: ExecutionTest) {
let canister_id = test.universal_canister().unwrap();
let initial_cycles = test.canister_state(canister_id).system_state.balance();
let payload = wasm()
.mint_cycles128(Cycles::from(10_000_000_000_u128))
.reply_data_append()
.reply()
.build();
let err = test.ingress(canister_id, "update", payload).unwrap_err();
assert_eq!(ErrorCode::CanisterContractViolation, err.code());
assert!(err
.description()
.contains("ic0.mint_cycles cannot be executed"));
let canister_state = test.canister_state(canister_id);
assert_eq!(0, canister_state.system_state.queues().output_queues_len());
assert_balance_equals(
initial_cycles,
canister_state.system_state.balance(),
BALANCE_EPSILON,
);
}

#[test]
fn ic0_mint_cycles128_fails_on_application_subnet() {
let test = ExecutionTestBuilder::new().build();
verify_error_and_no_effect(test);
}

#[test]
fn ic0_mint_cycles128_fails_on_system_subnet_non_cmc() {
let test = ExecutionTestBuilder::new()
.with_subnet_type(SubnetType::System)
.build();
verify_error_and_no_effect(test);
}

#[test]
fn ic0_mint_cycles128_succeeds_on_cmc() {
let mut test = ExecutionTestBuilder::new()
.with_subnet_type(SubnetType::System)
.build();
let mut canister_id = test.universal_canister().unwrap();
for _ in 0..4 {
canister_id = test.universal_canister().unwrap();
}
assert_eq!(canister_id, CYCLES_MINTING_CANISTER_ID);
let initial_cycles = test.canister_state(canister_id).system_state.balance();
let amount: u128 = (1u128 << 64) + 2u128;
let payload = wasm()
.mint_cycles128(Cycles::from(amount))
.reply_data_append()
.reply()
.build();
let result = test.ingress(canister_id, "update", payload).unwrap();
assert_eq!(WasmResult::Reply(amount.to_le_bytes().to_vec()), result);
let canister_state = test.canister_state(canister_id);

assert_eq!(0, canister_state.system_state.queues().output_queues_len());
assert_balance_equals(
initial_cycles + Cycles::new(amount),
canister_state.system_state.balance(),
BALANCE_EPSILON,
);
}

#[test]
fn ic0_call_enqueues_request() {
let mut test = ExecutionTestBuilder::new().build();
Expand Down
22 changes: 4 additions & 18 deletions rs/interfaces/src/execution_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ pub enum SystemApiCallId {
IsController,
/// Tracker for `ic0.mint_cycles()`
MintCycles,
/// Tracker for `ic0.mint_cycles128()`
MintCycles128,
/// Tracker for `ic0.msg_arg_data_copy()`
MsgArgDataCopy,
/// Tracker for `ic0.msg_arg_data_size()`
Expand Down Expand Up @@ -1127,25 +1125,13 @@ pub trait SystemApi {
///
/// Adds no more cycles than `amount`.
///
/// The canister balance afterwards does not exceed
/// maximum amount of cycles it can hold.
/// However, canisters on system subnets have no balance limit.
///
/// Returns the amount of cycles added to the canister's balance.
fn ic0_mint_cycles(&mut self, amount: u64) -> HypervisorResult<u64>;

/// Mints the `amount` cycles
/// Adds cycles to the canister's balance.
///
/// Adds no more cycles than `amount`. The balance afterwards cannot
/// exceed u128::MAX, so the amount added may be less than `amount`.
///
/// The amount of cycles added to the canister's balance is
/// represented by a 128-bit value and is copied in the canister
/// memory starting at the location `dst`.
fn ic0_mint_cycles128(
&mut self,
amount: Cycles,
dst: usize,
heap: &mut [u8],
) -> HypervisorResult<()>;

/// Checks whether the principal identified by src/size is one of the
/// controllers of the canister. If yes, then a value of 1 is returned,
/// otherwise a 0 is returned. It can be called multiple times.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ async fn test_deployment_swap_upgrade() {
}

/// Upgrade Tests
#[ignore]
#[tokio::test]
async fn test_upgrade_swap() {
test_sns_upgrade(vec![SnsCanisterType::Swap]).await;
Expand Down
Loading

0 comments on commit 4828410

Please sign in to comment.