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
add eth_resend API #1894
Conversation
api/api_ethereum.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
@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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Proposed changes
Types of changes
Please put an x in the boxes related to your change.
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.
$ make test
)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...