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

Server only api #37

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d173ad2
add validation for the 'from' an 'to' params of the 'compute_transfer…
jaensen May 17, 2023
a24e84d
fixed format strings for error messages
jaensen May 17, 2023
5144dfb
fixed format strings for error messages
jaensen May 17, 2023
b19584e
moved the rpc call dispatching to rpc_handler.rs and the function imp…
jaensen May 17, 2023
1ad37fe
added a CallContext for loggin of rpc requests and moved the rpc call…
jaensen May 18, 2023
de6324f
log startup info
jaensen May 18, 2023
2201bf9
dropped the incremental chunked results for simpler code. + log resul…
jaensen May 18, 2023
fd7268c
removed all code that's not directly required for the server use of t…
jaensen May 18, 2023
d7579f4
more logging
jaensen May 18, 2023
6668e27
trial and erroring a memory leak :/
jaensen May 18, 2023
b7992c4
more logging, more dropping
jaensen May 18, 2023
5b10d16
removed trace logging after the pathfinder ran for ~ 8h without issues.
jaensen May 19, 2023
96befac
unfinished: Allow to 'push' graph updates via http.
jaensen May 23, 2023
2aece90
get the test-data from the 'dev' branch
jaensen May 23, 2023
5320349
trying different trust_transfer_limit implementation
jaensen May 23, 2023
0626107
restored 'trust_transfer_limit' logic
jaensen May 24, 2023
cd108e0
fixed build warning
jaensen May 24, 2023
80aed20
refactored the compute_flow function to better show the data flow and…
jaensen May 24, 2023
7b89934
moved 'trust_transfer_limit' from safe to db
jaensen May 25, 2023
ca465fb
re-added fn default() -> CallContext for use in tests
jaensen May 25, 2023
e268db6
add capacity edges from users that hold accepted tokens to orgas
jaensen May 25, 2023
159a951
removed unnecessary field
jaensen May 25, 2023
5950ab8
add flow-edges from users with trusted tokens to the organizations th…
jaensen May 30, 2023
ee593af
OP-159: fix(workflow): add feature/server_only branch trigger, remove…
almereyda Jul 20, 2023
60fa1b1
Merge pull request #42 from CirclesUBI/fix/op-159-server_only
almereyda Jul 20, 2023
4baf76d
Edit compute_edges
Jul 24, 2023
9b1d4e8
update with fixed workflows
JacqueGM Aug 7, 2023
48fce9e
fix format
JacqueGM Aug 7, 2023
b37076d
Merge branch 'dev' of https://github.com/CirclesUBI/pathfinder2 into …
JacqueGM Aug 7, 2023
7f3050a
fix format
JacqueGM Aug 7, 2023
ad3398d
update lint issues
JacqueGM Aug 7, 2023
a6f2198
fix lint
JacqueGM Aug 7, 2023
a9fd2d2
fix map and lint
JacqueGM Aug 7, 2023
0d273ed
update branch
JacqueGM Aug 7, 2023
bbac07b
avoid building for server_only for now
JacqueGM Aug 10, 2023
2f07179
fix lint and add test back
JacqueGM Aug 10, 2023
2c187c0
git test fmt
JacqueGM Aug 10, 2023
9e7d27a
add default trait
JacqueGM Aug 10, 2023
329302d
adding test but with error with call_context
JacqueGM Aug 10, 2023
9b7db63
fix format
JacqueGM Aug 10, 2023
98b3c17
fix call_context error
JacqueGM Aug 10, 2023
cf3b970
remove some test to start
JacqueGM Aug 10, 2023
d3125e9
Exclude edges with equeal source and destination
Aug 24, 2023
4091056
Make compiler happy
Aug 27, 2023
a022f69
Resolve merge conflicts
Aug 27, 2023
c94dbc8
Remove repeated comments
Aug 27, 2023
bc2ac09
Fix imports
Aug 27, 2023
a0d0c57
Merge pull request #43 from CirclesUBI/compute-edges-all
JacqueGM Aug 28, 2023
e8aec86
update build work
JacqueGM Aug 28, 2023
18d2cc3
apply format changes
JacqueGM Aug 28, 2023
d515a68
update clippy failing
JacqueGM Aug 28, 2023
9c53202
fix fmt
JacqueGM Aug 28, 2023
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
3 changes: 0 additions & 3 deletions .github/workflows/container-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
branches:
- dev
- feature/server_only
workflow_dispatch:

jobs:
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,46 @@ Example:
`cargo run --bin convert --safes-json safes.json --edges-bin edges.dat`

Converts a safe json file called `safes.json` into a binary edge database file called `edges.dat`.


```shell
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"method": "load_safes_binary",
"params": {
"file": "/home/daniel/src/CirclesUBI/pathfinder2/graph_at_20230523_15_00.db"
}
}' \
"http://localhost:1234"

curl -X POST \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"method": "load_safes_binary",
"params": {
"file": "/var/pathfinder2/data/graph_at_20230523_15_00.db"
}
}' \
"http://65.109.109.165:54390"



curl -X POST \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"method": "compute_transfer",
"params": {
"from": "0xde374ece6fa50e781e81aac78e811b33d16912c7",
"to": "0x6de572faa138048ce8142c4a206eb09a8ec39e45",
"value": "9999999999999999999999999",
"iterative": false,
"prune": true
}
}' \
"http://localhost:1234"

```
143 changes: 0 additions & 143 deletions src/bin/cli.rs

This file was deleted.

60 changes: 0 additions & 60 deletions src/bin/convert.rs

This file was deleted.

11 changes: 0 additions & 11 deletions src/graph/adjacencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ pub struct Adjacencies<'a> {
capacity_adjustments: HashMap<Node, HashMap<Node, U256>>,
}

// fn pseudo_node(edge: Edge) -> Node {
// Node::TokenEdge(edge.from, edge.token)
// }

fn balance_node(edge: &Edge) -> Node {
Node::BalanceNode(edge.from, edge.token)
}
Expand All @@ -22,13 +18,6 @@ fn trust_node(edge: &Edge) -> Node {
Node::TrustNode(edge.to, edge.token)
}

// fn source_address_of(node: &Node) -> &Address {
// match node {
// Node::Node(addr) => addr,
// Node::TokenEdge(from, _) => from,
// }
// }

impl<'a> Adjacencies<'a> {
pub fn new(edges: &'a EdgeDB) -> Self {
Adjacencies {
Expand Down
54 changes: 54 additions & 0 deletions src/graph/augmenting_path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use crate::graph::adjacencies::Adjacencies;
use crate::graph::Node;
use crate::types::{Address, U256};
use std::cmp::min;
use std::collections::{HashMap, VecDeque};

pub fn augmenting_path(
source: &Address,
sink: &Address,
adjacencies: &mut Adjacencies,
max_distance: Option<u64>,
) -> (U256, Vec<Node>) {
let mut parent = HashMap::new();
if *source == *sink {
return (U256::default(), vec![]);
}
let mut queue = VecDeque::<(Node, (u64, U256))>::new();
queue.push_back((Node::Node(*source), (0, U256::default() - U256::from(1))));
while let Some((node, (depth, flow))) = queue.pop_front() {
if let Some(max) = max_distance {
// * 3 because we have three edges per trust connection (two intermediate nodes).
if depth >= max * 3 {
continue;
}
}
for (target, capacity) in adjacencies.outgoing_edges_sorted_by_capacity(&node) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the current implementation sorting only by capacity? I understand that we generating here a priority for the edges to be selected for the final path. Is here the place where we could also prioritize the edges that transfer tokens to their owners?

if !parent.contains_key(&target) && capacity > U256::default() {
parent.insert(target.clone(), node.clone());
let new_flow = min(flow, capacity);
if target == Node::Node(*sink) {
return (
new_flow,
trace(parent, &Node::Node(*source), &Node::Node(*sink)),
);
}
queue.push_back((target, (depth + 1, new_flow)));
}
}
}
(U256::default(), vec![])
}

fn trace(parent: HashMap<Node, Node>, source: &Node, sink: &Node) -> Vec<Node> {
let mut t = vec![sink.clone()];
let mut node = sink;
loop {
node = parent.get(node).unwrap();
t.push(node.clone());
if *node == *source {
break;
}
}
t
}
Loading
Loading