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

Fix upenumbra priority score and adjust scores of assets #98

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions input/chains/penumbra-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@
"priorityScoresByBase": {
"upenumbra": 999999999999,
"transfer/channel-2/uusdc": 100000000000,
"transfer/channel-4/factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT": 10000000000,
"transfer/channel-4/factory/osmo1k6c8jln7ejuqwtqmay3yvzrg3kueaczl96pk067ldg8u835w0yhsw27twm/alloyed/allETH": 10000000000,
"transfer/channel-4/factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL": 10000000000,
"transfer/channel-4/factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC": 10000000000,
"transfer/channel-4/factory/osmo1z0qrq605sjgcqpylfl4aa6s90x738j7m58wyatt0tdzflg2ha26q67k743/wbtc": 10000000000,
"transfer/channel-4/factory/osmo18zdw5yvs6gfp95rp74qqwug9yduw2fyr8kplk2xgs726s9axc5usa2vpgw/alloyed/allLINK": 1000000000,
"transfer/channel-4/factory/osmo1r53fx9fvcdzncrs7zkn4gw5vfelx5gk8k5wc6wqha2jpkh992rusr5tk02/alloyed/allDOT": 1000000000,
"transfer/channel-4/factory/osmo14mafhhp337yjj2aujplawz0tks6jd2lel4hkwz4agyzhvvztzaqsqzjq8x/alloyed/allTRX": 100000000,
"transfer/channel-4/factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT": 100000000000,
"transfer/channel-4/factory/osmo1z6r6qdknhgsc0zeracktgpcxf43j6sekq07nw8sxduc9lg0qjjlqfu25e3/alloyed/allBTC": 70000000000,
"transfer/channel-4/factory/osmo1z0qrq605sjgcqpylfl4aa6s90x738j7m58wyatt0tdzflg2ha26q67k743/wbtc": 70000000000,
"transfer/channel-4/factory/osmo1k6c8jln7ejuqwtqmay3yvzrg3kueaczl96pk067ldg8u835w0yhsw27twm/alloyed/allETH": 60000000000,
"transfer/channel-4/factory/osmo1n3n75av8awcnw4jl62n3l48e6e4sxqmaf97w5ua6ddu4s475q5qq9udvx4/alloyed/allSOL": 50000000000,
"transfer/channel-4/factory/osmo18zdw5yvs6gfp95rp74qqwug9yduw2fyr8kplk2xgs726s9axc5usa2vpgw/alloyed/allLINK": 4000000000,
"transfer/channel-4/factory/osmo1r53fx9fvcdzncrs7zkn4gw5vfelx5gk8k5wc6wqha2jpkh992rusr5tk02/alloyed/allDOT": 3000000000,
"transfer/channel-4/factory/osmo14mafhhp337yjj2aujplawz0tks6jd2lel4hkwz4agyzhvvztzaqsqzjq8x/alloyed/allTRX": 200000000,
"transfer/channel-4/factory/osmo1p7x454ex08s4f9ztmm7wfv7lvtgdkfztj2u7v7fezfcauy85q35qmqrdpk/alloyed/allARB": 100000000,
"transfer/channel-4/factory/osmo1nufyzqlm8qhu2w7lm0l4rrax0ec8rsk69mga4tel8eare7c7ljaqpk2lyg/alloyed/allOP": 100000000,
"transfer/channel-4/factory/osmo12lnwf54yd30p6amzaged2atln8k0l32n7ncxf04ctg7u7ymnsy7qkqgsw4/alloyed/allTON": 100000000,
Expand Down
19 changes: 10 additions & 9 deletions registry/chains/penumbra-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
}
}
],
"priorityScore": "100000000"
"priorityScore": "200000000"
},
"5B0jxWP9LX+U4uD7aU9OVsIk0U385uD2q+a2eEerHg0=": {
"description": "Cosmos Airdrop Chat",
Expand Down Expand Up @@ -744,7 +744,8 @@
{
"svg": "https://raw.githubusercontent.com/prax-wallet/registry/main/images/um.svg"
}
]
],
"priorityScore": "999999999999"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here it is

},
"LdexCcIS7h5jbSjieMV+MoC2IB1XmuKxzNNeRgq4QAQ=": {
"description": "An alloy of SOL asset variants on Osmosis.",
Expand Down Expand Up @@ -787,7 +788,7 @@
"theme": {}
}
],
"priorityScore": "10000000000"
"priorityScore": "50000000000"
},
"MMDbC4jQ7GUP6yEU+Yo2xkW85LyRKJASJN4MPHAPmhE=": {
"description": "Levana Well-funded Perps is a protocol for perpetual swaps, which are leveraged trading contracts.",
Expand Down Expand Up @@ -1108,7 +1109,7 @@
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/allBTC.svg"
}
],
"priorityScore": "10000000000"
"priorityScore": "70000000000"
},
"Rvh55FJrd8q3kT8xYIl5ApTOc9ErxyL8m1NS5RArHxE=": {
"description": "An alloy of OP asset variants on Osmosis.",
Expand Down Expand Up @@ -1188,7 +1189,7 @@
}
}
],
"priorityScore": "1000000000"
"priorityScore": "3000000000"
},
"SChNnza9qDQMNGqwSoQMzB2x2M5nmEBtST1EoSy29gM=": {
"description": "An alloy of UNI asset variants on Osmosis.",
Expand Down Expand Up @@ -1290,7 +1291,7 @@
}
}
],
"priorityScore": "10000000000"
"priorityScore": "70000000000"
},
"UxSzPuz9XKLpnAttHgzK/j0t1YHJUtgU+2T99R+FxBE=": {
"description": "Celestia is a modular blockchain network focused on data availability, allowing developers to deploy their own customizable blockchains with ease.",
Expand Down Expand Up @@ -1677,7 +1678,7 @@
}
}
],
"priorityScore": "1000000000"
"priorityScore": "4000000000"
},
"hOnMqQbpe5Abe7vvfHYda77fg3Zit88fatqDfPO1bgQ=": {
"description": "An alloy of SHIB asset variants on Osmosis.",
Expand Down Expand Up @@ -2130,7 +2131,7 @@
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/allUSDT.svg"
}
],
"priorityScore": "10000000000"
"priorityScore": "100000000000"
},
"vSCVmtndzw2C2RYuB2vcKWfkPVZRCP9GNN8MwB6QUAU=": {
"description": "Cosmus Cartol always get rich",
Expand Down Expand Up @@ -2254,7 +2255,7 @@
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/allETH.svg"
}
],
"priorityScore": "10000000000"
"priorityScore": "60000000000"
},
"xNdg/Pc2CvrtawUX41EBLTlgj83RTenRJaBFXxsSTwk=": {
"description": "ION is the second native token of Osmosis.",
Expand Down
26 changes: 14 additions & 12 deletions tools/compiler/src/processor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::anyhow;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use tracing::instrument;
Expand Down Expand Up @@ -103,7 +102,6 @@ pub fn generate_registry() -> AppResult<()> {
pub fn transport_metadata_along_channel(
ibc_data: &IbcInput,
source_asset: Metadata,
priority_scores_by_base: &HashMap<String, u64>,
) -> AppResult<Metadata> {
// The `Metadata` structure doesn't allow modifying the internals, so drop to raw proto data
let mut pb_metadata: pb::Metadata = source_asset.into();
Expand All @@ -126,11 +124,6 @@ pub fn transport_metadata_along_channel(
// Without this, decoding will fail because the asset ID won't match.
pb_metadata.penumbra_asset_id = None;

// Add priority score if available
if let Some(score) = priority_scores_by_base.get(&pb_metadata.base) {
pb_metadata.priority_score = *score;
}

tracing::trace!(?pb_metadata, "new");
Ok(Metadata::try_from(pb_metadata)?)
}
Expand Down Expand Up @@ -171,15 +164,24 @@ fn process_chain_config(chain_config: ChainConfig) -> AppResult<Registry> {
let asset_json = serde_json::to_string(&source_asset)?;
let source_asset_metadata = serde_json::from_str(&asset_json)?;

let transferred_asset = transport_metadata_along_channel(
ibc_input,
source_asset_metadata,
&chain_config.priority_scores_by_base,
)?;
let transferred_asset =
transport_metadata_along_channel(ibc_input, source_asset_metadata)?;
all_metadata.push(transferred_asset);
}
}

// add priority score if available
for metadata in &mut all_metadata {
if let Some(score) = chain_config
.priority_scores_by_base
.get(&metadata.base_denom().denom)
{
let mut pb_metadata: pb::Metadata = metadata.clone().into();
pb_metadata.priority_score = *score;
*metadata = Metadata::try_from(pb_metadata)?;
}
}

Ok(Registry {
chain_id: chain_config.chain_id,
ibc_connections: chain_config
Expand Down
15 changes: 2 additions & 13 deletions tools/compiler/tests/test_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ fn test_transport_metadata_along_channel() {
"#;
let input_metadata = serde_json::from_str(input_json).unwrap();

let priority_scores_by_base = r#"
{
"transfer/channel-123/ugm": 7
}
"#;

let priority_scores_by_base_json = serde_json::from_str(priority_scores_by_base).unwrap();

let output_json = r#"
{
"denomUnits": [
Expand All @@ -76,14 +68,11 @@ fn test_transport_metadata_along_channel() {
"symbol": "GM",
"penumbraAssetId": {
"inner": "YGObCaxvA7dR5tg6FeoNDxIGbwl9HK5eYr7jFho/GwQ="
},
"priorityScore": "7"
}
}
"#;
let output_metadata = serde_json::from_str(output_json).unwrap();

let result =
transport_metadata_along_channel(&ibc_data, input_metadata, &priority_scores_by_base_json)
.unwrap();
let result = transport_metadata_along_channel(&ibc_data, input_metadata).unwrap();
assert_eq!(result, output_metadata);
}
Loading