From 2d76b6f6d9dbe9ff5b2ce0253716054f574a3cdb Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Mon, 4 Dec 2023 11:38:44 +0100 Subject: [PATCH 01/12] Bump version to 0.14.0 --- Cargo.lock | 2 +- Cargo.toml | 6 +++--- pyproject.toml | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bafbac46a7..65a3e4d89a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9251,7 +9251,7 @@ dependencies = [ [[package]] name = "yagna" -version = "0.13.2" +version = "0.14.0" dependencies = [ "actix-rt", "actix-service", diff --git a/Cargo.toml b/Cargo.toml index 6adb30a6f7..cb72061bb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yagna" -version = "0.13.2" +version = "0.14.0" description = "Open platform and marketplace for distributed computations" readme = "README.md" authors = ["Golem Factory "] @@ -239,8 +239,8 @@ derive_more = "0.99.11" ya-relay-stack = { git = "https://github.com/golemfactory/ya-relay.git", rev = "c92a75b0cf062fcc9dbb3ea2a034d913e5fad8e5" } ya-relay-client = { git = "https://github.com/golemfactory/ya-relay.git", rev = "785c9c4271f514d47fe18018efb9438007ae611a" } -gftp = { version = "0.4.0", path="core/gftp" } -ya-agreement-utils = { version = "0.6", path="utils/agreement-utils" } +gftp = { version = "0.4.0", path = "core/gftp" } +ya-agreement-utils = { version = "0.6", path = "utils/agreement-utils" } [patch.crates-io] diff --git a/pyproject.toml b/pyproject.toml index f677f32b19..3dccc7e5e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,14 +4,12 @@ build-backend = "maturin" [project] name = "golem-node" -version = "0.13.2" +version = "0.14.0" description = "golem-node" readme = "README.md" requires-python = ">=3.7" license = { file = "LICENSE" } -keywords = [ - "Golem", -] +keywords = ["Golem"] classifiers = [ "Development Status :: 3 - Alpha", "Environment :: Console", @@ -25,7 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Rust" + "Programming Language :: Rust", ] urls = { repository = "https://github.com/golemfactory/yagna" } @@ -34,4 +32,3 @@ bindings = "bin" manifest-path = "Cargo.toml" python-source = "python" strip = true - From 49133139e91fb2ed91a2e5ba1129f8367100ce87 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Tue, 5 Dec 2023 19:35:25 +0100 Subject: [PATCH 02/12] Metrics --- Cargo.lock | 17 +- Cargo.toml | 2 +- core/metrics/src/service.rs | 25 ++ .../erc20next/config-payments.toml | 416 +++++------------- 4 files changed, 159 insertions(+), 301 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65a3e4d89a..04b2990c21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1956,9 +1956,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erc20_payment_lib" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ec0c57fe6b4a104c9c9f860d1e867dca4838085aa505625b209d8c4f931546e" +checksum = "a8c0620a07f8a1c30600526bb99efc1cc33b9d89ab309a5b31cfd95bfcec673c" dependencies = [ "actix-files", "actix-web", @@ -1975,6 +1975,7 @@ dependencies = [ "humantime 2.1.0", "lazy_static", "log", + "metrics 0.12.1", "rand 0.8.5", "regex", "rust_decimal", @@ -1996,9 +1997,9 @@ dependencies = [ [[package]] name = "erc20_payment_lib_common" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec6027442066984459d7e98711f91427aab622a960ab6f6d483dabcbeddbaf73" +checksum = "eb715a1d31ad9254d012e6691acfd1b64ec51fd1464d033fb21df143245142e3" dependencies = [ "actix-files", "actix-web", @@ -2013,6 +2014,9 @@ dependencies = [ "humantime 2.1.0", "lazy_static", "log", + "metrics 0.12.1", + "metrics-core", + "metrics-runtime", "rand 0.8.5", "regex", "rust_decimal", @@ -2034,9 +2038,9 @@ dependencies = [ [[package]] name = "erc20_rpc_pool" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd51cee570e856fe8ba5040ec1538d31482a6c106db2acc40db89a6df5110ed1" +checksum = "c8f122c88169091c04bd19d4f1a8dc907707176ee767df612a889a23043897c0" dependencies = [ "actix-files", "actix-web", @@ -2055,6 +2059,7 @@ dependencies = [ "humantime 2.1.0", "lazy_static", "log", + "metrics 0.12.1", "rand 0.8.5", "reqwest", "rust_decimal", diff --git a/Cargo.toml b/Cargo.toml index cb72061bb9..d99e2a97d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -231,7 +231,7 @@ members = [ libsqlite3-sys = { version = "0.26.0", features = ["bundled"] } #erc20_payment_lib = { version = "0.3.2", git = "https://github.com/golemfactory/erc20_payment_lib", rev = "2fb9949b43ccedf0dfad61926d567debd2d6086f" } #erc20_payment_lib = { path = "../../payments/erc20_payment_lib/crates/erc20_payment_lib" } -erc20_payment_lib = { version = "=0.3.13" } +erc20_payment_lib = { version = "=0.3.14" } rand = "0.8.5" url = "2.3.1" trust-dns-resolver = "0.22" diff --git a/core/metrics/src/service.rs b/core/metrics/src/service.rs index aacc85c0ad..0d56a98f13 100644 --- a/core/metrics/src/service.rs +++ b/core/metrics/src/service.rs @@ -64,8 +64,33 @@ impl MetricsService { actix_web::Scope::new("metrics-api/v1") // TODO:: add wrapper injecting Bearer to avoid hack in auth middleware .route("/expose", actix_web::web::get().to(export_metrics)) + .route("/sorted", actix_web::web::get().to(export_metrics_sorted)) } } +//algorith is returning metrics in random order, which is fine for prometheus, but not for human checking metrics +pub fn sort_metrics_txt(metrics: &str) -> String { + let Some(first_line_idx) = metrics.find('\n') else { + return metrics.to_string(); + }; + let (first_line, metrics_content) = metrics.split_at(first_line_idx); + + let mut entries = metrics_content + .split("\n\n") //splitting by double new line to get separate metrics + .map(|s| { + let trimmed = s.trim(); + let mut lines = trimmed.split('\n').collect::>(); + lines.sort(); //sort by properties + lines.join("\n") + }) + .collect::>(); + entries.sort(); //sort by metric name + + first_line.to_string() + "\n" + entries.join("\n\n").as_str() +} + +async fn export_metrics_sorted() -> String { + sort_metrics_txt(&METRICS.lock().await.export()) +} pub async fn export_metrics() -> String { METRICS.lock().await.export() diff --git a/core/payment-driver/erc20next/config-payments.toml b/core/payment-driver/erc20next/config-payments.toml index 7b98a8bc24..ec6e21dc4d 100644 --- a/core/payment-driver/erc20next/config-payments.toml +++ b/core/payment-driver/erc20next/config-payments.toml @@ -19,7 +19,7 @@ process-interval-after-no-gas-or-token-increase = 1.5 # report alive interval (in seconds) is to set how often we want to report that we are alive # minimum 1 second, maximum is capped by gather-interval -report-alive-interval = 30 +report-alive-interval = 10 # gather interval (in seconds) is to set how often payments are gathered # minimum 1 second, no maximum limit gather-interval = 60 @@ -29,6 +29,7 @@ automatic-recover = false # set to true to not respect deadlines attached to payments ignore-deadlines = false + [chain.ethereum] chain-name = "Ethereum" chain-id = 1 @@ -40,63 +41,37 @@ transaction-timeout = 100 token = { address = "0x7DD9c5Cba05E151C895FDe1CF355C9A1D5DA6429", symbol = "GLM" } confirmation-blocks = 1 block-explorer-url = "https://etherscan.io" +external-source-check-interval = 300 [[chain.ethereum.rpc-endpoints]] -name = "eth.llamarpc.com" -endpoint = "https://eth.llamarpc.com" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.ethereum.rpc-endpoints]] -name = "public.blastapi.io" -endpoint = "https://eth-mainnet.public.blastapi.io" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.ethereum.rpc-endpoints]] -name = "rpc.ankr.com/eth" -endpoint = "https://rpc.ankr.com/eth" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.ethereum.rpc-endpoints]] -name = "rpc.flashbots.net" -endpoint = "https://rpc.flashbots.net" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.ethereum.rpc-endpoints]] -name = "cloudflare-eth.com" -endpoint = "https://cloudflare-eth.com/" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.ethereum.rpc-endpoints]] -name = "ethereum.publicnode.com" -endpoint = "https://ethereum.publicnode.com" +names = """ + virginia.rpc.blxrbdn.com, + public.blastapi.io, + rpc.ankr.com/eth,rpc.flashbots.net, + cloudflare-eth.com, + ethereum.publicnode.com, + rpc.payload.de + """ +endpoints = """ + https://virginia.rpc.blxrbdn.com, + https://eth-mainnet.public.blastapi.io, + https://rpc.ankr.com/eth, + https://rpc.flashbots.net, + https://cloudflare-eth.com, + https://ethereum.publicnode.com, + https://rpc.payload.de + """ priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 [[chain.ethereum.rpc-endpoints]] -name = "chainstack" -endpoint = "https://chainstack.com/" priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 - +dns-source = "ethereum.rpc-node.dev.golem.network." [chain.goerli] @@ -109,114 +84,55 @@ gas-left-warning-limit = 1000000 transaction-timeout = 100 token = { address = "0x33af15c79d64b85ba14aaffaa4577949104b22e8", symbol = "tGLM" } multi-contract = { address = "0x7777784f803a7bf1d7f115f849d29ce5706da64a", max-at-once = 10 } -faucet-client = { max-eth-allowed = 0.009, faucet-srv = "_eth-faucet._tcp", faucet-host = "faucet.testnet.golem.network", faucet-lookup-domain = "dev.golem.network", faucet-srv-port = 4001 } +faucet-client = { max-eth-allowed = 0.009, faucet-srv = "_goerli-faucet._tcp", faucet-host = "faucet.testnet.golem.network", faucet-lookup-domain = "dev.golem.network", faucet-srv-port = 4001 } mint-contract = { address = "0xCCA41b09C1F50320bFB41BD6822BD0cdBDC7d85C", max-glm-allowed = 400 } confirmation-blocks = 0 block-explorer-url = "https://goerli.etherscan.io" +external-source-check-interval = 300 [[chain.goerli.rpc-endpoints]] -name = "eth-goerli.g.alchemy.com" -endpoint = "https://eth-goerli.g.alchemy.com/v2/demo" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "eth-goerli.public.blastapi.io" -endpoint = "https://eth-goerli.public.blastapi.io" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "eth-goerli.api.onfinality.io/public" -endpoint = "https://eth-goerli.api.onfinality.io/public" +names = """ +eth-goerli.g.alchemy.com/v2/demo, +eth-goerli.public.blastapi.io, +eth-goerli.api.onfinality.io/public, +rpc.goerli.mudit.blog, +endpoints.omniatech.io/v1/eth/goerli/public, +rpc.goerli.eth.gateway.fm, +goerli.blockpi.network/v1/rpc/public, +goerli.infura.io/v3/9aa, +rpc.ankr.com/eth_goerli, +ethereum-goerli-rpc.allthatnode.com, +rpc.slock.it/goerli, +www.ethercluster.com/goerli, +rpc.ankr.com/eth_goerli, +""" +endpoints = """ +https://eth-goerli.g.alchemy.com/v2/demo, +https://eth-goerli.public.blastapi.io, +https://eth-goerli.api.onfinality.io/public, +https://rpc.goerli.mudit.blog, +https://endpoints.omniatech.io/v1/eth/goerli/public, +https://rpc.goerli.eth.gateway.fm, +https://goerli.blockpi.network/v1/rpc/public, +https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161, +https://rpc.ankr.com/eth_goerli, +https://ethereum-goerli-rpc.allthatnode.com, +https://rpc.slock.it/goerli, +https://www.ethercluster.com/goerli, +https://rpc.ankr.com/eth_goerli, +""" priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "rpc.goerli.mudit.blog" -endpoint = "https://rpc.goerli.mudit.blog" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "endpoints.omniatech.io/v1/eth/goerli/public" -endpoint = "https://endpoints.omniatech.io/v1/eth/goerli/public" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "rpc.goerli.eth.gateway.fm" -endpoint = "https://rpc.goerli.eth.gateway.fm" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "goerli.blockpi.network/v1/rpc/public" -endpoint = "https://goerli.blockpi.network/v1/rpc/public" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161" -endpoint = "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "rpc.ankr.com/eth_goerli" -endpoint = "https://rpc.ankr.com/eth_goerli" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "ethereum-goerli-rpc.allthatnode.com" -endpoint = "https://ethereum-goerli-rpc.allthatnode.com" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.goerli.rpc-endpoints]] -name = "rpc.slock.it/goerli" -endpoint = "https://rpc.slock.it/goerli" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +allowed-head-behind-secs = 60 [[chain.goerli.rpc-endpoints]] -name = "www.ethercluster.com/goerli" -endpoint = "https://www.ethercluster.com/goerli" priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 +dns-source = "goerli.rpc-node.dev.golem.network." -[[chain.goerli.rpc-endpoints]] -name = "rpc.ankr.com/eth_goerli" -endpoint = "https://rpc.ankr.com/eth_goerli" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 [chain.holesky] chain-name = "Holesky" @@ -229,68 +145,41 @@ transaction-timeout = 100 token = { address = "0x8888888815bf4DB87e57B609A50f938311EEd068", symbol = "tGLM" } multi-contract = { address = "0xAaAAAaA00E1841A63342db7188abA84BDeE236c7", max-at-once = 10 } mint-contract = { address = "0xFACe100969FF47EB58d2CF603321B581A84bcEaC", max-glm-allowed = 400 } -faucet-client = { max-eth-allowed = 0.009, faucet-srv = "_eth-faucet._tcp", faucet-host = "faucet.testnet.golem.network", faucet-lookup-domain = "dev.golem.network", faucet-srv-port = 4002 } +lock-contract = { address = "0xCE78e3fe557E3754781Cc89eB7B01e940733e3F1" } +faucet-client = { max-eth-allowed = 0.009, faucet-srv = "_holesky-faucet._tcp", faucet-host = "faucet.testnet.golem.network", faucet-lookup-domain = "dev.golem.network", faucet-srv-port = 4002 } confirmation-blocks = 0 block-explorer-url = "https://holesky.etherscan.io" - - +external-source-check-interval = 300 [[chain.holesky.rpc-endpoints]] -name = "holesky.publicnode.com" -endpoint = "https://ethereum-holesky.publicnode.com" +names = """ + holesky.publicnode.com, + 1rpc.io/holesky, + rpc.ankr.com/eth_holesky, + eth-holesky.public.blastapi.io, + holesky.drpc.org, + holesky.rpc.thirdweb.com +""" + +endpoints = """ + https://holesky.publicnode.com, + https://1rpc.io/holesky, + https://rpc.ankr.com/eth_holesky, + https://eth-holesky.public.blastapi.io, + https://holesky.drpc.org, + https://holesky.rpc.thirdweb.com +""" priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 [[chain.holesky.rpc-endpoints]] -name = "1rpc.io/holesky" -endpoint = "https://1rpc.io/holesky" priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 - -[[chain.holesky.rpc-endpoints]] -name = "rpc.ankr.com/eth_holesky" -endpoint = "https://rpc.ankr.com/eth_holesky" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.holesky.rpc-endpoints]] -name = "holesky.public.blastapi.io" -endpoint = "https://eth-holesky.public.blastapi.io" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.holesky.rpc-endpoints]] -name = "holesky.drpc.org" -endpoint = "https://holesky.drpc.org" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.holesky.rpc-endpoints]] -name = "gateway.tenderly.co" -endpoint = "https://holesky.gateway.tenderly.co" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - -[[chain.holesky.rpc-endpoints]] -name = "holesky.rpc.thirdweb.com" -endpoint = "https://holesky.rpc.thirdweb.com" -priority = 0 -max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 - +dns-source = "holesky.rpc-node.dev.golem.network." [chain.mumbai] @@ -305,91 +194,43 @@ token = { address = "0x2036807B0B3aaf5b1858EE822D0e111fDdac7018", symbol = "tGLM multi-contract = { address = "0x800010D7d0d315DCA795110ecCf0127cBd76b89f", max-at-once = 10 } confirmation-blocks = 1 block-explorer-url = "https://mumbai.polygonscan.com" +external-source-check-interval = 300 [[chain.mumbai.rpc-endpoints]] -name = "g.alchemy.com/v2/demo" -endpoint = "https://polygon-mumbai.g.alchemy.com/v2/demo" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "blockpi.network/v1/rpc/public" -endpoint = "https://polygon-mumbai.blockpi.network/v1/rpc/public" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "public.blastapi.io/public" -endpoint = "https://polygon-testnet.public.blastapi.io" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "omniatech.io/mumbai/public" -endpoint = "https://endpoints.omniatech.io/v1/matic/mumbai/public" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "maticvigil.com/public" -endpoint = "https://rpc-mumbai.maticvigil.com" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "terminet.io/public" -endpoint = "https://polygontestapi.terminet.io/rpc" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "chainstacklabs.com/public" -endpoint = "https://matic-mumbai.chainstacklabs.com" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "archive-rpc.bwarelabs/public" -endpoint = "https://matic-testnet-archive-rpc.bwarelabs.com" +names = """ +polygon-mumbai.g.alchemy.com/v2/demo, +polygon-testnet.public.blastapi.io, +endpoints.omniatech.io/v1/matic/mumbai/public, +rpc-mumbai.maticvigil.com, +polygontestapi.terminet.io/rpc, +matic-mumbai.chainstacklabs.com, +matic-testnet-archive-rpc.bwarelabs.com, +rpc.ankr.com/polygon_mumbai, +polygon-testnet-archive.allthatnode.com:8545, +polygon-testnet-rpc.allthatnode.com:8545, +""" +endpoints = """ +https://polygon-mumbai.g.alchemy.com/v2/demo, +https://polygon-testnet.public.blastapi.io, +https://endpoints.omniatech.io/v1/matic/mumbai/public, +https://rpc-mumbai.maticvigil.com, +https://polygontestapi.terminet.io/rpc, +https://matic-mumbai.chainstacklabs.com, +https://matic-testnet-archive-rpc.bwarelabs.com, +https://rpc.ankr.com/polygon_mumbai, +https://polygon-testnet-archive.allthatnode.com:8545, +https://polygon-testnet-rpc.allthatnode.com:8545, +""" priority = 0 max-timeout-ms = 5000 allowed-head-behind-secs = 60 [[chain.mumbai.rpc-endpoints]] -name = "rpc.ankr.com/public" -endpoint = "https://rpc.ankr.com/polygon_mumbai" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "lavanet.xyz" -endpoint = "https://g.w.lavanet.xyz:443/gateway/polygon1t/rpc-http/f7ee0000000000000000000000000000" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 60 - -[[chain.mumbai.rpc-endpoints]] -name = "archive.allthatnode.com" -endpoint = "https://polygon-testnet-archive.allthatnode.com:8545" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 120 - -[[chain.mumbai.rpc-endpoints]] -name = "rpc.allthatnode.com" -endpoint = "https://polygon-testnet-rpc.allthatnode.com:8545" priority = 0 max-timeout-ms = 5000 +verify-interval-secs = 60 allowed-head-behind-secs = 120 - +dns-source = "mumbai.rpc-node.dev.golem.network." [chain.polygon] chain-name = "Polygon mainnet" @@ -403,48 +244,35 @@ token = { address = "0x0B220b82F3eA3B7F6d9A1D8ab58930C064A2b5Bf", symbol = "GLM" # multi-contract = { address = "0x50100d4faf5f3b09987dea36dc2eddd57a3e561b", max-at-once = 10 } confirmation-blocks = 1 block-explorer-url = "https://polygonscan.com" +external-source-check-interval = 300 [[chain.polygon.rpc-endpoints]] -name = "polygon-rpc.com" -endpoint = "https://polygon-rpc.com" +names = """ +polygon-rpc.com, +rpc-mainnet.maticvigil.com, +rpc-mainnet.matic.quiknode.pro, +bor.golem.network, +polygon-mainnet-archive.allthatnode.com:8545, +polygon-mainnet-rpc.allthatnode.com:8545, +""" +endpoints = """ +https://polygon-rpc.com, +https://rpc-mainnet.maticvigil.com, +https://rpc-mainnet.matic.quiknode.pro, +https://bor.golem.network, +https://polygon-mainnet-archive.allthatnode.com:8545, +https://polygon-mainnet-rpc.allthatnode.com:8545, +""" priority = 0 max-timeout-ms = 5000 allowed-head-behind-secs = 120 [[chain.polygon.rpc-endpoints]] -name = "maticvigil.com" -endpoint = "https://rpc-mainnet.maticvigil.com" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 120 - -[[chain.polygon.rpc-endpoints]] -name = "quiknode.pro" -endpoint = "https://rpc-mainnet.matic.quiknode.pro" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 120 - -[[chain.polygon.rpc-endpoints]] -name = "golem.network" -endpoint = "https://bor.golem.network" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 120 - -[[chain.polygon.rpc-endpoints]] -name = "allthatnode.com-archive" -endpoint = "https://polygon-mainnet-archive.allthatnode.com:8545" -priority = 0 -max-timeout-ms = 5000 -allowed-head-behind-secs = 120 - -[[chain.polygon.rpc-endpoints]] -name = "allthatnode.com-norm" -endpoint = "https://polygon-mainnet-rpc.allthatnode.com:8545" priority = 0 max-timeout-ms = 5000 +verify-interval-secs = 60 allowed-head-behind-secs = 120 +dns-source = "polygon.rpc-node.dev.golem.network." From 0832d23f7d2e0bf82e7e504db8c77ea03c4ea77f Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 11:53:26 +0100 Subject: [PATCH 03/12] update erc20lib to 0.3.15 --- Cargo.toml | 2 +- core/payment-driver/erc20next/config-payments.toml | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d99e2a97d1..4ecc90c5cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -231,7 +231,7 @@ members = [ libsqlite3-sys = { version = "0.26.0", features = ["bundled"] } #erc20_payment_lib = { version = "0.3.2", git = "https://github.com/golemfactory/erc20_payment_lib", rev = "2fb9949b43ccedf0dfad61926d567debd2d6086f" } #erc20_payment_lib = { path = "../../payments/erc20_payment_lib/crates/erc20_payment_lib" } -erc20_payment_lib = { version = "=0.3.14" } +erc20_payment_lib = { version = "=0.3.15" } rand = "0.8.5" url = "2.3.1" trust-dns-resolver = "0.22" diff --git a/core/payment-driver/erc20next/config-payments.toml b/core/payment-driver/erc20next/config-payments.toml index ec6e21dc4d..6d5b0d2902 100644 --- a/core/payment-driver/erc20next/config-payments.toml +++ b/core/payment-driver/erc20next/config-payments.toml @@ -36,7 +36,6 @@ chain-id = 1 currency-symbol = "ETH" priority-fee = 1.01 max-fee-per-gas = 40.0 -gas-left-warning-limit = 1000000 transaction-timeout = 100 token = { address = "0x7DD9c5Cba05E151C895FDe1CF355C9A1D5DA6429", symbol = "GLM" } confirmation-blocks = 1 @@ -80,7 +79,6 @@ chain-id = 5 currency-symbol = "tETH" priority-fee = 0.000001 max-fee-per-gas = 10.0 -gas-left-warning-limit = 1000000 transaction-timeout = 100 token = { address = "0x33af15c79d64b85ba14aaffaa4577949104b22e8", symbol = "tGLM" } multi-contract = { address = "0x7777784f803a7bf1d7f115f849d29ce5706da64a", max-at-once = 10 } @@ -140,7 +138,6 @@ chain-id = 17000 currency-symbol = "tETH" priority-fee = 0.000001 max-fee-per-gas = 10.0 -gas-left-warning-limit = 1000000 transaction-timeout = 100 token = { address = "0x8888888815bf4DB87e57B609A50f938311EEd068", symbol = "tGLM" } multi-contract = { address = "0xAaAAAaA00E1841A63342db7188abA84BDeE236c7", max-at-once = 10 } @@ -188,7 +185,6 @@ chain-id = 80001 currency-symbol = "tMATIC" priority-fee = 1.0 max-fee-per-gas = 14.0 -gas-left-warning-limit = 1000000 transaction-timeout = 60 token = { address = "0x2036807B0B3aaf5b1858EE822D0e111fDdac7018", symbol = "tGLM" } multi-contract = { address = "0x800010D7d0d315DCA795110ecCf0127cBd76b89f", max-at-once = 10 } @@ -238,7 +234,6 @@ chain-id = 137 currency-symbol = "MATIC" priority-fee = 30.111 max-fee-per-gas = 500.0 -gas-left-warning-limit = 1000000 transaction-timeout = 100 token = { address = "0x0B220b82F3eA3B7F6d9A1D8ab58930C064A2b5Bf", symbol = "GLM" } # multi-contract = { address = "0x50100d4faf5f3b09987dea36dc2eddd57a3e561b", max-at-once = 10 } From 859e61dbaefa296a3c2f7784dd12033ab5ebaed6 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 11:57:44 +0100 Subject: [PATCH 04/12] Fix lock file --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04b2990c21..20b4a08d47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1956,9 +1956,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erc20_payment_lib" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8c0620a07f8a1c30600526bb99efc1cc33b9d89ab309a5b31cfd95bfcec673c" +checksum = "c50dbcc5cf9c89afbdfe71b61aa891dfcd2a55a3a695299916b0931fef31a7b8" dependencies = [ "actix-files", "actix-web", From c664703f0e78d536a8cb5d340c87d989003dbf18 Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Wed, 6 Dec 2023 14:33:11 +0100 Subject: [PATCH 05/12] erc20next: remove faulty goerli endpoint (mudit) --- core/payment-driver/erc20next/config-payments.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/core/payment-driver/erc20next/config-payments.toml b/core/payment-driver/erc20next/config-payments.toml index 6d5b0d2902..a2da79be78 100644 --- a/core/payment-driver/erc20next/config-payments.toml +++ b/core/payment-driver/erc20next/config-payments.toml @@ -93,7 +93,6 @@ names = """ eth-goerli.g.alchemy.com/v2/demo, eth-goerli.public.blastapi.io, eth-goerli.api.onfinality.io/public, -rpc.goerli.mudit.blog, endpoints.omniatech.io/v1/eth/goerli/public, rpc.goerli.eth.gateway.fm, goerli.blockpi.network/v1/rpc/public, @@ -108,7 +107,6 @@ endpoints = """ https://eth-goerli.g.alchemy.com/v2/demo, https://eth-goerli.public.blastapi.io, https://eth-goerli.api.onfinality.io/public, -https://rpc.goerli.mudit.blog, https://endpoints.omniatech.io/v1/eth/goerli/public, https://rpc.goerli.eth.gateway.fm, https://goerli.blockpi.network/v1/rpc/public, @@ -131,7 +129,6 @@ verify-interval-secs = 60 allowed-head-behind-secs = 120 dns-source = "goerli.rpc-node.dev.golem.network." - [chain.holesky] chain-name = "Holesky" chain-id = 17000 @@ -268,6 +265,3 @@ max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 dns-source = "polygon.rpc-node.dev.golem.network." - - - From 97c87323ee21bd589098f377791c3ebcbe4c381e Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Wed, 6 Dec 2023 16:11:20 +0100 Subject: [PATCH 06/12] payment: fix unbound handle_status_change --- core/payment-driver/erc20next/src/lib.rs | 2 +- core/payment/src/service.rs | 457 ++++++++++++----------- 2 files changed, 233 insertions(+), 226 deletions(-) diff --git a/core/payment-driver/erc20next/src/lib.rs b/core/payment-driver/erc20next/src/lib.rs index f925e8fe8b..b17d610491 100644 --- a/core/payment-driver/erc20next/src/lib.rs +++ b/core/payment-driver/erc20next/src/lib.rs @@ -33,7 +33,7 @@ pub const MUMBAI_CURRENCY_LONG: &str = "Test MATIC"; pub const MAINNET_NETWORK: &str = "mainnet"; pub const MAINNET_TOKEN: &str = "GLM"; -pub const MAINNET_PLATFORM: &str = "erc20next=mainnet-glm"; +pub const MAINNET_PLATFORM: &str = "erc20next-mainnet-glm"; pub const MAINNET_CURRENCY_SHORT: &str = "ETH"; pub const MAINNET_CURRENCY_LONG: &str = "Ether"; diff --git a/core/payment/src/service.rs b/core/payment/src/service.rs index 0c0cef0e09..ceafe393f9 100644 --- a/core/payment/src/service.rs +++ b/core/payment/src/service.rs @@ -50,10 +50,16 @@ mod local { use super::*; use crate::dao::*; use chrono::NaiveDateTime; - use std::collections::BTreeMap; - use ya_client_model::payment::{Account, DocumentStatus, DriverDetails, DriverStatusProperty}; + use std::{collections::BTreeMap, convert::TryInto}; + use ya_client_model::{ + payment::{ + Account, DebitNoteEventType, DocumentStatus, DriverDetails, DriverStatusProperty, + InvoiceEventType, + }, + NodeId, + }; use ya_core_model::{ - driver::{driver_bus_id, DriverStatus, DriverStatusError}, + driver::{driver_bus_id, Ack, DriverStatus, DriverStatusError}, payment::local::*, }; use ya_persistence::types::Role; @@ -75,6 +81,7 @@ mod local { .bind_with_processor(release_allocations) .bind_with_processor(get_drivers) .bind_with_processor(payment_driver_status) + .bind_with_processor(handle_status_change) .bind_with_processor(shut_down); // Initialize counters to 0 value. Otherwise they won't appear on metrics endpoint @@ -404,6 +411,228 @@ mod local { Ok(status_props) } + // *************************** PAYMENT **************************** + async fn handle_status_change( + db: DbExecutor, + _processor: Arc>, + _caller: String, + msg: PaymentDriverStatusChange, + ) -> Result { + /// Payment platform affected by status + /// + /// It doesn't contain the token because we don't actually + /// support multiple tokens on one chain. + /// + /// TODO: remove references to token stuff in yagna and ideally + /// make payment platforms properly typed along the way. + #[derive(Hash, PartialEq, Eq)] + struct Platform { + driver: String, + network: String, + } + + impl Platform { + fn new(driver: impl Into, network: impl Into) -> Self { + Platform { + driver: driver.into(), + network: network.into(), + } + } + } + + let platform_str_to_platform = |platform: &str| -> Result { + let parts = platform.split('-').collect::>(); + let [driver, network, _]: [_; 3] = parts.try_into().map_err(|_| { + GenericError::new("Payment platform must be of the form {driver}-{network}-{token}") + })?; + + Ok(Platform::new(driver, network)) + }; + + /// Event broadcast information + /// + /// Each status property shall be broadcasted to all debit notes + /// and invoices affected. + /// + /// If properties are empty, a PaymentOkEvent will be sent. + #[derive(Default)] + struct Broadcast { + debit_notes: Vec<(String, NodeId)>, + invoices: Vec<(String, NodeId)>, + properties: Vec, + } + + // Create a mapping between platforms and relevant properties. + // + // This relies on the fact that a given payment driver status property + // can only affect one platform. + let mut broadcast = HashMap::::default(); + for prop in msg.properties { + let Some(network) = prop.network() else { + continue; + }; + + let value = broadcast + .entry(Platform::new(prop.driver(), network)) + .or_default(); + value.properties.push(prop); + } + + // All DAOs + let debit_note_dao: DebitNoteDao = db.as_dao(); + let debit_note_ev_dao: DebitNoteEventDao = db.as_dao(); + let invoice_dao: InvoiceDao = db.as_dao(); + let invoice_ev_dao: InvoiceEventDao = db.as_dao(); + + let accepted_notes = debit_note_dao + .list( + Some(Role::Requestor), + Some(DocumentStatus::Accepted), + Some(true), + ) + .await + .map_err(GenericError::new)?; + + // Populate broadcasts with affected debit_notes + for debit_note in accepted_notes { + let platform = platform_str_to_platform(&debit_note.payment_platform)?; + + // checks if the last payment-status event was PAYMENT_OK or no such event was emitted + let was_already_ok = debit_note_ev_dao + .get_for_debit_note_id( + debit_note.debit_note_id.clone(), + None, + None, + None, + vec!["PAYMENT_EVENT".into(), "PAYMENT_OK".into()], + vec![], + ) + .await + .map_err(GenericError::new)? + .last() + .map(|ev_type| { + matches!( + &ev_type.event_type, + DebitNoteEventType::DebitNotePaymentOkEvent + ) + }) + .unwrap_or(true); + + if !was_already_ok { + // If debit note has reported driver errors before, we *must* send a broadcast on status change. + // This will either be a new problem, or PaymentOkEvent if no errors are found. + broadcast + .entry(platform) + .or_default() + .debit_notes + .push((debit_note.debit_note_id, debit_note.issuer_id)); + } else if let Some(broadcast) = broadcast.get_mut(&platform) { + broadcast + .debit_notes + .push((debit_note.debit_note_id, debit_note.issuer_id)); + } + } + + let accepted_invoices = invoice_dao + .list(Some(Role::Requestor), Some(DocumentStatus::Accepted)) + .await + .map_err(GenericError::new)?; + + // Populate broadcasts with affected invoices + for invoice in accepted_invoices { + let platform = platform_str_to_platform(&invoice.payment_platform)?; + + // checks if the last payment-status event was PAYMENT_OK or no such event was emitted + let was_already_ok = invoice_ev_dao + .get_for_invoice_id( + invoice.invoice_id.clone(), + None, + None, + None, + vec!["PAYMENT_EVENT".into(), "PAYMENT_OK".into()], + vec![], + ) + .await + .map_err(GenericError::new)? + .last() + .map(|ev_type| { + matches!(&ev_type.event_type, InvoiceEventType::InvoicePaymentOkEvent) + }) + .unwrap_or(true); + + if !was_already_ok { + // If invoice has reported driver errors before, we *must* send a broadcast on status change. + // This will either be a new problem, or PaymentOkEvent if no errors are found. + broadcast + .entry(platform) + .or_default() + .invoices + .push((invoice.invoice_id, invoice.issuer_id)); + } else if let Some(broadcast) = broadcast.get_mut(&platform) { + broadcast + .invoices + .push((invoice.invoice_id, invoice.issuer_id)); + } + } + + // Emit debit note & invoice events. + for broadcast in broadcast.into_values() { + // If properties are empty, send OkEvents. Otherwise send the wrapped properties. + if broadcast.properties.is_empty() { + for (debit_note_id, owner_id) in &broadcast.debit_notes { + debit_note_ev_dao + .create( + debit_note_id.clone(), + *owner_id, + DebitNoteEventType::DebitNotePaymentOkEvent, + ) + .await + .map_err(GenericError::new)?; + } + + for (invoice_id, owner_id) in &broadcast.invoices { + invoice_ev_dao + .create( + invoice_id.clone(), + *owner_id, + InvoiceEventType::InvoicePaymentOkEvent, + ) + .await + .map_err(GenericError::new)?; + } + } else { + for prop in broadcast.properties { + for (invoice_id, owner_id) in &broadcast.invoices { + invoice_ev_dao + .create( + invoice_id.clone(), + *owner_id, + InvoiceEventType::InvoicePaymentStatusEvent { + property: prop.clone(), + }, + ) + .await + .map_err(GenericError::new)?; + } + for (debit_note_id, owner_id) in &broadcast.debit_notes { + debit_note_ev_dao + .create( + debit_note_id.clone(), + *owner_id, + DebitNoteEventType::DebitNotePaymentStatusEvent { + property: prop.clone(), + }, + ) + .await + .map_err(GenericError::new)?; + } + } + } + } + + Ok(Ack {}) + } + async fn shut_down( db: DbExecutor, processor: Arc>, @@ -419,7 +648,6 @@ mod local { } mod public { - use std::convert::TryInto; use std::str::FromStr; use super::*; @@ -432,7 +660,6 @@ mod public { // use crate::error::processor::VerifyPaymentError; use ya_client_model::{payment::*, NodeId}; - use ya_core_model::payment::local::PaymentDriverStatusChange; use ya_core_model::payment::public::*; use ya_persistence::types::Role; @@ -827,226 +1054,6 @@ mod public { } } - // *************************** PAYMENT **************************** - async fn handle_status_change( - db: DbExecutor, - msg: PaymentDriverStatusChange, - ) -> Result { - /// Payment platform affected by status - /// - /// It doesn't contain the token because we don't actually - /// support multiple tokens on one chain. - /// - /// TODO: remove references to token stuff in yagna and ideally - /// make payment platforms properly typed along the way. - #[derive(Hash, PartialEq, Eq)] - struct Platform { - driver: String, - network: String, - } - - impl Platform { - fn new(driver: impl Into, network: impl Into) -> Self { - Platform { - driver: driver.into(), - network: network.into(), - } - } - } - - let platform_str_to_platform = |platform: &str| -> Result { - let parts = platform.split('-').collect::>(); - let [driver, network, _]: [_; 3] = parts.try_into().map_err(|_| { - GenericError::new("Payment platform must be of the form {driver}-{network}-{token}") - })?; - - Ok(Platform::new(driver, network)) - }; - - /// Event broadcast information - /// - /// Each status property shall be broadcasted to all debit notes - /// and invoices affected. - /// - /// If properties are empty, a PaymentOkEvent will be sent. - #[derive(Default)] - struct Broadcast { - debit_notes: Vec<(String, NodeId)>, - invoices: Vec<(String, NodeId)>, - properties: Vec, - } - - // Create a mapping between platforms and relevant properties. - // - // This relies on the fact that a given payment driver status property - // can only affect one platform. - let mut broadcast = HashMap::::default(); - for prop in msg.properties { - let Some(network) = prop.network() else { - continue; - }; - - let value = broadcast - .entry(Platform::new(prop.driver(), network)) - .or_default(); - value.properties.push(prop); - } - - // All DAOs - let debit_note_dao: DebitNoteDao = db.as_dao(); - let debit_note_ev_dao: DebitNoteEventDao = db.as_dao(); - let invoice_dao: InvoiceDao = db.as_dao(); - let invoice_ev_dao: InvoiceEventDao = db.as_dao(); - - let accepted_notes = debit_note_dao - .list( - Some(Role::Requestor), - Some(DocumentStatus::Accepted), - Some(true), - ) - .await - .map_err(GenericError::new)?; - - // Populate broadcasts with affected debit_notes - for debit_note in accepted_notes { - let platform = platform_str_to_platform(&debit_note.payment_platform)?; - - // checks if the last payment-status event was PAYMENT_OK or no such event was emitted - let was_already_ok = debit_note_ev_dao - .get_for_debit_note_id( - debit_note.debit_note_id.clone(), - None, - None, - None, - vec!["PAYMENT_EVENT".into(), "PAYMENT_OK".into()], - vec![], - ) - .await - .map_err(GenericError::new)? - .last() - .map(|ev_type| { - matches!( - &ev_type.event_type, - DebitNoteEventType::DebitNotePaymentOkEvent - ) - }) - .unwrap_or(true); - - if !was_already_ok { - // If debit note has reported driver errors before, we *must* send a broadcast on status change. - // This will either be a new problem, or PaymentOkEvent if no errors are found. - broadcast - .entry(platform) - .or_default() - .debit_notes - .push((debit_note.debit_note_id, debit_note.issuer_id)); - } else if let Some(broadcast) = broadcast.get_mut(&platform) { - broadcast - .debit_notes - .push((debit_note.debit_note_id, debit_note.issuer_id)); - } - } - - let accepted_invoices = invoice_dao - .list(Some(Role::Requestor), Some(DocumentStatus::Accepted)) - .await - .map_err(GenericError::new)?; - - // Populate broadcasts with affected invoices - for invoice in accepted_invoices { - let platform = platform_str_to_platform(&invoice.payment_platform)?; - - // checks if the last payment-status event was PAYMENT_OK or no such event was emitted - let was_already_ok = invoice_ev_dao - .get_for_invoice_id( - invoice.invoice_id.clone(), - None, - None, - None, - vec!["PAYMENT_EVENT".into(), "PAYMENT_OK".into()], - vec![], - ) - .await - .map_err(GenericError::new)? - .last() - .map(|ev_type| { - matches!(&ev_type.event_type, InvoiceEventType::InvoicePaymentOkEvent) - }) - .unwrap_or(true); - - if !was_already_ok { - // If invoice has reported driver errors before, we *must* send a broadcast on status change. - // This will either be a new problem, or PaymentOkEvent if no errors are found. - broadcast - .entry(platform) - .or_default() - .invoices - .push((invoice.invoice_id, invoice.issuer_id)); - } else if let Some(broadcast) = broadcast.get_mut(&platform) { - broadcast - .invoices - .push((invoice.invoice_id, invoice.issuer_id)); - } - } - - // Emit debit note & invoice events. - for broadcast in broadcast.into_values() { - // If properties are empty, send OkEvents. Otherwise send the wrapped properties. - if broadcast.properties.is_empty() { - for (debit_note_id, owner_id) in &broadcast.debit_notes { - debit_note_ev_dao - .create( - debit_note_id.clone(), - *owner_id, - DebitNoteEventType::DebitNotePaymentOkEvent, - ) - .await - .map_err(GenericError::new)?; - } - - for (invoice_id, owner_id) in &broadcast.invoices { - invoice_ev_dao - .create( - invoice_id.clone(), - *owner_id, - InvoiceEventType::InvoicePaymentOkEvent, - ) - .await - .map_err(GenericError::new)?; - } - } else { - for prop in broadcast.properties { - for (invoice_id, owner_id) in &broadcast.invoices { - invoice_ev_dao - .create( - invoice_id.clone(), - *owner_id, - InvoiceEventType::InvoicePaymentStatusEvent { - property: prop.clone(), - }, - ) - .await - .map_err(GenericError::new)?; - } - for (debit_note_id, owner_id) in &broadcast.debit_notes { - debit_note_ev_dao - .create( - debit_note_id.clone(), - *owner_id, - DebitNoteEventType::DebitNotePaymentStatusEvent { - property: prop.clone(), - }, - ) - .await - .map_err(GenericError::new)?; - } - } - } - } - - Ok(Ack {}) - } - async fn send_payment( db: DbExecutor, processor: Arc>, From 7a26032a95edd691af8510d23bba0803f6ac935f Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 16:11:42 +0100 Subject: [PATCH 07/12] fix ethereum to mainnet --- core/payment-driver/erc20next/config-payments.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/payment-driver/erc20next/config-payments.toml b/core/payment-driver/erc20next/config-payments.toml index 6d5b0d2902..5cc8c8e173 100644 --- a/core/payment-driver/erc20next/config-payments.toml +++ b/core/payment-driver/erc20next/config-payments.toml @@ -30,8 +30,8 @@ automatic-recover = false ignore-deadlines = false -[chain.ethereum] -chain-name = "Ethereum" +[chain.mainnet] +chain-name = "Mainnet" chain-id = 1 currency-symbol = "ETH" priority-fee = 1.01 @@ -42,7 +42,7 @@ confirmation-blocks = 1 block-explorer-url = "https://etherscan.io" external-source-check-interval = 300 -[[chain.ethereum.rpc-endpoints]] +[[chain.mainnet.rpc-endpoints]] names = """ virginia.rpc.blxrbdn.com, public.blastapi.io, @@ -65,7 +65,7 @@ max-timeout-ms = 5000 verify-interval-secs = 60 allowed-head-behind-secs = 120 -[[chain.ethereum.rpc-endpoints]] +[[chain.mainnet.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 verify-interval-secs = 60 From f44b4ed034721326a401c35e5a60d6edacc110b1 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 16:19:52 +0100 Subject: [PATCH 08/12] fix compilation --- core/payment/src/service.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/payment/src/service.rs b/core/payment/src/service.rs index ceafe393f9..7d1f5a4f01 100644 --- a/core/payment/src/service.rs +++ b/core/payment/src/service.rs @@ -59,9 +59,10 @@ mod local { NodeId, }; use ya_core_model::{ - driver::{driver_bus_id, Ack, DriverStatus, DriverStatusError}, + driver::{driver_bus_id, DriverStatus, DriverStatusError}, payment::local::*, }; + use ya_core_model::payment::public::Ack; use ya_persistence::types::Role; pub fn bind_service(db: &DbExecutor, processor: Arc>) { From 13c0c18881ace06e30ce51e9ca006fe4fa5e41ca Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 16:51:52 +0100 Subject: [PATCH 09/12] bump version --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20b4a08d47..306740f2e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1956,9 +1956,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "erc20_payment_lib" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50dbcc5cf9c89afbdfe71b61aa891dfcd2a55a3a695299916b0931fef31a7b8" +checksum = "e435361cd1112f235c1ad7dc03a20e81687df8e690e6e8fbaa079a26c1eeb493" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 4ecc90c5cd..0b3b10abfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -231,7 +231,7 @@ members = [ libsqlite3-sys = { version = "0.26.0", features = ["bundled"] } #erc20_payment_lib = { version = "0.3.2", git = "https://github.com/golemfactory/erc20_payment_lib", rev = "2fb9949b43ccedf0dfad61926d567debd2d6086f" } #erc20_payment_lib = { path = "../../payments/erc20_payment_lib/crates/erc20_payment_lib" } -erc20_payment_lib = { version = "=0.3.15" } +erc20_payment_lib = { version = "=0.3.17" } rand = "0.8.5" url = "2.3.1" trust-dns-resolver = "0.22" From c4870f85080474dd1197ff05d4872cf1533167fc Mon Sep 17 00:00:00 2001 From: scx1332 Date: Wed, 6 Dec 2023 17:31:32 +0000 Subject: [PATCH 10/12] fmt --- core/payment/src/service.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/payment/src/service.rs b/core/payment/src/service.rs index 7d1f5a4f01..6976b64c99 100644 --- a/core/payment/src/service.rs +++ b/core/payment/src/service.rs @@ -58,11 +58,11 @@ mod local { }, NodeId, }; + use ya_core_model::payment::public::Ack; use ya_core_model::{ driver::{driver_bus_id, DriverStatus, DriverStatusError}, payment::local::*, }; - use ya_core_model::payment::public::Ack; use ya_persistence::types::Role; pub fn bind_service(db: &DbExecutor, processor: Arc>) { From 2248b024175e2dbece1917941274ba45d32e156c Mon Sep 17 00:00:00 2001 From: Kamil Koczurek Date: Thu, 7 Dec 2023 11:53:57 +0100 Subject: [PATCH 11/12] golemsp: remove rinkeby --- golem_cli/src/command/yagna.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/golem_cli/src/command/yagna.rs b/golem_cli/src/command/yagna.rs index 7c75c8b938..cbb5125f28 100644 --- a/golem_cli/src/command/yagna.rs +++ b/golem_cli/src/command/yagna.rs @@ -193,7 +193,6 @@ lazy_static! { ngm.insert( NetworkGroup::Testnet, vec![ - NetworkName::Rinkeby, NetworkName::Mumbai, NetworkName::Holesky, NetworkName::Goerli, From fa10df5dbd3131fb1906fc8492834951b0a1b9e2 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Thu, 7 Dec 2023 14:35:36 +0100 Subject: [PATCH 12/12] Changed default payment settings --- .../erc20next/config-payments.toml | 117 ++++-------------- 1 file changed, 24 insertions(+), 93 deletions(-) diff --git a/core/payment-driver/erc20next/config-payments.toml b/core/payment-driver/erc20next/config-payments.toml index 9305079ebc..01dc06f3e6 100644 --- a/core/payment-driver/erc20next/config-payments.toml +++ b/core/payment-driver/erc20next/config-payments.toml @@ -19,7 +19,7 @@ process-interval-after-no-gas-or-token-increase = 1.5 # report alive interval (in seconds) is to set how often we want to report that we are alive # minimum 1 second, maximum is capped by gather-interval -report-alive-interval = 10 +report-alive-interval = 30 # gather interval (in seconds) is to set how often payments are gathered # minimum 1 second, no maximum limit gather-interval = 60 @@ -44,33 +44,22 @@ external-source-check-interval = 300 [[chain.mainnet.rpc-endpoints]] names = """ - virginia.rpc.blxrbdn.com, - public.blastapi.io, - rpc.ankr.com/eth,rpc.flashbots.net, - cloudflare-eth.com, - ethereum.publicnode.com, - rpc.payload.de + geth.golem.network, """ endpoints = """ - https://virginia.rpc.blxrbdn.com, - https://eth-mainnet.public.blastapi.io, - https://rpc.ankr.com/eth, - https://rpc.flashbots.net, - https://cloudflare-eth.com, - https://ethereum.publicnode.com, - https://rpc.payload.de + https://geth.golem.network:55555, """ priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 [[chain.mainnet.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 -dns-source = "ethereum.rpc-node.dev.golem.network." +verify-interval-secs = 300 +allowed-head-behind-secs = 60 +dns-source = "mainnet.rpc-node.dev.golem.network." [chain.goerli] @@ -90,43 +79,21 @@ external-source-check-interval = 300 [[chain.goerli.rpc-endpoints]] names = """ -eth-goerli.g.alchemy.com/v2/demo, -eth-goerli.public.blastapi.io, -eth-goerli.api.onfinality.io/public, -endpoints.omniatech.io/v1/eth/goerli/public, -rpc.goerli.eth.gateway.fm, -goerli.blockpi.network/v1/rpc/public, -goerli.infura.io/v3/9aa, -rpc.ankr.com/eth_goerli, ethereum-goerli-rpc.allthatnode.com, -rpc.slock.it/goerli, -www.ethercluster.com/goerli, -rpc.ankr.com/eth_goerli, """ endpoints = """ -https://eth-goerli.g.alchemy.com/v2/demo, -https://eth-goerli.public.blastapi.io, -https://eth-goerli.api.onfinality.io/public, -https://endpoints.omniatech.io/v1/eth/goerli/public, -https://rpc.goerli.eth.gateway.fm, -https://goerli.blockpi.network/v1/rpc/public, -https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161, -https://rpc.ankr.com/eth_goerli, https://ethereum-goerli-rpc.allthatnode.com, -https://rpc.slock.it/goerli, -https://www.ethercluster.com/goerli, -https://rpc.ankr.com/eth_goerli, """ priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 +verify-interval-secs = 300 allowed-head-behind-secs = 60 [[chain.goerli.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 dns-source = "goerli.rpc-node.dev.golem.network." [chain.holesky] @@ -147,32 +114,22 @@ external-source-check-interval = 300 [[chain.holesky.rpc-endpoints]] names = """ - holesky.publicnode.com, - 1rpc.io/holesky, - rpc.ankr.com/eth_holesky, - eth-holesky.public.blastapi.io, - holesky.drpc.org, - holesky.rpc.thirdweb.com + holesky.geth.golem.netork """ endpoints = """ - https://holesky.publicnode.com, - https://1rpc.io/holesky, - https://rpc.ankr.com/eth_holesky, - https://eth-holesky.public.blastapi.io, - https://holesky.drpc.org, - https://holesky.rpc.thirdweb.com + https://holesky.geth.golem.netork, """ priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 [[chain.holesky.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 dns-source = "holesky.rpc-node.dev.golem.network." @@ -191,38 +148,21 @@ external-source-check-interval = 300 [[chain.mumbai.rpc-endpoints]] names = """ -polygon-mumbai.g.alchemy.com/v2/demo, -polygon-testnet.public.blastapi.io, -endpoints.omniatech.io/v1/matic/mumbai/public, -rpc-mumbai.maticvigil.com, -polygontestapi.terminet.io/rpc, -matic-mumbai.chainstacklabs.com, -matic-testnet-archive-rpc.bwarelabs.com, -rpc.ankr.com/polygon_mumbai, -polygon-testnet-archive.allthatnode.com:8545, polygon-testnet-rpc.allthatnode.com:8545, """ endpoints = """ -https://polygon-mumbai.g.alchemy.com/v2/demo, -https://polygon-testnet.public.blastapi.io, -https://endpoints.omniatech.io/v1/matic/mumbai/public, -https://rpc-mumbai.maticvigil.com, -https://polygontestapi.terminet.io/rpc, -https://matic-mumbai.chainstacklabs.com, -https://matic-testnet-archive-rpc.bwarelabs.com, -https://rpc.ankr.com/polygon_mumbai, -https://polygon-testnet-archive.allthatnode.com:8545, https://polygon-testnet-rpc.allthatnode.com:8545, """ priority = 0 max-timeout-ms = 5000 +verify-interval-secs = 300 allowed-head-behind-secs = 60 [[chain.mumbai.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 dns-source = "mumbai.rpc-node.dev.golem.network." [chain.polygon] @@ -240,28 +180,19 @@ external-source-check-interval = 300 [[chain.polygon.rpc-endpoints]] names = """ -polygon-rpc.com, -rpc-mainnet.maticvigil.com, -rpc-mainnet.matic.quiknode.pro, bor.golem.network, -polygon-mainnet-archive.allthatnode.com:8545, -polygon-mainnet-rpc.allthatnode.com:8545, """ endpoints = """ -https://polygon-rpc.com, -https://rpc-mainnet.maticvigil.com, -https://rpc-mainnet.matic.quiknode.pro, https://bor.golem.network, -https://polygon-mainnet-archive.allthatnode.com:8545, -https://polygon-mainnet-rpc.allthatnode.com:8545, """ priority = 0 max-timeout-ms = 5000 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 [[chain.polygon.rpc-endpoints]] priority = 0 max-timeout-ms = 5000 -verify-interval-secs = 60 -allowed-head-behind-secs = 120 +verify-interval-secs = 300 +allowed-head-behind-secs = 60 dns-source = "polygon.rpc-node.dev.golem.network."