Skip to content

Commit

Permalink
New payment model. You have to set how often yagna has to pay. Yagna …
Browse files Browse the repository at this point in the history
…will automatically batch transactions for payment driver. You can set payments based on cron or just interval. It's a bit beta and need some testing.

* fix error causing payments not to be confirmed

* new profile for development

* fix payments sum

* fix payments sum

* Do not change invoice status on settled prematurely

* New version of allocation table. Working on changes accordingly

* Working on up.sql

* Work up

* changes in allocation

* changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

* changed name to allocation_expenditure

* fix after merge

* migration script updated

* migrations cannot be applied

* fix migration script

* fix

* added allocation id

* fix

* working on allocation expenditure

* working on allocations - not compiling

* Fix compilation errors after merge-rebase

* Working on payments from allocation

* Working on payments from allocation (deposits)

* Added deposit_status field to allocation to track deposit status

* Working on allocations

* Total amount scheduled doesn't matter anymore

* Fixed issue with updating activity null values

* Remove schedule message

* Removed dead code related to removed order table

* Simplify notify payment message

* Further simplifying the code

* More elegant filter

* Added post migration to sum paid activities into agreements

* Added post migration to sum paid activities into agreements

* Add missing allocation id foreign key reference to payment documents

* Fix merge

* Removed unused code

* Windows build

* Fix client version

* Fix client version

* Windows build

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Working on serve - fix payee_addr

* Adding frontend to build

* Adding frontend to build - fmt

* Fix warnings

* fetch tags

* fetch tags automatically

* fetch tags automatically

* fix warning

* Update frontend

* Fix fronted display

* Fix fronted display

* Fix fronted

* Fix problems with pay_payments

* Gather allocations without deposit into group and sum payments accordingly

* Update payments

* fmt

* wip

* wip

* All debit notes payable

* Fix value paid

* Work in progress

* Working on flush payments

* Merging Reqc code

* Merging Reqc code

* Merging Reqc code

* Merging Reqc code

* working on mockup data for testing

* wip

* wip

* wip

* wip

* extending API

* extending API

* extending API

* extending API

* extending API - added debit note chain query for activity

* extending API - added debit note chain query for activity

* fix date generation in mockup generator

* remove debug message

* fmt

* fix foreign keys in db

* add get invoice route

* wip

* working on batch payments

* working on batch payments

* working on batch payments, fix floats and format

* wip-not working

* API for batch orders

* working on API for batch orders

* working on API for batch orders, separating resolve invoices from resolve agreements

* first process activities, then invoices improving queries and accounting logic that way (easier checking which activity is paid).

* removed unused table payment

* Added debit_nonce field to debit notes

* Improving API

* Improvements

* Improvements

* Working on additional messages

* removed driver

* fixed what was broken, created DebitNotForApi

* fmt

* working on resolving invoices

* working on resolving invoices

* fmt

* fix

* fix

* fix compilation after merge

* move migrations

* work on cycles

* work on cycles

* work on cycles update

* fmt

* working on batch cycles

* added api

* added platform to cycles

* fmt

* working on cron

* working on nice cli presentation

* working on interval cli presentation

* working on interval cli presentation

* working on interval cli presentation - fix setup

* working on interval cli presentation - better set info

* working on interval cli presentation

* working on interval cli api

* fix error causing payments not to be confirmed

* fix payments sum

* fix payments sum

* Do not change invoice status on settled prematurely

* New version of allocation table. Working on changes accordingly

* Working on up.sql

* Work up

* changes in allocation

* changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

changed separate pay_agreement_payment and pay_activity_payment into one pay_payment_document

* changed name to allocation_expenditure

* fix after merge

* migration script updated

* migrations cannot be applied

* fix migration script

* fix

* added allocation id

* fix

* working on allocation expenditure

* working on allocations - not compiling

* Fix compilation errors after merge-rebase

* Working on payments from allocation

* Working on payments from allocation (deposits)

* Added deposit_status field to allocation to track deposit status

* Working on allocations

* Total amount scheduled doesn't matter anymore

* Fixed issue with updating activity null values

* Remove schedule message

* Removed dead code related to removed order table

* Simplify notify payment message

* Further simplifying the code

* More elegant filter

* Added post migration to sum paid activities into agreements

* Added post migration to sum paid activities into agreements

* Add missing allocation id foreign key reference to payment documents

* Fix merge

* Removed unused code

* Windows build

* Fix client version

* Fix client version

* Windows build

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Windows build with cache

* Working on serve - fix payee_addr

* Adding frontend to build

* Adding frontend to build - fmt

* fetch tags

* fetch tags automatically

* fetch tags automatically

* Update frontend

* Fix fronted display

* Fix fronted display

* Fix fronted

* Fix problems with pay_payments

* Gather allocations without deposit into group and sum payments accordingly

* Working on payment notifications

* Working on payment notifications for peers

* Merging

* Fix ya-client version

* db manip moved to separate repo

* Added deduplication of merged allocations into payment

* Fix after merge

* Reverting unneeded changes

* Removed unused code

* fmt

* moved post migration into separate file

* Removed unused message

* Removed paid column. paid_amount is updated now

* Better order behaviour. Update date shows when last payment was done

* Fix index name

* Add primary key to pay_payment table

* Fixed migration

* Fix missing columns and change signature and signed_bytes to blob and text accordingly

* Added peer id to document payment

* Fix script

* useful sql scripts

* Fix schema relationship for document payment

* Batch cycles improvements

* improve batch cycle message

* Update after merge

* Check if goth will work when set 24s interval

* fix goth test

* fix goth tests

* fix logs

* fix logs2

* lock

* lock

* lock

* change default payment cycle

* todo fix

* update poetry

* reverted goth to main version
  • Loading branch information
scx1332 authored Feb 10, 2025
1 parent 564eccf commit 8755c9d
Show file tree
Hide file tree
Showing 63 changed files with 6,665 additions and 2,500 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-sgx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
working-directory: exe-unit
run: |
echo "TODO: fix sgx tests"
# cargo test --features sgx
# cargo test --features sgx
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ db.sqlite-wal

# bak files (generated by notepad++)
**/*.bak

# Suggested debug data dirs
yagnadir
providerdir

*.bat
18 changes: 16 additions & 2 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ arc_with_non_send_sync = "allow"
blocks_in_conditions = "allow"
get_first = "allow"
doc_lazy_continuation = "allow"
len_zero = "allow"

[workspace]
members = [
Expand Down Expand Up @@ -287,8 +288,8 @@ ya-sb-proto = { version = "0.6.2" }
ya-sb-util = { version = "0.5.1" }
parking_lot = "0.12.3"
mime = "0.3.17"
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "653e7ed3ff8836837b660a76e604055e167b1f2e" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "653e7ed3ff8836837b660a76e604055e167b1f2e" }
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "b4bf2aab46181d594dcba5b6956c03172ee1f2ea" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "b4bf2aab46181d594dcba5b6956c03172ee1f2ea" }

ya-compile-time-utils.path = "utils/compile-time-utils"
ya-manifest-utils = { path = "utils/manifest-utils" }
Expand Down Expand Up @@ -325,8 +326,8 @@ ya-framework-basic.path = "test-utils/test-framework/framework-basic"
ya-framework-mocks.path = "test-utils/test-framework/framework-mocks"

[patch.crates-io]
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "653e7ed3ff8836837b660a76e604055e167b1f2e" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "653e7ed3ff8836837b660a76e604055e167b1f2e" }
ya-client = { git = "https://github.com/golemfactory/ya-client.git", rev = "b4bf2aab46181d594dcba5b6956c03172ee1f2ea" }
ya-client-model = { git = "https://github.com/golemfactory/ya-client.git", rev = "b4bf2aab46181d594dcba5b6956c03172ee1f2ea" }
golem-certificate = { git = "https://github.com/golemfactory/golem-certificate.git", rev = "f2d7514c18fc066e9cfb796090b90f5b27cfe1c6" }
ethereum-tx-sign = { git = "https://github.com/golemfactory/ethereum-tx-sign.git", rev = "1164c74187a9e2947faeaea7dde104c3cdec4195" }
graphene-sgx = { git = " https://github.com/golemfactory/graphene-rust.git", rev = "dbd993ebad7f9190410ea390a589348479af6407" }
Expand Down
2 changes: 1 addition & 1 deletion core/activity/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl ResponseError for Error {
}
_ => {
let e = self.to_string();
log::error!("Activity API server error: {}", e);
//log::error!("Activity API server error: {}", e);
HttpResponse::InternalServerError().json(ErrorMessage::new(e))
}
}
Expand Down
42 changes: 41 additions & 1 deletion core/model/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use derive_more::From;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use std::time::Duration;
use ya_client_model::payment::{allocation::Deposit, Allocation, DriverStatusProperty, Payment};
use ya_client_model::payment::{
allocation::Allocation, allocation::Deposit, DriverStatusProperty, Payment,
};
use ya_client_model::NodeId;
use ya_service_bus::RpcMessage;

pub fn driver_bus_id<T: Display>(driver_name: T) -> String {
Expand Down Expand Up @@ -296,6 +299,43 @@ impl RpcMessage for Init {
type Error = GenericError;
}

// ************************** FLUSH PAYMENTS **************************

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FlushPayments {
node_id: Option<NodeId>,
flush_date: DateTime<Utc>,
}

impl FlushPayments {
pub fn new(node_id: Option<NodeId>, flush_date: DateTime<Utc>) -> FlushPayments {
FlushPayments {
node_id,
flush_date,
}
}

pub fn flush_date(&self) -> DateTime<Utc> {
self.flush_date
}

pub fn node_id(&self) -> Option<NodeId> {
self.node_id
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum FlushPaymentResult {
FlushScheduled,
FlushNotNeeded,
}

impl RpcMessage for FlushPayments {
const ID: &'static str = "FlushPayments";
type Item = FlushPaymentResult;
type Error = GenericError;
}

// ************************** SCHEDULE PAYMENT **************************

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
Loading

0 comments on commit 8755c9d

Please sign in to comment.