-
Notifications
You must be signed in to change notification settings - Fork 70
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
Ethereum Settlement Engine improvements #150
Conversation
27a837d
to
cd767e0
Compare
This is not part of our deps |
@gakonst what version of |
crates/interledger-settlement-engines/src/engines/ethereum_ledger/types.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/types.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/types.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/utils.rs
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/utils.rs
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/stores/redis_ethereum_ledger/store.rs
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/stores/redis_ethereum_ledger/store.rs
Show resolved
Hide resolved
.query_async(self.connection.clone()) | ||
.map_err(move |err| error!("Error loading account data: {:?}", err)) | ||
.and_then( | ||
move |(_conn, ret): (_, u64)| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move |(_conn, ret): (_, u64)| { | |
move |(_conn, ret): (_, bool)| { |
crates/interledger-settlement-engines/src/stores/redis_ethereum_ledger/store.rs
Outdated
Show resolved
Hide resolved
) | ||
} | ||
|
||
fn credit_tx(&self, tx_hash: H256) -> Box<dyn Future<Item = (), Error = ()> + Send> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility that separating credit_tx
from check_tx_credited
could cause a race condition? Is it possible that two threads or tasks could call check_tx_credited
at the same time, both get a return value that indicates that it hasn't been credited, and both credit the balance accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not make sense to set poll_frequency
to less than 60 seconds in Ethereum, since block time is targeted at 15 sec, and you want a buffer of some blocks to avoid reorgs. So I doubt it can happen in that case.
I think you are right though that if the function gets called frequently enough for the same range of blocks this can happen.
Re: RUSTSEC-2019-0011 What's actually happening is we retroactively updated the advisory to note that the older versions of https://rustsec.org/advisories/RUSTSEC-2019-0011.html It's been one of the more controversial vulns we've added to the database in that it falls into the "high severity / low exploitability" category. However, I would say the more we investigated what could go wrong based on particular patterns of misuse, the severity of the vulnerability continued to escalate, to first memory exposure and then to remote code execution. If you feel comfortable with the current usage patterns, note that |
a81f828
to
331e2c6
Compare
…ved data We cannot assume that the operator's balance will keep increasing, since they may transfer funds to another address
- use join_all to avoid callback hell - avoid using spawn's - mark a transaction as credited only after the call to the connector was successful - save the last observed block only after all calls in that block range has been successfully credited
…tions which are already in the mempool Allows the removal of the nonce middleware
Otherwise we would be signing any message that gets sent to us and that is insecure
331e2c6
to
5047462
Compare
92ee904
to
69b0e15
Compare
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
re security advisory: tokio-rs/tokio#1345 |
…ccount Otherwise it may take too long for the connector to ping its engine to get the address from its peer
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
crates/interledger-settlement-engines/src/engines/ethereum_ledger/eth_engine.rs
Outdated
Show resolved
Hide resolved
This ensures the same transaction is never processed twice by the connector (also minor improvements in variable/function naming
also more verbose failure log when max retries get exceeded to notify connector about an incoming settlement
Adding it resulted in incorerct behavior the balance is already lowered in the PROCESS_FULFILL script. With it, the balance was lowered by 2x the amount it should. Note that the reason the balance is lowered first is because we don't want two packets fulfilled simultaneously to trigger settlements for the same amount_to_settle. By reducing the balance by the amount_to_settle before making the settlement client send the request to the settlement engine, this ensures that the settlement will only happen once. The refund_settlement is there in case that call to the SE fails and we need to revert the change to the balance.
bd6e4c3
to
ee965bd
Compare
Fixes most of #149
TODO: Add more tests for SPSP payments in
interledger
similar tothree_nodes.rs