Skip to content

Commit

Permalink
feat: rename stacks pricing (#299)
Browse files Browse the repository at this point in the history
* rename stacks pricing

* resolve tests
  • Loading branch information
jorgeantonio21 authored Dec 21, 2024
1 parent d8eeb47 commit 6f20fb6
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion atoma-bin/atoma_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async fn main() -> Result<()> {
.image_generations_service_url
.context("Image generations service URL not configured")?,
keystore: Arc::new(keystore),
address_index: address_index,
address_index,
};

let daemon_app_state = DaemonState {
Expand Down
2 changes: 1 addition & 1 deletion atoma-service/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod middleware {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 600,
price: 1,
price_per_one_million_compute_units: 1,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down
22 changes: 11 additions & 11 deletions atoma-state/src/migrations/20241121103103_create_node_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ CREATE TABLE IF NOT EXISTS node_subscriptions (

-- Create stacks table
CREATE TABLE IF NOT EXISTS stacks (
stack_small_id BIGINT PRIMARY KEY,
owner_address TEXT NOT NULL,
stack_id TEXT UNIQUE NOT NULL,
task_small_id BIGINT NOT NULL,
selected_node_id BIGINT NOT NULL,
num_compute_units BIGINT NOT NULL,
price BIGINT NOT NULL,
already_computed_units BIGINT NOT NULL,
in_settle_period BOOLEAN NOT NULL,
total_hash BYTEA NOT NULL,
num_total_messages BIGINT NOT NULL,
stack_small_id BIGINT PRIMARY KEY,
owner_address TEXT NOT NULL,
stack_id TEXT UNIQUE NOT NULL,
task_small_id BIGINT NOT NULL,
selected_node_id BIGINT NOT NULL,
num_compute_units BIGINT NOT NULL,
price_per_one_million_compute_units BIGINT NOT NULL,
already_computed_units BIGINT NOT NULL,
in_settle_period BOOLEAN NOT NULL,
total_hash BYTEA NOT NULL,
num_total_messages BIGINT NOT NULL,
CONSTRAINT check_compute_units CHECK (already_computed_units <= num_compute_units),
FOREIGN KEY (selected_node_id, task_small_id)
REFERENCES node_subscriptions (node_small_id, task_small_id)
Expand Down
78 changes: 39 additions & 39 deletions atoma-state/src/state_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,12 +1165,12 @@ impl AtomaState {
task_small_id = %stack.task_small_id,
selected_node_id = %stack.selected_node_id,
num_compute_units = %stack.num_compute_units,
price = %stack.price)
price = %stack.price_per_one_million_compute_units)
)]
pub async fn insert_new_stack(&self, stack: Stack) -> Result<()> {
sqlx::query(
"INSERT INTO stacks
(owner_address, stack_small_id, stack_id, task_small_id, selected_node_id, num_compute_units, price, already_computed_units, in_settle_period, total_hash, num_total_messages)
(owner_address, stack_small_id, stack_id, task_small_id, selected_node_id, num_compute_units, price_per_one_million_compute_units, already_computed_units, in_settle_period, total_hash, num_total_messages)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
ON CONFLICT (stack_small_id) DO UPDATE
SET already_computed_units = stacks.already_computed_units + $8
Expand All @@ -1182,7 +1182,7 @@ impl AtomaState {
.bind(stack.task_small_id)
.bind(stack.selected_node_id)
.bind(stack.num_compute_units)
.bind(stack.price)
.bind(stack.price_per_one_million_compute_units)
.bind(stack.already_computed_units)
.bind(stack.in_settle_period)
.bind(stack.total_hash)
Expand Down Expand Up @@ -2377,7 +2377,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2423,7 +2423,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 30,
in_settle_period: false,
total_hash: vec![0; 32],
Expand Down Expand Up @@ -2508,7 +2508,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2562,7 +2562,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 15,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2613,7 +2613,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2676,7 +2676,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2773,7 +2773,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -2890,7 +2890,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -3006,7 +3006,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -3190,7 +3190,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![1, 2, 3],
Expand All @@ -3203,7 +3203,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 50,
in_settle_period: true,
total_hash: vec![4, 5, 6],
Expand All @@ -3216,7 +3216,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 2,
num_compute_units: 300,
price: 3000,
price_per_one_million_compute_units: 3000,
already_computed_units: 100,
in_settle_period: false,
total_hash: vec![7, 8, 9],
Expand All @@ -3242,13 +3242,13 @@ mod tests {
assert!(
result
.iter()
.any(|s| s.stack_small_id == 1 && s.price == 1000),
.any(|s| s.stack_small_id == 1 && s.price_per_one_million_compute_units == 1000),
"Should find stack 1"
);
assert!(
result
.iter()
.any(|s| s.stack_small_id == 2 && s.price == 2000),
.any(|s| s.stack_small_id == 2 && s.price_per_one_million_compute_units == 2000),
"Should find stack 2"
);

Expand Down Expand Up @@ -3321,7 +3321,7 @@ mod tests {
assert_eq!(stack.task_small_id, 1);
assert_eq!(stack.selected_node_id, 2);
assert_eq!(stack.num_compute_units, 300);
assert_eq!(stack.price, 3000);
assert_eq!(stack.price_per_one_million_compute_units, 3000);
assert_eq!(stack.already_computed_units, 100);
assert!(!stack.in_settle_period);
assert_eq!(stack.total_hash, vec![7, 8, 9]);
Expand Down Expand Up @@ -3377,7 +3377,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![0; 32],
Expand All @@ -3391,7 +3391,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![0; 32],
Expand Down Expand Up @@ -3458,7 +3458,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![0; 32],
Expand All @@ -3472,7 +3472,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 2,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![0; 32],
Expand Down Expand Up @@ -3544,7 +3544,7 @@ mod tests {
selected_node_id: 1,
num_compute_units: 100,
already_computed_units: 90,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand All @@ -3558,7 +3558,7 @@ mod tests {
selected_node_id: 1,
num_compute_units: 100,
already_computed_units: 50,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand All @@ -3572,7 +3572,7 @@ mod tests {
selected_node_id: 2,
num_compute_units: 100,
already_computed_units: 95,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand All @@ -3586,7 +3586,7 @@ mod tests {
selected_node_id: 3,
num_compute_units: 100,
already_computed_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand Down Expand Up @@ -3693,7 +3693,7 @@ mod tests {
selected_node_id: 1,
num_compute_units: 0,
already_computed_units: 0,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand All @@ -3709,7 +3709,7 @@ mod tests {
selected_node_id: 1,
num_compute_units: i64::MAX,
already_computed_units: i64::MAX / 2 + i64::MAX / 4,
price: 1000,
price_per_one_million_compute_units: 1000,
in_settle_period: false,
total_hash: vec![0; 32],
num_total_messages: 0,
Expand Down Expand Up @@ -3772,7 +3772,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -3854,7 +3854,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 10,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![],
Expand Down Expand Up @@ -3969,7 +3969,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: vec![0; 32],
Expand All @@ -3982,7 +3982,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 50,
in_settle_period: true,
total_hash: vec![0; 32],
Expand All @@ -3995,7 +3995,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 2,
num_compute_units: 300,
price: 3000,
price_per_one_million_compute_units: 3000,
already_computed_units: 100,
in_settle_period: false,
total_hash: vec![0; 32],
Expand Down Expand Up @@ -4118,7 +4118,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 0,
in_settle_period: false,
total_hash: hash1.clone(),
Expand All @@ -4141,7 +4141,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 0,
in_settle_period: false,
total_hash: hash2.clone(),
Expand All @@ -4155,7 +4155,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 300,
price: 3000,
price_per_one_million_compute_units: 3000,
already_computed_units: 0,
in_settle_period: false,
total_hash: hash3.clone(),
Expand Down Expand Up @@ -4244,7 +4244,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 1,
num_compute_units: 100,
price: 1000,
price_per_one_million_compute_units: 1000,
already_computed_units: 50,
in_settle_period: true,
total_hash: vec![],
Expand All @@ -4257,7 +4257,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 2,
num_compute_units: 200,
price: 2000,
price_per_one_million_compute_units: 2000,
already_computed_units: 150,
in_settle_period: true,
total_hash: vec![],
Expand All @@ -4270,7 +4270,7 @@ mod tests {
task_small_id: 1,
selected_node_id: 3,
num_compute_units: 300,
price: 3000,
price_per_one_million_compute_units: 3000,
already_computed_units: 250,
in_settle_period: true,
total_hash: vec![],
Expand Down
Loading

0 comments on commit 6f20fb6

Please sign in to comment.