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

all : implement dynamicGasPrice(kip-71) #1493

Merged
merged 261 commits into from Jul 7, 2022
Merged

all : implement dynamicGasPrice(kip-71) #1493

merged 261 commits into from Jul 7, 2022

Conversation

kjeom
Copy link
Contributor

@kjeom kjeom commented Jul 6, 2022

Proposed changes

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

Further comments

  • The baseFee increases/decreases only by up to 5% per block
  • The default gasTarget is 30 million that means at least about 1500 value transfer txs are needed to increase the baseFee
  • You can change governance parameters for kip71 by voting
  • If you want to set the kip71 hardforked block number in genesis.json, use homi option with kip71-compatible-blocknumber number
  • A baseFee field is added to the block header, so a hard fork is required.

kale and others added 30 commits May 16, 2022 14:39
…ist of transactions that greater than or equal to the given baseFee.
…ponding nonce already exists, a transaction with a high gasPrice is added.
…of newTx is bigger than gasPrice of oldTx, replace it.
Co-authored-by: Junghyun Colin Kim <colin.klaytn@krustuniverse.com>
Co-authored-by: Junghyun Colin Kim <colin.klaytn@krustuniverse.com>
Co-authored-by: Junghyun Colin Kim <colin.klaytn@krustuniverse.com>
@kjeom kjeom assigned kjeom and ghost Jul 6, 2022
@kjeom kjeom added the need to merge Need to merge for the next time label Jul 6, 2022
@kjeom kjeom added this to the v1.9.0 milestone Jul 6, 2022
hqjang-pepper
hqjang-pepper previously approved these changes Jul 6, 2022
Copy link
Contributor

@hqjang-pepper hqjang-pepper left a comment

Choose a reason for hiding this comment

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

Nice work :)

Copy link
Member

@aidan-kwon aidan-kwon left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@aidan-kwon aidan-kwon left a comment

Choose a reason for hiding this comment

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

When a node processes a block, it doesn't verify the gas price of block transactions whether it is higher than the block base fee.

@@ -1464,10 +1493,14 @@ func (api *EthereumAPI) rpcMarshalHeader(head *types.Header) (map[string]interfa
"receiptsRoot": head.ReceiptHash,
}

// TODO-Klaytn needs to add kip71 hardfork condition
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this line?

Comment on lines +148 to +149
// TODO-klaytn temporal number for test
KIP71CompatibleBlockNum = big.NewInt(95000000)
Copy link
Member

Choose a reason for hiding this comment

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

Time to remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can fix the block number now? I think we can fix this after the hardforked block number is confirmed.

@jimni1222
Copy link
Contributor

@kjeom Can you resolve conflict?

@kjeom
Copy link
Contributor Author

kjeom commented Jul 7, 2022

@jimni1222 Yes, I resolved the conflict twice.

@aeharvlee
Copy link
Contributor

aeharvlee commented Jul 7, 2022

@kjeom
[Issue Reporting]

CN: Cannot process the tx.

Logs

Full Logs
Below logs are appended continuously and KCN cannot process the txs.

images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:138]  [RC] Prepare messages received before startNewRound  address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" from=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd round=8069 len(prepares)=0 messages="\n"
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:140]  [RC] Commit messages received before startNewRound  address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" from=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd round=8069 len(commits)=0 messages="\n"
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:142]  [RC] Received 2f+1 Round Change Messages. Starting new round  address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" from=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd currentRound=8069 newRound=8069
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/preprepare.go:95]    Failed to verify proposal                 address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd from=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" err="invalid baseFee: have 25000000000, want 190020286334, parentBaseFee 200000000000, parentGasUsed 60859" duration=0s
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:42]   [RC] sendNextRoundChange happened         where="handlePreprepare. Proposal verification failure. Not ErrFutureBlock"
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:57]   [RC] Prepare messages received before catchUpRound  address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" len(prepares)=0 messages="\n"
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/roundchange.go:59]   [RC] Commit messages received before catchUpRound  address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" len(commits)=0 messages="\n"
images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/core.go:310]         [RC] Catch up round                       address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd old_round=8069 old_seq=195 old_proposer=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd new_round=8070 new_seq=195 new_proposer=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd

Problem Log

images-CN-0-1  | WARN[07/06,21:31:41 -04] [25|consensus/istanbul/core/preprepare.go:95]    Failed to verify proposal                 address=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd from=0x73718C4980728857f3Aa5148E9d1B471eFa3a7dd state="Accept request" err="invalid baseFee: have 25000000000, want 190020286334, parentBaseFee 200000000000, parentGasUsed 60859" duration=0s

This error is produced by

func VerifyKIP71Header(config *params.ChainConfig, parentHeader, header *types.Header) error {
	if header.BaseFee == nil {
		return fmt.Errorf("header is missing baseFee")
	}
	// Verify the baseFee is correct based on the parent header.
	expectedBaseFee := NextBlockBaseFee(parentHeader, config)
	if header.BaseFee.Cmp(expectedBaseFee) != 0 {
		return fmt.Errorf("invalid baseFee: have %s, want %s, parentBaseFee %s, parentGasUsed %d",
			header.BaseFee, expectedBaseFee, parentHeader.BaseFee, parentHeader.GasUsed)
	}
	return nil
}

Problem Situation

  • As you can see, there is just one tx for some blocks. Most of blocks contains ZERO transactions.
Block number Base fee per gas txs in a block
183 0x5d21dba00 1
185 0x5d21dba00 1
187 0x5d21dba00 1
192 0x5d21dba00 1
193 0x5d21dba00 0
194 0x2e90edd000 (= 200 ston) 1

After block number 194, the error occurred.

How to Re-produce issue
If you have problem when re-produce the situation, feel free to contact me :)

git clone https://github.com/klaytn/caver-java.git
cd caver-java/.circleci/images
docker-compose up -d
docker-compose logs -f # Check the container status, you can see also KCN logs after KCN is up

After 5 mins later... (It takes few minutes to KCN up)
Run unit test

I recommended run this unit test using Intelli J Ultimate

cc. @jimni1222

@kjhman21
Copy link
Collaborator

kjhman21 commented Jul 7, 2022

@kjeom @aidan-kwon Let's merge this and resolve the bug in other PRs.
cc @jimni1222 @aeharvlee @bobpkr

@kjeom kjeom merged commit eb48bd7 into dev Jul 7, 2022
@blukat29 blukat29 removed the need to merge Need to merge for the next time label Feb 17, 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.

None yet

10 participants