Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment CLI changes #952

Merged
merged 41 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
86ef8e4
[mkt] proposal self reaction attempt check
tworec Jan 12, 2021
508f7dd
Merge branch 'master' into market/proposal-self-reaction
tworec Jan 13, 2021
a1cbc39
Merge branch 'master' into market/proposal-self-reaction
tworec Jan 13, 2021
28603ec
fix
tworec Jan 13, 2021
d6f22af
simplify
tworec Jan 13, 2021
f673ab4
golemsp can ask for status in new naming convention
nieznanysprawiciel Jan 18, 2021
3a66171
[pay] payment status cli stub
tworec Jan 18, 2021
78b664c
[pay-drv] mainnet GLM as a default network and token for both drivers
tworec Jan 18, 2021
94edd6b
[pay] cli status a bit less hardcoded
tworec Jan 18, 2021
a199be7
Add --network parameter; Handle drivers, networks, tokens and platfor…
nieznanysprawiciel Jan 19, 2021
0ce88a9
Merge branch 'payment-status/yagna/stub' of github.com:golemfactory/y…
nieznanysprawiciel Jan 19, 2021
8470748
Diiferentiate between token and token displayed name; Print token bas…
nieznanysprawiciel Jan 19, 2021
7cfed82
Remove mentions of (N)GNT; Display GLM or tGLM (where possible)
nieznanysprawiciel Jan 19, 2021
3dfaed0
Revert "[pay-drv] mainnet GLM as a default network and token for both…
tworec Jan 19, 2021
e60779a
apply revie comments
tworec Jan 19, 2021
bc67b3c
Merge pull request #935 from golemfactory/payment-status/yagna/stub
tworec Jan 19, 2021
b001ff8
[yagna] full `payment status --driver --network` support
tworec Jan 19, 2021
0cb0f63
Merge pull request #941 from golemfactory/payment-status/yagna
nieznanysprawiciel Jan 20, 2021
f63125a
Merge branch 'payment-status/master' of github.com:golemfactory/yagna…
nieznanysprawiciel Jan 20, 2021
683c36d
Don't pass --token to yagna payment status
nieznanysprawiciel Jan 20, 2021
cbc48ba
Change GNT to GLM where it is safe to do so
nieznanysprawiciel Jan 20, 2021
3f156a9
Revert changes in payment driver to avoid conflicts
nieznanysprawiciel Jan 20, 2021
cb11704
[golemsp] invoke `payment init --sender` instad `-p`
tworec Jan 19, 2021
c613bc0
[golemsp] fix token name for zksync rinkeby
tworec Jan 19, 2021
d767912
Rename --network to --payment-network
nieznanysprawiciel Jan 20, 2021
00d57eb
Merge pull request #944 from golemfactory/payment-status/golemsp
tworec Jan 20, 2021
e17c82f
report yagna version as metrics
etam Jan 19, 2021
0a32ced
Merge branch 'master' into etam/version_at_metrics
tworec Jan 21, 2021
ed4bafb
Merge branch 'master' into market/proposal-self-reaction
tworec Jan 21, 2021
25d7789
Merge pull request #933 from golemfactory/etam/version_at_metrics
tworec Jan 21, 2021
4edb7ae
Merge branch 'master' into market/proposal-self-reaction
tworec Jan 21, 2021
b496712
Merge pull request #914 from golemfactory/market/proposal-self-reaction
tworec Jan 21, 2021
84f99ef
[golemsp] add network to the status output
tworec Jan 20, 2021
aee77df
[pay cli] status formatted as table, --json back compatible
tworec Jan 20, 2021
23e9e10
[golemsp] token got from `yagna status` or hardcoded
tworec Jan 20, 2021
9fe5017
Payment CLI changes
Wiezzel Jan 21, 2021
c2f2450
Merge branch 'master' into payment-status/edited
Wiezzel Jan 21, 2021
cb9c59f
[golemsp] status: version splitted to make output narrower
tworec Jan 21, 2021
b500470
[pay cli] status: all amounts with tokes
tworec Jan 21, 2021
0519e52
[golemsp] status: adress colspan=2 to make output narrower
tworec Jan 21, 2021
53b2211
[golemsp] adapt to changed `yagna payment init`
tworec Jan 21, 2021
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
40 changes: 38 additions & 2 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions agent/provider/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It is rather straightforward and minimal:
* requires `golem.srv.comp.expiration` to be set
* if provided (via env or CLI) sets also `golem.node.debug.subnet`
* properties:
* linear pricing (see sample below: 0.01 NGNT/sec + 1.2 NGNT/CPUsec + 1.5 NGNT const)
* linear pricing (see sample below: 0.01 GLM/sec + 1.2 GLM/CPUsec + 1.5 GLM const)
* hardware: memory and storage (sample below: 1 gib RAM and 10 gib disk)
* node name set via env or CLI
* runtime (sample below: wasmtime)
Expand Down Expand Up @@ -203,9 +203,9 @@ Name: default
ExeUnit: wasmtime
Pricing model: linear
Coefficients:
Duration 0.1 NGNT
CPU 0.2 NGNT
Init price 1 NGNT
Duration 0.1 GLM
CPU 0.2 GLM
Init price 1 GLM
```

Expand Down
2 changes: 1 addition & 1 deletion agent/provider/src/market/presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl fmt::Display for Preset {
for (name, coeff) in self.usage_coeffs.iter() {
write!(
f,
" {:width$}{} NGNT\n",
" {:width$}{} GLM\n",
name.to_readable(),
coeff,
width = align_coeff
Expand Down
2 changes: 1 addition & 1 deletion agent/provider/src/preset_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl PresetUpdater {
.cloned()
.unwrap_or(0.);
let price = Input::<f64>::new()
.with_prompt(&format!("{} (NGNT)", coefficient.to_readable()))
.with_prompt(&format!("{} (GLM)", coefficient.to_readable()))
.default(prev_price)
.show_default(true)
.interact()?;
Expand Down
23 changes: 9 additions & 14 deletions core/market/src/negotiation/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::db::{
TakeEventsError,
},
model::{
Agreement, AgreementEvent, AgreementId, AgreementState, AppSessionId, Issuer, MarketEvent,
Owner, Proposal, ProposalId, ProposalState, SubscriptionId,
Agreement, AgreementEvent, AgreementId, AgreementState, AppSessionId, MarketEvent, Owner,
Proposal, ProposalId, ProposalState, SubscriptionId,
},
};
use crate::matcher::{store::SubscriptionStore, RawProposal};
Expand Down Expand Up @@ -116,12 +116,6 @@ impl CommonBroker {
self.validate_proposal(&prev_proposal, caller_id, caller_role)
.await?;

if prev_proposal.body.issuer == Issuer::Us {
Err(ProposalValidationError::OwnProposal(
prev_proposal.body.id.clone(),
))?;
}

let is_first = prev_proposal.body.prev_proposal_id.is_none();
let new_proposal = prev_proposal.from_client(proposal)?;

Expand Down Expand Up @@ -153,12 +147,6 @@ impl CommonBroker {
self.validate_proposal(&proposal, caller_id, caller_role)
.await?;

if proposal.body.issuer == Issuer::Us && proposal_id.owner() == caller_role {
let e = ProposalValidationError::OwnProposal(proposal.body.id.clone());
log::warn!("{}", e);
Err(e)?;
}

self.db
.as_dao::<ProposalDao>()
.change_proposal_state(proposal_id, ProposalState::Rejected)
Expand Down Expand Up @@ -643,6 +631,13 @@ impl CommonBroker {
ProposalValidationError::Unauthorized(proposal.body.id.clone(), caller_id.clone());
}

if &proposal.issuer() == caller_id {
let e = ProposalValidationError::OwnProposal(proposal.body.id.clone());
log::warn!("{}", e);
counter!("market.proposals.self-reaction-attempt", 1);
Err(e)?;
}

// check Offer
self.store.get_offer(&proposal.negotiation.offer_id).await?;

Expand Down
1 change: 1 addition & 0 deletions core/market/src/negotiation/requestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl RequestorBroker {
counter!("market.proposals.requestor.received", 0);
counter!("market.proposals.requestor.rejected.by-them", 0);
counter!("market.proposals.requestor.rejected.by-us", 0);
counter!("market.proposals.self-reaction-attempt", 0);

tokio::spawn(proposal_receiver_thread(broker, proposal_receiver));
Ok(engine)
Expand Down
7 changes: 6 additions & 1 deletion core/model/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ pub mod local {

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GetStatus {
pub platform: String,
pub address: String,
pub driver: String,
pub network: Option<String>,
pub token: Option<String>,
}

impl RpcMessage for GetStatus {
Expand All @@ -248,6 +250,9 @@ pub mod local {
pub reserved: BigDecimal,
pub outgoing: StatusNotes,
pub incoming: StatusNotes,
pub driver: String,
pub network: String,
pub token: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, Default)]
Expand Down
8 changes: 4 additions & 4 deletions core/payment/examples/cancel_invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn main() -> anyhow::Result<()> {
payment_due_date: Some(Utc::now()),
};
log::info!(
"Issuing debit note for activity 1 (total amount due: {} NGNT)...",
"Issuing debit note for activity 1 (total amount due: {} GLM)...",
&debit_note.total_amount_due
);
let debit_note = provider.issue_debit_note(&debit_note).await?;
Expand All @@ -84,7 +84,7 @@ async fn main() -> anyhow::Result<()> {
payment_due_date: Some(Utc::now()),
};
log::info!(
"Issuing debit note for activity 2 (total amount due: {} NGNT)...",
"Issuing debit note for activity 2 (total amount due: {} GLM)...",
debit_note2.total_amount_due
);
let debit_note2 = provider.issue_debit_note(&debit_note2).await?;
Expand All @@ -107,7 +107,7 @@ async fn main() -> anyhow::Result<()> {
amount: BigDecimal::from(3u64),
payment_due_date: Utc::now(),
};
log::info!("Issuing invoice (amount: {} NGNT)...", &invoice.amount);
log::info!("Issuing invoice (amount: {} GLM)...", &invoice.amount);
let invoice = provider.issue_invoice(&invoice).await?;
log::info!("Invoice issued.");

Expand Down Expand Up @@ -178,7 +178,7 @@ async fn main() -> anyhow::Result<()> {
amount: BigDecimal::from(3u64),
payment_due_date: Utc::now(),
};
log::info!("Issuing invoice (amount: {} NGNT)...", &invoice.amount);
log::info!("Issuing invoice (amount: {} GLM)...", &invoice.amount);
let invoice = provider.issue_invoice(&invoice).await?;
log::info!("Invoice issued.");

Expand Down
8 changes: 4 additions & 4 deletions core/payment/examples/debit_note_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {
payment_due_date: Some(Utc::now()),
};
log::info!(
"Issuing debit note (total amount due: {} NGNT)...",
"Issuing debit note (total amount due: {} GLM)...",
&debit_note.total_amount_due
);
let debit_note = provider.issue_debit_note(&debit_note).await?;
Expand Down Expand Up @@ -109,7 +109,7 @@ async fn main() -> anyhow::Result<()> {
log::info!("Debit note accepted.");

log::info!("Waiting for payment...");
let timeout = Some(Duration::from_secs(300)); // Should be enough for GNT transfer
let timeout = Some(Duration::from_secs(300)); // Should be enough for GLM transfer
let mut payments = provider
.get_payments(Some(&now), timeout, None, None)
.await?;
Expand All @@ -130,7 +130,7 @@ async fn main() -> anyhow::Result<()> {
payment_due_date: Some(Utc::now()),
};
log::info!(
"Issuing debit note (total amount due: {} NGNT)...",
"Issuing debit note (total amount due: {} GLM)...",
debit_note2.total_amount_due
);
let debit_note2 = provider.issue_debit_note(&debit_note2).await?;
Expand All @@ -154,7 +154,7 @@ async fn main() -> anyhow::Result<()> {
log::info!("Debit note accepted.");

log::info!("Waiting for payment...");
let timeout = Some(Duration::from_secs(300)); // Should be enough for GNT transfer
let timeout = Some(Duration::from_secs(300)); // Should be enough for GLM transfer
let mut payments = provider
.get_payments(Some(&now), timeout, None, args.app_session_id.clone())
.await?;
Expand Down
2 changes: 1 addition & 1 deletion core/payment/examples/invoice_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async fn main() -> anyhow::Result<()> {
log::debug!("events 2: {:?}", &invoice_events_accepted);

log::info!("Waiting for payment...");
let timeout = Some(Duration::from_secs(300)); // Should be enough for GNT transfer
let timeout = Some(Duration::from_secs(300)); // Should be enough for GLM transfer
let mut payments = provider
.get_payments(Some(&now), timeout, None, args.app_session_id.clone())
.await?;
Expand Down
Loading