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

No need to deposit event each block #604

Merged

Conversation

boundless-forest
Copy link
Collaborator

It is not a good idea to deposit this event so frequently(each block).

image

Copy link
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. The base fee can be fetched easily through the access function.

@crystalin
Copy link
Contributor

If this can wait for @tgmichel or @nanocryk to agree.
We have ~200 events per block, I don't think this one is adding much to the total.
We can maybe only emit it when it changes, would that work for you @AsceticBear ?

@boundless-forest
Copy link
Collaborator Author

@tgmichel @nanocryk What is your opinion?

@AurevoirXavier
Copy link
Contributor

AurevoirXavier commented Mar 15, 2022

// IIRC, using `try_mutate` will avoid unnecessary writing OP.
<BaseFeePerGas<T>>::try_mutate(|bf| {
	let new_bf = ...;

	if bf != new_bf {
		*bf = new_bf;
		deposit_event(new_bf);

		Ok(())
	} else {
		Err(())
	}
});

@boundless-forest
Copy link
Collaborator Author

boundless-forest commented Mar 16, 2022

We can maybe only emit it when it changes, would that work for you

In the current implementation of the base fee pallet, the fee update almost every block, the usage blow or above the target fullness. That means only emit when it changes similar to emit each block. This way only works when many consecutive empty blocks, the fee decrease to the minimal value, then no adjustment happened, no more event. @crystalin

if usage > target {
    // increase
} else {
    // decreate
}

when many consecutive empty blocks, the fee decrease to the minimal value

See:

  1. Abnormal Base Fee darwinia-network/darwinia-2.0#62
  2. https://github.com/paritytech/frontier/blob/master/frame/base-fee/src/lib.rs#L405-L418

Maybe we should introduce a FixedMinFee to the minimum value of a fee.

@tgmichel
Copy link
Contributor

I agree with Wei, I see no harm in just removing the event.

@sorpaas sorpaas merged commit 4258b30 into polkadot-evm:master Mar 16, 2022
@boundless-forest boundless-forest deleted the bear-fix-upstream-event branch March 17, 2022 01:07
jordy25519 pushed a commit to cennznet/frontier that referenced this pull request Apr 6, 2022
boundless-forest added a commit to darwinia-network/frontier that referenced this pull request May 11, 2022
abhijeetbhagat pushed a commit to web3labs/frontier that referenced this pull request Jan 11, 2023
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.

5 participants