-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 migration and orm changes for additional lgs fields and delegate #10722
Closed
jinhoonbang
wants to merge
10
commits into
develop
from
VRF-574-move-legacy-gas-station-and-sidecar-out-of-chainlink-ccip
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d0a41ed
add migration and orm changes for additional lgs fields
jinhoonbang a6582b4
implement legacy gas station lib interfaces, changes for lgs job spec…
jinhoonbang a2a661a
add sidecar, orm and integration test
jinhoonbang e1e0b0e
Merge branch 'develop' into VRF-574-move-legacy-gas-station-and-sidec…
jinhoonbang 75279c6
unit tests for blockchain client
jinhoonbang 42ce472
update go.mod with cap markets repo
jinhoonbang 32101b6
bump migration version and add unit test for blockchain client
jinhoonbang 0d1b72a
Merge branch 'develop' into VRF-574-move-legacy-gas-station-and-sidec…
jinhoonbang 24eaa9e
remove local import
jinhoonbang e2b27ab
update go sum
jinhoonbang 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 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 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,4 +4,5 @@ type Feature interface { | |
FeedsManager() bool | ||
UICSAKeys() bool | ||
LogPoller() bool | ||
EAL() bool | ||
} |
This file contains 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package eal | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
gethcommon "github.com/ethereum/go-ethereum/common" | ||
libcommon "github.com/smartcontractkit/capital-markets-projects/lib/common" | ||
Check failure on line 11 in core/services/eal/blockchain_client.go GitHub Actions / Analyze go
Check failure on line 11 in core/services/eal/blockchain_client.go GitHub Actions / lint
|
||
"github.com/smartcontractkit/capital-markets-projects/lib/web/jsonrpc" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/client" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config" | ||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr" | ||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/keystore" | ||
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ethkey" | ||
) | ||
|
||
var _ libcommon.BlockchainClientInterface = &BlockchainClient{} | ||
|
||
type BlockchainClient struct { | ||
lggr logger.Logger | ||
txm txmgr.TxManager | ||
gethks keystore.Eth | ||
fromAddresses []ethkey.EIP55Address | ||
chainID uint64 | ||
maxGasLimit uint32 | ||
client client.Client | ||
} | ||
|
||
func NewBlockchainClient( | ||
lggr logger.Logger, | ||
txm txmgr.TxManager, | ||
gethks keystore.Eth, | ||
fromAddresses []ethkey.EIP55Address, | ||
chainID uint64, | ||
cfg config.EVM, | ||
client client.Client, | ||
) (*BlockchainClient, error) { | ||
return &BlockchainClient{ | ||
lggr: lggr, | ||
txm: txm, | ||
gethks: gethks, | ||
fromAddresses: fromAddresses, | ||
chainID: chainID, | ||
maxGasLimit: cfg.GasEstimator().LimitMax(), | ||
client: client, | ||
}, nil | ||
} | ||
|
||
func (c *BlockchainClient) EstimateGas( | ||
ctx context.Context, | ||
address gethcommon.Address, | ||
payload []byte, | ||
) (uint32, error) { | ||
fromAddresses := c.sendingKeys() | ||
fromAddress, err := c.gethks.GetRoundRobinAddress(big.NewInt(0).SetUint64(c.chainID), fromAddresses...) | ||
if err != nil { | ||
return 0, err | ||
} | ||
c.lggr.Debugw("estimate gas details", | ||
"toAddress", address, | ||
"fromAddress", fromAddress, | ||
) | ||
gasLimit, err := c.client.EstimateGas(ctx, ethereum.CallMsg{ | ||
From: fromAddress, | ||
To: &address, | ||
Data: payload, | ||
}) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
if gasLimit > uint64(c.maxGasLimit) { | ||
return 0, errors.New(jsonrpc.EstimateGasExceededErrorMsg) | ||
} | ||
// safe cast because gas estimator limit max is uint32 | ||
return uint32(gasLimit), nil | ||
} | ||
|
||
// SimulateTransaction makes eth_call to simulate transaction | ||
// TODO: look into accepting optional parameters (gas, gasPrice, value) | ||
func (c *BlockchainClient) SimulateTransaction( | ||
ctx context.Context, | ||
address gethcommon.Address, | ||
payload []byte, | ||
gasLimit uint32, | ||
) error { | ||
fromAddresses := c.sendingKeys() | ||
fromAddress, err := c.gethks.GetRoundRobinAddress(big.NewInt(0).SetUint64(c.chainID), fromAddresses...) | ||
if err != nil { | ||
return err | ||
} | ||
c.lggr.Debugw("eth_call details", | ||
"toAddress", address, | ||
"fromAddress", fromAddress, | ||
"gasLimit", gasLimit, | ||
) | ||
_, err = c.client.CallContract(ctx, ethereum.CallMsg{ | ||
To: &address, | ||
From: fromAddress, | ||
Data: payload, | ||
Gas: uint64(gasLimit), | ||
}, nil /*blocknumber*/) | ||
|
||
return err | ||
} | ||
|
||
func (c *BlockchainClient) sendingKeys() []gethcommon.Address { | ||
var addresses []gethcommon.Address | ||
for _, a := range c.fromAddresses { | ||
addresses = append(addresses, a.Address()) | ||
} | ||
return addresses | ||
} |
Oops, something went wrong.
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.
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.
Is it an acronym?