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 eth_resend API #1894

Merged
merged 7 commits into from Jul 26, 2023
Merged

add eth_resend API #1894

merged 7 commits into from Jul 26, 2023

Conversation

JayChoi1736
Copy link
Contributor

@JayChoi1736 JayChoi1736 commented Jul 25, 2023

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

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@JayChoi1736 JayChoi1736 self-assigned this Jul 25, 2023
api/api_ethereum.go Outdated Show resolved Hide resolved
@aidan-kwon aidan-kwon added the need to merge Need to merge for the next time label Jul 25, 2023
hyunsooda
hyunsooda previously approved these changes Jul 25, 2023
@@ -1453,7 +1453,45 @@ func (api *EthereumAPI) PendingTransactions() ([]*EthRPCTransaction, error) {
// Resend accepts an existing transaction and a new gas price and limit. It will remove
// the given transaction from the pool and reinsert it with the new gas price and limit.
func (api *EthereumAPI) Resend(ctx context.Context, sendArgs EthTransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
return common.Hash{}, errors.New("this api is not supported by Klaytn because Klaytn use fixed gasPrice policy")
if sendArgs.Nonce == nil {
Copy link
Contributor

@kjeom kjeom Jul 25, 2023

Choose a reason for hiding this comment

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

func klaytnTypedArgs(sendArgs EthTransactionArgs) SendTxArgs {
	ethTx := sendArgs.toTransaction()
	txType := ethTx.Type()
	return SendTxArgs{
		TypeInt: &txType,
		From: *sendArgs.From,
		Recipient: sendArgs.To,
		...
	}
}

func (api *EthereumAPI) Resend(ctx context.Context, sendArgs EthTransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) {
	sendTxArgs := klaytnTypedArgs(sendArgs)
	return api.publicTransactionPoolAPI.Resend(sendTxArgs)
}

How do you think about this?

Copy link
Member

Choose a reason for hiding this comment

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

Or you can make an interface for EthTransactionArgs and SendTxArgs. Since both implementation has the same methods, setDefaults and toTransaction, already, you can just add getters or setters for From, Gas, GasPrice, and Nonce

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have added EthTransactionArgs in NewTxArgs Interface.
Other parts of api_ethereum.go can be refactored by these, and it will be reflected in next PR

api/tx_args.go Outdated Show resolved Hide resolved
aidan-kwon
aidan-kwon previously approved these changes Jul 26, 2023
@aidan-kwon
Copy link
Member

@JayChoi1736 Please resolve the conflict

}

// Resend accepts an existing transaction and a new gas price and limit. It will remove
// the given transaction from the pool and reinsert it with the new gas price and limit.
Copy link
Member

Choose a reason for hiding this comment

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

The description of this function says that it removes the existing transaction.
But it doesn't seem to be removed, only reinsert.

Copy link
Member

Choose a reason for hiding this comment

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

@nohkwak Good question. This API is supposed to be used to adjust gasPrice of existing transactions. The API finally calls s.b.SendTx(), and the new tx will be validated again inside of s.b.SendTx(). If the new gas price is bigger than the gas price of txpool tx, then it will replace the exiting tx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you.
I also found a few mistake in formal comments in api files.
Let me fix all things in api refactoring PR after this

@JayChoi1736 JayChoi1736 merged commit 16858e5 into klaytn:dev Jul 26, 2023
12 checks passed
@aidan-kwon aidan-kwon mentioned this pull request Aug 3, 2023
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need to merge Need to merge for the next time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants