Skip to content

Instantly share code, notes, and snippets.

View erwanor's full-sized avatar
🧿
🤚

Erwan Or erwanor

🧿
🤚
  • penumbra labs
  • toronto, canada
  • X @erwanor
View GitHub Profile
@erwanor
erwanor / unbonding_excerpt.rs
Created January 23, 2024 17:55
Unbonding excerpt
async fn unbonding_end_epoch_for(
&self,
id: &IdentityKey,
start_epoch_index: u64,
) -> Result<u64> {
let unbonding_epochs = self.get_stake_params().await?.unbonding_epochs;
let default_unbonding = start_epoch_index + unbonding_epochs;
let validator_unbonding =
@erwanor
erwanor / a.rs
Created September 25, 2023 20:36
/// Materializes the entire current validator set as a Tendermint update.
///
/// This re-defines all validators every time, to simplify the code compared to
/// trying to track delta updates.
#[instrument(skip(self))]
async fn build_tendermint_validator_updates(&mut self) -> Result<()> {
let current_consensus_keys: CurrentConsensusKeys = self
.get(state_key::current_consensus_keys())
.await?
.expect("current consensus keys must be present");
┌──────┐ ───────────┐
│ │ │
│ pd │ ◄───────┐ │
│ │ │ │
┌──┴──────┴────┐ │ │
│ tendermint │ │ │
└──────┬───────┘ │ │
│ fetch │ │
ws feed │ executions│ │
───────────────────┴──────────────┼──┼─────────
⋊> ~/p/p/c/c/c/dex on main ◦ cargo fix 12:27:13
warning: unused import: `async_stream::try_stream`
--> crates/proto/src/lib.rs:123:17
|
123 | use async_stream::try_stream;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `futures::Stream`
@erwanor
erwanor / log.csv
Created June 29, 2023 13:30
`path_search` loop detour
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
:EndBlock{height=45227}:dex:handle_batch_swaps:route_and_fill: filled all input, exiting route_and_fill"
:EndBlock{height=45227}:dex:handle_batch_swaps:route_and_fill: filled along best path input=1000000 output=2426597 unfilled=0
:EndBlock{height=45227}:dex:handle_batch_swaps:route_and_fill:fill_route: returning swap execution of filled route swap_execution=SwapExecution { traces: [[Value { amount: 1000000, asset_id: pen }, Value { amount: 20000000, asset_id: test_usd }, Value { amount: 1000000, asset_id: pen }, Value { amount: 2426597, asset_id: gm }]], input: Value { amount: 1000000, asset_id: pen }, output: Value { amount: 2426597, asset_id: gm } }"
:EndBlock{height=45227}:dex:handle_batch_swaps:route_and_fill:fill_route:put_position{id=plpid1vhcjwcmz9egx8rwnxzadvaanx8en4v2jd8t8yw8mxsqkh5g7q72qmeca8t}: indexing position for 2=>1 trades
:EndBlock{height=45227}:dex:handle_batch_swaps:route_and_fill:fill_route:put_position{id=plpid1vhcjwcmz9egx8rwnxzadvaanx8en4v2jd8t8yw8mxsqkh5g7q72qmeca8t}: indexing positio
@erwanor
erwanor / response.json
Created June 28, 2023 03:10
`SimulateTrade` rpc hallucinations
{
"output": {
"traces": [
{
"value": [
{
"amount": {
"lo": "1000000"
},
"assetId": {
@erwanor
erwanor / fn_0.log
Created June 20, 2023 19:30
devnet 53.1 diverge logs between two penumbra full nodes
This file has been truncated, but you can view the full file.
abci:EndBlock{height=36066}:dex: key=b""chain/epoch_by_height/36066"" key_hash=KeyHash(""e1a88f12e2458f93987082a5c94a9cd04c3b9247a164b0ea5844e611cb96750b"")"
abci:EndBlock{height=36066}:dex:handle_batch_swaps: delta_1=402102 delta_2=0 trading_pair=TradingPair { asset_1: test_btc, asset_2: pen }"
abci:EndBlock{height=36066}:dex:handle_batch_swaps:route_and_fill: starting route_and_fill delta_1=402102 asset_1=test_btc asset_2=pen
abci:EndBlock{height=36066}:dex:handle_batch_swaps:route_and_fill:path_search{max_hops=4}: searching for path src=test_btc dst=pen max_hops=4
abci:EndBlock{height=36066}:dex:handle_batch_swaps:route_and_fill:path_search{max_hops=4}:path{start=test_btc}: beginning path
abci:EndBlock{height=36066}:dex:handle_batch_swaps:route_and_fill:path_search{max_hops=4}: relaxing active paths active_paths_len=1
abci:EndBlock{height=36066}:dex:handle_batch_swaps:route_and_fill:path_search{max_hops=4}:path{start=test_btc}: relaxing path degree=7 candidates=[gm, test_btc, test_usd, test_osmo, test_atom
@erwanor
erwanor / gist:361811178029ddbd1aa18549a7427e02
Created June 17, 2023 17:15
generate some devnet activity for testing
#!/bin/bash
run_number=0
DATE=$(date +%Y%m%d_%H%M%S)
UUID=$(uuidgen)
FILENAME="repro_${DATE}_${UUID}.txt"
while true
do
AMOUNT_1=$(echo "scale=2; 0.5 + $RANDOM/32767*2.5" | bc)
2023-06-02T18:38:59.290999Z INFO penumbra_storage::storage: opening rocksdb path="/var/folders/j7/mbymjl4j16bfslngd1r6gt4h0000gn/T/.tmp8XGPZg/storage.db"
2023-06-02T18:38:59.321478Z DEBUG jmt: key=b"block_height" key_hash=KeyHash("c4b4e25a8824650a238d3451f754dcda1551dec8bec1a96abe23d2ff8b454db8")
2023-06-02T18:38:59.321520Z DEBUG jmt: key=b"chain/epoch_by_height/0" key_hash=KeyHash("ac0564683e6400e242f342e2b31a882a1195ac1aab399be415baef324ea87845")
2023-06-02T18:38:59.333391Z INFO penumbra_dex::component::tests: penumbra_id=passet1984fctenw8m2fpl8a9wzguzp7j34d7vravryuhft808nyt9fdggqxmanqm
2023-06-02T18:38:59.333471Z INFO penumbra_dex::component::tests: test_usd_id=passet14h46dmcyy6fl5vyz7xx933n8l7jy202ahrxg92kad6yfladsvcyqczcwda
2023-06-02T18:38:59.333613Z DEBUG put_position{id=plpid17uuhzt0544hck7x8fsv4fg8qtfwcm49897ahqudyq0745kwwct4qyyy72y}: penumbra_dex::component::position_manager: position=Position { state: Opened, reserves: Reserves { r1: 110000000, r2: 0 }, phi: TradingFunction { component: BareTrad
2023-06-02T14:14:43.571129Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}: searching for path src=pen dst=pen max_hops=5
2023-06-02T14:14:43.571192Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}:path{start=pen}: beginning path
2023-06-02T14:14:43.571265Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}: relaxing active paths active_paths_len=1
2023-06-02T14:14:43.571310Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}:path{start=pen}: relaxing path degree=7 candidates=[gm, test_btc, test_usd, test_osmo, test_atom, pen, gn]
2023-06-02T14:14:43.571680Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}:path{start=pen}:extend_to{new_end=gn}: no best position, failing to extend path
2023-06-02T14:14:43.571744Z DEBUG abci:EndBlock{height=3424}:dex:arbitrage:route_and_fill:path_search{max_hops=5}:path{start=pen}:extend_to{new_en