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

Add Evm Allowlist Feature to SBT Pallet #1057

Merged
merged 106 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
0f7db79
init sbt pallet
ferrell-code Dec 19, 2022
e44457c
update polkadot version for uniques
ferrell-code Dec 19, 2022
20be86a
fix mock and start tests
ferrell-code Dec 20, 2022
86e17b1
clean up code
ferrell-code Dec 21, 2022
6182abf
some tests, add checks to_private
ferrell-code Dec 21, 2022
9be7e5c
cleanup deps
ferrell-code Dec 22, 2022
04a5a27
fix dependencies
ferrell-code Dec 22, 2022
f3f296e
add pallet sbt to dolphin runtime
ferrell-code Dec 26, 2022
a049db5
fix rpc
ferrell-code Dec 27, 2022
f79911d
add reserve sbt
ferrell-code Jan 13, 2023
81f311a
fix mock
ferrell-code Jan 13, 2023
eae937d
fmt
ferrell-code Jan 16, 2023
42a717f
merge to 0.5.9
ferrell-code Jan 17, 2023
ab331a3
merge manta
ferrell-code Jan 17, 2023
b88ecae
clean up deps
ferrell-code Jan 17, 2023
13af87a
fix sender ledger to return Ok((()) rather than error
ferrell-code Jan 17, 2023
90fd61d
merge master
ferrell-code Jan 31, 2023
d85bb2a
restructure for some common code
ferrell-code Feb 2, 2023
70ab257
benchmark sbt
ferrell-code Feb 2, 2023
8769b68
add weights file
ferrell-code Feb 3, 2023
10c61a0
clean up & tests
ferrell-code Feb 3, 2023
6d34075
remove duplicate code
ferrell-code Feb 3, 2023
48fb1da
add tests and docs
ferrell-code Feb 3, 2023
07166f7
fmt
ferrell-code Feb 3, 2023
0269c07
flip order of event to be more logical
ferrell-code Feb 4, 2023
f6aa48a
change AssetMetadata to enum supporting different types of metadata
ferrell-code Feb 5, 2023
ea75cf2
update runtimes to new asset manager
ferrell-code Feb 5, 2023
8405911
add events to asset manager
ferrell-code Feb 5, 2023
2b8d8fa
remove uniques
ferrell-code Feb 5, 2023
5f6b799
move storage change to UpdateMetadata trait
ferrell-code Feb 5, 2023
43263a4
fix Cargo.toml
ferrell-code Feb 5, 2023
7a3860b
fmt Cargo.toml
ferrell-code Feb 6, 2023
3803c7a
fix clippy lints
ferrell-code Feb 6, 2023
f9579e1
fix benchmarking
ferrell-code Feb 6, 2023
734736f
add test for asset-manager, add docs and feedback
ferrell-code Feb 6, 2023
04a5b97
tests
ferrell-code Feb 7, 2023
9df5438
make const and clippy fix
ferrell-code Feb 7, 2023
802eb71
fix clippy lints
ferrell-code Feb 7, 2023
3b4700c
fmt
ferrell-code Feb 7, 2023
c35520e
fix benchmark
ferrell-code Feb 7, 2023
0294f4b
fix benchmarking
ferrell-code Feb 7, 2023
24c1acb
better comments and add better errors
ferrell-code Feb 8, 2023
2b5ed78
make more functional
ferrell-code Feb 9, 2023
fa32fec
review comment
ferrell-code Feb 9, 2023
9bc1554
remove unnecessary into_iter()
ferrell-code Feb 9, 2023
5ddc24c
Better docs
ferrell-code Feb 10, 2023
1413bbf
better name for event
ferrell-code Feb 10, 2023
95e6aca
fix 2022
ferrell-code Feb 20, 2023
4eddb4f
merge master
ferrell-code Feb 20, 2023
44a5669
change back to use separate storage
ferrell-code Feb 21, 2023
7624686
revert asset manager changes
ferrell-code Feb 21, 2023
ce5b53b
revert benchmarks too
ferrell-code Feb 21, 2023
c0fd636
cleanup
ferrell-code Feb 21, 2023
8015706
more cleanup
ferrell-code Feb 21, 2023
4e5f60d
Merge branch 'manta' into fer/feat/sbt
ferrell-code Feb 21, 2023
ef2ff80
Merge branch 'manta' into fer/feat/sbt
ferrell-code Feb 22, 2023
f57715e
fix error handling
ferrell-code Feb 22, 2023
5375a4d
fix clippy
ferrell-code Feb 22, 2023
d9206c0
update bench and remove unneeded Balance config
ferrell-code Feb 22, 2023
e36bd17
common types and redo weights
ferrell-code Feb 23, 2023
fb72d25
add tests
ferrell-code Feb 23, 2023
102c37b
fmt
ferrell-code Feb 23, 2023
9959170
remove unneeded clones
ferrell-code Feb 23, 2023
5e54fc5
remove unneeded pull_senders
ferrell-code Feb 23, 2023
1475c1a
add constant attribute to constants in Config
ferrell-code Feb 23, 2023
9632e0d
docs and make counter start at 1
ferrell-code Feb 24, 2023
3291f92
Merge branch 'manta' into fer/feat/sbt
ferrell-code Feb 24, 2023
cf905a9
update to manta-rs v0.5.12
ferrell-code Mar 14, 2023
2064ce4
fix clippy
ferrell-code Mar 14, 2023
0134696
fix benchmarks
ferrell-code Mar 15, 2023
9a6e7be
Merge branch 'manta' into fer/feat/sbt
ferrell-code Mar 22, 2023
514a7fc
add zkSbt to calamari
ferrell-code Mar 22, 2023
fe4f470
update error handling and add weights file
ferrell-code Mar 22, 2023
cb6420a
make it expensive to mint sbt
ferrell-code Mar 22, 2023
4c6dc1d
initial evm sbt implementation
ferrell-code Mar 27, 2023
a59caa7
add to runtime and add whitelist account to storage
ferrell-code Mar 27, 2023
f296259
Add metadata to minting
ferrell-code Mar 28, 2023
73a2ab4
after minting remove account from whitelist
ferrell-code Mar 28, 2023
e601d78
add enum types and change signature to use proof field
ferrell-code Mar 29, 2023
b079c0e
fix version and more tests
ferrell-code Mar 30, 2023
50939d7
merge master
ferrell-code Mar 30, 2023
ba94bcd
fix tests
ferrell-code Mar 30, 2023
31d0e7a
add timestamp logic
ferrell-code Mar 30, 2023
0e78caa
add eth mint and timestamp tests
ferrell-code Mar 30, 2023
2f31fe3
add to tests some more
ferrell-code Mar 30, 2023
149e94f
Merge branch 'manta' into fer-sbt-eth
ferrell-code Mar 31, 2023
255863d
change whiteist to allowlist
ferrell-code Mar 31, 2023
8480998
add benchmarks
ferrell-code Apr 1, 2023
bc26f49
add weights for new calls
ferrell-code Apr 1, 2023
900191f
add and fix docs
ferrell-code Apr 2, 2023
241945b
fix docs
ferrell-code Apr 2, 2023
6430c55
fix typos
ferrell-code Apr 2, 2023
0fa5149
add AlreadyMinted Error
ferrell-code Apr 2, 2023
c99fc48
update unit test
ferrell-code Apr 2, 2023
525ee57
decouple from pallet_timestamp
ferrell-code Apr 3, 2023
3eec43b
Merge branch 'manta' into fer-sbt-eth
ferrell-code Apr 3, 2023
e73d321
fmt
ferrell-code Apr 3, 2023
e4cfb23
add check for valid time range
ferrell-code Apr 3, 2023
e153c18
add metadata
zqhxuyuan Apr 4, 2023
df045e1
metadata optional
zqhxuyuan Apr 4, 2023
10ee131
add chain_id config
zqhxuyuan Apr 4, 2023
c8fd8f0
rename time range to mint info
zqhxuyuan Apr 4, 2023
8cc0381
make storage bounded
ferrell-code Apr 4, 2023
460a19a
MintChainInfo generic and add docs
ferrell-code Apr 4, 2023
6d8c57e
Merge branch 'manta' into fer-sbt-eth
ferrell-code Apr 4, 2023
9b5f541
2/3 tech commitee and add comments
ferrell-code Apr 4, 2023
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
7 changes: 5 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions pallets/manta-sbt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = 'GPL-3.0'
name = 'pallet-manta-sbt'
readme = 'README.md'
repository = 'https://github.com/Manta-Network/Manta/'
version = '4.0.2'
version = '4.0.4'

[[bin]]
name = "precompute_coins"
Expand All @@ -20,6 +20,7 @@ default = ["std"]
# Runtime Benchmarks
runtime-benchmarks = [
"frame-benchmarking",
"libsecp256k1/hmac",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"manta-primitives/runtime-benchmarks",
Expand All @@ -28,6 +29,8 @@ runtime-benchmarks = [
# Standard Library
std = [
"anyhow/std",
"sha3/std",
"libsecp256k1/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
Expand All @@ -36,6 +39,8 @@ std = [
"sp-runtime/std",
"sp-api/std",
"sp-std/std",
"sp-core/std",
"sp-io/std",
"manta-primitives/std",
"manta-accounting/std",
"manta-crypto/std",
Expand Down Expand Up @@ -83,7 +88,9 @@ precompute-coins = [
anyhow = { version = "1.0.55", optional = true, default-features = false }
base64 = { version = "0.20", default-features = false, features = ["alloc"] }
indoc = { version = "1.0.3", optional = true, default-features = false }
libsecp256k1 = { version = "0.7", default-features = false, features = ["hmac", "static-context"], optional = true }
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
sha3 = { version = "0.10.6", default-features = false }
tempfile = { version = "3.3.0", optional = true, default-features = false }

# substrate dependencies
Expand All @@ -94,6 +101,8 @@ scale-codec = { package = "parity-scale-codec", version = '3.1.2', default-featu
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
sp-api = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", optional = true, default-features = false }
sp-blockchain = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", optional = true, default-features = false }
sp-core = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }
sp-io = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28", default-features = false }
sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }

Expand All @@ -116,8 +125,7 @@ pallet-asset-manager = { path = "../asset-manager" }
pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
pallet-manta-pay = { path = "../manta-pay" }
pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
pallet-tx-pause = { path = "../tx-pause" }
sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.28" }
tempfile = "3.3.0"
xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
69 changes: 68 additions & 1 deletion pallets/manta-sbt/src/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@
// along with Manta. If not, see <http://www.gnu.org/licenses/>.

use crate::{
benchmark::precomputed_coins::TO_PRIVATE, AccountId, Box, Call, Config, Pallet, TransferPost,
benchmark::precomputed_coins::TO_PRIVATE, AccountId, Box, Call, Config, EvmAddressType,
MintType, Pallet, Pallet as MantaSBTPallet, TransferPost,
};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, vec, whitelisted_caller};
use frame_support::traits::{Currency, Get};
use frame_system::RawOrigin;
use scale_codec::Decode;
use sp_core::H160;
use sp_io::hashing::keccak_256;

mod precomputed_coins;

fn alice() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap()
}

benchmarks! {
where_clause { where T::AccountId: From<AccountId> + Into<AccountId> }
to_private {
Expand All @@ -45,6 +52,66 @@ benchmarks! {
}: reserve_sbt (
RawOrigin::Signed(caller)
)

change_allowlist_account{
let caller: T::AccountId = whitelisted_caller();
}: change_allowlist_account (
RawOrigin::Root,
Some(caller)
)

allowlist_evm_account {
let caller: T::AccountId = whitelisted_caller();
MantaSBTPallet::<T>::change_allowlist_account(
RawOrigin::Root.into(),
Some(caller.clone())
)?;
}: allowlist_evm_account (
RawOrigin::Signed(caller),
EvmAddressType::Bab(H160::default())
)

set_mint_chain_info {
}: set_mint_chain_info (
RawOrigin::Root,
MintType::Bab,
0,
5u32.into(),
Some(10u32.into())
)

mint_sbt_eth {
let caller: T::AccountId = whitelisted_caller();
MantaSBTPallet::<T>::change_allowlist_account(
RawOrigin::Root.into(),
Some(caller.clone())
)?;
let bab_alice = EvmAddressType::Bab(MantaSBTPallet::<T>::eth_address(&alice()));
MantaSBTPallet::<T>::set_mint_chain_info(
RawOrigin::Root.into(),
MintType::Bab,
0,
0_u32.into(),
None
)?;

MantaSBTPallet::<T>::allowlist_evm_account(
RawOrigin::Signed(caller.clone()).into(),
bab_alice,
)?;
let mint_post = TransferPost::decode(&mut &*TO_PRIVATE).unwrap();

let signature = MantaSBTPallet::<T>::eth_sign(&alice(), &mint_post.proof, 0);

}: mint_sbt_eth(
RawOrigin::Signed(caller),
Box::new(mint_post),
signature,
bab_alice,
Some(0),
Some(0),
Some(vec![0].try_into().unwrap())
)
}

impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
Loading