Skip to content

Commit

Permalink
Macro all proposal creation hooks, fix build issues (#727)
Browse files Browse the repository at this point in the history
* Macro all proposal creation hooks, fix build issues

* Fix tests build

* Fix test

* Fix
  • Loading branch information
drewstone authored Dec 12, 2023
1 parent 165313d commit 125d553
Show file tree
Hide file tree
Showing 25 changed files with 790 additions and 1,478 deletions.
1,845 changes: 683 additions & 1,162 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
description = "A fresh FRAME-based Substrate runtime, ready for hacking."
description = "Event listening, watching, transacting relayer workspace"
authors = ["Webb tools"]
license = "Unlicense"
publish = false
Expand Down Expand Up @@ -68,7 +68,7 @@ auto_impl = "1.0.0"
itertools = "0.10.3"
rstest = "0.12.0"
env_logger = "0.9.0"
webb-proposals = { git = "https://github.com/webb-tools/webb-rs", branch="polkadot-sdk-v1.0.0", default-features = false, features = ["scale", "evm", "substrate"] }
webb-proposals = { git = "https://github.com/webb-tools/webb-rs", default-features = false, features = ["scale", "evm", "substrate"] }
curv = { package = "curv-kzen", version = "0.10.0", default-features = false }
libsecp256k1 = { version = "0.7.1", default-features = false }
tracing = "0.1.37"
Expand Down
2 changes: 1 addition & 1 deletion dkg-gadget/src/gossip_engine/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl<B: Block + 'static> GossipHandler<B> {
}
},
SyncEvent::PeerDisconnected(remote) => {
self.service.remove_peers_from_reserved_set(
let _ = self.service.remove_peers_from_reserved_set(
self.protocol_name.clone(),
iter::once(remote).collect(),
);
Expand Down
4 changes: 3 additions & 1 deletion dkg-runtime-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ethereum = { version = "0.14.0", default-features = false, features = [
"with-codec",
] }
ethereum-types = { version = "0.14.1", default-features = false }
webb-proposals = { workspace = true, default-features = false, features = ["substrate"] }
webb-proposals = { workspace = true, default-features = false, features = ["scale", "evm"] }

sp-api = { workspace = true }
sp-io = { workspace = true }
Expand All @@ -33,10 +33,12 @@ sp-application-crypto = { workspace = true }
sp-runtime = { workspace = true }
frame-system = { workspace = true }
frame-support = { workspace = true }
log = { workspace = true }

[features]
default = ["std"]
std = [
"log/std",
"codec/std",
"ethabi/std",
"ethereum/std",
Expand Down
23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/add_token_to_set.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/anchor_update.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/fee_recipient_update.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/fee_update.rs

This file was deleted.

This file was deleted.

This file was deleted.

70 changes: 50 additions & 20 deletions dkg-runtime-primitives/src/handlers/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,59 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// Bridge proposals
/// Governor proposals
pub mod refresh;
pub mod resource_id_update;

/// Anchor proposals
pub mod anchor_update;
pub mod set_verifier;

/// Token update proposals
pub mod add_token_to_set;
pub mod fee_update;
pub mod remove_token_from_set;
/// EVM tx
pub mod evm_tx;

/// Treasury Proposals
pub mod fee_recipient_update;
pub mod set_treasury_handler;
use webb_proposals::evm::*;

/// Rescue tokens
pub mod rescue_tokens;
/// Macro for creating modules with proposal creation functions
macro_rules! proposal_module {
($mod_name:ident, $proposal_type:ty, $proposal_length:expr) => {
pub mod $mod_name {
use super::*;
use crate::handlers::validate_proposals::ValidationError;
use codec::alloc::string::ToString;
use webb_proposals::from_slice;

/// fees & limits
pub mod max_deposit_limit_update;
pub mod min_withdrawal_limit_update;
pub fn create(data: &[u8]) -> Result<$proposal_type, ValidationError> {
let bytes: [u8; $proposal_length] =
data.try_into().map_err(|_| ValidationError::InvalidProposalBytesLength)?;
from_slice::<$proposal_type>(&bytes).map_err(|e| {
log::error!("Error while decoding proposal: {:?}", e);
ValidationError::InvalidDecoding(e.to_string())
})
}
}
};
}

/// EVM tx
pub mod evm_tx;
proposal_module!(add_token_to_set, TokenAddProposal, TokenAddProposal::LENGTH);
proposal_module!(remove_token_from_set, TokenRemoveProposal, TokenRemoveProposal::LENGTH);
proposal_module!(fee_update, WrappingFeeUpdateProposal, WrappingFeeUpdateProposal::LENGTH);
proposal_module!(
fee_recipient_update,
FeeRecipientUpdateProposal,
FeeRecipientUpdateProposal::LENGTH
);
proposal_module!(
max_deposit_limit_update,
MaxDepositLimitProposal,
MaxDepositLimitProposal::LENGTH
);
proposal_module!(
min_withdrawal_limit_update,
MinWithdrawalLimitProposal,
MinWithdrawalLimitProposal::LENGTH
);
proposal_module!(rescue_tokens, RescueTokensProposal, RescueTokensProposal::LENGTH);
proposal_module!(anchor_update, AnchorUpdateProposal, AnchorUpdateProposal::LENGTH);
proposal_module!(resource_id_update, ResourceIdUpdateProposal, ResourceIdUpdateProposal::LENGTH);
proposal_module!(
set_treasury_handler,
SetTreasuryHandlerProposal,
SetTreasuryHandlerProposal::LENGTH
);
proposal_module!(set_verifier, SetVerifierProposal, SetVerifierProposal::LENGTH);
23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/remove_token_from_set.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/rescue_tokens.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/resource_id_update.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/set_treasury_handler.rs

This file was deleted.

23 changes: 0 additions & 23 deletions dkg-runtime-primitives/src/handlers/evm/set_verifier.rs

This file was deleted.

2 changes: 1 addition & 1 deletion pallets/bridge-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sp-runtime = { workspace = true }
sp-std = { workspace = true }
serde = { workspace = true }
hex = { workspace = true }

log = { workspace = true }
dkg-runtime-primitives = { workspace = true, default-features = false }
frame-benchmarking = { workspace = true, optional = true }
pallet-identity = { workspace = true }
Expand Down
Loading

0 comments on commit 125d553

Please sign in to comment.