diff --git a/generator/CHANGELOG.md b/generator/CHANGELOG.md index 76d999da..9777362e 100644 --- a/generator/CHANGELOG.md +++ b/generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1 + +Stop `wccd` mode from minting to everyone faster than the specified TPS. + ## 1.1.0 Support protocol 6 and node version 6. diff --git a/generator/Cargo.lock b/generator/Cargo.lock index 0855a058..ed47ce27 100644 --- a/generator/Cargo.lock +++ b/generator/Cargo.lock @@ -978,7 +978,7 @@ dependencies = [ [[package]] name = "generator" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "chrono", diff --git a/generator/Cargo.toml b/generator/Cargo.toml index 9722bc31..2816fddc 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "generator" -version = "1.1.0" +version = "1.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/generator/README.md b/generator/README.md index 58715098..13d6aaf6 100644 --- a/generator/README.md +++ b/generator/README.md @@ -69,7 +69,7 @@ The transactions are sent in a round robin fashion. ### `wccd` -The tool first deploys and initializes the [`cis2-wccd`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/cis2-wccd) example contract. It then mints 1 (micro) wCCD for each account on the chain in order to increase the size of the state of the contract. The transactions alternate between wrapping, transferring, and unwrapping wCCD. In each case the receiver is the sender, since it is simple and there is no special handling of this in the contract. +The tool first deploys and initializes the [`cis2-wccd`](https://github.com/Concordium/concordium-rust-smart-contracts/tree/fcc668d87207aaf07b43f5a3b02b6d0a634368d0/examples/cis2-wccd) example contract. It then starts minting 1 (micro) wCCD for each account on the chain in order to increase the size of the state of the contract. After that, the transactions alternate between wrapping, transferring, and unwrapping wCCD. In each case the receiver is the sender, since it is simple and there is no special handling of this in the contract. ### `register-credentials` diff --git a/generator/src/generator.rs b/generator/src/generator.rs index 373b6ce9..1e1a3262 100644 --- a/generator/src/generator.rs +++ b/generator/src/generator.rs @@ -540,10 +540,11 @@ impl Generate for TransferCis2Generator { /// A generator that makes transactions that wrap, unwrap, and transfer WCCDs. pub struct WccdGenerator { - client: Cis2Contract, - args: CommonArgs, - nonce: Nonce, - count: usize, + client: Cis2Contract, + args: CommonArgs, + nonce: Nonce, + count: usize, + accounts: Vec, } #[derive(concordium_std::Serial)] @@ -596,8 +597,7 @@ impl WccdGenerator { // Give everyone on the network a wCCD token to increase the size of the state // of the contract. - println!("Minting wCCD tokens for everyone..."); - let receivers: Vec<_> = client + let accounts: Vec<_> = client .get_account_list(BlockIdentifier::LastFinal) .await .context("Could not obtain a list of accounts.")? @@ -605,36 +605,14 @@ impl WccdGenerator { .try_collect() .await?; - let mut client = Cis2Contract::create(client, contract_address).await?; - - for recv in receivers { - let params = WrapParams { - to: Receiver::Account(recv), - data: AdditionalData::new(vec![])?, - }; - - let metadata = ContractTransactionMetadata { - sender_address: args.keys.address, - nonce: nonce.nonce, - expiry: TransactionTime::seconds_after(args.expiry), - energy: GivenEnergy::Absolute(Energy::from(3500)), - amount: Amount::from_micro_ccd(1), - }; - let transaction_hash = client - .update::<_, anyhow::Error>(&args.keys, &metadata, "wrap", ¶ms) - .await?; - nonce.nonce.next_mut(); - println!( - "{}: Transferred 1 wCCD to {recv} (hash = {transaction_hash}).", - chrono::Utc::now(), - ); - } + let client = Cis2Contract::create(client, contract_address).await?; Ok(Self { client, args, nonce: nonce.nonce, count: 0, + accounts, }) } } @@ -651,10 +629,32 @@ impl Generate for WccdGenerator { amount: Amount::zero(), }; + // Before doing anything else, we transfer a single wCCD to each account on the + // network to increase the size of the contract state. + if self.count < self.accounts.len() { + let recv = self.accounts[self.count]; + let params = WrapParams { + to: Receiver::Account(recv), + data: AdditionalData::new(vec![])?, + }; + metadata.amount = Amount::from_micro_ccd(1); + + let tx = self.client.make_update::<_, anyhow::Error>( + &self.args.keys, + &metadata, + "wrap", + ¶ms, + )?; + self.nonce.next_mut(); + self.count += 1; + + return Ok(tx); + } + // We modulate between wrapping, transferring, and unwrapping. All wCCD are // minted for and transferred to our own account, which is fine for testing, // since there is no special logic for this in the contract. - let tx = match self.count % 3 { + let tx = match (self.count - self.accounts.len()) % 3 { // Wrap 0 => { let params = WrapParams {