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

fees-analysis tool #21

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

fees-analysis tool #21

wants to merge 6 commits into from

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Oct 20, 2022

can be used to perform experiments on fees & generate charts.

for the instructions:

/**
 * This test assumes the following:
 *  + moonbeam
 *    - EVM calls are unfiltered.
 *        NormalFilter - Call::EVM(_) => true
 *    - EVM origin is allowed for all.
 *        type CallOrigin = EnsureAddressAlways;
 *
 *        pub struct EnsureAddressAlways;
 *        impl<OuterOrigin> EnsureAddressOrigin<OuterOrigin> for EnsureAddressAlways {
 *           type Success = ();
 *
 *           fn try_address_origin(
 *                   _address: &H160,
 *                   _origin: OuterOrigin,
 *           ) -> Result<Self::Success, OuterOrigin> {
 *                   Ok(())
 *           }
 *
 *           fn ensure_address_origin(
 *                   _address: &H160,
 *                   _origin: OuterOrigin,
 *           ) -> Result<Self::Success, sp_runtime::traits::BadOrigin> {
 *                   Ok(())
 *           }
 *        }
 *  + frontier
 *    - Baltathar pays no EVM fees and full substrate fees, while Charleth pays the opposite.
 *        let baltathar_addr = H160::from_str("0x3cd0a705a2dc65e5b1e1205896baa2be8a07c6e0").unwrap();
 *        let (validate, payable) = if source == baltathar_addr {
 *                (false, Pays::Yes)
 *        } else {
 *                (true, Pays::No)
 *        };
 *
 * Then start the node with the following command
 ./target/release/moonbeam \
 --execution=Native \
 --wasm-execution=interpreted-i-know-what-i-do \
 --ethapi=txpool \
 --no-hardware-benchmarks \
 --no-telemetry \
 --no-prometheus \
 --force-authoring \
 --rpc-cors=all \
 --alice \
 --chain=moonbase-dev \
 --sealing=manual \
 --in-peers=0 \
 --out-peers=0 -linfo \
 --tmp
 *
 * Examples:
 *  ts-node ./src/tools/fees.ts --name fees --type compute
 *  ts-node ./src/tools/fees.ts --name fees --type compute --multiplier 300000000
 *  ts-node ./src/tools/fees.ts --name fees --type length-small
 *  ts-node ./src/tools/fees.ts --name fees --type length-big
 *
 * The result will open in the browser once done
 */

/**
 * Observations
 * - The first EVM call causes the SmartContract storage to be initialized and costs around 20,000 gas (we avoid this by pre-initializing the storage)
 * - The fees sometime jump abruptly and stay at that level, this is due to nonce going from 1 byte to 2 bytes and so on
 * - The block fill ratio is computed differently by transaction-payment; the multiplier is updated only due to `Normal` weight class (actual / max).
 *   The actual weight also contains some extra weight that doesn't belong to extrinsics (maybe coming from on_initialize/on_finalize)
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant