From bcf17dda9bebf70e996408f687cdcf1d2e5483de Mon Sep 17 00:00:00 2001 From: Five Hunter Date: Fri, 2 Feb 2024 01:29:55 +0200 Subject: [PATCH] Update to namada v0.31.0 modules --- Cargo.lock | 264 +++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 +- Makefile | 2 +- src/database.rs | 28 ++--- src/server/tx.rs | 18 ++-- src/utils.rs | 2 +- 6 files changed, 273 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35fbca3..8925645 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1992,6 +1992,17 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fd-lock" +version = "3.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" +dependencies = [ + "cfg-if", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "ff" version = "0.13.0" @@ -3444,7 +3455,7 @@ dependencies = [ [[package]] name = "masp_note_encryption" version = "1.0.0" -source = "git+https://github.com/anoma/masp?tag=v1.0.0#c3c6047a9c9da54058afc71219b913ac9f79e48b" +source = "git+https://github.com/anoma/masp?tag=v1.1.0#f24691c0eb76909e3c15ae03aef294dccebd2df3" dependencies = [ "borsh", "chacha20", @@ -3457,7 +3468,7 @@ dependencies = [ [[package]] name = "masp_primitives" version = "1.0.0" -source = "git+https://github.com/anoma/masp?tag=v1.0.0#c3c6047a9c9da54058afc71219b913ac9f79e48b" +source = "git+https://github.com/anoma/masp?tag=v1.1.0#f24691c0eb76909e3c15ae03aef294dccebd2df3" dependencies = [ "aes", "bip0039", @@ -3488,7 +3499,7 @@ dependencies = [ [[package]] name = "masp_proofs" version = "1.0.0" -source = "git+https://github.com/anoma/masp?tag=v1.0.0#c3c6047a9c9da54058afc71219b913ac9f79e48b" +source = "git+https://github.com/anoma/masp?tag=v1.1.0#f24691c0eb76909e3c15ae03aef294dccebd2df3" dependencies = [ "bellman", "blake2b_simd", @@ -3670,32 +3681,40 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "namada_account" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "namada_core", + "namada_macros", + "namada_storage", + "serde", +] + [[package]] name = "namada_core" -version = "0.28.1" -source = "git+https://github.com/anoma/namada?rev=v0.28.1#468d3d3bcadd2bd11760855d2bbfcc0b4ce27e14" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" dependencies = [ - "ark-bls12-381", - "ark-serialize", "bech32 0.8.1", "borsh", "borsh-ext", "chrono", "data-encoding", - "derivative", "ed25519-consensus 1.2.1", "ethabi", "ethbridge-structs", "eyre", "ibc", - "ibc-derive", "ics23", "impl-num-traits", "index-set", - "itertools 0.10.5", "k256", "masp_primitives", "namada_macros", + "num-derive", "num-integer", "num-rational 0.4.1", "num-traits", @@ -3714,7 +3733,6 @@ dependencies = [ "tendermint-proto", "thiserror", "tiny-keccak", - "tonic-build", "tracing", "uint", "zeroize", @@ -3722,45 +3740,135 @@ dependencies = [ [[package]] name = "namada_ethereum_bridge" -version = "0.28.1" -source = "git+https://github.com/anoma/namada?rev=v0.28.1#468d3d3bcadd2bd11760855d2bbfcc0b4ce27e14" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" dependencies = [ "borsh", - "borsh-ext", + "ethabi", "ethers", "eyre", "itertools 0.10.5", "namada_core", "namada_macros", + "namada_parameters", "namada_proof_of_stake", + "namada_state", + "namada_storage", + "namada_trans_token", + "namada_tx", + "namada_vote_ext", "rand 0.8.5", "serde", "serde_json", "tendermint", "tendermint-proto", "tendermint-rpc", + "thiserror", + "tracing", +] + +[[package]] +name = "namada_gas" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "namada_core", + "serde", + "thiserror", +] + +[[package]] +name = "namada_governance" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "namada_core", + "namada_macros", + "namada_parameters", + "namada_state", + "namada_trans_token", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "namada_ibc" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "ibc", + "ibc-derive", + "ics23", + "masp_primitives", + "namada_core", + "namada_governance", + "namada_parameters", + "namada_state", + "namada_storage", + "namada_trans_token", + "primitive-types", + "prost 0.12.3", + "sha2 0.9.9", + "thiserror", "tracing", ] [[package]] name = "namada_macros" -version = "0.28.1" -source = "git+https://github.com/anoma/namada?rev=v0.28.1#468d3d3bcadd2bd11760855d2bbfcc0b4ce27e14" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "namada_merkle_tree" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "eyre", + "ics23", + "namada_core", + "prost 0.12.3", + "sparse-merkle-tree", + "thiserror", +] + +[[package]] +name = "namada_parameters" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "namada_core", + "namada_macros", + "namada_storage", + "thiserror", +] + [[package]] name = "namada_proof_of_stake" -version = "0.28.1" -source = "git+https://github.com/anoma/namada?rev=v0.28.1#468d3d3bcadd2bd11760855d2bbfcc0b4ce27e14" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" dependencies = [ "borsh", "data-encoding", "derivative", + "namada_account", "namada_core", + "namada_governance", + "namada_parameters", + "namada_storage", + "namada_trans_token", + "num-traits", "once_cell", "serde", "thiserror", @@ -3769,8 +3877,8 @@ dependencies = [ [[package]] name = "namada_sdk" -version = "0.28.1" -source = "git+https://github.com/anoma/namada?rev=v0.28.1#468d3d3bcadd2bd11760855d2bbfcc0b4ce27e14" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" dependencies = [ "async-trait", "bimap", @@ -3781,14 +3889,25 @@ dependencies = [ "derivation-path", "ethbridge-bridge-contract", "ethers", + "fd-lock", "futures", "itertools 0.10.5", "lazy_static", "masp_primitives", "masp_proofs", + "namada_account", "namada_core", "namada_ethereum_bridge", + "namada_governance", + "namada_ibc", + "namada_parameters", "namada_proof_of_stake", + "namada_state", + "namada_storage", + "namada_token", + "namada_tx", + "namada_vote_ext", + "num-traits", "num256", "orion", "owo-colors", @@ -3802,6 +3921,7 @@ dependencies = [ "serde_json", "sha2 0.9.9", "slip10_ed25519", + "tendermint-config", "tendermint-rpc", "thiserror", "tiny-bip39", @@ -3813,6 +3933,110 @@ dependencies = [ "zeroize", ] +[[package]] +name = "namada_shielded_token" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "masp_primitives", + "namada_core", + "namada_parameters", + "namada_state", + "namada_storage", + "namada_trans_token", + "tracing", +] + +[[package]] +name = "namada_state" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "ics23", + "itertools 0.10.5", + "namada_core", + "namada_gas", + "namada_merkle_tree", + "namada_parameters", + "namada_storage", + "namada_trans_token", + "namada_tx", + "sha2 0.9.9", + "sparse-merkle-tree", + "thiserror", + "tiny-keccak", + "tracing", +] + +[[package]] +name = "namada_storage" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "itertools 0.10.5", + "namada_core", + "namada_gas", + "namada_merkle_tree", + "namada_tx", + "thiserror", + "tracing", +] + +[[package]] +name = "namada_token" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "namada_core", + "namada_shielded_token", + "namada_storage", + "namada_trans_token", +] + +[[package]] +name = "namada_trans_token" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "namada_core", + "namada_storage", +] + +[[package]] +name = "namada_tx" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "ark-bls12-381", + "borsh", + "data-encoding", + "masp_primitives", + "namada_core", + "namada_gas", + "num-derive", + "num-traits", + "prost 0.12.3", + "prost-types 0.12.3", + "serde", + "serde_json", + "sha2 0.9.9", + "thiserror", + "tonic-build", +] + +[[package]] +name = "namada_vote_ext" +version = "0.31.0" +source = "git+https://github.com/anoma/namada?rev=v0.31.0#720304bc49aec3390f9bf127b69cd1e875612fc4" +dependencies = [ + "borsh", + "namada_core", + "namada_tx", + "serde", +] + [[package]] name = "namadexer" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index c97db86..88caf0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ path = "src/bin/indexer.rs" [dependencies] getrandom = { version = "0.2" } async-trait = "0.1.51" -namada_sdk = { git = "https://github.com/anoma/namada", rev = "v0.28.1" } +namada_sdk = { git = "https://github.com/anoma/namada", rev = "v0.31.0" } rand = { version = "0.8", default-features = false } rand_core = { version = "0.6", default-features = false } tokio = { version = "1.26.0", features = ["rt-multi-thread"] } diff --git a/Makefile b/Makefile index 410f87d..a0b907f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ #!/bin/sh -NAMADA_VERSION := 0.28.1 +NAMADA_VERSION := 0.31.0 BASE_URL := https://raw.githubusercontent.com/anoma/namada URL := $(BASE_URL)/v$(NAMADA_VERSION)/wasm/checksums.json diff --git a/src/database.rs b/src/database.rs index 290f922..6654295 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,24 +1,27 @@ use crate::queries::insert_block_query; use crate::{config::DatabaseConfig, error::Error, utils}; -use namada_sdk::core::types::key::common::PublicKey; +use namada_sdk::types::key::common::PublicKey; use namada_sdk::{ borsh::BorshDeserialize, - core::types::{ + types::{ address::Address, eth_bridge_pool::PendingTransfer, // key::PublicKey, token, - transaction::{ - account::{InitAccount, UpdateAccount}, - governance::VoteProposalData, - pgf::UpdateStewardCommission, + }, + account::{InitAccount, UpdateAccount}, + governance::VoteProposalData, + tx::{ + Tx, + data::{ pos::{Bond, Unbond}, - TxType, - }, + pgf::UpdateStewardCommission, + TxType + } }, - proto, tendermint_proto::types::EvidenceList as RawEvidenceList, + }; use sqlx::postgres::{PgPool, PgPoolOptions, PgRow as Row}; use sqlx::Row as TRow; @@ -595,7 +598,7 @@ impl Database { let mut i: usize = 0; for t in txs.iter() { - let tx = proto::Tx::try_from(t.as_slice()).map_err(|_| Error::InvalidTxData)?; + let tx = Tx::try_from(t.as_slice()).map_err(|_| Error::InvalidTxData)?; let mut code = Default::default(); let mut txid_wrapper: Vec = vec![]; @@ -791,7 +794,8 @@ impl Database { .push_values(std::iter::once(0), |mut b, _| { b.push_bind(proposal_id) .push_bind(tx_data.vote.is_yay()) - .push_bind(tx_data.vote.is_default_vote()) + .push_bind(tx_data.vote.is_nay()) + .push_bind(tx_data.vote.is_abstain()) .push_bind(tx_data.voter.encode()) .push_bind(&hash_id); }) @@ -895,7 +899,7 @@ impl Database { let mut gas_limit_multiplier: Option = None; if let TxType::Wrapper(txw) = tx.header().tx_type { fee_amount_per_gas_unit = - Some(txw.fee.amount_per_gas_unit.raw_amount().to_string()); + Some(txw.fee.amount_per_gas_unit.amount().to_string()); fee_token = Some(txw.fee.token.to_string()); let multiplier: u64 = txw.gas_limit.into(); // WARNING! converting into i64 might ended up changing the value but there is little diff --git a/src/server/tx.rs b/src/server/tx.rs index 4aa0b28..dbffb9c 100644 --- a/src/server/tx.rs +++ b/src/server/tx.rs @@ -1,25 +1,27 @@ use crate::error::Error; -use namada_sdk::core::types::key::common::PublicKey; -use namada_sdk::core::types::transaction::pos::BecomeValidator; +use namada_sdk::types::key::common::PublicKey; +use namada_sdk::tx::data::pos::BecomeValidator; use namada_sdk::ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use namada_sdk::{ borsh::BorshDeserialize, - core::types::{ + types::{ address::Address, eth_bridge_pool::PendingTransfer, - transaction::{ - governance::VoteProposalData, + }, + governance::VoteProposalData, + tx::{ + data::{ pgf::UpdateStewardCommission, pos::{Bond, Unbond, Withdraw}, }, }, - core::types::{ + types::{ token, - transaction::account::{InitAccount, UpdateAccount}, }, + account::{InitAccount, UpdateAccount}, }; -use namada_sdk::core::ibc::primitives::proto::Any; +use namada_sdk::ibc::primitives::proto::Any; use prost::Message; use serde::{Deserialize, Serialize}; diff --git a/src/utils.rs b/src/utils.rs index 9682c38..f547ed0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,4 @@ -use namada_sdk::core::types::transaction::TxType; +use namada_sdk::tx::data::TxType; use std::collections::HashMap; use std::{env, fs};