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

✅ ETH Compatibility Tests #425

Open
wants to merge 1 commit into
base: 10-14-ethereum_compatibility
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ sp-authority-discovery = { version = "33.0.0", default-features = false }
sp-consensus-babe = { version = "0.39.0", default-features = false }
pallet-message-queue = { version = "38.0.0", default-features = false }
sp-weights = { version = "31.0.0", default-features = false }
sp-application-crypto = {version = "37.0.0", default-features = false}

# FRAME
assets-common = { version = "0.14.0", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ std = [
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system/std",
"hex/std",
"itertools/use_std",
"orml-oracle/std",
"pallet-asset-tx-payment/std",
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/src/tests/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::PolimecRuntime;
use frame_support::BoundedVec;
pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToUSDBalance};
pub use pallet_funding::instantiator::{BidParams, ContributionParams, EvaluationParams};
use pallet_funding::{
AcceptedFundingAsset, BiddingTicketSizes, ContributingTicketSizes, CurrencyMetadata, ParticipantsAccountType,
ParticipationMode, PriceProviderOf, ProjectMetadata, ProjectMetadataOf, TicketSize,
Expand Down Expand Up @@ -91,11 +91,11 @@ pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf<polimec_
participants_account_type: ParticipantsAccountType::Polkadot,
}
}
pub fn default_evaluations() -> Vec<UserToUSDBalance<PolimecRuntime>> {
pub fn default_evaluations() -> Vec<EvaluationParams<PolimecRuntime>> {
vec![
UserToUSDBalance::new(EVAL_1.into(), 500_000 * PLMC),
UserToUSDBalance::new(EVAL_2.into(), 250_000 * PLMC),
UserToUSDBalance::new(EVAL_3.into(), 320_000 * PLMC),
EvaluationParams::from((EVAL_1.into(), 500_000 * PLMC)),
EvaluationParams::from((EVAL_2.into(), 250_000 * PLMC)),
EvaluationParams::from((EVAL_3.into(), 320_000 * PLMC)),
]
}
pub fn default_bidders() -> Vec<AccountId> {
Expand Down
40 changes: 40 additions & 0 deletions integration-tests/src/tests/ethereum_support.rs
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
use crate::*;
use hex_literal::hex;
use sp_runtime::traits::Convert;

generate_accounts!(ETH_BUYER);

#[test]
fn test_hardcoded_signatures() {
let polimec_account: PolimecAccountId = ETH_BUYER.into();
let project_id = 0;

// Values generated with `https://github.com/lrazovic/ethsigner`
let polimec_account_ss58 = polimec_runtime::SS58Converter::convert(polimec_account.clone());
dbg!(polimec_account_ss58);
let ethereum_account: [u8; 20] = hex!("FCAd0B19bB29D4674531d6f115237E16AfCE377c");
let signature: [u8; 65] = hex!("4fa35369a2d654112d3fb419e24dc0d7d61b7e3f23936d6d4df0ac8608fa4530795971d4d1967da60853aa974ad57252a521f97bcd5a68ddea5f8959a5c60b471c");

PolimecNet::execute_with(|| {
assert_ok!(PolimecFunding::verify_receiving_account_signature(
&polimec_account,
project_id,
&Junction::AccountKey20 { network: Some(NetworkId::Ethereum { chain_id: 1 }), key: ethereum_account },
signature,
));
JuaniRios marked this conversation as resolved.
Show resolved Hide resolved
});

let polkadot_signature: [u8; 64] = hex!("7efee88bb61b74c91e6dc0ad48ea5b0118db77a579da8a8a753933d76cdc9e029c11f32a51b00fd3a1e3ce5b56cd1e275b179d4b195e7d527eebc60680291b81");
let mut signature: [u8; 65] = [0u8; 65];
signature[..64].copy_from_slice(polkadot_signature.as_slice());
signature[64] = 0;
let polkadot_address: [u8; 32] = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d");

PolimecNet::execute_with(|| {
assert_ok!(PolimecFunding::verify_receiving_account_signature(
&polimec_account,
project_id,
&Junction::AccountId32 { network: Some(NetworkId::Polkadot), id: polkadot_address },
signature,
));
});
}
4 changes: 2 additions & 2 deletions integration-tests/src/tests/evaluator_slash_sideffects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn evaluator_slash_reduces_vesting_schedules() {
vesting_info_4
));

let alice_evaluation = UserToUSDBalance::<PolimecRuntime>::new(alice.clone(), 35_000 * USD_UNIT);
let alice_evaluation = EvaluationParams::<PolimecRuntime>::new(alice.clone(), 35_000 * USD_UNIT);
let alice_plmc_evaluated = inst.calculate_evaluation_plmc_spent(vec![alice_evaluation.clone()])[0].plmc_amount;
let alice_slashed = slash_percent * alice_plmc_evaluated;

Expand All @@ -92,7 +92,7 @@ fn evaluator_slash_reduces_vesting_schedules() {
Id(bob.clone()),
vesting_info_5
));
let bob_evaluation = UserToUSDBalance::<PolimecRuntime>::new(bob.clone(), BOB_EVALUATION * USD_UNIT);
let bob_evaluation = EvaluationParams::<PolimecRuntime>::new(bob.clone(), BOB_EVALUATION * USD_UNIT);
let bob_plmc_evaluated = inst.calculate_evaluation_plmc_spent(vec![bob_evaluation.clone()])[0].plmc_amount;
let bob_slashed = slash_percent * bob_plmc_evaluated;

Expand Down
8 changes: 5 additions & 3 deletions pallets/funding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ frame-benchmarking = { workspace = true, optional = true }
hex-literal.workspace = true
k256.workspace = true
hex.workspace = true
#sp-application-crypto.workspace = true

# Used in the instantiator.
itertools.workspace = true
Expand All @@ -62,12 +63,14 @@ xcm-builder.workspace = true
xcm-executor.workspace = true

[features]
default = [ "std", "sp-core/serde" ]
default = [ "sp-core/serde", "std" ]
std = [
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"hex/std",
"itertools/use_std",
"k256/std",
"log/std",
"on-slash-vesting/std",
"pallet-assets/std",
Expand All @@ -86,15 +89,14 @@ std = [
"serde/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-core/full_crypto",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
"k256/std",
"hex/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down
Loading