Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8b6a0a3
test: test view functions
think-in-universe Jan 15, 2026
221e15a
test: fix bulid error
think-in-universe Jan 15, 2026
153ecea
test: fix view functions
think-in-universe Jan 15, 2026
beed4be
fix: get owner function
think-in-universe Jan 15, 2026
8a299fc
test: get owner
think-in-universe Jan 15, 2026
49ea422
fix: get owner ID
think-in-universe Jan 15, 2026
21ae79b
fix: get owners
think-in-universe Jan 15, 2026
02a6302
fix: function args
think-in-universe Jan 15, 2026
cad64fa
fix: acl_get_super_admins
think-in-universe Jan 15, 2026
a1e39ac
test: remove compose hash
think-in-universe Jan 15, 2026
e857098
test: invalid app compose json
think-in-universe Jan 15, 2026
1b8eb48
test: two create_liquidity_pool call in parallel
think-in-universe Jan 15, 2026
41029aa
test: fix build error
think-in-universe Jan 15, 2026
e1b8ff9
test: fix build error
think-in-universe Jan 15, 2026
f6e3d5e
test: fix build error
think-in-universe Jan 15, 2026
23d1093
fix: build error on linux
think-in-universe Jan 15, 2026
4b6d046
fix: build error on linux
think-in-universe Jan 15, 2026
e6ad357
fix: upgrade contract
think-in-universe Jan 15, 2026
474008d
fix: upgrade contract
think-in-universe Jan 15, 2026
d8b09f1
test: fix upgrade
think-in-universe Jan 15, 2026
67ea2f0
test: fix lint
think-in-universe Jan 15, 2026
d518d5f
fix: resolve comments
think-in-universe Jan 16, 2026
6822f51
fix: log
think-in-universe Jan 17, 2026
1a8436f
fix: upgrade dcap-qvl to v0.3.10
think-in-universe Jan 24, 2026
de09fdf
fix: pck_certificate_chain parsing
think-in-universe Jan 24, 2026
d3a1dde
fix: upgrade to dcap-qvl v0.3.11
think-in-universe Jan 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[build]
# Reduce memory usage during linking
[target.'cfg(target_os = "linux")']
rustflags = [
# Reduce memory usage during linking
"-C", "link-arg=-Wl,--no-keep-memory",
]

[profile.test]
# Optimize tests slightly to reduce memory usage during compilation
# Keep debug info for test debugging
opt-level = 1
debug = true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
**/target/
.cargo/
.idea/
.vscode/
.cursor
Expand Down
2 changes: 1 addition & 1 deletion contracts/solver-registry/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Contract {
.emit();
}

/// Remove an approved docker compose has
/// Remove an approved docker compose hash
#[access_control_any(roles(Role::Owner))]
pub fn remove_compose_hash(&mut self, compose_hash: String) {
DockerComposeHash::try_from_hex(&compose_hash)
Expand Down
1 change: 1 addition & 0 deletions contracts/solver-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mod ext;
pub mod pool;
mod token_receiver;
pub mod types;
mod upgrade;
mod view;

const GAS_ADD_WORKER_KEY: Gas = Gas::from_tgas(20);
Expand Down
12 changes: 6 additions & 6 deletions contracts/solver-registry/src/upgrade.rs
Copy link
Copy Markdown
Collaborator Author

@think-in-universe think-in-universe Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to remove this upgrade module because near-plugins has already support contract upgradability.

Just let me know what's your thoughts about this.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{Contract, ContractExt};
use crate::{Contract, ContractExt, Role};
use near_plugins::{AccessControllable, access_control_any};

use near_sdk::{
AccountId, Gas, GasWeight, NearToken, Promise, PromiseOrValue, assert_one_yocto, env,
near_bindgen,
AccountId, Gas, GasWeight, NearToken, Promise, PromiseOrValue, assert_one_yocto, env, near,
};

#[near_bindgen]
#[near]
impl Contract {
#[init(ignore_state)]
#[payable]
Expand All @@ -17,8 +17,8 @@ impl Contract {
env::state_read::<Self>().unwrap_or_else(|| env::panic_str("Failed to read contract state"))
}

#[access_control_any(roles(Role::Owner))]
pub fn upgrade(&mut self) -> PromiseOrValue<AccountId> {
self.assert_owner();
let code = env::input().unwrap_or_else(|| env::panic_str("Code not found"));
Promise::new(env::current_account_id())
.deploy_contract(code)
Expand All @@ -30,7 +30,7 @@ impl Contract {
GasWeight(1),
)
.function_call_weight(
"get_owner_id".into(),
"acl_get_permissioned_accounts".into(),
vec![],
NearToken::ZERO,
Gas::from_tgas(10),
Expand Down
1 change: 1 addition & 0 deletions contracts/solver-registry/tests/common/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub const COMPOSE_HASH: &str = "f68cf65a75ad980289144ef3c096a007fc4583ea6d1f90589757f229dbc6cdab";
pub const DEFAULT_WORKER_PING_TIMEOUT_MS: u64 = 10 * 60 * 1000;

// Worker Info: Alice
pub const SECRET_KEY_ALICE: &str = "ed25519:3uHrtHQ6422oAj7WhvDgf9KdewGZLvCLbY6AyDdfkctRkUgyai1yMFn7TGnY2a4zQ8o2a1xQpaPPuaTcjRNaxTqP";
Expand Down
84 changes: 84 additions & 0 deletions contracts/solver-registry/tests/common/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,27 @@ pub async fn approve_compose_hash(
Ok(())
}

// Helper function to remove compose hash
pub async fn remove_compose_hash(
owner: &Account,
solver_registry: &Contract,
compose_hash: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let result = owner
.call(solver_registry.id(), "remove_compose_hash")
.args_json(json!({
"compose_hash": compose_hash.to_string()
}))
.transact()
.await?;
assert!(
result.is_success(),
"{:#?}",
result.into_result().unwrap_err()
);
Ok(())
}

// Helper function to register a worker
pub async fn register_worker(
worker: &Account,
Expand Down Expand Up @@ -475,6 +496,69 @@ pub async fn get_pool_info(
Ok(pool_info)
}

// Helper function to get owner IDs
pub async fn get_owners(
solver_registry: &Contract,
skip: u64,
limit: u64,
) -> Result<Vec<AccountId>, Box<dyn std::error::Error>> {
let result = solver_registry
.view("acl_get_super_admins")
.args_json(json!({
"skip": skip,
"limit": limit
}))
.await?;
let owners: Vec<AccountId> = serde_json::from_slice(&result.result).unwrap();
Ok(owners)
}

// Helper function to get approved compose hashes
pub async fn get_approved_compose_hashes(
solver_registry: &Contract,
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let result = solver_registry.view("get_approved_compose_hashes").await?;
let approved_compose_hashes: Vec<String> = serde_json::from_slice(&result.result).unwrap();
Ok(approved_compose_hashes)
}

// Helper function to get pool length
pub async fn get_pool_len(solver_registry: &Contract) -> Result<u32, Box<dyn std::error::Error>> {
let result = solver_registry.view("get_pool_len").await?;
let pool_length: u32 = serde_json::from_slice(&result.result).unwrap();
Ok(pool_length)
}

// Helper function to get worker length
pub async fn get_worker_len(solver_registry: &Contract) -> Result<u32, Box<dyn std::error::Error>> {
let result = solver_registry.view("get_worker_len").await?;
let worker_length: u32 = serde_json::from_slice(&result.result).unwrap();
Ok(worker_length)
}

// Helper function to get workers
pub async fn get_workers(
solver_registry: &Contract,
offset: u32,
limit: u32,
) -> Result<Vec<WorkerInfo>, Box<dyn std::error::Error>> {
let result = solver_registry
.view("get_workers")
.args_json(json!({"offset": offset, "limit": limit}))
.await?;
let workers: Vec<WorkerInfo> = serde_json::from_slice(&result.result).unwrap();
Ok(workers)
}

// Helper function to get worker ping timeout
pub async fn get_worker_ping_timeout_ms(
solver_registry: &Contract,
) -> Result<u64, Box<dyn std::error::Error>> {
let result = solver_registry.view("get_worker_ping_timeout_ms").await?;
let worker_ping_timeout_ms: u64 = serde_json::from_slice(&result.result).unwrap();
Ok(worker_ping_timeout_ms)
}

// Helper function to ping as a worker
pub async fn ping_worker(
worker: &Account,
Expand Down
Loading