-
Notifications
You must be signed in to change notification settings - Fork 15
Lo6165 price bump cap #62
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d412a80
fix price bump condition
c5db28a
impl replace price check and make ethclient be interface for testing
6621802
define txpool's function as method
3213c9c
move client interface to ethereum package
a845932
check returned tx in test
557c2b0
remove txpool method from ETHClient
4901d10
use ethereum.* interface
19e9c1e
check both feeCap and tipCap exceed old
993e18a
check price equility
1e5dd27
fix test case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,13 @@ import ( | |
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
"github.com/ethereum/go-ethereum/common" | ||
gethtypes "github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
|
||
"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/client" | ||
"github.com/datachainlab/ethereum-ibc-relay-chain/pkg/client/txpool" | ||
) | ||
|
||
func (chain *Chain) CallOpts(ctx context.Context, height int64) *bind.CallOpts { | ||
|
@@ -26,10 +32,6 @@ func (chain *Chain) TxOpts(ctx context.Context, useLatestNonce bool) (*bind.Tran | |
Signer: chain.ethereumSigner.Sign, | ||
} | ||
|
||
if err := NewGasFeeCalculator(chain.client, &chain.config).Apply(ctx, txOpts); err != nil { | ||
return nil, err | ||
} | ||
|
||
if useLatestNonce { | ||
if nonce, err := chain.client.NonceAt(ctx, addr, nil); err != nil { | ||
return nil, err | ||
|
@@ -38,5 +40,38 @@ func (chain *Chain) TxOpts(ctx context.Context, useLatestNonce bool) (*bind.Tran | |
} | ||
} | ||
|
||
if err := NewGasFeeCalculator(chain.client, &chain.config).Apply(ctx, txOpts); err != nil { | ||
return nil, err | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. statement move to fix bug |
||
return txOpts, nil | ||
} | ||
|
||
// wrapping interface of client.ETHClient struct | ||
type IChainClient interface { | ||
SuggestGasPrice(ctx context.Context) (*big.Int, error) | ||
HeaderByNumber(ctx context.Context, number *big.Int) (*gethtypes.Header, error); | ||
FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error) | ||
GetMinimumRequiredFee(ctx context.Context, address common.Address, nonce uint64, priceBump uint64) (*txpool.RPCTransaction, *big.Int, *big.Int, error); | ||
} | ||
siburu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type ChainClient struct { | ||
*client.ETHClient | ||
} | ||
|
||
// implements IETHChainClient | ||
func (cl *ChainClient) SuggestGasPrice(ctx context.Context) (*big.Int, error) { | ||
return cl.ETHClient.Client.SuggestGasPrice(ctx) | ||
} | ||
func (cl *ChainClient) HeaderByNumber(ctx context.Context, number *big.Int) (*gethtypes.Header, error) { | ||
return cl.ETHClient.Client.HeaderByNumber(ctx, number) | ||
} | ||
func (cl *ChainClient) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error) { | ||
return cl.ETHClient.Client.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles) | ||
} | ||
siburu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func (cl *ChainClient) GetMinimumRequiredFee(ctx context.Context, address common.Address, nonce uint64, priceBump uint64) (*txpool.RPCTransaction, *big.Int, *big.Int, error) { | ||
return txpool.GetMinimumRequiredFee(ctx, cl.ETHClient.Client, address, nonce, priceBump); | ||
} | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
hexuti.Big.ToInt() returns same pointer of receiver instance and following inclByPercent() overwrite it. This make problems when targetTx object is stored and reused such as testing mock.